Merge branch 'master' into 'master'
Removal of FUZEPATH Glorious day it is See merge request !17
This commit is contained in:
commit
4b3829612b
@ -41,7 +41,7 @@ class Config extends Bus{
|
|||||||
* @return StdObject of config
|
* @return StdObject of config
|
||||||
*/
|
*/
|
||||||
public function loadConfigFile($name, $directory = null) {
|
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";
|
$file = $dir . 'config.' . strtolower($name).".php";
|
||||||
|
|
||||||
if (file_exists($file)) {
|
if (file_exists($file)) {
|
||||||
@ -88,7 +88,7 @@ class Config extends Bus{
|
|||||||
* @param String directory, default is Application/Config
|
* @param String directory, default is Application/Config
|
||||||
*/
|
*/
|
||||||
public function set($name, $key, $value, $directory = null) {
|
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";
|
$file = $dir . 'config.' . strtolower($name).".php";
|
||||||
if (file_exists($file)) {
|
if (file_exists($file)) {
|
||||||
$DECODED = require($file);
|
$DECODED = require($file);
|
||||||
|
@ -4,11 +4,6 @@ namespace FuzeWorks;
|
|||||||
use \stdClass;
|
use \stdClass;
|
||||||
use \Exception;
|
use \Exception;
|
||||||
|
|
||||||
if (!defined('FUZESYSPATH')) {
|
|
||||||
define('STARTTIME', microtime(true));
|
|
||||||
define( 'FUZESYSPATH', dirname(__FILE__) . '/' );
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* FuzeWorks Core
|
* FuzeWorks Core
|
||||||
*
|
*
|
||||||
@ -29,6 +24,9 @@ class Core {
|
|||||||
|
|
||||||
## START/STOP
|
## START/STOP
|
||||||
public function init() {
|
public function init() {
|
||||||
|
if (!defined('STARTTIME')) {
|
||||||
|
define('STARTTIME', microtime(true));
|
||||||
|
}
|
||||||
// Load basics
|
// Load basics
|
||||||
ignore_user_abort(true);
|
ignore_user_abort(true);
|
||||||
register_shutdown_function(array($this, "shutdown"));
|
register_shutdown_function(array($this, "shutdown"));
|
||||||
@ -51,19 +49,19 @@ class Core {
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
// Load core abstracts
|
// Load core abstracts
|
||||||
require_once(FUZESYSPATH . "/class.abstract.bus.php");
|
require_once("Core/System/class.abstract.bus.php");
|
||||||
require_once(FUZESYSPATH . "/class.abstract.event.php");
|
require_once("Core/System/class.abstract.event.php");
|
||||||
require_once(FUZESYSPATH . "/class.abstract.module.php");
|
require_once("Core/System/class.abstract.module.php");
|
||||||
require_once(FUZESYSPATH . "/class.abstract.model.php");
|
require_once("Core/System/class.abstract.model.php");
|
||||||
require_once(FUZESYSPATH . "/class.abstract.controller.php");
|
require_once("Core/System/class.abstract.controller.php");
|
||||||
require_once(FUZESYSPATH . "/class.abstract.eventPriority.php");
|
require_once("Core/System/class.abstract.eventPriority.php");
|
||||||
|
|
||||||
// Load the core classes
|
// Load the core classes
|
||||||
require_once(FUZESYSPATH . "/class.config.php");
|
require_once("Core/System/class.config.php");
|
||||||
require_once(FUZESYSPATH . "/class.logger.php");
|
require_once("Core/System/class.logger.php");
|
||||||
require_once(FUZESYSPATH . "/class.models.php");
|
require_once("Core/System/class.models.php");
|
||||||
require_once(FUZESYSPATH . "/class.layout.php");
|
require_once("Core/System/class.layout.php");
|
||||||
require_once(FUZESYSPATH . "/class.events.php");
|
require_once("Core/System/class.events.php");
|
||||||
|
|
||||||
// Load them
|
// Load them
|
||||||
$this->mods->events = new Events ($this);
|
$this->mods->events = new Events ($this);
|
||||||
@ -81,7 +79,7 @@ class Core {
|
|||||||
|
|
||||||
public function loadMod($name) {
|
public function loadMod($name) {
|
||||||
// Where the modules are
|
// Where the modules are
|
||||||
$path = FUZEPATH . "Modules/";
|
$path = "Modules/";
|
||||||
|
|
||||||
// Check if the requested module is registered
|
// Check if the requested module is registered
|
||||||
if (isset($this->register[$name])) {
|
if (isset($this->register[$name])) {
|
||||||
@ -164,7 +162,7 @@ class Core {
|
|||||||
$this->mods->logger->newLevel("Loading Module Headers", 'Core');
|
$this->mods->logger->newLevel("Loading Module Headers", 'Core');
|
||||||
|
|
||||||
// Get all the module directories
|
// Get all the module directories
|
||||||
$dir = FUZEPATH . "Modules/";
|
$dir = "Modules/";
|
||||||
$mod_dirs = array();
|
$mod_dirs = array();
|
||||||
$mod_dirs = array_values(array_diff(scandir($dir), array('..', '.')));
|
$mod_dirs = array_values(array_diff(scandir($dir), array('..', '.')));
|
||||||
|
|
||||||
|
@ -87,7 +87,7 @@ class Events extends Bus{
|
|||||||
$eventName = $input;
|
$eventName = $input;
|
||||||
if(!class_exists($eventClass)){
|
if(!class_exists($eventClass)){
|
||||||
// Check if the file even exists
|
// Check if the file even exists
|
||||||
$file = FUZEPATH . "/Core/Events/event.".$eventName.".php";
|
$file = "Core/Events/event.".$eventName.".php";
|
||||||
if(file_exists($file)){
|
if(file_exists($file)){
|
||||||
// Load the file
|
// Load the file
|
||||||
require_once($file);
|
require_once($file);
|
||||||
|
@ -23,7 +23,7 @@ class Layout extends Bus {
|
|||||||
|
|
||||||
private function load() {
|
private function load() {
|
||||||
// Load Smarty
|
// Load Smarty
|
||||||
$smartyDir = FUZEPATH . "/Core/System/Smarty";
|
$smartyDir = "Core/System/Smarty";
|
||||||
|
|
||||||
if (!defined('SMARTY_DIR')) {
|
if (!defined('SMARTY_DIR')) {
|
||||||
define('SMARTY_DIR', $smartyDir . DIRECTORY_SEPARATOR . "libs" . DIRECTORY_SEPARATOR);
|
define('SMARTY_DIR', $smartyDir . DIRECTORY_SEPARATOR . "libs" . DIRECTORY_SEPARATOR);
|
||||||
@ -40,8 +40,8 @@ class Layout extends Bus {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function getSmartyBasicVars($Smarty) {
|
public function getSmartyBasicVars($Smarty) {
|
||||||
$Smarty->setCompileDir(FUZEPATH . "/Core/Cache/Compile");
|
$Smarty->setCompileDir("Core/Cache/Compile");
|
||||||
$Smarty->setCacheDir(FUZEPATH . "/Core/Cache/");
|
$Smarty->setCacheDir("Core/Cache/");
|
||||||
$Smarty->assign('siteURL', $this->config->main->SITE_URL);
|
$Smarty->assign('siteURL', $this->config->main->SITE_URL);
|
||||||
$Smarty->assign('serverName', $this->config->main->SERVER_NAME);
|
$Smarty->assign('serverName', $this->config->main->SERVER_NAME);
|
||||||
$Smarty->assign('siteDomain', $this->config->main->SITE_DOMAIN);
|
$Smarty->assign('siteDomain', $this->config->main->SITE_DOMAIN);
|
||||||
@ -89,7 +89,7 @@ class Layout extends Bus {
|
|||||||
$this->load();
|
$this->load();
|
||||||
|
|
||||||
$event = $this->events->fireEvent('layoutLoadEvent', $view);
|
$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);
|
$view = ($event->layout === null ? $view : $event->layout);
|
||||||
|
|
||||||
// Set the file name and location
|
// Set the file name and location
|
||||||
@ -119,24 +119,18 @@ class Layout extends Bus {
|
|||||||
$this->Smarty['main']->assign('title', $this->title);
|
$this->Smarty['main']->assign('title', $this->title);
|
||||||
|
|
||||||
// Get the viewdir
|
// Get the viewdir
|
||||||
// @TODO: Fix this for custom directories
|
$viewDir = $this->config->main->SITE_URL . "/" . substr($directory . "/", -strlen($directory . "/"));
|
||||||
$one = FUZEPATH;
|
$this->layout->assign('viewDir', $viewDir);
|
||||||
$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);
|
|
||||||
|
|
||||||
try{
|
try{
|
||||||
|
|
||||||
// Load the page
|
// Load the page
|
||||||
$this->Smarty['main']->display($vw);
|
$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){
|
}catch (\SmartyException $e){
|
||||||
|
|
||||||
// Throw error on failure
|
// 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);
|
throw new Exception\Layout('Could not load view '.$directory.'/'.$vw);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -147,29 +141,25 @@ class Layout extends Bus {
|
|||||||
$this->load();
|
$this->load();
|
||||||
|
|
||||||
// Set the directory
|
// Set the directory
|
||||||
$directory = ($directory == "" ? FUZEPATH . "/Application/" . '/Views' : $directory);
|
$directory = ($directory == "" ? "Application/" . '/Views' : $directory);
|
||||||
$this->Smarty['main']->setTemplateDir($directory);
|
$this->Smarty['main']->setTemplateDir($directory);
|
||||||
|
|
||||||
// Set the title
|
// Set the title
|
||||||
$this->Smarty['main']->assign('title', $this->title);
|
$this->Smarty['main']->assign('title', $this->title);
|
||||||
|
|
||||||
// Get the viewdir
|
// Get the viewdir
|
||||||
$one = FUZEPATH;
|
$viewDir = $this->config->main->SITE_URL . "/" . substr($directory . "/", -strlen($directory . "/"));
|
||||||
$two = $directory . "/";
|
$this->layout->assign('viewDir', $viewDir);
|
||||||
$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);
|
|
||||||
try{
|
try{
|
||||||
|
|
||||||
// Load the page
|
// Load the page
|
||||||
return $this->Smarty['main']->fetch('view.'.$view.'.tpl');
|
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){
|
}catch (\SmartyException $e){
|
||||||
|
|
||||||
// Throw error on failure
|
// 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');
|
throw new Exception\Layout('Could not load view '.$directory.'/view.'.$view.'.tpl');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -302,8 +302,8 @@ class Logger extends Bus{
|
|||||||
511 => 'Network Authentication Required'
|
511 => 'Network Authentication Required'
|
||||||
);
|
);
|
||||||
|
|
||||||
$this->logError('HTTP-error '.$errno.' called', 'FuzeWorks->Logger');
|
$this->logError('HTTP-error '.$errno.' called', 'Logger');
|
||||||
$this->logInfo('Sending header HTTP/1.1 '.$errno.' '.$http_codes[$errno], 'FuzeWorks->Logger', __FILE__, __LINE__);
|
$this->logInfo('Sending header HTTP/1.1 '.$errno.' '.$http_codes[$errno], 'Logger', __FILE__, __LINE__);
|
||||||
header('HTTP/1.1 '.$errno.' '.$http_codes[$errno]);
|
header('HTTP/1.1 '.$errno.' '.$http_codes[$errno]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -24,7 +24,7 @@ class Models extends Bus{
|
|||||||
public function loadModel($name, $directory = null){
|
public function loadModel($name, $directory = null){
|
||||||
// Model load event
|
// Model load event
|
||||||
$event = $this->events->fireEvent('modelLoadEvent', $name);
|
$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);
|
$name = ($event->model === null ? $name : $event->model);
|
||||||
|
|
||||||
$file = $directory.'/model.'.$name.'.php';
|
$file = $directory.'/model.'.$name.'.php';
|
||||||
@ -38,7 +38,7 @@ class Models extends Bus{
|
|||||||
$this->models_array[$name] = new $model($this->core);
|
$this->models_array[$name] = new $model($this->core);
|
||||||
} else{
|
} else{
|
||||||
$this->logger->logWarning('The requested model: \''.$name.'\' could not be found. Loading empty model', 'Models');
|
$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');
|
$this->logger->logInfo('Loading Model: interprated databasemodel', 'Models');
|
||||||
$model = new Interpret($this->core);
|
$model = new Interpret($this->core);
|
||||||
$model->table($name);
|
$model->table($name);
|
||||||
|
@ -92,7 +92,7 @@ class Router extends Module {
|
|||||||
$this->controllerName = ($event->controller === null || empty($event->controller) ? $this->config->main->default_controller : $event->controller);
|
$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->function = ($event->function === null || empty($event->function) ? $this->config->main->default_function : $event->function);
|
||||||
$this->parameters = $event->parameters;
|
$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);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -136,9 +136,9 @@ class Main extends Module {
|
|||||||
'name' => $name,
|
'name' => $name,
|
||||||
'module_section' => $module_section,
|
'module_section' => $module_section,
|
||||||
'module_name' => $module_name,
|
'module_name' => $module_name,
|
||||||
'controller_path' => FUZEPATH . $controller_path,
|
'controller_path' => $controller_path,
|
||||||
'model_path' => FUZEPATH . $model_path,
|
'model_path' => $model_path,
|
||||||
'view_path' => FUZEPATH . $view_path,
|
'view_path' => $view_path,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,9 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
// Include framework
|
// Include framework
|
||||||
if (!defined('FUZEPATH')) {
|
|
||||||
define( 'FUZEPATH', dirname(__FILE__) . '/' );
|
|
||||||
}
|
|
||||||
|
|
||||||
require_once( dirname(__FILE__) . "/Core/System/class.core.php");
|
require_once( dirname(__FILE__) . "/Core/System/class.core.php");
|
||||||
|
|
||||||
// Load it
|
// Load it
|
||||||
|
Loading…
Reference in New Issue
Block a user