Merge branch 'master' into 'master'

Removal of FUZEPATH

Glorious day it is

See merge request !17
This commit is contained in:
Abel Hoogeveen 2015-05-01 20:57:34 +02:00
commit 4b3829612b
9 changed files with 41 additions and 57 deletions

View File

@ -41,7 +41,7 @@ class Config extends Bus{
* @return StdObject of config
*/
public function loadConfigFile($name, $directory = null) {
$dir = (isset($directory) ? $directory : FUZEPATH . "Application//config/");
$dir = (isset($directory) ? $directory : "Application/config/");
$file = $dir . 'config.' . strtolower($name).".php";
if (file_exists($file)) {
@ -88,7 +88,7 @@ class Config extends Bus{
* @param String directory, default is Application/Config
*/
public function set($name, $key, $value, $directory = null) {
$dir = (isset($directory) ? $directory : FUZEPATH . "Application//config/");
$dir = (isset($directory) ? $directory : "Application/config/");
$file = $dir . 'config.' . strtolower($name).".php";
if (file_exists($file)) {
$DECODED = require($file);

View File

@ -4,11 +4,6 @@ namespace FuzeWorks;
use \stdClass;
use \Exception;
if (!defined('FUZESYSPATH')) {
define('STARTTIME', microtime(true));
define( 'FUZESYSPATH', dirname(__FILE__) . '/' );
}
/**
* FuzeWorks Core
*
@ -29,6 +24,9 @@ class Core {
## START/STOP
public function init() {
if (!defined('STARTTIME')) {
define('STARTTIME', microtime(true));
}
// Load basics
ignore_user_abort(true);
register_shutdown_function(array($this, "shutdown"));
@ -51,19 +49,19 @@ class Core {
return;
// Load core abstracts
require_once(FUZESYSPATH . "/class.abstract.bus.php");
require_once(FUZESYSPATH . "/class.abstract.event.php");
require_once(FUZESYSPATH . "/class.abstract.module.php");
require_once(FUZESYSPATH . "/class.abstract.model.php");
require_once(FUZESYSPATH . "/class.abstract.controller.php");
require_once(FUZESYSPATH . "/class.abstract.eventPriority.php");
require_once("Core/System/class.abstract.bus.php");
require_once("Core/System/class.abstract.event.php");
require_once("Core/System/class.abstract.module.php");
require_once("Core/System/class.abstract.model.php");
require_once("Core/System/class.abstract.controller.php");
require_once("Core/System/class.abstract.eventPriority.php");
// Load the core classes
require_once(FUZESYSPATH . "/class.config.php");
require_once(FUZESYSPATH . "/class.logger.php");
require_once(FUZESYSPATH . "/class.models.php");
require_once(FUZESYSPATH . "/class.layout.php");
require_once(FUZESYSPATH . "/class.events.php");
require_once("Core/System/class.config.php");
require_once("Core/System/class.logger.php");
require_once("Core/System/class.models.php");
require_once("Core/System/class.layout.php");
require_once("Core/System/class.events.php");
// Load them
$this->mods->events = new Events ($this);
@ -81,7 +79,7 @@ class Core {
public function loadMod($name) {
// Where the modules are
$path = FUZEPATH . "Modules/";
$path = "Modules/";
// Check if the requested module is registered
if (isset($this->register[$name])) {
@ -164,7 +162,7 @@ class Core {
$this->mods->logger->newLevel("Loading Module Headers", 'Core');
// Get all the module directories
$dir = FUZEPATH . "Modules/";
$dir = "Modules/";
$mod_dirs = array();
$mod_dirs = array_values(array_diff(scandir($dir), array('..', '.')));

View File

@ -87,7 +87,7 @@ class Events extends Bus{
$eventName = $input;
if(!class_exists($eventClass)){
// Check if the file even exists
$file = FUZEPATH . "/Core/Events/event.".$eventName.".php";
$file = "Core/Events/event.".$eventName.".php";
if(file_exists($file)){
// Load the file
require_once($file);

View File

@ -23,7 +23,7 @@ class Layout extends Bus {
private function load() {
// Load Smarty
$smartyDir = FUZEPATH . "/Core/System/Smarty";
$smartyDir = "Core/System/Smarty";
if (!defined('SMARTY_DIR')) {
define('SMARTY_DIR', $smartyDir . DIRECTORY_SEPARATOR . "libs" . DIRECTORY_SEPARATOR);
@ -40,8 +40,8 @@ class Layout extends Bus {
}
public function getSmartyBasicVars($Smarty) {
$Smarty->setCompileDir(FUZEPATH . "/Core/Cache/Compile");
$Smarty->setCacheDir(FUZEPATH . "/Core/Cache/");
$Smarty->setCompileDir("Core/Cache/Compile");
$Smarty->setCacheDir("Core/Cache/");
$Smarty->assign('siteURL', $this->config->main->SITE_URL);
$Smarty->assign('serverName', $this->config->main->SERVER_NAME);
$Smarty->assign('siteDomain', $this->config->main->SITE_DOMAIN);
@ -89,7 +89,7 @@ class Layout extends Bus {
$this->load();
$event = $this->events->fireEvent('layoutLoadEvent', $view);
$directory = ($event->directory === null ? FUZEPATH . "/Application/Views" : $event->directory);
$directory = ($event->directory === null ? "Application/Views" : $event->directory);
$view = ($event->layout === null ? $view : $event->layout);
// Set the file name and location
@ -119,24 +119,18 @@ class Layout extends Bus {
$this->Smarty['main']->assign('title', $this->title);
// Get the viewdir
// @TODO: Fix this for custom directories
$one = FUZEPATH;
$two = $directory . "/";
$count_one = strlen($one);
$count_two = strlen($two);
$length_three = $count_two - $count_one;
$three = $this->config->main->SITE_URL . "/" . substr($two, -$length_three);
$this->layout->assign('viewDir', $three);
$viewDir = $this->config->main->SITE_URL . "/" . substr($directory . "/", -strlen($directory . "/"));
$this->layout->assign('viewDir', $viewDir);
try{
// Load the page
$this->Smarty['main']->display($vw);
$this->logger->logInfo("VIEW LOAD: '".$vw."'", "FuzeWorks->Layout", __FILE__, __LINE__);
$this->logger->logInfo("VIEW LOAD: '".$vw."'", "Layout", __FILE__, __LINE__);
}catch (\SmartyException $e){
// Throw error on failure
$this->logger->logError('Could not load view '.$directory.'/'.$vw.' :: ' . $e->getMessage(), 'FuzeWorks->Layout', __FILE__, __LINE__);
$this->logger->logError('Could not load view '.$directory.'/'.$vw.' :: ' . $e->getMessage(), 'Layout', __FILE__, __LINE__);
throw new Exception\Layout('Could not load view '.$directory.'/'.$vw);
}
}
@ -147,29 +141,25 @@ class Layout extends Bus {
$this->load();
// Set the directory
$directory = ($directory == "" ? FUZEPATH . "/Application/" . '/Views' : $directory);
$directory = ($directory == "" ? "Application/" . '/Views' : $directory);
$this->Smarty['main']->setTemplateDir($directory);
// Set the title
$this->Smarty['main']->assign('title', $this->title);
// Get the viewdir
$one = FUZEPATH;
$two = $directory . "/";
$count_one = strlen($one);
$count_two = strlen($two);
$length_three = $count_two - $count_one;
$three = $this->config->main->SITE_URL . "/" . substr($two, -$length_three);
$this->layout->assign('viewdir', $three);
$viewDir = $this->config->main->SITE_URL . "/" . substr($directory . "/", -strlen($directory . "/"));
$this->layout->assign('viewDir', $viewDir);
try{
// Load the page
return $this->Smarty['main']->fetch('view.'.$view.'.tpl');
$this->logger->logInfo("VIEW LOAD: 'view.".$view.'.tpl'."'", "FuzeWorks->Layout", __FILE__, __LINE__);
$this->logger->logInfo("VIEW LOAD: 'view.".$view.'.tpl'."'", "Layout", __FILE__, __LINE__);
}catch (\SmartyException $e){
// Throw error on failure
$this->logger->logError('Could not load view '.$directory.'/view.'.$view.'.tpl :: ' . $e->getMessage(), 'FuzeWorks->Layout', __FILE__, __LINE__);
$this->logger->logError('Could not load view '.$directory.'/view.'.$view.'.tpl :: ' . $e->getMessage(), 'Layout', __FILE__, __LINE__);
throw new Exception\Layout('Could not load view '.$directory.'/view.'.$view.'.tpl');
}
}

View File

@ -302,8 +302,8 @@ class Logger extends Bus{
511 => 'Network Authentication Required'
);
$this->logError('HTTP-error '.$errno.' called', 'FuzeWorks->Logger');
$this->logInfo('Sending header HTTP/1.1 '.$errno.' '.$http_codes[$errno], 'FuzeWorks->Logger', __FILE__, __LINE__);
$this->logError('HTTP-error '.$errno.' called', 'Logger');
$this->logInfo('Sending header HTTP/1.1 '.$errno.' '.$http_codes[$errno], 'Logger', __FILE__, __LINE__);
header('HTTP/1.1 '.$errno.' '.$http_codes[$errno]);
}

View File

@ -24,7 +24,7 @@ class Models extends Bus{
public function loadModel($name, $directory = null){
// Model load event
$event = $this->events->fireEvent('modelLoadEvent', $name);
$directory = ($event->directory === null ? FUZEPATH . "/Application/Models" : $event->directory);
$directory = ($event->directory === null ? "Application/Models" : $event->directory);
$name = ($event->model === null ? $name : $event->model);
$file = $directory.'/model.'.$name.'.php';
@ -38,7 +38,7 @@ class Models extends Bus{
$this->models_array[$name] = new $model($this->core);
} else{
$this->logger->logWarning('The requested model: \''.$name.'\' could not be found. Loading empty model', 'Models');
require_once(FUZEPATH . "/Core/System/Models/model.interpret.php");
require_once("Core/System/Models/model.interpret.php");
$this->logger->logInfo('Loading Model: interprated databasemodel', 'Models');
$model = new Interpret($this->core);
$model->table($name);

View File

@ -92,7 +92,7 @@ class Router extends Module {
$this->controllerName = ($event->controller === null || empty($event->controller) ? $this->config->main->default_controller : $event->controller);
$this->function = ($event->function === null || empty($event->function) ? $this->config->main->default_function : $event->function);
$this->parameters = $event->parameters;
$this->directory = ($event->directory === null || empty($event->directory) ? FUZEPATH . "/Application/Controller/" : $event->directory);
$this->directory = ($event->directory === null || empty($event->directory) ? "Application/Controller/" : $event->directory);
}
/**

View File

@ -136,9 +136,9 @@ class Main extends Module {
'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,
'controller_path' => $controller_path,
'model_path' => $model_path,
'view_path' => $view_path,
);
}

View File

@ -1,9 +1,5 @@
<?php
// Include framework
if (!defined('FUZEPATH')) {
define( 'FUZEPATH', dirname(__FILE__) . '/' );
}
require_once( dirname(__FILE__) . "/Core/System/class.core.php");
// Load it