From 865c3a7beced00a1cfd4adbb48c73f8349cbb782 Mon Sep 17 00:00:00 2001 From: Abel Hoogeveen Date: Thu, 26 Feb 2015 14:09:41 +0100 Subject: [PATCH 1/9] Added core Start Event for complete control over the FuzeWorks start proces --- Core/System/class.core.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Core/System/class.core.php b/Core/System/class.core.php index e1984bb..7d3caf5 100644 --- a/Core/System/class.core.php +++ b/Core/System/class.core.php @@ -21,6 +21,8 @@ class Core { // Load core functionality $this->mods = new stdClass(); $this->loadStartupFiles(); + + $this->mods->events->fireEvent('coreStartEvent'); } public function loadStartupFiles() { From 409702e037b3b1e3bd19dfc2c5386d032ac10374 Mon Sep 17 00:00:00 2001 From: Abel Hoogeveen Date: Thu, 26 Feb 2015 15:45:15 +0100 Subject: [PATCH 2/9] Implemented Section Editor and Documentation. Also removed useless line in config class --- Core/Mods/sections/class.sections.php | 72 +++++++++++++++++++++------ Core/System/class.config.php | 1 - 2 files changed, 58 insertions(+), 15 deletions(-) diff --git a/Core/Mods/sections/class.sections.php b/Core/Mods/sections/class.sections.php index f0dd2a5..4fbdaa4 100644 --- a/Core/Mods/sections/class.sections.php +++ b/Core/Mods/sections/class.sections.php @@ -1,5 +1,6 @@ cfg = $this->config->loadConfigFile('sections', $this->getModulePath()); @@ -31,13 +32,55 @@ class Sections extends Module { $this->events->addListener(array($this, 'routerEvent'), 'routerRouteEvent', EventPriority::NORMAL); } + /** + * Registers this module in the eventRegister for routerRouteEvent + * @access public + * @param eventRegisterBuildEvent Event + * @return eventRegisterBuildEvent Event + */ public function eventRegisterBuild($event) { $event->addEvent('sections', 'routerRouteEvent'); return $event; } - public function routerEvent($event) { + /** + * Add a section to the config file + * @access public + * @param String section_name, name of the section + * @param Boolean module_section wether this is a module_section + * @param String module_name to use when this is a module_section + * @param String Controller_path, where to find the controllers for this section + * @param String Model_path, where to find the models for this section + * @param String View_path, where to find the views for this section + */ + public function addSection($name, $module_section = false, $module_name = null, $controller_path = null, $model_path = null, $view_path = null) { + $data = array( + 'name' => $name, + 'module_section' => $module_section, + 'module_name' => $module_name, + 'controller_path' => FUZEPATH . $controller_path, + 'model_path' => FUZEPATH . $model_path, + 'view_path' => FUZEPATH . $view_path, + ); + $this->config->set('sections', $name, $data, $this->getModulePath()); + } + /** + * Removes a section from the config file + * @access public + * @param String section_name, name of the section to remove + */ + public function removeSection($name) { + $this->config->set('sections', $name, null, $this->getModulePath()); + } + + /** + * Get's called on routerRouteEvent. Redirects when a section is found + * @access public + * @param routerRouteEvent Event + * @return routerRouteEvent Event + */ + public function routerEvent($event) { $name = $event->controller; $controller = null; $function = null; @@ -50,12 +93,12 @@ class Sections extends Module { $this->currentSection = $name; // Logic here, first for module sections - if ($section->module_section) { - $this->core->loadMod($section->module_name); - $event->directory = $this->mods->{$section->module_name}->getModulePath() . "/Controller/"; + if ($section['module_section']) { + $this->core->loadMod($section['module_name']); + $event->directory = $this->mods->{$section['module_name']}->getModulePath() . "/Controller/"; } else { // Now for regular sections - $event->directory = $section->controller_path; + $event->directory = $section['controller_path']; } // Move the path so it matches the new regime @@ -77,22 +120,23 @@ class Sections extends Module { return $event; } + /** + * Retrieves section information from the config file + * @access public + * @param String section_name, name of the section + * @return Array section_information or null + */ public function __get($name){ // Something given? if(empty($name)) { - // Currently in a section? if($this->currentSection !== null){ - // Return that one then return $this->cfg[$this->currentSection]; } - - // Emptiness... return null; } - // Return element $name of the config file if (isset($this->cfg->$name)) { $section = $this->cfg->$name; diff --git a/Core/System/class.config.php b/Core/System/class.config.php index 81f12ad..ec58af7 100644 --- a/Core/System/class.config.php +++ b/Core/System/class.config.php @@ -87,7 +87,6 @@ class Config extends Bus{ public function set($name, $key, $value, $directory = null) { $dir = (isset($directory) ? $directory : FUZEPATH . "Application//config/"); $file = $dir . 'config.' . strtolower($name).".php"; - $file2 = $dir . 'config.' . strtolower($name).".enc.cfg"; if (file_exists($file)) { $DECODED = require($file); if (!is_array($DECODED)) { From f6f72cc09da3f72f800355183952b5b6f735e69e Mon Sep 17 00:00:00 2001 From: Abel Hoogeveen Date: Sat, 7 Mar 2015 13:53:10 +0100 Subject: [PATCH 3/9] Added the possibility to retrieve a mod and not add them to the mod register --- Core/System/class.core.php | 102 +++++++++++++++++++------------------ 1 file changed, 53 insertions(+), 49 deletions(-) diff --git a/Core/System/class.core.php b/Core/System/class.core.php index 7d3caf5..6d0d4c1 100644 --- a/Core/System/class.core.php +++ b/Core/System/class.core.php @@ -58,64 +58,68 @@ class Core { ## MODLOADING public function loadMod($name) { + if (!isset($this->mods->$name)) { + $CLASS = $this->loadModule($name); + $this->mods->{strtolower($name)} = &$CLASS; + } + } + + public function getMod($name) { + $CLASS = $this->loadModule($name); + return $CLASS; + } + + private function loadModule($name) { // Class name $class_name = ucfirst($name); - // Check if mod is already loaded - if (!isset($this->mods->$name)) { - // Check if class is already included - // If the class is not loaded, load it - if (!class_exists($class_name)) { + // If the mod is in the top mod directory, load it directly + $file = FUZEPATH . "/Core/Mods/class.".$class_name.".php"; + if (file_exists($file)) { + $this->mods->logger->log("Loading module '".$class_name."'"); + $path = FUZEPATH . "/Core/Mods/class.".$class_name.".php"; + require_once($file); - // If the mod is in the top mod directory, load it directly - $file = FUZEPATH . "/Core/Mods/class.".$class_name.".php"; - if (file_exists($file)) { - $this->mods->logger->log("Loading module '".$class_name."'"); - $path = FUZEPATH . "/Core/Mods/class.".$class_name.".php"; - require_once($file); + // If not, and a mod config file is found, follow that + } elseif ( file_exists(FUZEPATH . "/Core/Mods/".strtolower($name)."/moduleInfo.php" )) { + // Load the config file + $cfg = (object) require(FUZEPATH . "/Core/Mods/".strtolower($name)."/moduleInfo.php"); - // If not, and a mod config file is found, follow that - } elseif ( file_exists(FUZEPATH . "/Core/Mods/".strtolower($name)."/moduleInfo.php" )) { - // Load the config file - $cfg = (object) require(FUZEPATH . "/Core/Mods/".strtolower($name)."/moduleInfo.php"); + // Load the class name and file + $class_file = FUZEPATH . "/Core/Mods/".strtolower($name)."/" . $cfg->module_file; + $class_name = $cfg->module_class; - // Load the class name and file - $class_file = FUZEPATH . "/Core/Mods/".strtolower($name)."/" . $cfg->module_file; - $class_name = $cfg->module_class; - - // Load the dependencies first - $deps = (isset($cfg->dependencies) ? $cfg->dependencies : array()); - for ($i=0; $i < count($deps); $i++) { - $this->loadMod($deps[$i]); - } - - $path = FUZEPATH . "/Core/Mods/".strtolower($name)."/"; - $this->mods->logger->log("Loading Module '".$cfg->name."' v".$cfg->version." made by '".$cfg->author."' : '".$cfg->website."'"); - - require_once($class_file); - - // If no config file found, but a main class is, load that - } elseif ( file_exists(FUZEPATH . "/Core/Mods/".strtolower($name)."/class.".$class_name.".php") ){ - $this->mods->logger->log("Loading module '".$class_name."'"); - $path = FUZEPATH . "/Core/Mods/".strtolower($name)."/"; - require_once(FUZEPATH . "/Core/Mods/".strtolower($name)."/class.".$class_name.".php"); - - // Otherwise Abort - } else { - // MOD NOT FOUND - throw new Exception("Requested mod '".$name."' was not found", 1); - return false; - } + // Load the dependencies first + $deps = (isset($cfg->dependencies) ? $cfg->dependencies : array()); + for ($i=0; $i < count($deps); $i++) { + $this->loadMod($deps[$i]); } - // Create class object - $CLASS = new $class_name($this); - if (method_exists($CLASS, 'setModulePath')) { - $CLASS->setModulePath($path); - } - $this->mods->{strtolower($name)} = &$CLASS; - $CLASS->onLoad(); + $path = FUZEPATH . "/Core/Mods/".strtolower($name)."/"; + $this->mods->logger->log("Loading Module '".$cfg->name."' v".$cfg->version." made by '".$cfg->author."' : '".$cfg->website."'"); + + require_once($class_file); + + // If no config file found, but a main class is, load that + } elseif ( file_exists(FUZEPATH . "/Core/Mods/".strtolower($name)."/class.".$class_name.".php") ){ + $this->mods->logger->log("Loading module '".$class_name."'"); + $path = FUZEPATH . "/Core/Mods/".strtolower($name)."/"; + require_once(FUZEPATH . "/Core/Mods/".strtolower($name)."/class.".$class_name.".php"); + + // Otherwise Abort + } else { + // MOD NOT FOUND + throw new Exception("Requested mod '".$name."' was not found", 1); + return false; } + + // Create class object + $CLASS = new $class_name($this); + if (method_exists($CLASS, 'setModulePath')) { + $CLASS->setModulePath($path); + } + $CLASS->onLoad(); + return $CLASS; } } From 68c68cf91c22afc58947a9ae15f2eb4688c7dc3e Mon Sep 17 00:00:00 2001 From: Abel Hoogeveen Date: Sat, 14 Mar 2015 15:46:05 +0100 Subject: [PATCH 4/9] Added a mod register which allows the system to load advanced modules. This allows for the future build of module versions, prevention of module name conflicts and much more. --- Application/Config/config.main.php | 1 + Application/Config/config.modregister.php | 0 Core/System/class.abstract.module.php | 23 ++++ Core/System/class.core.php | 157 +++++++++++++++------- Core/System/class.events.php | 6 +- 5 files changed, 138 insertions(+), 49 deletions(-) create mode 100644 Application/Config/config.modregister.php diff --git a/Application/Config/config.main.php b/Application/Config/config.main.php index 76e258c..118ca4b 100644 --- a/Application/Config/config.main.php +++ b/Application/Config/config.main.php @@ -2,6 +2,7 @@ 'SITE_URL' => '', 'SITE_DOMAIN' => '', 'SERVER_NAME' => '', + 'registers_update_interval' => 3600, 'administrator_mail' => '', 'default_controller' => 'standard', 'default_function' => 'index', diff --git a/Application/Config/config.modregister.php b/Application/Config/config.modregister.php new file mode 100644 index 0000000..e69de29 diff --git a/Core/System/class.abstract.module.php b/Core/System/class.abstract.module.php index 3cab4e5..0003a7c 100644 --- a/Core/System/class.abstract.module.php +++ b/Core/System/class.abstract.module.php @@ -17,6 +17,11 @@ class Module extends Bus { */ protected $moduleName = 'placeholder'; + /** + * @var String name used in the mod array + */ + protected $linkName = 'placeholder'; + /** * Constructor * @@ -59,4 +64,22 @@ class Module extends Bus { if($this->modulePath === null) $this->modulePath = $modulePath; } + + /** + * Set the link name of the module. The link name is the address in the module array so that the module can self reference. + * @access public + * @param String link name + */ + public function setModuleLinkName($linkName) { + $this->linkName = $linkName; + } + + /** + * The name that is required to load itself, eg 'exampleauthor/examplemodulename' or 'techfuze/cms' + * @access public + * @param String module name + */ + public function setModuleName($modName) { + $this->moduleName = $modName; + } } \ No newline at end of file diff --git a/Core/System/class.core.php b/Core/System/class.core.php index 6d0d4c1..a1cde43 100644 --- a/Core/System/class.core.php +++ b/Core/System/class.core.php @@ -11,6 +11,7 @@ class Core { public $mods; private $loaded = false; + private $register; ## START/STOP public function init() { @@ -23,6 +24,12 @@ class Core { $this->loadStartupFiles(); $this->mods->events->fireEvent('coreStartEvent'); + // Mod register exists, check if expired + if ( ( date('U') - $this->mods->config->main->registers_last_update) > $this->mods->config->main->registers_update_interval) { + $this->mods->logger->log("Registers have expired. Updating...", 'Core'); + $this->buildModRegister(); + $this->mods->events->buildEventRegister(); + } } public function loadStartupFiles() { @@ -57,69 +64,127 @@ class Core { } ## MODLOADING - public function loadMod($name) { + public function loadMod($name, $version = null) { if (!isset($this->mods->$name)) { $CLASS = $this->loadModule($name); - $this->mods->{strtolower($name)} = &$CLASS; + $this->mods->{strtolower($CLASS[1])} = &$CLASS[0]; } } - public function getMod($name) { + public function getMod($name, $version = null) { $CLASS = $this->loadModule($name); - return $CLASS; + return $CLASS[0]; } - private function loadModule($name) { - // Class name - $class_name = ucfirst($name); - - // If the mod is in the top mod directory, load it directly - $file = FUZEPATH . "/Core/Mods/class.".$class_name.".php"; - if (file_exists($file)) { - $this->mods->logger->log("Loading module '".$class_name."'"); - $path = FUZEPATH . "/Core/Mods/class.".$class_name.".php"; - require_once($file); - - // If not, and a mod config file is found, follow that - } elseif ( file_exists(FUZEPATH . "/Core/Mods/".strtolower($name)."/moduleInfo.php" )) { - // Load the config file - $cfg = (object) require(FUZEPATH . "/Core/Mods/".strtolower($name)."/moduleInfo.php"); - - // Load the class name and file - $class_file = FUZEPATH . "/Core/Mods/".strtolower($name)."/" . $cfg->module_file; - $class_name = $cfg->module_class; - - // Load the dependencies first - $deps = (isset($cfg->dependencies) ? $cfg->dependencies : array()); - for ($i=0; $i < count($deps); $i++) { - $this->loadMod($deps[$i]); - } - - $path = FUZEPATH . "/Core/Mods/".strtolower($name)."/"; - $this->mods->logger->log("Loading Module '".$cfg->name."' v".$cfg->version." made by '".$cfg->author."' : '".$cfg->website."'"); - - require_once($class_file); - - // If no config file found, but a main class is, load that - } elseif ( file_exists(FUZEPATH . "/Core/Mods/".strtolower($name)."/class.".$class_name.".php") ){ - $this->mods->logger->log("Loading module '".$class_name."'"); - $path = FUZEPATH . "/Core/Mods/".strtolower($name)."/"; - require_once(FUZEPATH . "/Core/Mods/".strtolower($name)."/class.".$class_name.".php"); - - // Otherwise Abort + private function loadModule($name, $version = null) { + // Load the register if not loaded yet + if (!isset($this->mods->config->modregister->register)) { + $this->buildModRegister(); } else { - // MOD NOT FOUND + + $this->register = $this->mods->config->modregister->register; + } + + // The basic module path + $path = FUZEPATH . "/Core/Mods/"; + + // Chech if the requested module is set + if (isset($this->register[$name])) { + // Check if the config file is loaded + if (!empty($this->register[$name])) { + // Load the config file + $cfg = (object) $this->register[$name]; + + // Check if a specific version is requested + if (isset($version)) { + // @TODO: Implement + } else { + // Or load the main version + $file = $cfg->directory . $cfg->module_file; + + // Load the dependencies before the module loads + $deps = (isset($cfg->dependencies) ? $cfg->dependencies : array()); + for ($i=0; $i < count($deps); $i++) { + $this->loadMod($deps[$i]); + } + + // Check if the file exists + if (file_exists($file)) { + // And load it + require_once($file); + $class_name = $cfg->module_class; + $msg = "Loading Module '".ucfirst((isset($cfg->name) ? $cfg->name : $cfg->module_name)) . "'"; + $msg .= (isset($cfg->version) ? " version:".$cfg->version : ""); + $msg .= (isset($cfg->author) ? " made by ".$cfg->author : ""); + $msg .= (isset($cfg->website) ? " from ".$cfg->website: ""); + $this->mods->logger->log($msg); + } else { + // Throw Exception if the file does not exist + throw new Exception("Requested mod '".$name."' could not be loaded. Class file not found", 1); + return false; + } + } + } else { + // Throw Exception if the module has an invalid config file + throw new Exception("Requested mod '".$name."' could not be loaded. Invalid config", 1); + return false; + } + } else { + // Throw Exception if the module is not defined throw new Exception("Requested mod '".$name."' was not found", 1); - return false; + return false; } // Create class object $CLASS = new $class_name($this); if (method_exists($CLASS, 'setModulePath')) { - $CLASS->setModulePath($path); + $CLASS->setModulePath($cfg->directory); + } + if (method_exists($CLASS, 'setModuleLinkName')) { + $CLASS->setModuleLinkName($cfg->module_name); + } + if (method_exists($CLASS, 'setModuleName')) { + $CLASS->setModuleName($name); } $CLASS->onLoad(); - return $CLASS; + return array($CLASS, $cfg->module_name); + } + + public function buildModRegister() { + $this->mods->logger->newLevel("Building Mod Register", 'Core'); + $dir = FUZEPATH . "Core/Mods/"; + $mods = array_values(array_diff(scandir($dir), array('..', '.'))); + $register = array(); + for ($i=0; $i < count($mods); $i++) { + $mod_dir = $dir . $mods[$i] . "/"; + if (file_exists($mod_dir . "/moduleInfo.php")) { + $cfg = (object) require($mod_dir . "/moduleInfo.php"); + $name = ""; + $name .= (!empty($cfg->author) ? strtolower($cfg->author)."/" : ""); + $name .= strtolower($cfg->module_name); + + // Append directory + $cfg->directory = $mod_dir; + $register[$name] = (array) $cfg; + } else { + // Get the name + $name = $mods[$i]; + + // Build a dynamic module config + $cfg = new stdClass(); + $cfg->module_class = ucfirst($name); + $cfg->module_file = 'class.'.strtolower($name).".php"; + $cfg->module_name = $name; + $cfg->dependencies = array(); + $cfg->versions = array(); + $cfg->directory = $mod_dir; + $register[$name] = (array)$cfg; + } + } + + $this->mods->logger->stopLevel(); + $this->mods->config->set('modregister', 'register', $register); + $this->mods->config->set('main', 'registers_last_update', date('U')); } } diff --git a/Core/System/class.events.php b/Core/System/class.events.php index 78ea4ae..441e224 100644 --- a/Core/System/class.events.php +++ b/Core/System/class.events.php @@ -156,9 +156,9 @@ class Events extends Bus{ public function buildEventRegister() { $this->logger->newLevel("Building Event Register", 'Events'); $dir = FUZEPATH . "/Core/Mods/"; - $mods = array_values(array_diff(scandir($dir), array('..', '.'))); - for ($i=0; $i < count($mods); $i++) { - $this->core->loadMod($mods[$i]); + $mods = $this->config->modregister->register; + foreach ($mods as $key => $value) { + $this->core->loadMod($key); } $event = $this->fireEvent('eventRegisterBuildEvent', ''); From 892068d583ed846a6fe74c6ac9da9d97d20c24ab Mon Sep 17 00:00:00 2001 From: Abel Hoogeveen Date: Sat, 14 Mar 2015 16:02:18 +0100 Subject: [PATCH 5/9] Implemented versions --- Core/System/class.core.php | 57 +++++++++++++++++++++----------------- 1 file changed, 32 insertions(+), 25 deletions(-) diff --git a/Core/System/class.core.php b/Core/System/class.core.php index a1cde43..f33e310 100644 --- a/Core/System/class.core.php +++ b/Core/System/class.core.php @@ -97,32 +97,39 @@ class Core { // Check if a specific version is requested if (isset($version)) { - // @TODO: Implement + if (isset($cfg->versions)) { + if (isset($cfg->versions[$version])) { + $ncfg = (object) $cfg->versions[$version]; + foreach ($ncfg as $key => $value) { + $cfg->$key = $value; + } + } + } + } + + // Or load the main version + $file = $cfg->directory . $cfg->module_file; + + // Load the dependencies before the module loads + $deps = (isset($cfg->dependencies) ? $cfg->dependencies : array()); + for ($i=0; $i < count($deps); $i++) { + $this->loadMod($deps[$i]); + } + + // Check if the file exists + if (file_exists($file)) { + // And load it + require_once($file); + $class_name = $cfg->module_class; + $msg = "Loading Module '".ucfirst((isset($cfg->name) ? $cfg->name : $cfg->module_name)) . "'"; + $msg .= (isset($cfg->version) ? " version:".$cfg->version : ""); + $msg .= (isset($cfg->author) ? " made by ".$cfg->author : ""); + $msg .= (isset($cfg->website) ? " from ".$cfg->website: ""); + $this->mods->logger->log($msg); } else { - // Or load the main version - $file = $cfg->directory . $cfg->module_file; - - // Load the dependencies before the module loads - $deps = (isset($cfg->dependencies) ? $cfg->dependencies : array()); - for ($i=0; $i < count($deps); $i++) { - $this->loadMod($deps[$i]); - } - - // Check if the file exists - if (file_exists($file)) { - // And load it - require_once($file); - $class_name = $cfg->module_class; - $msg = "Loading Module '".ucfirst((isset($cfg->name) ? $cfg->name : $cfg->module_name)) . "'"; - $msg .= (isset($cfg->version) ? " version:".$cfg->version : ""); - $msg .= (isset($cfg->author) ? " made by ".$cfg->author : ""); - $msg .= (isset($cfg->website) ? " from ".$cfg->website: ""); - $this->mods->logger->log($msg); - } else { - // Throw Exception if the file does not exist - throw new Exception("Requested mod '".$name."' could not be loaded. Class file not found", 1); - return false; - } + // Throw Exception if the file does not exist + throw new Exception("Requested mod '".$name."' could not be loaded. Class file not found", 1); + return false; } } else { // Throw Exception if the module has an invalid config file From 44ae54445eab0aa3b98a6dce3006bcd6b5f576b1 Mon Sep 17 00:00:00 2001 From: Abel Hoogeveen Date: Sat, 14 Mar 2015 16:03:38 +0100 Subject: [PATCH 6/9] Added a very basic system to disabled modules using $enabled = false; in the moduleInfo.php --- Core/System/class.core.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Core/System/class.core.php b/Core/System/class.core.php index f33e310..48e230a 100644 --- a/Core/System/class.core.php +++ b/Core/System/class.core.php @@ -95,6 +95,13 @@ class Core { // Load the config file $cfg = (object) $this->register[$name]; + // Check if the module is enabled, otherwise abort + if (isset($cfg->enabled)) { + if (!$cfg->enabled) { + return false; + } + } + // Check if a specific version is requested if (isset($version)) { if (isset($cfg->versions)) { From b636e904621b1ea403a2a8dc2cb0d1922c0c87e4 Mon Sep 17 00:00:00 2001 From: Abel Hoogeveen Date: Sat, 14 Mar 2015 16:05:07 +0100 Subject: [PATCH 7/9] Added a logger entry --- Core/Mods/sections/class.sections.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Core/Mods/sections/class.sections.php b/Core/Mods/sections/class.sections.php index 4fbdaa4..a1b62f5 100644 --- a/Core/Mods/sections/class.sections.php +++ b/Core/Mods/sections/class.sections.php @@ -111,6 +111,8 @@ class Sections extends Module { // And finally set the controller, if no parameters are set, load the default function $controller = (!empty($event->function) ? $event->function : $this->config->main->default_controller ); + } else { + $this->logger->log("No section was found with name: '".$name."'", 'Sections'); } if($controller !== null)$event->controller = $controller; From 771727ca48c0018eab62bf39b2b282cdbc4d9233 Mon Sep 17 00:00:00 2001 From: Abel Hoogeveen Date: Sat, 14 Mar 2015 17:03:15 +0100 Subject: [PATCH 8/9] Bugfixes for module loading --- Core/System/class.core.php | 10 ++++++---- Core/System/class.events.php | 5 +++-- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/Core/System/class.core.php b/Core/System/class.core.php index 48e230a..171452c 100644 --- a/Core/System/class.core.php +++ b/Core/System/class.core.php @@ -65,10 +65,10 @@ class Core { ## MODLOADING public function loadMod($name, $version = null) { - if (!isset($this->mods->$name)) { - $CLASS = $this->loadModule($name); - $this->mods->{strtolower($CLASS[1])} = &$CLASS[0]; - } + $CLASS = $this->loadModule($name); + if (!isset($this->mods->{strtolower($CLASS[1])})) { + return $this->mods->{strtolower($CLASS[1])} = &$CLASS[0]; + } } public function getMod($name, $version = null) { @@ -98,6 +98,8 @@ class Core { // Check if the module is enabled, otherwise abort if (isset($cfg->enabled)) { if (!$cfg->enabled) { + // Module is disabled + throw new Exception("Module '".$name."' is not enabled!", 1); return false; } } diff --git a/Core/System/class.events.php b/Core/System/class.events.php index 441e224..8551276 100644 --- a/Core/System/class.events.php +++ b/Core/System/class.events.php @@ -158,9 +158,10 @@ class Events extends Bus{ $dir = FUZEPATH . "/Core/Mods/"; $mods = $this->config->modregister->register; foreach ($mods as $key => $value) { - $this->core->loadMod($key); + try { + $this->core->loadMod($key); + } catch (Exception $e) {} } - $event = $this->fireEvent('eventRegisterBuildEvent', ''); $this->config->set('eventregister', 'register', $event->register); From 883b45fac7798fa26f8b8fca38a22ea7eacb005e Mon Sep 17 00:00:00 2001 From: Abel Hoogeveen Date: Sun, 15 Mar 2015 11:23:56 +0100 Subject: [PATCH 9/9] Bugfix the sections module not being able to load module sections --- Core/Mods/sections/class.sections.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Core/Mods/sections/class.sections.php b/Core/Mods/sections/class.sections.php index a1b62f5..9ef404a 100644 --- a/Core/Mods/sections/class.sections.php +++ b/Core/Mods/sections/class.sections.php @@ -94,8 +94,8 @@ class Sections extends Module { // Logic here, first for module sections if ($section['module_section']) { - $this->core->loadMod($section['module_name']); - $event->directory = $this->mods->{$section['module_name']}->getModulePath() . "/Controller/"; + $mod = $this->core->loadMod($section['module_name']); + $event->directory = $mod->getModulePath() . "/Controller/"; } else { // Now for regular sections $event->directory = $section['controller_path'];