Revision 167
Added by ryan about 20 years ago
| trunk/wb/framework/functions.php | ||
|---|---|---|
| 682 | 682 |
|
| 683 | 683 |
} |
| 684 | 684 |
|
| 685 |
// Load addons into DB
|
|
| 686 |
function load_addons($search_dir, $install_modules = false) {
|
|
| 685 |
// Load module into DB
|
|
| 686 |
function load_module($directory, $install = false) {
|
|
| 687 | 687 |
global $database; |
| 688 |
if($handle = opendir($search_dir)) {
|
|
| 689 |
while(false !== ($file = readdir($handle))) {
|
|
| 690 |
if($file != '' AND substr($file, 0, 1) != '.' AND $file != 'admin.php' AND $file != 'index.php') {
|
|
| 691 |
// Load info file |
|
| 692 |
if(file_exists($search_dir.'/'.$file.'/info.php')) {
|
|
| 693 |
require($search_dir.'/'.$file.'/info.php'); |
|
| 694 |
} else {
|
|
| 695 |
require($search_dir.'/'.$file); |
|
| 688 |
if(file_exists($directory.'/info.php')) {
|
|
| 689 |
require($directory.'/info.php'); |
|
| 690 |
if(isset($module_name)) {
|
|
| 691 |
if(!isset($module_license)) { $module_license = 'GNU General Public License'; }
|
|
| 692 |
if(!isset($module_platform) AND isset($module_designed_for)) { $module_platform = $module_designed_for; }
|
|
| 693 |
if(!isset($module_function) AND isset($module_type)) { $module_function = $module_type; }
|
|
| 694 |
// Check that it doesn't already exist |
|
| 695 |
$result = $database->query("SELECT addon_id FROM ".TABLE_PREFIX."addons WHERE directory = '".$module_directory."' LIMIT 0,1");
|
|
| 696 |
if($result->numRows() == 0) {
|
|
| 697 |
// Load into DB |
|
| 698 |
$query = "INSERT INTO ".TABLE_PREFIX."addons ". |
|
| 699 |
"(directory,name,description,type,function,version,platform,author,license) ". |
|
| 700 |
"VALUES ('$module_directory','$module_name','".addslashes($module_description)."','module',".
|
|
| 701 |
"'$module_function','$module_version','$module_platform','$module_author','$module_license')"; |
|
| 702 |
$database->query($query); |
|
| 703 |
// Run installation script |
|
| 704 |
if($install == true) {
|
|
| 705 |
require($directory.'/install.php'); |
|
| 696 | 706 |
} |
| 697 |
// Get addon type |
|
| 698 |
if(isset($module_name)) {
|
|
| 699 |
if(!isset($module_license)) { $module_license = 'GNU General Public License'; }
|
|
| 700 |
if(!isset($module_platform) AND isset($module_designed_for)) { $module_platform = $module_designed_for; }
|
|
| 701 |
// Check that it doesn't already exist |
|
| 702 |
$result = $database->query("SELECT addon_id FROM ".TABLE_PREFIX."addons WHERE directory = '".$module_directory."' LIMIT 0,1");
|
|
| 703 |
if($result->numRows() == 0) {
|
|
| 704 |
// Load into DB |
|
| 705 |
$query = "INSERT INTO ".TABLE_PREFIX."addons ". |
|
| 706 |
"(directory,name,description,type,function,version,platform,author,license) ". |
|
| 707 |
"VALUES ('$module_directory','$module_name','".addslashes($module_description)."','module',".
|
|
| 708 |
"'$module_function','$module_version','$module_platform','$module_author','$module_license')"; |
|
| 709 |
$database->query($query); |
|
| 710 |
// Run installation script |
|
| 711 |
if($install_modules == true) {
|
|
| 712 |
require($search_dir.'/'.$file.'/install.php'); |
|
| 713 |
} |
|
| 714 |
} |
|
| 715 |
} elseif(isset($template_name)) {
|
|
| 716 |
if(!isset($template_license)) { $template_license = 'GNU General Public License'; }
|
|
| 717 |
if(!isset($template_platform) AND isset($template_designed_for)) { $template_platform = $template_designed_for; }
|
|
| 718 |
// Check that it doesn't already exist |
|
| 719 |
$result = $database->query("SELECT addon_id FROM ".TABLE_PREFIX."addons WHERE directory = '".$template_directory."' LIMIT 0,1");
|
|
| 720 |
if($result->numRows() == 0) {
|
|
| 721 |
// Load into DB |
|
| 722 |
$query = "INSERT INTO ".TABLE_PREFIX."addons ". |
|
| 723 |
"(directory,name,description,type,version,platform,author,license) ". |
|
| 724 |
"VALUES ('$template_directory','$template_name','".addslashes($template_description)."','template',".
|
|
| 725 |
"'$template_version','$template_platform','$template_author','$template_license')"; |
|
| 726 |
$database->query($query); |
|
| 727 |
} |
|
| 728 |
} elseif(isset($language_name)) {
|
|
| 729 |
if(!isset($language_license)) { $language_license = 'GNU General Public License'; }
|
|
| 730 |
if(!isset($language_platform) AND isset($language_designed_for)) { $language_platform = $language_designed_for; }
|
|
| 731 |
// Check that it doesn't already exist |
|
| 732 |
$result = $database->query("SELECT addon_id FROM ".TABLE_PREFIX."addons WHERE directory = '".$language_code."' LIMIT 0,1");
|
|
| 733 |
if($result->numRows() == 0) {
|
|
| 734 |
// Load into DB |
|
| 735 |
$query = "INSERT INTO ".TABLE_PREFIX."addons ". |
|
| 736 |
"(directory,name,type,version,platform,author,license) ". |
|
| 737 |
"VALUES ('$language_code','$language_name','language',".
|
|
| 738 |
"'$language_version','$language_platform','$language_author','$language_license')"; |
|
| 739 |
$database->query($query); |
|
| 740 |
} |
|
| 741 |
} |
|
| 742 | 707 |
} |
| 743 | 708 |
} |
| 744 |
closedir($handle); |
|
| 745 |
} else {
|
|
| 746 |
echo 'Can\'t open '.$search_dir; |
|
| 747 | 709 |
} |
| 748 | 710 |
} |
| 749 | 711 |
|
| 750 |
?> |
|
| 712 |
// Load template into DB |
|
| 713 |
function load_template($directory) {
|
|
| 714 |
global $database; |
|
| 715 |
if(file_exists($directory.'/info.php')) {
|
|
| 716 |
require($directory.'/info.php'); |
|
| 717 |
if(isset($template_name)) {
|
|
| 718 |
if(!isset($template_license)) { $template_license = 'GNU General Public License'; }
|
|
| 719 |
if(!isset($template_platform) AND isset($template_designed_for)) { $template_platform = $template_designed_for; }
|
|
| 720 |
// Check that it doesn't already exist |
|
| 721 |
$result = $database->query("SELECT addon_id FROM ".TABLE_PREFIX."addons WHERE directory = '".$template_directory."' LIMIT 0,1");
|
|
| 722 |
if($result->numRows() == 0) {
|
|
| 723 |
// Load into DB |
|
| 724 |
$query = "INSERT INTO ".TABLE_PREFIX."addons ". |
|
| 725 |
"(directory,name,description,type,version,platform,author,license) ". |
|
| 726 |
"VALUES ('$template_directory','$template_name','".addslashes($template_description)."','template',".
|
|
| 727 |
"'$template_version','$template_platform','$template_author','$template_license')"; |
|
| 728 |
$database->query($query); |
|
| 729 |
} |
|
| 730 |
} |
|
| 731 |
} |
|
| 732 |
} |
|
| 733 |
|
|
| 734 |
// Load language into DB |
|
| 735 |
function load_language($file) {
|
|
| 736 |
global $database; |
|
| 737 |
if(file_exists($file)) {
|
|
| 738 |
require($file); |
|
| 739 |
if(isset($language_name)) {
|
|
| 740 |
if(!isset($language_license)) { $language_license = 'GNU General Public License'; }
|
|
| 741 |
if(!isset($language_platform) AND isset($language_designed_for)) { $language_platform = $language_designed_for; }
|
|
| 742 |
// Check that it doesn't already exist |
|
| 743 |
$result = $database->query("SELECT addon_id FROM ".TABLE_PREFIX."addons WHERE directory = '".$language_code."' LIMIT 0,1");
|
|
| 744 |
if($result->numRows() == 0) {
|
|
| 745 |
// Load into DB |
|
| 746 |
$query = "INSERT INTO ".TABLE_PREFIX."addons ". |
|
| 747 |
"(directory,name,type,version,platform,author,license) ". |
|
| 748 |
"VALUES ('$language_code','$language_name','language',".
|
|
| 749 |
"'$language_version','$language_platform','$language_author','$language_license')"; |
|
| 750 |
$database->query($query); |
|
| 751 |
} |
|
| 752 |
} |
|
| 753 |
} |
|
| 754 |
} |
|
| 755 |
|
|
| 756 |
?> |
|
Also available in: Unified diff
Removed load_addons and replaced with load_module, load_template, and load_language