diff --git a/Application/Controller/controller.standard.php b/Application/Controller/controller.standard.php index 644309c..a17d212 100644 --- a/Application/Controller/controller.standard.php +++ b/Application/Controller/controller.standard.php @@ -1,5 +1,8 @@ core->loadMod($module_name); - $this->parentClass = new $class_name($this->core); + protected function setType($module_name, $model_type) { + $mod = $this->core->loadMod($module_name); + $this->parentClass = $mod->giveModel($model_type); } /** diff --git a/Core/System/class.abstract.module.php b/Core/System/class.abstract.module.php index 0003a7c..fa1550c 100644 --- a/Core/System/class.abstract.module.php +++ b/Core/System/class.abstract.module.php @@ -1,5 +1,7 @@ setModulePath($cfg->directory); } if (method_exists($CLASS, 'setModuleLinkName')) { - $CLASS->setModuleLinkName($cfg->name); + $CLASS->setModuleLinkName(strtolower($cfg->module_name)); } if (method_exists($CLASS, 'setModuleName')) { $CLASS->setModuleName($name); } + + if (!method_exists($CLASS, 'onLoad')) { + throw new Exception("Module '".$name."' does not have an onLoad() method! Invalid module", 1); + } $CLASS->onLoad(); // Add to the loaded modules diff --git a/Core/System/class.events.php b/Core/System/class.events.php index e3a98be..53bd4ba 100644 --- a/Core/System/class.events.php +++ b/Core/System/class.events.php @@ -3,7 +3,10 @@ * @author FuzeNetwork * @package files */ - + +namespace FuzeWorks; +use \Exception; + /** * @name Events */ @@ -84,10 +87,10 @@ class Events extends Bus{ // No event arguments? Looks like an notify-event if(func_num_args() == 1){ // Load notify-event-class - $eventClass = 'NotifierEvent'; + $eventClass = '\FuzeWorks\NotifierEvent'; }else{ // No notify-event: we tried all we could - throw new \Exception("Event ".$eventName." could not be found!"); + throw new Exception("Event ".$eventName." could not be found!"); } } } diff --git a/Core/System/class.layout.php b/Core/System/class.layout.php index f6aeb89..0539d6e 100644 --- a/Core/System/class.layout.php +++ b/Core/System/class.layout.php @@ -1,5 +1,8 @@ getTraceAsString()); + // reverse array to make steps line up chronologically + $trace = array_reverse($trace); + array_shift($trace); // remove {main} + array_pop($trace); // remove call to this method + $length = count($trace); + $result = array(); + + for ($i = 0; $i < $length; $i++) + { + $result[] = ($i + 1) . ')' . substr($trace[$i], strpos($trace[$i], ' ')); // replace '#someNum' with '$i)', set the right ordering + } + + return "\t" . implode("
", $result); + } + /* =========================================LOGGING METHODS==============================================================*/ diff --git a/Core/System/class.models.php b/Core/System/class.models.php index 1e4b574..0386e00 100644 --- a/Core/System/class.models.php +++ b/Core/System/class.models.php @@ -3,6 +3,8 @@ * @author FuzeNetwork */ +namespace FuzeWorks; + class Models extends Bus{ private $models_array = array(); @@ -25,7 +27,7 @@ class Models extends Bus{ $this->models_array[$name] = $this->model_types[$name]; } elseif (file_exists($file)){ require_once($file); - $model = ucfirst($name); + $model = "\Model\\" . ucfirst($name); $this->logger->logInfo('Loading Model: '.$model, $model); $this->models_array[$name] = new $model($this->core); } else{ diff --git a/Modules/database/class.database.php b/Modules/database/class.database.php index c7cacd3..5e077a3 100644 --- a/Modules/database/class.database.php +++ b/Modules/database/class.database.php @@ -1,6 +1,10 @@ core->loadMod('database'); + } + + public function onLoad() {} + + public function giveModel($type) { + return new DatabaseModel($this->core); } public function select(){ diff --git a/Modules/databasemodel/moduleInfo.php b/Modules/databasemodel/moduleInfo.php index aafc5dc..f4c85d6 100644 --- a/Modules/databasemodel/moduleInfo.php +++ b/Modules/databasemodel/moduleInfo.php @@ -1,11 +1,12 @@ 'DatabaseModel', + 'module_class' => 'Module\DatabaseModel', 'module_file' => 'class.model.php', 'module_name' => 'databasemodel', - 'abstract' => true, + 'abstract' => false, + 'dependencies' => array('database'), 'name' => 'DatabaseModel', 'description' => 'Abstract type for easy database queries', @@ -15,4 +16,6 @@ return array( 'date_created' => '26-02-2015', 'date_updated' => '26-02-2015', + + 'enabled' => true, ); diff --git a/Modules/router/class.router.php b/Modules/router/class.router.php index e7208d5..bf5e37d 100644 --- a/Modules/router/class.router.php +++ b/Modules/router/class.router.php @@ -1,6 +1,8 @@ controllerName))) require_once($file); - $this->controllerClass = ucfirst($this->controllerName); + $this->controllerClass = "\Controller\\" . ucfirst($this->controllerName); $this->controller = new $this->controllerClass($this->core); if (method_exists($this->controller, $this->function) || method_exists($this->controller, '__call')) { diff --git a/Modules/sections/class.sections.php b/Modules/sections/class.sections.php index 41cca0b..d5f99a1 100644 --- a/Modules/sections/class.sections.php +++ b/Modules/sections/class.sections.php @@ -1,8 +1,8 @@ logger->stopLevel(); // Register Events - $this->events->addListener(array($this, 'routerRouteEvent'), 'routerRouteEvent', EventPriority::NORMAL); - $this->events->addListener(array($this, 'layoutLoadEvent'), 'layoutLoadEvent', EventPriority::NORMAL); - $this->events->addListener(array($this, 'modelLoadevent'), 'modelLoadEvent', EventPriority::NORMAL); + $this->events->addListener(array($this, 'routerRouteEvent'), 'routerRouteEvent', EventPriority::LOWEST); + $this->events->addListener(array($this, 'layoutLoadEvent'), 'layoutLoadEvent', EventPriority::LOWEST); + $this->events->addListener(array($this, 'modelLoadevent'), 'modelLoadEvent', EventPriority::LOWEST); } /** diff --git a/Modules/sections/moduleInfo.php b/Modules/sections/moduleInfo.php index 51d6bb1..2441594 100644 --- a/Modules/sections/moduleInfo.php +++ b/Modules/sections/moduleInfo.php @@ -17,4 +17,6 @@ return array( 'date_created' => '29-04-2015', 'date_updated' => '29-04-2015', + + 'enabled' => true, ); diff --git a/index.php b/index.php index 5d28680..a6c445f 100644 --- a/index.php +++ b/index.php @@ -7,7 +7,7 @@ if (!defined('FUZEPATH')) { require_once( dirname(__FILE__) . "/Core/System/class.core.php"); // Load it -$core = new Core(); +$core = new \FuzeWorks\Core(); $core->init(); $core->loadMod('router'); $core->mods->router->setPath( (isset($_GET['path']) ? $_GET['path'] : null) );