Merge branch '100-make-fuzeworks-composer-compatible' into 'master'
Resolve "Make FuzeWorks Composer Compatible" ###### We want to make FuzeWorks Composer compatible so FuzeWorks can be loaded as a dependency. This will allow us to load FuzeWorks/Core into FuzeWorks/Application, and possibly use FuzeWorks in other projects as well. FuzeWorks will need to be trimmed down a lot, and directories should be determined in a different way. All tasks are still to be determined and put in here as a list. > Closes #100 See merge request !49
This commit is contained in:
commit
c4b2291556
|
@ -0,0 +1,6 @@
|
|||
.gitattributes export-ignore
|
||||
.gitignore export-ignore
|
||||
.gitlab_ci.yml export-ignore
|
||||
tests/ export-ignore
|
||||
CI/ export-ignore
|
||||
Application/ export-ignore
|
|
@ -11,17 +11,8 @@ FuzeWorks.esproj/*
|
|||
*.swp
|
||||
*.out
|
||||
|
||||
# Framework Files
|
||||
Core/Cache/
|
||||
Core/Logs/Error.log
|
||||
|
||||
# Build Files
|
||||
vendor/
|
||||
build/
|
||||
Modules/admin/themes/adminlte2.1/plugins/
|
||||
Modules/admin/themes/adminlte2.1/dist/
|
||||
Modules/admin/themes/adminlte2.1/bootstrap/
|
||||
doc
|
||||
nbproject
|
||||
Application/Cache
|
||||
Application/Logs
|
||||
|
|
|
@ -18,26 +18,6 @@ build:composer:
|
|||
paths:
|
||||
- vendor/
|
||||
|
||||
test:5.4:
|
||||
image: php:5.4
|
||||
script:
|
||||
- vendor/bin/phpunit -c tests/phpunit.xml --coverage-text
|
||||
cache:
|
||||
key: "$CI_BUILD_REF/$CI_BUILD_REF_NAME"
|
||||
paths:
|
||||
- vendor/
|
||||
allow_failure: true
|
||||
|
||||
test:5.5:
|
||||
image: php:5.5
|
||||
script:
|
||||
- vendor/bin/phpunit -c tests/phpunit.xml --coverage-text
|
||||
cache:
|
||||
key: "$CI_BUILD_REF/$CI_BUILD_REF_NAME"
|
||||
paths:
|
||||
- vendor/
|
||||
allow_failure: true
|
||||
|
||||
test:5.6:
|
||||
stage: test
|
||||
image: php:5.6
|
||||
|
@ -70,6 +50,7 @@ release:
|
|||
name: "${CI_BUILD_NAME}_${CI_BUILD_REF_NAME}"
|
||||
paths:
|
||||
- build/
|
||||
expire_in: 3 weeks
|
||||
cache:
|
||||
key: "$CI_BUILD_REF/$CI_BUILD_REF_NAME"
|
||||
paths:
|
||||
|
|
|
@ -1,95 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* FuzeWorks.
|
||||
*
|
||||
* The FuzeWorks MVC PHP FrameWork
|
||||
*
|
||||
* Copyright (C) 2015 TechFuze
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* @author TechFuze
|
||||
* @copyright Copyright (c) 2013 - 2016, Techfuze. (http://techfuze.net)
|
||||
* @copyright Copyright (c) 1996 - 2015, Free Software Foundation, Inc. (http://www.fsf.org/)
|
||||
* @license http://opensource.org/licenses/GPL-3.0 GPLv3 License
|
||||
*
|
||||
* @link http://fuzeworks.techfuze.net
|
||||
* @since Version 0.0.1
|
||||
*
|
||||
* @version Version 0.0.1
|
||||
*/
|
||||
?>
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<title>Page not found</title>
|
||||
<link href="//netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css" rel="stylesheet">
|
||||
<style>
|
||||
body {
|
||||
background: #ecf0f1;
|
||||
border-bottom: 1px solid #DDD;
|
||||
padding: 100px 0 100px;
|
||||
font-size: 16px;
|
||||
}
|
||||
|
||||
#setupcontainer {
|
||||
max-width: 950px;
|
||||
margin-left: auto;
|
||||
margin-right: auto;
|
||||
}
|
||||
|
||||
.col-centered{
|
||||
float: none;
|
||||
margin: 0 auto;
|
||||
}
|
||||
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div id='setupcontainer'>
|
||||
<div class='row'>
|
||||
<div class='col-lg-12 col-md-4 col-sm-12'>
|
||||
<div id='contentPanel' class="panel panel-default" style='display:none'>
|
||||
<div id='1' class="panel-body" style='display:none'>
|
||||
<p class="lead">Page not found</p>
|
||||
<p>
|
||||
The requested page could not be found.
|
||||
</p>
|
||||
<p>
|
||||
Our apologies for the inconvenience.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<footer>
|
||||
<script src="http://code.jquery.com/jquery-1.11.0.min.js"></script>
|
||||
<script src="//netdna.bootstrapcdn.com/bootstrap/3.1.1/js/bootstrap.min.js"></script>
|
||||
|
||||
<script>
|
||||
var currentPage = 0;
|
||||
var currentProgress = 0;
|
||||
|
||||
start();
|
||||
function start() {
|
||||
$("#contentPanel").fadeIn(500);
|
||||
$("#1").fadeIn(500);
|
||||
}
|
||||
</script>
|
||||
</footer>
|
||||
</body>
|
||||
</html>
|
|
@ -1,95 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* FuzeWorks.
|
||||
*
|
||||
* The FuzeWorks MVC PHP FrameWork
|
||||
*
|
||||
* Copyright (C) 2015 TechFuze
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* @author TechFuze
|
||||
* @copyright Copyright (c) 2013 - 2016, Techfuze. (http://techfuze.net)
|
||||
* @copyright Copyright (c) 1996 - 2015, Free Software Foundation, Inc. (http://www.fsf.org/)
|
||||
* @license http://opensource.org/licenses/GPL-3.0 GPLv3 License
|
||||
*
|
||||
* @link http://fuzeworks.techfuze.net
|
||||
* @since Version 0.0.1
|
||||
*
|
||||
* @version Version 0.0.1
|
||||
*/
|
||||
?>
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<title>Page not found</title>
|
||||
<link href="//netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css" rel="stylesheet">
|
||||
<style>
|
||||
body {
|
||||
background: #ecf0f1;
|
||||
border-bottom: 1px solid #DDD;
|
||||
padding: 100px 0 100px;
|
||||
font-size: 16px;
|
||||
}
|
||||
|
||||
#setupcontainer {
|
||||
max-width: 950px;
|
||||
margin-left: auto;
|
||||
margin-right: auto;
|
||||
}
|
||||
|
||||
.col-centered{
|
||||
float: none;
|
||||
margin: 0 auto;
|
||||
}
|
||||
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div id='setupcontainer'>
|
||||
<div class='row'>
|
||||
<div class='col-lg-12 col-md-4 col-sm-12'>
|
||||
<div id='contentPanel' class="panel panel-default" style='display:none'>
|
||||
<div id='1' class="panel-body" style='display:none'>
|
||||
<p class="lead">Internal Server Error</p>
|
||||
<p>
|
||||
The requested page could not be loaded.
|
||||
</p>
|
||||
<p>
|
||||
Our apologies for the inconvenience.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<footer>
|
||||
<script src="http://code.jquery.com/jquery-1.11.0.min.js"></script>
|
||||
<script src="//netdna.bootstrapcdn.com/bootstrap/3.1.1/js/bootstrap.min.js"></script>
|
||||
|
||||
<script>
|
||||
var currentPage = 0;
|
||||
var currentProgress = 0;
|
||||
|
||||
start();
|
||||
function start() {
|
||||
$("#contentPanel").fadeIn(500);
|
||||
$("#1").fadeIn(500);
|
||||
}
|
||||
</script>
|
||||
</footer>
|
||||
</body>
|
||||
</html>
|
|
@ -35,6 +35,7 @@ use FuzeWorks\Config;
|
|||
use FuzeWorks\ConfigException;
|
||||
use FuzeWorks\Database;
|
||||
use FuzeWorks\DatabaseException;
|
||||
use FuzeWorks\Core;
|
||||
|
||||
/**
|
||||
* Initialize the database
|
||||
|
@ -144,11 +145,11 @@ function &DB($params = '', $query_builder_override = NULL)
|
|||
$query_builder = $active_record;
|
||||
}
|
||||
|
||||
require_once('Core'.DS.'Database'.DS.'DB_driver.php');
|
||||
require_once(Core::$coreDir . DS . 'Database'.DS.'DB_driver.php');
|
||||
|
||||
if ( ! isset($query_builder) OR $query_builder === TRUE)
|
||||
{
|
||||
require_once('Core'.DS.'Database'.DS.'DB_query_builder.php');
|
||||
require_once(Core::$coreDir . DS . 'Database'.DS.'DB_query_builder.php');
|
||||
if ( ! class_exists('FW_DB', FALSE))
|
||||
{
|
||||
/**
|
||||
|
@ -171,7 +172,7 @@ function &DB($params = '', $query_builder_override = NULL)
|
|||
}
|
||||
|
||||
// Load the DB driver
|
||||
$driver_file = 'Core'.DS.'Database'.DS.'drivers/'.$params['dbdriver'].DS.$params['dbdriver'].'_driver.php';
|
||||
$driver_file = Core::$coreDir . DS . 'Database'.DS.'drivers/'.$params['dbdriver'].DS.$params['dbdriver'].'_driver.php';
|
||||
|
||||
if (!file_exists($driver_file))
|
||||
{
|
||||
|
@ -187,7 +188,7 @@ function &DB($params = '', $query_builder_override = NULL)
|
|||
// Check for a subdriver
|
||||
if ( ! empty($DB->subdriver))
|
||||
{
|
||||
$driver_file = 'Core'.DS.'Database'.DS.'drivers'.DS.$DB->dbdriver.'/subdrivers/'.$DB->dbdriver.'_'.$DB->subdriver.'_driver.php';
|
||||
$driver_file = Core::$coreDir . DS . 'Database'.DS.'drivers'.DS.$DB->dbdriver.'/subdrivers/'.$DB->dbdriver.'_'.$DB->subdriver.'_driver.php';
|
||||
|
||||
if (file_exists($driver_file))
|
||||
{
|
||||
|
|
|
@ -91,15 +91,7 @@ class FW_DB_Cache {
|
|||
*/
|
||||
public function check_path($path = '')
|
||||
{
|
||||
if ($path === '')
|
||||
{
|
||||
if ($this->db->cachedir === '')
|
||||
{
|
||||
return $this->db->cache_off();
|
||||
}
|
||||
|
||||
$path = $this->db->cachedir;
|
||||
}
|
||||
$path = ($path === '' ? Core::$tempDir . DS . 'Database' : $path);
|
||||
|
||||
// Add a trailing slash to the path if needed
|
||||
$path = realpath($path)
|
||||
|
@ -108,10 +100,13 @@ class FW_DB_Cache {
|
|||
|
||||
if ( ! is_dir($path))
|
||||
{
|
||||
Logger::logDebug('DB cache path error: '.$path);
|
||||
if (!mkdir($path, 0777, false))
|
||||
{
|
||||
Logger::logDebug('DB cache path error: '.$path);
|
||||
|
||||
// If the path is wrong we'll turn off caching
|
||||
return $this->db->cache_off();
|
||||
// If the path is wrong we'll turn off caching
|
||||
return $this->db->cache_off();
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! Core::isReallyWritable($path))
|
||||
|
|
|
@ -35,6 +35,7 @@ use FuzeWorks\Logger;
|
|||
use FuzeWorks\DatabaseException;
|
||||
use FuzeWorks\Utf8;
|
||||
use FuzeWorks\Language;
|
||||
use FuzeWorks\Core;
|
||||
|
||||
/**
|
||||
* Database Driver Class
|
||||
|
@ -764,8 +765,8 @@ abstract class FW_DB_driver {
|
|||
|
||||
if ( ! class_exists($driver, FALSE))
|
||||
{
|
||||
require_once('Core'.DS.'Database'.DS.'DB_result.php');
|
||||
require_once('Core'.DS.'database'.DS.'drivers'.DS.$this->dbdriver.'/'.$this->dbdriver.'_result.php');
|
||||
require_once(Core::$coreDir . DS . 'Database'.DS.'DB_result.php');
|
||||
require_once(Core::$coreDir . DS . 'database'.DS.'drivers'.DS.$this->dbdriver.'/'.$this->dbdriver.'_result.php');
|
||||
}
|
||||
|
||||
return $driver;
|
||||
|
@ -1690,7 +1691,7 @@ abstract class FW_DB_driver {
|
|||
{
|
||||
if ( ! class_exists('FW_DB_Cache', FALSE))
|
||||
{
|
||||
require_once('Core'.DS.'Database'.DS.'DB_cache.php');
|
||||
require_once(Core::$coreDir . DS . 'Database'.DS.'DB_cache.php');
|
||||
}
|
||||
elseif (is_object($this->CACHE))
|
||||
{
|
||||
|
@ -1771,7 +1772,7 @@ abstract class FW_DB_driver {
|
|||
$call['file'] = str_replace('\\', '/', $call['file']);
|
||||
}
|
||||
|
||||
if (strpos($call['file'], 'Core'.DS.'Database') === FALSE && strpos($call['class'], 'Loader') === FALSE)
|
||||
if (strpos($call['file'], Core::$coreDir . DS . 'Database') === FALSE && strpos($call['class'], 'Loader') === FALSE)
|
||||
{
|
||||
// Found it - use a relative path for safety
|
||||
$message[] = 'Filename: '.str_replace(array('Application', 'Core'), '', $call['file']);
|
||||
|
|
|
@ -32,6 +32,7 @@
|
|||
|
||||
namespace FuzeWorks\Library;
|
||||
use FuzeWorks\Factory;
|
||||
use FuzeWorks\Core;
|
||||
|
||||
/**
|
||||
* FuzeWorks File Caching Class
|
||||
|
@ -73,9 +74,7 @@ class FW_Cache_file extends FW_Driver {
|
|||
|
||||
// Load the required helpers
|
||||
$this->factory->helpers->load('file');
|
||||
|
||||
$path = $this->factory->config->get('cache')->cache_file_path;
|
||||
$this->_cache_path = ($path === '') ? 'Application'.DS.'Cache/' : $path;
|
||||
$this->_cache_path = Core::$tempDir . DS . 'CacheLibrary' . DS;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
|
@ -262,6 +261,14 @@ class FW_Cache_file extends FW_Driver {
|
|||
*/
|
||||
public function is_supported()
|
||||
{
|
||||
if ( ! is_dir($this->_cache_path))
|
||||
{
|
||||
if (!mkdir($this->_cache_path, 0777, false))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return is_really_writable($this->_cache_path);
|
||||
}
|
||||
|
||||
|
|
|
@ -35,6 +35,7 @@ use FuzeWorks\Config;
|
|||
use FuzeWorks\Logger;
|
||||
use FuzeWorks\LibraryException;
|
||||
use FuzeWorks\Factory;
|
||||
use FuzeWorks\Core;
|
||||
use ReflectionObject;
|
||||
|
||||
/**
|
||||
|
@ -132,7 +133,7 @@ class FW_Driver_Library {
|
|||
if (file_exists($file))
|
||||
{
|
||||
// Yes - require base class from BASEPATH
|
||||
$basepath = 'Core'.DS.'Libraries'.DS.$clean_class.DS.'drivers'.DS.$clean_class.'_'.$child.'.php';
|
||||
$basepath = Core::$coreDir . DS. 'Libraries'.DS.$clean_class.DS.'drivers'.DS.$clean_class.'_'.$child.'.php';
|
||||
if ( ! file_exists($basepath))
|
||||
{
|
||||
$msg = 'Unable to load the requested class: FW_'.$child_name;
|
||||
|
|
|
@ -59,7 +59,7 @@ class Config
|
|||
*
|
||||
* @var array Array of paths where helpers can be found
|
||||
*/
|
||||
protected $configPaths = array('Application'.DS.'Config');
|
||||
protected $configPaths = array();
|
||||
|
||||
/**
|
||||
* Temporary variable to remain compatible with old FuzeWorks code
|
||||
|
@ -69,6 +69,11 @@ class Config
|
|||
*/
|
||||
protected static $factory;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->configPaths[] = Core::$appDir . DS. 'Config';
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve a config file object
|
||||
*
|
||||
|
@ -115,10 +120,11 @@ class Config
|
|||
foreach ($configPaths as $directory)
|
||||
{
|
||||
// If file exists, load it and break the loop
|
||||
if (file_exists($directory . DS . 'config.'.$configName.'.php'))
|
||||
$file = $directory . DS . 'config.'.$configName.'.php';
|
||||
if (file_exists($file))
|
||||
{
|
||||
// Load object
|
||||
return new ConfigORM($directory . DS . 'config.'.$configName.'.php');
|
||||
return new ConfigORM($file);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,204 @@
|
|||
<?php
|
||||
/**
|
||||
* FuzeWorks.
|
||||
*
|
||||
* The FuzeWorks MVC PHP FrameWork
|
||||
*
|
||||
* Copyright (C) 2015 TechFuze
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* @author TechFuze
|
||||
* @copyright Copyright (c) 2013 - 2016, Techfuze. (http://techfuze.net)
|
||||
* @copyright Copyright (c) 1996 - 2015, Free Software Foundation, Inc. (http://www.fsf.org/)
|
||||
* @license http://opensource.org/licenses/GPL-3.0 GPLv3 License
|
||||
*
|
||||
* @link http://fuzeworks.techfuze.net
|
||||
* @since Version 0.0.1
|
||||
*
|
||||
* @version Version 0.0.1
|
||||
*/
|
||||
|
||||
namespace FuzeWorks;
|
||||
|
||||
/**
|
||||
* Class Configurator.
|
||||
*
|
||||
* The configurator prepares FuzeWorks and loads it when requested.
|
||||
*
|
||||
* The user passes variables into the Configurator and the Configurator makes sure
|
||||
* that FuzeWorks is loaded accordingly.
|
||||
*
|
||||
* This allows for more flexible startups.
|
||||
* @author Abel Hoogeveen <abel@techfuze.net>
|
||||
* @author David Grudl <https://davidgrudl.com>
|
||||
* @copyright Copyright (c) 2013 - 2016, Techfuze. (http://techfuze.net)
|
||||
*/
|
||||
class Configurator
|
||||
{
|
||||
/**
|
||||
* The parameters that will be passed to FuzeWorks.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $parameters;
|
||||
|
||||
const COOKIE_SECRET = 'fuzeworks-debug';
|
||||
|
||||
/**
|
||||
* Constructs the Configurator class.
|
||||
*
|
||||
* Loads the default parameters
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->parameters = $this->getDefaultParameters();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function getDefaultParameters()
|
||||
{
|
||||
$trace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS);
|
||||
$last = end($trace);
|
||||
$debugMode = static::detectDebugMode();
|
||||
return [
|
||||
'appDir' => isset($trace[1]['file']) ? dirname($trace[1]['file']) : NULL,
|
||||
'wwwDir' => isset($last['file']) ? dirname($last['file']) : NULL,
|
||||
'debugMode' => $debugMode
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets path to temporary directory.
|
||||
* @return self
|
||||
*/
|
||||
public function setLogDirectory($path)
|
||||
{
|
||||
$this->parameters['logDir'] = $path;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the default timezone.
|
||||
* @return self
|
||||
*/
|
||||
public function setTimeZone($timezone)
|
||||
{
|
||||
date_default_timezone_set($timezone);
|
||||
@ini_set('date.timezone', $timezone); // @ - function may be disabled
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds new parameters. The %params% will be expanded.
|
||||
* @return self
|
||||
*/
|
||||
public function setParameters(array $params)
|
||||
{
|
||||
foreach ($params as $key => $value) {
|
||||
$this->parameters[$key] = $value;
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets path to temporary directory.
|
||||
* @return self
|
||||
*/
|
||||
public function setTempDirectory($path)
|
||||
{
|
||||
$this->parameters['tempDir'] = $path;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function isDebugMode()
|
||||
{
|
||||
return $this->parameters['debugMode'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Set parameter %debugMode%.
|
||||
* @param bool|string|array
|
||||
* @return self
|
||||
*/
|
||||
public function setDebugMode($value)
|
||||
{
|
||||
if (is_string($value) || is_array($value)) {
|
||||
$value = static::detectDebugMode($value);
|
||||
} elseif (!is_bool($value)) {
|
||||
throw new InvalidArgumentException(sprintf('Value must be either a string, array, or boolean, %s given.', gettype($value)));
|
||||
}
|
||||
$this->parameters['debugMode'] = $value;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Detects debug mode by IP address.
|
||||
* @param string|array IP addresses or computer names whitelist detection
|
||||
* @return bool
|
||||
*/
|
||||
public static function detectDebugMode($list = NULL)
|
||||
{
|
||||
$addr = isset($_SERVER['REMOTE_ADDR'])
|
||||
? $_SERVER['REMOTE_ADDR']
|
||||
: php_uname('n');
|
||||
$secret = isset($_COOKIE[self::COOKIE_SECRET]) && is_string($_COOKIE[self::COOKIE_SECRET])
|
||||
? $_COOKIE[self::COOKIE_SECRET]
|
||||
: NULL;
|
||||
$list = is_string($list)
|
||||
? preg_split('#[,\s]+#', $list)
|
||||
: (array) $list;
|
||||
if (!isset($_SERVER['HTTP_X_FORWARDED_FOR'])) {
|
||||
$list[] = '127.0.0.1';
|
||||
$list[] = '::1';
|
||||
}
|
||||
return in_array($addr, $list, TRUE) || in_array("$secret@$addr", $list, TRUE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create the container which holds FuzeWorks.
|
||||
*
|
||||
* Due to the static nature of FuzeWorks, this is not yet possible.
|
||||
* When issue #101 is completed, this should be resolved.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function createContainer()
|
||||
{
|
||||
// First set all the directories
|
||||
Core::$appDir = $this->parameters['appDir'];
|
||||
Core::$wwwDir = $this->parameters['wwwDir'];
|
||||
Core::$tempDir = $this->parameters['tempDir'];
|
||||
Core::$logDir = $this->parameters['logDir'];
|
||||
|
||||
// Then set debug mode
|
||||
if ($this->parameters['debugMode'])
|
||||
{
|
||||
define('ENVIRONMENT', 'DEVELOPMENT');
|
||||
}
|
||||
else
|
||||
{
|
||||
define('ENVIRONMENT', 'PRODUCTION');
|
||||
}
|
||||
|
||||
// Then load the framework
|
||||
Core::init();
|
||||
}
|
||||
}
|
|
@ -49,11 +49,6 @@ class Core
|
|||
*/
|
||||
public static $version = '0.0.1';
|
||||
|
||||
/**
|
||||
* @var bool Whether the files has been loaded
|
||||
*/
|
||||
private static $loaded = false;
|
||||
|
||||
/**
|
||||
* Working directory of the Framework.
|
||||
*
|
||||
|
@ -63,6 +58,16 @@ class Core
|
|||
*/
|
||||
public static $cwd;
|
||||
|
||||
public static $appDir;
|
||||
|
||||
public static $wwwDir;
|
||||
|
||||
public static $coreDir;
|
||||
|
||||
public static $tempDir;
|
||||
|
||||
public static $logDir;
|
||||
|
||||
/**
|
||||
* Initializes the core.
|
||||
*
|
||||
|
@ -70,9 +75,12 @@ class Core
|
|||
*/
|
||||
public static function init()
|
||||
{
|
||||
// Set the CWD for usage in the shutdown function+
|
||||
// Set the CWD for usage in the shutdown function
|
||||
self::$cwd = getcwd();
|
||||
|
||||
// Set the core dir for when the loading of classes is required
|
||||
self::$coreDir = dirname(__DIR__);
|
||||
|
||||
// If the environment is not yet defined, use production settings
|
||||
if (!defined('ENVIRONMENT'))
|
||||
{
|
||||
|
@ -90,7 +98,7 @@ class Core
|
|||
register_shutdown_function(array('\FuzeWorks\Core', 'shutdown'));
|
||||
|
||||
// Load core functionality
|
||||
self::loadStartupFiles();
|
||||
new Factory();
|
||||
|
||||
// Load the config file of the FuzeWorks core
|
||||
$config = Config::get('core');
|
||||
|
@ -110,61 +118,15 @@ class Core
|
|||
);
|
||||
}
|
||||
|
||||
// Load Composer
|
||||
if ($config->enable_composer) {
|
||||
$file = ($config->composer_autoloader != '' ? $config->composer_autoloader : 'vendor/autoload.php');
|
||||
self::loadComposer($file);
|
||||
}
|
||||
|
||||
// And fire the coreStartEvent
|
||||
$event = Events::fireEvent('coreStartEvent');
|
||||
if ($event->isCancelled()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Load all the files of the FuzeWorks Framework.
|
||||
*/
|
||||
private static function loadStartupFiles()
|
||||
{
|
||||
if (self::$loaded) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Load core abstracts
|
||||
include_once 'Core/System/class.factory.php';
|
||||
include_once 'Core/System/class.exceptions.php';
|
||||
include_once 'Core/System/class.abstract.event.php';
|
||||
|
||||
// Load the core classes
|
||||
include_once 'Core/System/class.config.php';
|
||||
include_once 'Core/System/class.abstract.configOrmAbstract.php';
|
||||
include_once 'Core/System/class.configOrm.php';
|
||||
include_once 'Core/System/class.abstract.eventPriority.php';
|
||||
include_once 'Core/System/class.events.php';
|
||||
include_once 'Core/System/class.logger.php';
|
||||
include_once 'Core/System/class.abstract.model.php';
|
||||
include_once 'Core/System/class.models.php';
|
||||
include_once 'Core/System/class.layout.php';
|
||||
include_once 'Core/System/class.abstract.controllerabstract.php';
|
||||
include_once 'Core/System/class.router.php';
|
||||
include_once 'Core/System/class.abstract.module.php';
|
||||
include_once 'Core/System/class.modules.php';
|
||||
include_once 'Core/System/class.libraries.php';
|
||||
include_once 'Core/System/class.helpers.php';
|
||||
include_once 'Core/System/class.database.php';
|
||||
include_once 'Core/System/class.language.php';
|
||||
include_once 'Core/System/class.utf8.php';
|
||||
include_once 'Core/System/class.uri.php';
|
||||
include_once 'Core/System/class.security.php';
|
||||
include_once 'Core/System/class.input.php';
|
||||
include_once 'Core/System/class.output.php';
|
||||
|
||||
// Load the core classes
|
||||
new Factory();
|
||||
|
||||
self::$loaded = true;
|
||||
// And initialize multiple classes
|
||||
Layout::init();
|
||||
Language::init();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -189,27 +151,6 @@ class Core
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Load composer if it is present.
|
||||
*
|
||||
* @param string directory of composer autoload file (optional)
|
||||
*
|
||||
* @return bool true on success, false on failure
|
||||
*/
|
||||
private static function loadComposer($file = 'vendor/autoload.php')
|
||||
{
|
||||
if (file_exists($file)) {
|
||||
include $file;
|
||||
Logger::log('Loaded Composer');
|
||||
Logger::loadComposer();
|
||||
|
||||
return true;
|
||||
}
|
||||
Logger::log('Failed to load Composer. File \''.$file.'\' not found');
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks whether the current running version of PHP is equal to the input string.
|
||||
*
|
||||
|
|
|
@ -93,7 +93,7 @@ class Database
|
|||
return $reference = self::$defaultDB;
|
||||
}
|
||||
|
||||
require_once ('Core'.DS.'Database'.DS.'DB.php');
|
||||
require_once (Core::$coreDir . DS . 'Database'.DS.'DB.php');
|
||||
|
||||
if ($newInstance)
|
||||
{
|
||||
|
@ -131,12 +131,12 @@ class Database
|
|||
$database =& self::$defaultDB;
|
||||
}
|
||||
|
||||
require_once ('Core'.DS.'Database'.DS.'DB_forge.php');
|
||||
require_once('Core'.DS.'Database'.DS.'drivers'.DS.$database->dbdriver.DS.$database->dbdriver.'_forge.php');
|
||||
require_once (Core::$coreDir . DS . 'Database'.DS.'DB_forge.php');
|
||||
require_once(Core::$coreDir . DS . 'Database'.DS.'drivers'.DS.$database->dbdriver.DS.$database->dbdriver.'_forge.php');
|
||||
|
||||
if ( ! empty($database->subdriver))
|
||||
{
|
||||
$driver_path = 'Core'.DS.'Database'.DS.'drivers'.DS.$database->dbdriver.DS.'subdrivers'.DS.$database->dbdriver.'_'.$database->subdriver.'_forge.php';
|
||||
$driver_path = Core::$coreDir . DS . 'Database'.DS.'drivers'.DS.$database->dbdriver.DS.'subdrivers'.DS.$database->dbdriver.'_'.$database->subdriver.'_forge.php';
|
||||
if (file_exists($driver_path))
|
||||
{
|
||||
require_once($driver_path);
|
||||
|
@ -185,8 +185,8 @@ class Database
|
|||
$database = & self::$defaultDB;
|
||||
}
|
||||
|
||||
require_once ('Core'.DS.'Database'.DS.'DB_utility.php');
|
||||
require_once('Core'.DS.'Database'.DS.'drivers'.DS.$database->dbdriver.DS.$database->dbdriver.'_utility.php');
|
||||
require_once (Core::$coreDir . DS . 'Database'.DS.'DB_utility.php');
|
||||
require_once(Core::$coreDir . DS . 'Database'.DS.'drivers'.DS.$database->dbdriver.DS.$database->dbdriver.'_utility.php');
|
||||
$class = 'FW_DB_'.$database->dbdriver.'_utility';
|
||||
|
||||
if ($newInstance)
|
||||
|
|
|
@ -157,7 +157,7 @@ class Events
|
|||
$eventName = $input;
|
||||
if (!class_exists($eventClass)) {
|
||||
// Check if the file even exists
|
||||
$file = 'Core/Events/event.'.$eventName.'.php';
|
||||
$file = Core::$coreDir . DS . 'Events' . DS . 'event.'.$eventName.'.php';
|
||||
if (file_exists($file)) {
|
||||
// Load the file
|
||||
$eventClass = "\FuzeWorks\Event\\".$eventClass;
|
||||
|
|
|
@ -190,4 +190,14 @@ class SecurityException extends Exception
|
|||
*/
|
||||
class FactoryException extends Exception
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Class InvalidArgumentException.
|
||||
*
|
||||
* @author Abel Hoogeveen <abel@techfuze.net>
|
||||
* @copyright Copyright (c) 2013 - 2016, Techfuze. (http://techfuze.net)
|
||||
*/
|
||||
class InvalidArgumentException extends Exception
|
||||
{
|
||||
}
|
|
@ -68,7 +68,15 @@ class Helpers
|
|||
*
|
||||
* @var array Array of paths where helpers can be found
|
||||
*/
|
||||
protected $helperPaths = array('Application'.DS.'Helpers', 'Core'.DS.'Helpers');
|
||||
protected $helperPaths = array();
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->helperPaths = [
|
||||
Core::$appDir . DS . 'Helpers',
|
||||
Core::$coreDir . DS . 'Helpers'
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Load a helper.
|
||||
|
@ -111,7 +119,7 @@ class Helpers
|
|||
// If an extension is loaded there needs to be a base helper
|
||||
if ($extendedHelperLoaded)
|
||||
{
|
||||
$baseHelper = 'Core'.DS.'Helpers'.$helperName.'.php';
|
||||
$baseHelper = Core::$coreDir . DS . 'Helpers' . DS . $helperName.'.php';
|
||||
if (!file_exists($baseHelper))
|
||||
{
|
||||
throw new HelperException("Could not load helper. Base Helper not found while Extension loaded", 1);
|
||||
|
|
|
@ -62,7 +62,7 @@ class Language
|
|||
* Paths where the class can find translations
|
||||
* @var array
|
||||
*/
|
||||
protected static $languagePaths = array('Application'.DS.'Language');
|
||||
protected static $languagePaths = array();
|
||||
|
||||
/**
|
||||
* The current language array
|
||||
|
@ -76,6 +76,11 @@ class Language
|
|||
*/
|
||||
protected static $is_loaded = array();
|
||||
|
||||
public static function init()
|
||||
{
|
||||
self::$languagePaths[] = Core::$appDir . DS . 'Language';
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve a language file and return the language array
|
||||
*
|
||||
|
@ -115,7 +120,7 @@ class Language
|
|||
$lang = array();
|
||||
|
||||
// Load the base file, so any others found can override it
|
||||
$basepath = 'Core'.DS.'Language'.DS.$idiom.DS.$langfile;
|
||||
$basepath = Core::$coreDir . DS. 'Language'.DS.$idiom.DS.$langfile;
|
||||
if (($found = file_exists($basepath)) === TRUE)
|
||||
{
|
||||
$lang = array_merge($lang, (array) include($basepath));
|
||||
|
|
|
@ -43,6 +43,7 @@ use FuzeWorks\TemplateEngine\TemplateEngine;
|
|||
*
|
||||
* @author Abel Hoogeveen <abel@techfuze.net>
|
||||
* @copyright Copyright (c) 2013 - 2016, Techfuze. (http://techfuze.net)
|
||||
* @todo Make Object, remove static stuff
|
||||
*/
|
||||
class Layout
|
||||
{
|
||||
|
@ -58,7 +59,7 @@ class Layout
|
|||
*
|
||||
* @var string
|
||||
*/
|
||||
public static $directory = 'Application/Views';
|
||||
public static $directory;
|
||||
|
||||
/**
|
||||
* All assigned currently assigned to the template.
|
||||
|
@ -95,6 +96,11 @@ class Layout
|
|||
*/
|
||||
private static $current_engine;
|
||||
|
||||
public static function init()
|
||||
{
|
||||
self::$directory = Core::$appDir . DS .'Views';
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve a template file using a string and a directory and immediatly parse it to the output class.
|
||||
*
|
||||
|
@ -157,7 +163,7 @@ class Layout
|
|||
}
|
||||
|
||||
// Then assign some basic variables for the template
|
||||
self::$assigned_variables['viewDir'] = Config::get('main')->base_url.preg_replace('#/+#', '/', substr(self::$directory.'/', -strlen(self::$directory.'/')));
|
||||
self::$assigned_variables['wwwDir'] = Config::get('main')->base_url;
|
||||
self::$assigned_variables['siteURL'] = Config::get('main')->base_url;
|
||||
self::$assigned_variables['serverName'] = Config::get('main')->server_name;
|
||||
self::$assigned_variables['adminMail'] = Config::get('main')->administrator_mail;
|
||||
|
@ -521,7 +527,7 @@ class Layout
|
|||
|
||||
self::$current_engine = null;
|
||||
self::$assigned_variables = array();
|
||||
self::$directory = 'Application/Views';
|
||||
self::$directory = Core::$appDir . DS . 'Views';
|
||||
Logger::log('Reset the layout manager to its default state');
|
||||
}
|
||||
}
|
||||
|
@ -529,6 +535,7 @@ class Layout
|
|||
namespace FuzeWorks\TemplateEngine;
|
||||
|
||||
use FuzeWorks\LayoutException;
|
||||
use FuzeWorks\Core;
|
||||
use Smarty;
|
||||
use Latte\Engine as Latte;
|
||||
|
||||
|
@ -688,8 +695,8 @@ class SmartyEngine implements TemplateEngine
|
|||
$this->smartyInstance = new Smarty();
|
||||
|
||||
// Then prepare all variables
|
||||
$this->smartyInstance->setCompileDir('Core/Cache/Compile');
|
||||
$this->smartyInstance->setCacheDir('Core/Cache/');
|
||||
$this->smartyInstance->setCompileDir(Core::$tempDir . DS . 'Smarty' . DS . 'Compile');
|
||||
$this->smartyInstance->setCacheDir(Core::$tempDir . DS . 'Smarty');
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -782,7 +789,7 @@ class LatteEngine implements TemplateEngine
|
|||
{
|
||||
// If possible, load Latte\Engine
|
||||
$this->latte = new Latte;
|
||||
$this->latte->setTempDirectory(realpath('Application'.DS.'Cache'));
|
||||
$this->latte->setTempDirectory(realpath(Core::$tempDir . DS . 'Latte'));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -74,7 +74,7 @@ class Libraries
|
|||
*
|
||||
* @var array Library paths
|
||||
*/
|
||||
protected $libraryPaths = array('Core'.DS.'Libraries', 'Application'.DS.'Libraries');
|
||||
protected $libraryPaths = array();
|
||||
|
||||
/**
|
||||
* Array of all the loaded library objects
|
||||
|
@ -89,6 +89,8 @@ class Libraries
|
|||
public function __construct()
|
||||
{
|
||||
$this->factory = Factory::getInstance();
|
||||
$this->libraryPaths[] = Core::$coreDir . DS . 'Libraries';
|
||||
$this->libraryPaths[] = Core::$appDir . DS . 'Libraries';
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -135,7 +137,7 @@ class Libraries
|
|||
// Load the driver class if it is not yet loaded
|
||||
if ( ! class_exists('FuzeWorks\FW_Driver_Library', false))
|
||||
{
|
||||
require_once('Core'.DS.'Libraries'.DS.'Driver.php');
|
||||
require_once(Core::$coreDir . DS . 'Libraries'.DS.'Driver.php');
|
||||
}
|
||||
|
||||
// And then load and return the library
|
||||
|
@ -177,7 +179,7 @@ class Libraries
|
|||
$class = ucfirst($class);
|
||||
|
||||
// Is the library a core library, then load a core library
|
||||
if (file_exists('Core'.DS.'Libraries'.DS.$subdir.$class.'.php'))
|
||||
if (file_exists(Core::$coreDir . DS . 'Libraries'.DS.$subdir.$class.'.php'))
|
||||
{
|
||||
// Load base library
|
||||
return $this->loadCoreLibrary($class, $subdir, $parameters, $directories, $newInstance);
|
||||
|
@ -239,7 +241,7 @@ class Libraries
|
|||
}
|
||||
|
||||
// Remove the core directory from the checklist
|
||||
if (in_array('Core'.DS.'Libraries', $directories))
|
||||
if (in_array(Core::$coreDir . DS . 'Libraries', $directories))
|
||||
{
|
||||
array_shift($directories);
|
||||
}
|
||||
|
@ -267,7 +269,7 @@ class Libraries
|
|||
}
|
||||
|
||||
// Second base; if no base class is found in the app folder, load it from the core folder
|
||||
include_once('Core'.DS.'Libraries'.DS.$subdir.$class.'.php');
|
||||
include_once(Core::$coreDir . DS . 'Libraries'.DS.$subdir.$class.'.php');
|
||||
|
||||
// Now let's check for extensions
|
||||
$subclass = $this->factory->config->getConfig('main')->application_prefix . $class;
|
||||
|
@ -325,7 +327,7 @@ class Libraries
|
|||
foreach ($directories as $directory)
|
||||
{
|
||||
// Skip the core directory
|
||||
if ($directory === 'Core'.DS.'Libraries')
|
||||
if ($directory === Core::$coreDir . DS . 'Libraries')
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
|
|
@ -139,6 +139,8 @@ class Logger {
|
|||
self::$log_to_file = Config::get('error')->log_to_file;
|
||||
self::$logger_template = Config::get('error')->logger_template;
|
||||
self::newLevel('Logger Initiated');
|
||||
|
||||
self::loadTracy();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -146,17 +148,17 @@ class Logger {
|
|||
*
|
||||
* @return void
|
||||
*/
|
||||
public static function loadComposer()
|
||||
public static function loadTracy()
|
||||
{
|
||||
if (class_exists('\Tracy\Debugger', true))
|
||||
{
|
||||
if (ENVIRONMENT === 'DEVELOPMENT')
|
||||
{
|
||||
Debugger::enable(Debugger::DEVELOPMENT, realpath('Application'.DS.'Logs'));
|
||||
Debugger::enable(Debugger::DEVELOPMENT, realpath(Core::$logDir));
|
||||
}
|
||||
else
|
||||
{
|
||||
Debugger::enable(Debugger::PRODUCTION, realpath('Application'.DS.'Logs'));
|
||||
Debugger::enable(Debugger::PRODUCTION, realpath(Core::$logDir));
|
||||
}
|
||||
self::$useTracy = true;
|
||||
}
|
||||
|
@ -279,15 +281,15 @@ class Logger {
|
|||
|
||||
Layout::reset();
|
||||
Layout::assign('Logs', self::$Logs);
|
||||
Layout::view(self::$logger_template, 'Core'.DS.'Views', true);
|
||||
Layout::view(self::$logger_template, Core::$coreDir . DS . 'Views', true);
|
||||
}
|
||||
|
||||
public static function logToFile()
|
||||
{
|
||||
Layout::reset();
|
||||
Layout::assign('Logs', self::$Logs);
|
||||
$contents = Layout::get('logger_cli', 'Core'.DS.'Views');
|
||||
$file = 'Application'.DS.'Logs'.DS.'log_latest.php';
|
||||
$contents = Layout::get('logger_cli', Core::$coreDir . DS . 'Views');
|
||||
$file = Core::$logDir .DS. 'Logs'.DS.'log_latest.php';
|
||||
if (is_writable($file))
|
||||
{
|
||||
file_put_contents($file, '<?php ' . $contents);
|
||||
|
|
|
@ -69,10 +69,10 @@ class Models
|
|||
{
|
||||
// Model load event
|
||||
$event = Events::fireEvent('modelLoadEvent', $name, $directory);
|
||||
$directory = ($event->directory === null ? 'Application/Models' : $event->directory);
|
||||
$directory = ($event->directory === null ? Core::$appDir . DS . 'Models' : $event->directory);
|
||||
$name = ($event->model === null ? $name : $event->model);
|
||||
|
||||
$file = $directory.'/model.'.$name.'.php';
|
||||
$file = $directory.DS.'model.'.$name.'.php';
|
||||
if (isset(self::$model_types[$name])) {
|
||||
Logger::log('Loading Model: '.get_class(self::$model_types[$name]), get_class(self::$model_types[$name]));
|
||||
self::$models_array[$name] = self::$model_types[$name];
|
||||
|
|
|
@ -92,7 +92,7 @@ class Modules
|
|||
public static function get($name)
|
||||
{
|
||||
// Where the modules are
|
||||
$path = 'Modules/';
|
||||
$path = Core::$appDir . DS . 'Modules/';
|
||||
|
||||
// Check if the requested module is registered
|
||||
if (isset(self::$register[$name])) {
|
||||
|
@ -413,7 +413,7 @@ class Modules
|
|||
Logger::newLevel('Loading Module Headers', 'Core');
|
||||
|
||||
// Get all the module directories
|
||||
$dir = 'Modules/';
|
||||
$dir = Core::$appDir . DS . 'Modules/';
|
||||
$mod_dirs = array();
|
||||
$mod_dirs = array_values(array_diff(scandir($dir), array('..', '.')));
|
||||
|
||||
|
|
|
@ -532,12 +532,22 @@ class Output {
|
|||
*/
|
||||
public function _write_cache($output)
|
||||
{
|
||||
$path = $this->config->cache->cache_file_path;
|
||||
$cache_path = ($path === '') ? 'Application'.DS.'Cache'.DS : $path;
|
||||
$cache_path = Core::$tempDir . DS . 'Output' . DS;
|
||||
|
||||
if ( ! is_dir($cache_path) OR ! Core::isReallyWritable($cache_path))
|
||||
// First try and see if the directory exists
|
||||
if ( ! is_dir($cache_path))
|
||||
{
|
||||
Logger::logError('Unable to write cache file: '.$cache_path);
|
||||
// Then try and create the directory
|
||||
if (!mkdir($cache_path, 0777, false))
|
||||
{
|
||||
Logger::logError('Unable to write cache file: \''.$cache_path.'\' Cannot create directory');
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (! Core::isReallyWritable($cache_path))
|
||||
{
|
||||
Logger::logError('Unable to write cache file: \''.$cache_path.'\' Directory not writeable');
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -561,7 +571,7 @@ class Output {
|
|||
|
||||
if ( ! $fp = @fopen($cache_path, 'w+b'))
|
||||
{
|
||||
Logger::logError('Unable to write cache file: '.$cache_path);
|
||||
Logger::logError('Unable to write cache file: \''.$cache_path.'\' Directory not writeable');
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -635,7 +645,7 @@ class Output {
|
|||
*/
|
||||
public function _display_cache()
|
||||
{
|
||||
$cache_path = ($this->config->cache->cache_file_path === '') ? 'Application'.DS.'Cache'.DS : $this->config->cache->cache_file_path;
|
||||
$cache_path = Core::$tempDir . DS . 'Output' . DS;
|
||||
|
||||
// Build the file path. The file name is an MD5 hash of the full URI
|
||||
$main = $this->config->main;
|
||||
|
@ -715,11 +725,7 @@ class Output {
|
|||
*/
|
||||
public function delete_cache($uri = '')
|
||||
{
|
||||
$cache_path = $this->config->cache->cache_file_path;
|
||||
if ($cache_path === '')
|
||||
{
|
||||
$cache_path = 'Application'.DS.'Cache'.DS;
|
||||
}
|
||||
$cache_path = Core::$tempDir . DS . 'Output' . DS;
|
||||
|
||||
if ( ! is_dir($cache_path))
|
||||
{
|
||||
|
|
|
@ -505,8 +505,8 @@ class Router
|
|||
|
||||
// Construct file paths and classes
|
||||
$class = '\Application\Controller\\'.ucfirst($controller);
|
||||
$directory = 'Application/Controller/';
|
||||
$file = $directory . 'controller.'.$controller.'.php';
|
||||
$directory = Core::$appDir . DS . 'Controller';
|
||||
$file = $directory . DS .'controller.'.$controller.'.php';
|
||||
|
||||
$event = Events::fireEvent('routerLoadControllerEvent',
|
||||
$file,
|
||||
|
|
|
@ -51,8 +51,6 @@ if (!function_exists('getColoredString'))
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
$mask = "|%5s |%-90s | %10s |\n";
|
||||
$id = 1;
|
||||
|
||||
|
|
|
@ -1,98 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* FuzeWorks.
|
||||
*
|
||||
* The FuzeWorks MVC PHP FrameWork
|
||||
*
|
||||
* Copyright (C) 2015 TechFuze
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* @author TechFuze
|
||||
* @copyright Copyright (c) 2013 - 2016, Techfuze. (http://techfuze.net)
|
||||
* @copyright Copyright (c) 1996 - 2015, Free Software Foundation, Inc. (http://www.fsf.org/)
|
||||
* @license http://opensource.org/licenses/GPL-3.0 GPLv3 License
|
||||
*
|
||||
* @link http://fuzeworks.techfuze.net
|
||||
* @since Version 0.0.1
|
||||
*
|
||||
* @version Version 0.0.1
|
||||
*/
|
||||
|
||||
namespace Module\Admin;
|
||||
|
||||
use FuzeWorks\Module;
|
||||
|
||||
/**
|
||||
* Admin Module.
|
||||
*
|
||||
* Admin panel module controller
|
||||
*
|
||||
* @author Abel Hoogeveen <abel@techfuze.net>
|
||||
* @copyright Copyright (c) 2013 - 2016, Techfuze. (http://techfuze.net)
|
||||
*/
|
||||
class Main
|
||||
{
|
||||
use Module;
|
||||
|
||||
/**
|
||||
* Loads the module and registers the events.
|
||||
*/
|
||||
public function onLoad()
|
||||
{
|
||||
include_once self::getModulePath().'/classes/class.layout_manager.php';
|
||||
include_once self::getModulePath().'/classes/class.admin_exception.php';
|
||||
include_once self::getModulePath().'/classes/class.theme_manager.php';
|
||||
include_once self::getModulePath().'/classes/class.advertise_fetcher.php';
|
||||
include_once self::getModulePath().'/classes/class.page_loader.php';
|
||||
include_once self::getModulePath().'/classes/class.page_data.php';
|
||||
include_once self::getModulePath().'/classes/class.page.php';
|
||||
include_once self::getModulePath().'/classes/class.page_list.php';
|
||||
include_once self::getModulePath().'/classes/class.page_router_interface.php';
|
||||
include_once self::getModulePath().'/classes/class.page_interface.php';
|
||||
include_once self::getModulePath().'/classes/class.admin_router.php';
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets called when the path matches the regex of this module.
|
||||
*
|
||||
* @param array Regex matches
|
||||
*/
|
||||
public function route($matches = array())
|
||||
{
|
||||
// First create a pageList based on the advertisements
|
||||
$advertisements = self::getAdvertisements('admin');
|
||||
if (!is_array($advertisements)) {
|
||||
throw new AdminException('Could not load advertised modules. Malformed object retrieved', 1);
|
||||
}
|
||||
|
||||
$pageList = AdvertiseFetcher::getPageList($advertisements);
|
||||
|
||||
// After that, load the authenticator and check if user is logged in
|
||||
// @TODO IMPLEMENT
|
||||
|
||||
// After that, load the theme that is set
|
||||
LayoutManager::setPageList($pageList);
|
||||
LayoutManager::setMatches($matches);
|
||||
$html = LayoutManager::loadPanel();
|
||||
|
||||
// And print it
|
||||
echo $html;
|
||||
}
|
||||
|
||||
public function getAdminRouter()
|
||||
{
|
||||
return new AdminRouter();
|
||||
}
|
||||
}
|
|
@ -1,43 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* FuzeWorks.
|
||||
*
|
||||
* The FuzeWorks MVC PHP FrameWork
|
||||
*
|
||||
* Copyright (C) 2015 TechFuze
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* @author TechFuze
|
||||
* @copyright Copyright (c) 2013 - 2016, Techfuze. (http://techfuze.net)
|
||||
* @copyright Copyright (c) 1996 - 2015, Free Software Foundation, Inc. (http://www.fsf.org/)
|
||||
* @license http://opensource.org/licenses/GPL-3.0 GPLv3 License
|
||||
*
|
||||
* @link http://fuzeworks.techfuze.net
|
||||
* @since Version 0.0.1
|
||||
*
|
||||
* @version Version 0.0.1
|
||||
*/
|
||||
|
||||
namespace Module\Admin;
|
||||
|
||||
/**
|
||||
* Class Exception.
|
||||
*
|
||||
* @author Abel Hoogeveen <abel@techfuze.net>
|
||||
* @copyright Copyright (c) 2013 - 2016, Techfuze. (http://techfuze.net)
|
||||
*/
|
||||
class AdminException extends \Exception
|
||||
{
|
||||
}
|
|
@ -1,58 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* FuzeWorks.
|
||||
*
|
||||
* The FuzeWorks MVC PHP FrameWork
|
||||
*
|
||||
* Copyright (C) 2015 TechFuze
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* @author TechFuze
|
||||
* @copyright Copyright (c) 2013 - 2016, Techfuze. (http://techfuze.net)
|
||||
* @copyright Copyright (c) 1996 - 2015, Free Software Foundation, Inc. (http://www.fsf.org/)
|
||||
* @license http://opensource.org/licenses/GPL-3.0 GPLv3 License
|
||||
*
|
||||
* @link http://fuzeworks.techfuze.net
|
||||
* @since Version 0.0.1
|
||||
*
|
||||
* @version Version 0.0.1
|
||||
*/
|
||||
|
||||
namespace Module\Admin;
|
||||
|
||||
class AdminRouter implements PageRouterInterface
|
||||
{
|
||||
private $pageObject;
|
||||
|
||||
public function route()
|
||||
{
|
||||
//echo $pagePath;
|
||||
}
|
||||
|
||||
/**
|
||||
* Import the page object from the Admin Module.
|
||||
*
|
||||
* @param Page $pageObject Page object
|
||||
*/
|
||||
public function importPage($pageObject)
|
||||
{
|
||||
$this->pageObject = $pageObject;
|
||||
}
|
||||
|
||||
public function getPage()
|
||||
{
|
||||
return $this->pageObject;
|
||||
}
|
||||
}
|
|
@ -1,104 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* FuzeWorks.
|
||||
*
|
||||
* The FuzeWorks MVC PHP FrameWork
|
||||
*
|
||||
* Copyright (C) 2015 TechFuze
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* @author TechFuze
|
||||
* @copyright Copyright (c) 2013 - 2016, Techfuze. (http://techfuze.net)
|
||||
* @copyright Copyright (c) 1996 - 2015, Free Software Foundation, Inc. (http://www.fsf.org/)
|
||||
* @license http://opensource.org/licenses/GPL-3.0 GPLv3 License
|
||||
*
|
||||
* @link http://fuzeworks.techfuze.net
|
||||
* @since Version 0.0.1
|
||||
*
|
||||
* @version Version 0.0.1
|
||||
*/
|
||||
|
||||
namespace Module\Admin;
|
||||
|
||||
use FuzeWorks\Logger;
|
||||
|
||||
class AdvertiseFetcher
|
||||
{
|
||||
/**
|
||||
* Create a pageList using the advertisements from the admin module.
|
||||
*
|
||||
* @param array $advertisements The advertisement repository
|
||||
*
|
||||
* @throws AdminException On fatal and/or missing data
|
||||
*
|
||||
* @return PageList An object oriented page list with details
|
||||
*
|
||||
* @todo Implement Unit Test
|
||||
*/
|
||||
public static function getPageList($advertisements)
|
||||
{
|
||||
// Prepare a pageList
|
||||
Logger::newLevel('Generating PageList');
|
||||
$pageList = new PageList();
|
||||
|
||||
// First get the modules
|
||||
foreach ($advertisements as $module => $data) {
|
||||
// Apple regular data
|
||||
$identifier = (isset($data['identifier']) ? $data['identifier'] : null);
|
||||
$pages = (isset($data['pages']) ? $data['pages'] : null);
|
||||
|
||||
// Check if everything is set, if not shout out in terror
|
||||
if (is_null($identifier) || is_null($pages)) {
|
||||
throw new AdminException("Incomplete data for module '".$module."'", 1);
|
||||
}
|
||||
|
||||
// And then the pages
|
||||
foreach ($pages as $pageData) {
|
||||
// Create page variable and add module and identifier
|
||||
$page = new PageData();
|
||||
$page->setModule($module);
|
||||
$page->setIdentifier($identifier);
|
||||
|
||||
// First the required data for every page
|
||||
$page_path = (isset($pageData['page_path']) ? $pageData['page_path'] : null);
|
||||
$name = (isset($pageData['name']) ? $pageData['name'] : null);
|
||||
|
||||
// And throw errors if non-existent
|
||||
if (is_null($page_path) || is_null($name)) {
|
||||
throw new AdminException("Incomplete data for module '".$module."'", 1);
|
||||
}
|
||||
|
||||
// And set those values
|
||||
$page->setPagePath($page_path);
|
||||
$page->setName($name);
|
||||
$unique_identifier = $identifier.'/'.$page_path;
|
||||
Logger::log("Adding page '".$name."' on '".$unique_identifier."'");
|
||||
|
||||
// And at last for the optional values
|
||||
$page->setIcon((isset($pageData['icon']) ? $pageData['icon'] : ''));
|
||||
$page->setPermissionGroups((isset($pageData['permissionGroups']) ? $pageData['permissionGroups'] : array()));
|
||||
$page->setPriority((isset($pageData['priority']) ? $pageData['priority'] : 1));
|
||||
|
||||
// And finally add the page
|
||||
$pageList->addPage($page, $unique_identifier);
|
||||
}
|
||||
}
|
||||
|
||||
// And finally return the pageList\
|
||||
Logger::stopLevel();
|
||||
|
||||
return $pageList;
|
||||
}
|
||||
}
|
|
@ -1,121 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* FuzeWorks.
|
||||
*
|
||||
* The FuzeWorks MVC PHP FrameWork
|
||||
*
|
||||
* Copyright (C) 2015 TechFuze
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* @author TechFuze
|
||||
* @copyright Copyright (c) 2013 - 2016, Techfuze. (http://techfuze.net)
|
||||
* @copyright Copyright (c) 1996 - 2015, Free Software Foundation, Inc. (http://www.fsf.org/)
|
||||
* @license http://opensource.org/licenses/GPL-3.0 GPLv3 License
|
||||
*
|
||||
* @link http://fuzeworks.techfuze.net
|
||||
* @since Version 0.0.1
|
||||
*
|
||||
* @version Version 0.0.1
|
||||
*/
|
||||
|
||||
namespace Module\Admin;
|
||||
|
||||
use FuzeWorks\Layout;
|
||||
use FuzeWorks\Config;
|
||||
|
||||
class LayoutManager
|
||||
{
|
||||
private static $pageList;
|
||||
private static $matches;
|
||||
|
||||
/**
|
||||
* Load the panel of this admin interface.
|
||||
*
|
||||
* @throws AdminException
|
||||
*
|
||||
* @return string HTML
|
||||
*/
|
||||
public static function loadPanel()
|
||||
{
|
||||
// First check if the pageList is set and valid
|
||||
if (is_null(self::$pageList)) {
|
||||
throw new AdminException('Can not load panel. PageList is not set', 1);
|
||||
}
|
||||
|
||||
// Load the theme
|
||||
ThemeManager::loadTheme();
|
||||
|
||||
// Set the PageLoader variables
|
||||
PageLoader::setPageList(self::$pageList);
|
||||
|
||||
// Get the page we are trying to load
|
||||
PageLoader::loadPage(self::$matches);
|
||||
$html = PageLoader::getHtml();
|
||||
$activePage = PageLoader::getActivePage();
|
||||
|
||||
// And add the pageList
|
||||
Layout::assign('pageList', self::$pageList);
|
||||
Layout::assign('activePage', $activePage);
|
||||
Layout::assign('pageHTML', $html);
|
||||
|
||||
// And add more basic variables
|
||||
foreach (self::getVariables() as $key => $value) {
|
||||
Layout::assign($key, $value);
|
||||
}
|
||||
|
||||
// And load the file
|
||||
return Layout::get('panel');
|
||||
}
|
||||
|
||||
public static function loadPanelAPI()
|
||||
{
|
||||
}
|
||||
|
||||
public static function loadLogin()
|
||||
{
|
||||
}
|
||||
|
||||
public static function loadLoginAPI()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the pageList.
|
||||
*
|
||||
* @param PageList $pageList PageList
|
||||
*/
|
||||
public static function setPageList($pageList)
|
||||
{
|
||||
self::$pageList = $pageList;
|
||||
}
|
||||
|
||||
public static function setMatches($matches)
|
||||
{
|
||||
self::$matches = $matches;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all the basic variables required for every template.
|
||||
*
|
||||
* @return array with settings
|
||||
*/
|
||||
private static function getVariables()
|
||||
{
|
||||
$vars = array();
|
||||
$vars['adminURL'] = Config::get('main')->base_url.'admin/';
|
||||
|
||||
return $vars;
|
||||
}
|
||||
}
|
|
@ -1,162 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* FuzeWorks.
|
||||
*
|
||||
* The FuzeWorks MVC PHP FrameWork
|
||||
*
|
||||
* Copyright (C) 2015 TechFuze
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* @author TechFuze
|
||||
* @copyright Copyright (c) 2013 - 2016, Techfuze. (http://techfuze.net)
|
||||
* @copyright Copyright (c) 1996 - 2015, Free Software Foundation, Inc. (http://www.fsf.org/)
|
||||
* @license http://opensource.org/licenses/GPL-3.0 GPLv3 License
|
||||
*
|
||||
* @link http://fuzeworks.techfuze.net
|
||||
* @since Version 0.0.1
|
||||
*
|
||||
* @version Version 0.0.1
|
||||
*/
|
||||
|
||||
namespace Module\Admin;
|
||||
|
||||
class Page
|
||||
{
|
||||
private $pagePath;
|
||||
private $subPath = array();
|
||||
private $html;
|
||||
private $title;
|
||||
private $breadcrumbs = array();
|
||||
|
||||
/**
|
||||
* Gets the value of pagePath.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function getPagePath()
|
||||
{
|
||||
return $this->pagePath;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the value of pagePath.
|
||||
*
|
||||
* @param mixed $pagePath the page path
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public function setPagePath($pagePath)
|
||||
{
|
||||
$this->pagePath = $pagePath;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the value of subPath.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function getSubPath()
|
||||
{
|
||||
return $this->subPath;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the value of subPath.
|
||||
*
|
||||
* @param mixed $subPath the sub path
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public function setSubPath($subPath)
|
||||
{
|
||||
$this->subPath = $subPath;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the value of html.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function getHtml()
|
||||
{
|
||||
return $this->html;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the value of html.
|
||||
*
|
||||
* @param mixed $html the html
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public function setHtml($html)
|
||||
{
|
||||
$this->html = $html;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the value of title.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function getTitle()
|
||||
{
|
||||
return $this->title;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the value of title.
|
||||
*
|
||||
* @param mixed $title the title
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public function setTitle($title)
|
||||
{
|
||||
$this->title = $title;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the value of breadcrumbs.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function getBreadcrumbs()
|
||||
{
|
||||
return $this->breadcrumbs;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the value of breadcrumbs.
|
||||
*
|
||||
* @param mixed $breadcrumbs the breadcrumbs
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public function setBreadcrumbs($breadcrumbs)
|
||||
{
|
||||
$this->breadcrumbs = $breadcrumbs;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
|
@ -1,212 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* FuzeWorks.
|
||||
*
|
||||
* The FuzeWorks MVC PHP FrameWork
|
||||
*
|
||||
* Copyright (C) 2015 TechFuze
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* @author TechFuze
|
||||
* @copyright Copyright (c) 2013 - 2016, Techfuze. (http://techfuze.net)
|
||||
* @copyright Copyright (c) 1996 - 2015, Free Software Foundation, Inc. (http://www.fsf.org/)
|
||||
* @license http://opensource.org/licenses/GPL-3.0 GPLv3 License
|
||||
*
|
||||
* @link http://fuzeworks.techfuze.net
|
||||
* @since Version 0.0.1
|
||||
*
|
||||
* @version Version 0.0.1
|
||||
*/
|
||||
|
||||
namespace Module\Admin;
|
||||
|
||||
class PageData
|
||||
{
|
||||
public $module;
|
||||
public $identifier;
|
||||
public $page_path;
|
||||
public $icon;
|
||||
public $permissionGroups = array();
|
||||
public $name;
|
||||
public $priority;
|
||||
|
||||
/**
|
||||
* Gets the value of module.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function getModule()
|
||||
{
|
||||
return $this->module;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the value of module.
|
||||
*
|
||||
* @param mixed $module the module
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public function setModule($module)
|
||||
{
|
||||
$this->module = $module;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the value of identifier.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function getIdentifier()
|
||||
{
|
||||
return $this->identifier;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the value of identifier.
|
||||
*
|
||||
* @param mixed $identifier the identifier
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public function setIdentifier($identifier)
|
||||
{
|
||||
$this->identifier = $identifier;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the value of page_path.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function getPagePath()
|
||||
{
|
||||
return $this->page_path;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the value of page_path.
|
||||
*
|
||||
* @param mixed $page_path the page path
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public function setPagePath($page_path)
|
||||
{
|
||||
$this->page_path = $page_path;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the value of icon.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function getIcon()
|
||||
{
|
||||
return $this->icon;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the value of icon.
|
||||
*
|
||||
* @param mixed $icon the icon
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public function setIcon($icon)
|
||||
{
|
||||
$this->icon = $icon;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the value of permissionGroups.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function getPermissionGroups()
|
||||
{
|
||||
return $this->permissionGroups;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the value of permissionGroups.
|
||||
*
|
||||
* @param mixed $permissionGroups the permission groups
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public function setPermissionGroups($permissionGroups)
|
||||
{
|
||||
$this->permissionGroups = $permissionGroups;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the value of name.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function getName()
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the value of name.
|
||||
*
|
||||
* @param mixed $name the name
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public function setName($name)
|
||||
{
|
||||
$this->name = $name;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the value of priority.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function getPriority()
|
||||
{
|
||||
return $this->priority;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the value of priority.
|
||||
*
|
||||
* @param mixed $priority the priority
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public function setPriority($priority)
|
||||
{
|
||||
$this->priority = $priority;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
|
@ -1,70 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* FuzeWorks.
|
||||
*
|
||||
* The FuzeWorks MVC PHP FrameWork
|
||||
*
|
||||
* Copyright (C) 2015 TechFuze
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* @author TechFuze
|
||||
* @copyright Copyright (c) 2013 - 2016, Techfuze. (http://techfuze.net)
|
||||
* @copyright Copyright (c) 1996 - 2015, Free Software Foundation, Inc. (http://www.fsf.org/)
|
||||
* @license http://opensource.org/licenses/GPL-3.0 GPLv3 License
|
||||
*
|
||||
* @link http://fuzeworks.techfuze.net
|
||||
* @since Version 0.0.1
|
||||
*
|
||||
* @version Version 0.0.1
|
||||
*/
|
||||
|
||||
namespace Module\Admin;
|
||||
|
||||
class PageList
|
||||
{
|
||||
public $pages = array();
|
||||
|
||||
/**
|
||||
* Gets the value of pages.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function getPages()
|
||||
{
|
||||
return $this->pages;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve a page.
|
||||
*
|
||||
* @param string $unique_identifier Unique name for the page
|
||||
*
|
||||
* @return PageData PageData Object
|
||||
*/
|
||||
public function getPage($unique_identifier)
|
||||
{
|
||||
return $this->pages[$unique_identifier];
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a page to the array.
|
||||
*
|
||||
* @param PageData $page PageData Object
|
||||
*/
|
||||
public function addPage($page, $unique_identifier)
|
||||
{
|
||||
$this->pages[$unique_identifier] = $page;
|
||||
}
|
||||
}
|
|
@ -1,158 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* FuzeWorks.
|
||||
*
|
||||
* The FuzeWorks MVC PHP FrameWork
|
||||
*
|
||||
* Copyright (C) 2015 TechFuze
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* @author TechFuze
|
||||
* @copyright Copyright (c) 2013 - 2016, Techfuze. (http://techfuze.net)
|
||||
* @copyright Copyright (c) 1996 - 2015, Free Software Foundation, Inc. (http://www.fsf.org/)
|
||||
* @license http://opensource.org/licenses/GPL-3.0 GPLv3 License
|
||||
*
|
||||
* @link http://fuzeworks.techfuze.net
|
||||
* @since Version 0.0.1
|
||||
*
|
||||
* @version Version 0.0.1
|
||||
*/
|
||||
|
||||
namespace Module\Admin;
|
||||
|
||||
use FuzeWorks\Logger;
|
||||
use FuzeWorks\Layout;
|
||||
use FuzeWorks\Modules;
|
||||
|
||||
class PageLoader
|
||||
{
|
||||
private static $pageList;
|
||||
private static $activePage;
|
||||
private static $html;
|
||||
private static $breadcrumbs = array();
|
||||
private static $title;
|
||||
|
||||
/**
|
||||
* Set the pageList.
|
||||
*
|
||||
* @param PageList $pageList PageList
|
||||
*/
|
||||
public static function setPageList($pageList)
|
||||
{
|
||||
self::$pageList = $pageList;
|
||||
}
|
||||
|
||||
public static function loadPage($matches)
|
||||
{
|
||||
// First check if any data is given at all
|
||||
Logger::newLevel('Retrieving page from module');
|
||||
if (!isset($matches['identifier']) && !isset($matches['page'])) {
|
||||
// If nothing is provided, load the dashboard
|
||||
Logger::log('No input retrieved. Loading dashboard');
|
||||
|
||||
return self::dashboard();
|
||||
} elseif (!isset($matches['identifier']) || !isset($matches['page'])) {
|
||||
// If incomplete data is provided, load a 404
|
||||
Logger::log('Invalid input retrieved. Loading 404 not found page');
|
||||
|
||||
return self::error404();
|
||||
}
|
||||
|
||||
// If enough data is provided, try and load a page
|
||||
Logger::log('Input received. Attempting to find page');
|
||||
$unique_identifier = $matches['identifier'].'/'.$matches['page'];
|
||||
if (isset(self::$pageList->pages[$unique_identifier])) {
|
||||
// Page found, start loading process
|
||||
$page = self::$pageList->getPage($unique_identifier);
|
||||
|
||||
// Load the designated module
|
||||
$module = Modules::get($page->getModule());
|
||||
|
||||
// Check if it implements the PageRouterInterface
|
||||
if (method_exists($module, 'getAdminRouter')) {
|
||||
$router = $module->getAdminRouter();
|
||||
|
||||
// Then check if the router is valid, if not, return 500
|
||||
if (!$router instanceof PageRouterInterface) {
|
||||
Logger::logError("Could not load '".$unique_identifier."' on module '".$page->getModule()."'. ".get_class($router)." does not implement \Module\Admin\PageRouterInterface");
|
||||
|
||||
return self::error500();
|
||||
}
|
||||
|
||||
// Route the request into the module
|
||||
Logger::log('Input valid and module loaded. Attempting to route request');
|
||||
|
||||
// Generating page object
|
||||
$pageObject = new Page();
|
||||
$pageObject->setPagePath($matches['page']);
|
||||
$pageObject->setSubPath((isset($matches['subdata']) ? $matches['subdata'] : null));
|
||||
|
||||
// And send it
|
||||
$router->importPage($pageObject);
|
||||
$router->route();
|
||||
|
||||
// And retrieve it
|
||||
$pageObject = $router->getPage();
|
||||
|
||||
// And retrieve some data
|
||||
self::$html = $pageObject->getHtml();
|
||||
// $html = $pageObject->getHtml();
|
||||
|
||||
Logger::stopLevel();
|
||||
|
||||
return '';
|
||||
} else {
|
||||
// Error, router does not exist
|
||||
Logger::logError("Could not load '".$unique_identifier."' on module '".$page->getModule()."'. ".get_class($module).' does not implement method getAdminRouter()');
|
||||
Logger::stopLevel();
|
||||
|
||||
return self::error500();
|
||||
}
|
||||
}
|
||||
|
||||
Logger::log('Matching page was not found. Loading 404 not found page');
|
||||
Logger::stopLevel();
|
||||
|
||||
return self::error404();
|
||||
}
|
||||
|
||||
public static function getHtml()
|
||||
{
|
||||
return self::$html;
|
||||
}
|
||||
|
||||
public static function getActivePage()
|
||||
{
|
||||
return 'fuzeadmin/testPage';
|
||||
}
|
||||
|
||||
public static function dashboard()
|
||||
{
|
||||
}
|
||||
|
||||
public static function error404()
|
||||
{
|
||||
Logger::http_error(404, false);
|
||||
|
||||
return Layout::get('404');
|
||||
}
|
||||
|
||||
public static function error500()
|
||||
{
|
||||
Logger::http_error(500, false);
|
||||
|
||||
return Layout::get('500');
|
||||
}
|
||||
}
|
|
@ -1,39 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* FuzeWorks.
|
||||
*
|
||||
* The FuzeWorks MVC PHP FrameWork
|
||||
*
|
||||
* Copyright (C) 2015 TechFuze
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* @author TechFuze
|
||||
* @copyright Copyright (c) 2013 - 2016, Techfuze. (http://techfuze.net)
|
||||
* @copyright Copyright (c) 1996 - 2015, Free Software Foundation, Inc. (http://www.fsf.org/)
|
||||
* @license http://opensource.org/licenses/GPL-3.0 GPLv3 License
|
||||
*
|
||||
* @link http://fuzeworks.techfuze.net
|
||||
* @since Version 0.0.1
|
||||
*
|
||||
* @version Version 0.0.1
|
||||
*/
|
||||
|
||||
namespace Module\Admin;
|
||||
|
||||
interface PageRouterInterface
|
||||
{
|
||||
public function importPage($pageObject);
|
||||
public function getPage();
|
||||
}
|
|
@ -1,56 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* FuzeWorks.
|
||||
*
|
||||
* The FuzeWorks MVC PHP FrameWork
|
||||
*
|
||||
* Copyright (C) 2015 TechFuze
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* @author TechFuze
|
||||
* @copyright Copyright (c) 2013 - 2016, Techfuze. (http://techfuze.net)
|
||||
* @copyright Copyright (c) 1996 - 2015, Free Software Foundation, Inc. (http://www.fsf.org/)
|
||||
* @license http://opensource.org/licenses/GPL-3.0 GPLv3 License
|
||||
*
|
||||
* @link http://fuzeworks.techfuze.net
|
||||
* @since Version 0.0.1
|
||||
*
|
||||
* @version Version 0.0.1
|
||||
*/
|
||||
|
||||
namespace Module\Admin;
|
||||
|
||||
use FuzeWorks\Layout;
|
||||
|
||||
class ThemeManager
|
||||
{
|
||||
private static $themeDir = 'views/adminlte2.1/';
|
||||
|
||||
public static function loadTheme($theme = null)
|
||||
{
|
||||
self::$themeDir = Main::getModulePath().'themes/adminlte2.1/';
|
||||
Layout::setDirectory(self::$themeDir);
|
||||
}
|
||||
|
||||
public static function getDirectory()
|
||||
{
|
||||
// First check if the theme is actually loaded
|
||||
if (empty(self::$themeDir)) {
|
||||
throw new AdminException('Could not load panel. Theme not loaded', 1);
|
||||
}
|
||||
// And then return the theme Directory
|
||||
return self::$themeDir;
|
||||
}
|
||||
}
|
|
@ -1,53 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* FuzeWorks.
|
||||
*
|
||||
* The FuzeWorks MVC PHP FrameWork
|
||||
*
|
||||
* Copyright (C) 2015 TechFuze
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* @author TechFuze
|
||||
* @copyright Copyright (c) 2013 - 2016, Techfuze. (http://techfuze.net)
|
||||
* @copyright Copyright (c) 1996 - 2015, Free Software Foundation, Inc. (http://www.fsf.org/)
|
||||
* @license http://opensource.org/licenses/GPL-3.0 GPLv3 License
|
||||
*
|
||||
* @link http://fuzeworks.techfuze.net
|
||||
* @since Version 0.0.1
|
||||
*
|
||||
* @version Version 0.0.1
|
||||
*/
|
||||
|
||||
return array(
|
||||
|
||||
'module_class' => 'Module\Admin\Main',
|
||||
'module_file' => 'class.main.php',
|
||||
'module_name' => 'Admin',
|
||||
'abstract' => false,
|
||||
'aliases' => array(),
|
||||
'dependencies' => array(),
|
||||
'events' => array(),
|
||||
'routes' => array('admin(|\/(?P<identifier>.*?)(|\/(?<page>.*?)(|\/(?P<subdata>.*?))))'),
|
||||
'advertise' => array('admin' => array('identifier' => 'fuzeadmin', 'pages' => array(array('name' => 'TEST', 'page_path' => 'testPage', 'icon' => 'fa-plane')))),
|
||||
'listenFor' => array('admin'),
|
||||
'name' => 'FuzeWorks Admin Panel',
|
||||
'description' => 'Control Panel for FuzeWorks Modules and FrameWork',
|
||||
'author' => 'core',
|
||||
'version' => '1.0.0',
|
||||
'website' => 'http://fuzeworks.techfuze.net/',
|
||||
'date_created' => '13-01-2016',
|
||||
'date_updated' => '17-01-2016',
|
||||
'enabled' => true,
|
||||
);
|
|
@ -1,18 +0,0 @@
|
|||
<div class="error-page">
|
||||
<h2 class="headline text-yellow"> 404</h2>
|
||||
<div class="error-content">
|
||||
<h3><i class="fa fa-warning text-yellow"></i> Oops! Page not found.</h3>
|
||||
<p>
|
||||
We could not find the page you were looking for.
|
||||
Meanwhile, you may <a href="../../index.html">return to dashboard</a> or try using the search form.
|
||||
</p>
|
||||
<form class="search-form">
|
||||
<div class="input-group">
|
||||
<input type="text" name="search" class="form-control" placeholder="Search">
|
||||
<div class="input-group-btn">
|
||||
<button type="submit" name="submit" class="btn btn-warning btn-flat"><i class="fa fa-search"></i></button>
|
||||
</div>
|
||||
</div><!-- /.input-group -->
|
||||
</form>
|
||||
</div><!-- /.error-content -->
|
||||
</div><!-- /.error-page -->
|
|
@ -1,18 +0,0 @@
|
|||
<div class="error-page">
|
||||
<h2 class="headline text-red">500</h2>
|
||||
<div class="error-content">
|
||||
<h3><i class="fa fa-warning text-red"></i> Oops! Something went wrong.</h3>
|
||||
<p>
|
||||
We will work on fixing that right away.
|
||||
Meanwhile, you may <a href="../../index.html">return to dashboard</a> or try using the search form.
|
||||
</p>
|
||||
<form class="search-form">
|
||||
<div class="input-group">
|
||||
<input type="text" name="search" class="form-control" placeholder="Search">
|
||||
<div class="input-group-btn">
|
||||
<button type="submit" name="submit" class="btn btn-danger btn-flat"><i class="fa fa-search"></i></button>
|
||||
</div>
|
||||
</div><!-- /.input-group -->
|
||||
</form>
|
||||
</div>
|
||||
</div><!-- /.error-page -->
|
|
@ -1,253 +0,0 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<title>FuzeDev | @todo: Implement</title>
|
||||
<!-- Tell the browser to be responsive to screen width -->
|
||||
<meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
|
||||
<!-- Bootstrap 3.3.5 -->
|
||||
<link rel="stylesheet" href="<?php echo $vars['viewDir']; ?>/assets/bootstrap/css/bootstrap.min.css">
|
||||
<!-- Font Awesome -->
|
||||
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.4.0/css/font-awesome.min.css">
|
||||
<!-- Ionicons -->
|
||||
<link rel="stylesheet" href="https://code.ionicframework.com/ionicons/2.0.1/css/ionicons.min.css">
|
||||
<!-- Theme style -->
|
||||
<link rel="stylesheet" href="<?php echo $vars['viewDir']; ?>/assets/dist/css/AdminLTE.min.css">
|
||||
<!-- AdminLTE Skins. We have chosen the skin-blue for this starter
|
||||
page. However, you can choose any other skin. Make sure you
|
||||
apply the skin class to the body tag so the changes take effect.
|
||||
-->
|
||||
<link rel="stylesheet" href="<?php echo $vars['viewDir']; ?>/assets/dist/css/skins/skin-blue.min.css">
|
||||
|
||||
<!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
|
||||
<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
|
||||
<!--[if lt IE 9]>
|
||||
<script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
|
||||
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
|
||||
<![endif]-->
|
||||
</head>
|
||||
<body class="hold-transition skin-blue sidebar-mini">
|
||||
<div class="wrapper">
|
||||
|
||||
<!-- Main Header -->
|
||||
<header class="main-header">
|
||||
|
||||
<!-- Logo -->
|
||||
<a href="index2.html" class="logo">
|
||||
<!-- mini logo for sidebar mini 50x50 pixels -->
|
||||
<span class="logo-mini"><b>F</b>Dev</span>
|
||||
<!-- logo for regular state and mobile devices -->
|
||||
<span class="logo-lg"><b>Fuze</b>Dev</span>
|
||||
</a>
|
||||
|
||||
<!-- Header Navbar -->
|
||||
<nav class="navbar navbar-static-top" role="navigation">
|
||||
<!-- Sidebar toggle button-->
|
||||
<a href="#" class="sidebar-toggle" data-toggle="offcanvas" role="button">
|
||||
<span class="sr-only">Toggle navigation</span>
|
||||
</a>
|
||||
<!-- Navbar Right Menu -->
|
||||
<div class="navbar-custom-menu">
|
||||
<ul class="nav navbar-nav">
|
||||
<!-- User Account Menu -->
|
||||
<li class="dropdown user user-menu">
|
||||
<!-- Menu Toggle Button -->
|
||||
<a href="#" class="dropdown-toggle" data-toggle="dropdown">
|
||||
<!-- The user image in the navbar-->
|
||||
<img src="" class="user-image" alt="User Image">
|
||||
<!-- hidden-xs hides the username on small devices so only the image appears. -->
|
||||
<span class="hidden-xs">USERNAME</span>
|
||||
</a>
|
||||
<ul class="dropdown-menu">
|
||||
<!-- The user image in the menu -->
|
||||
<li class="user-header">
|
||||
<img src="" class="img-circle" alt="User Image">
|
||||
<p>
|
||||
USERNAME - RANK
|
||||
<small>Member since MEMBER_TIME</small>
|
||||
</p>
|
||||
</li>
|
||||
<!-- Menu Body -->
|
||||
<li class="user-body">
|
||||
<div class="col-xs-4 text-center">
|
||||
<a href="#">Followers</a>
|
||||
</div>
|
||||
<div class="col-xs-4 text-center">
|
||||
<a href="#">Sales</a>
|
||||
</div>
|
||||
<div class="col-xs-4 text-center">
|
||||
<a href="#">Friends</a>
|
||||
</div>
|
||||
</li>
|
||||
<!-- Menu Footer-->
|
||||
<li class="user-footer">
|
||||
<div class="pull-left">
|
||||
<a href="#" class="btn btn-default btn-flat">Profile</a>
|
||||
</div>
|
||||
<div class="pull-right">
|
||||
<a href="#" class="btn btn-default btn-flat">Sign out</a>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<!-- Control Sidebar Toggle Button -->
|
||||
<li>
|
||||
<a href="#" data-toggle="control-sidebar"><i class="fa fa-gears"></i></a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</nav>
|
||||
</header>
|
||||
<!-- Left side column. contains the logo and sidebar -->
|
||||
<aside class="main-sidebar">
|
||||
|
||||
<!-- sidebar: style can be found in sidebar.less -->
|
||||
<section class="sidebar">
|
||||
|
||||
<!-- Sidebar user panel (optional) -->
|
||||
<div class="user-panel">
|
||||
<div class="pull-left image">
|
||||
<img src="" class="img-circle" alt="User Image">
|
||||
</div>
|
||||
<div class="pull-left info">
|
||||
<p>USERNAME</p>
|
||||
<!-- Status -->
|
||||
<a href="#"><i class="fa fa-circle text-success"></i> Online</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- search form (Optional) -->
|
||||
<form action="#" method="get" class="sidebar-form">
|
||||
<div class="input-group">
|
||||
<input type="text" name="q" class="form-control" placeholder="Search...">
|
||||
<span class="input-group-btn">
|
||||
<button type="submit" name="search" id="search-btn" class="btn btn-flat"><i class="fa fa-search"></i></button>
|
||||
</span>
|
||||
</div>
|
||||
</form>
|
||||
<!-- /.search form -->
|
||||
|
||||
<!-- Sidebar Menu -->
|
||||
<ul class="sidebar-menu">
|
||||
<li class="header">Navigate</li>
|
||||
<?php require 'view.sidebar.php'; ?>
|
||||
</ul><!-- /.sidebar-menu -->
|
||||
</section>
|
||||
<!-- /.sidebar -->
|
||||
</aside>
|
||||
|
||||
<!-- Content Wrapper. Contains page content -->
|
||||
<div class="content-wrapper">
|
||||
<!-- Content Header (Page header) -->
|
||||
<section class="content-header">
|
||||
<h1>
|
||||
Page Header
|
||||
<small>Optional description</small>
|
||||
</h1>
|
||||
<ol class="breadcrumb">
|
||||
<li><a href="#"><i class="fa fa-dashboard"></i> Level</a></li>
|
||||
<li class="active">Here</li>
|
||||
</ol>
|
||||
</section>
|
||||
|
||||
<!-- Main content -->
|
||||
<section class="content">
|
||||
<?php echo $vars['pageHTML']; ?>
|
||||
<!-- Your Page Content Here -->
|
||||
|
||||
</section><!-- /.content -->
|
||||
</div><!-- /.content-wrapper -->
|
||||
|
||||
<!-- Main Footer -->
|
||||
<footer class="main-footer">
|
||||
<!-- To the right -->
|
||||
<div class="pull-right hidden-xs">
|
||||
<b>Version</b> 0.0.1
|
||||
</div>
|
||||
<!-- Default to the left -->
|
||||
<strong>Copyright © 2016 <a href="#">FuzeDev</a>.</strong> All rights reserved.
|
||||
</footer>
|
||||
|
||||
<!-- Control Sidebar -->
|
||||
<aside class="control-sidebar control-sidebar-dark">
|
||||
<!-- Create the tabs -->
|
||||
<ul class="nav nav-tabs nav-justified control-sidebar-tabs">
|
||||
<li class="active"><a href="#control-sidebar-home-tab" data-toggle="tab"><i class="fa fa-home"></i></a></li>
|
||||
<li><a href="#control-sidebar-settings-tab" data-toggle="tab"><i class="fa fa-gears"></i></a></li>
|
||||
</ul>
|
||||
<!-- Tab panes -->
|
||||
<div class="tab-content">
|
||||
<!-- Home tab content -->
|
||||
<div class="tab-pane active" id="control-sidebar-home-tab">
|
||||
<h3 class="control-sidebar-heading">Recent Activity</h3>
|
||||
<ul class="control-sidebar-menu">
|
||||
<li>
|
||||
<a href="javascript::;">
|
||||
<i class="menu-icon fa fa-birthday-cake bg-red"></i>
|
||||
<div class="menu-info">
|
||||
<h4 class="control-sidebar-subheading">Langdon's Birthday</h4>
|
||||
<p>Will be 23 on April 24th</p>
|
||||
</div>
|
||||
</a>
|
||||
</li>
|
||||
</ul><!-- /.control-sidebar-menu -->
|
||||
|
||||
<h3 class="control-sidebar-heading">Tasks Progress</h3>
|
||||
<ul class="control-sidebar-menu">
|
||||
<li>
|
||||
<a href="javascript::;">
|
||||
<h4 class="control-sidebar-subheading">
|
||||
Custom Template Design
|
||||
<span class="label label-danger pull-right">70%</span>
|
||||
</h4>
|
||||
<div class="progress progress-xxs">
|
||||
<div class="progress-bar progress-bar-danger" style="width: 70%"></div>
|
||||
</div>
|
||||
</a>
|
||||
</li>
|
||||
</ul><!-- /.control-sidebar-menu -->
|
||||
|
||||
</div><!-- /.tab-pane -->
|
||||
<!-- Stats tab content -->
|
||||
<div class="tab-pane" id="control-sidebar-stats-tab">Stats Tab Content</div><!-- /.tab-pane -->
|
||||
<!-- Settings tab content -->
|
||||
<div class="tab-pane" id="control-sidebar-settings-tab">
|
||||
<form method="post">
|
||||
<h3 class="control-sidebar-heading">General Settings</h3>
|
||||
<div class="form-group">
|
||||
<label class="control-sidebar-subheading">
|
||||
Report panel usage
|
||||
<input type="checkbox" class="pull-right" checked>
|
||||
</label>
|
||||
<p>
|
||||
Some information about this general settings option
|
||||
</p>
|
||||
</div><!-- /.form-group -->
|
||||
</form>
|
||||
</div><!-- /.tab-pane -->
|
||||
</div>
|
||||
</aside><!-- /.control-sidebar -->
|
||||
<!-- Add the sidebar's background. This div must be placed
|
||||
immediately after the control sidebar -->
|
||||
<div class="control-sidebar-bg"></div>
|
||||
</div><!-- ./wrapper -->
|
||||
|
||||
<!-- REQUIRED JS SCRIPTS -->
|
||||
|
||||
<!-- jQuery 2.1.4 -->
|
||||
<script src="<?php echo $vars['viewDir']; ?>/assets/plugins/jQuery/jQuery-2.1.4.min.js"></script>
|
||||
<!-- Bootstrap 3.3.5 -->
|
||||
<script src="<?php echo $vars['viewDir']; ?>/assets/bootstrap/js/bootstrap.min.js"></script>
|
||||
<!-- AdminLTE App -->
|
||||
<script src="<?php echo $vars['viewDir']; ?>/assets/dist/js/app.min.js"></script>
|
||||
|
||||
<!-- SlimScroll -->
|
||||
<script src="<?php echo $vars['viewDir']; ?>/assets/plugins/slimScroll/jquery.slimscroll.min.js"></script>
|
||||
|
||||
<!-- Optionally, you can add Slimscroll and FastClick plugins.
|
||||
Both of these plugins are recommended to enhance the
|
||||
user experience. Slimscroll is required when using the
|
||||
fixed layout. -->
|
||||
</body>
|
||||
</html>
|
|
@ -1,10 +0,0 @@
|
|||
<?php
|
||||
|
||||
// First retrieve the pageList
|
||||
$pageList = $vars['pageList'];
|
||||
|
||||
// The cycle through all and print the sidebar links
|
||||
foreach ($pageList->getPages() as $page) {
|
||||
echo "<li name='sidebar:".$page->getIdentifier().'/'.$page->getPagePath()."'><a href='".$vars['adminURL'].$page->getIdentifier().'/'.$page->getPagePath()."'>
|
||||
<i class='".($page->getIcon() == '' ? '' : 'fa '.$page->getIcon())."'></i> <span>".$page->getName().'</span></a></li>';
|
||||
}
|
|
@ -1,57 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* FuzeWorks.
|
||||
*
|
||||
* The FuzeWorks MVC PHP FrameWork
|
||||
*
|
||||
* Copyright (C) 2015 TechFuze
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* @author TechFuze
|
||||
* @copyright Copyright (c) 2013 - 2016, Techfuze. (http://techfuze.net)
|
||||
* @copyright Copyright (c) 1996 - 2015, Free Software Foundation, Inc. (http://www.fsf.org/)
|
||||
* @license http://opensource.org/licenses/GPL-3.0 GPLv3 License
|
||||
*
|
||||
* @link http://fuzeworks.techfuze.net
|
||||
* @since Version 0.0.1
|
||||
*
|
||||
* @version Version 0.0.1
|
||||
*/
|
||||
|
||||
namespace Module\Api;
|
||||
|
||||
use FuzeWorks\Module;
|
||||
|
||||
/**
|
||||
* Loading class for multiple API types.
|
||||
*
|
||||
* Currently loads a REST API class which controllers can extend so they provide a standardized API
|
||||
*
|
||||
* @author Abel Hoogeveen <abel@techfuze.net>
|
||||
* @copyright Copyright (c) 2013 - 2016, Techfuze. (http://techfuze.net)
|
||||
*/
|
||||
class Main
|
||||
{
|
||||
use Module;
|
||||
/**
|
||||
* Gets loaded upon module initialization.
|
||||
*
|
||||
* Loads all the API types
|
||||
*/
|
||||
public function onLoad()
|
||||
{
|
||||
include_once self::getModulePath().'/class.rest.php';
|
||||
}
|
||||
}
|
|
@ -1,185 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* FuzeWorks.
|
||||
*
|
||||
* The FuzeWorks MVC PHP FrameWork
|
||||
*
|
||||
* Copyright (C) 2015 TechFuze
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* @author TechFuze
|
||||
* @copyright Copyright (c) 2013 - 2016, Techfuze. (http://techfuze.net)
|
||||
* @copyright Copyright (c) 1996 - 2015, Free Software Foundation, Inc. (http://www.fsf.org/)
|
||||
* @license http://opensource.org/licenses/GPL-3.0 GPLv3 License
|
||||
*
|
||||
* @link http://fuzeworks.techfuze.net
|
||||
* @since Version 0.0.1
|
||||
*
|
||||
* @version Version 0.0.1
|
||||
*/
|
||||
|
||||
namespace Module\Api;
|
||||
|
||||
use FuzeWorks\Layout;
|
||||
|
||||
/**
|
||||
* RestAPI class for creating API's out of modules or contrllers.
|
||||
*
|
||||
* Extend a Controller with this class, and be sure to return the data from methods of your controller.
|
||||
* This data will be parsed by this class and returned as valid JSON data.
|
||||
* The necessity of API keys can be configured in the controller by settings $this->requireApiKey = false;
|
||||
*
|
||||
* @author Abel Hoogeveen <abel@techfuze.net>
|
||||
* @copyright Copyright (c) 2013 - 2016, Techfuze. (http://techfuze.net)
|
||||
*/
|
||||
abstract class RestAPI
|
||||
{
|
||||
/**
|
||||
* Property: method
|
||||
* The HTTP method this request was made in, either GET, POST, PUT or DELETE.
|
||||
*/
|
||||
protected $method = '';
|
||||
/**
|
||||
* Property: endpoint
|
||||
* The Model requested in the URI. eg: /files.
|
||||
*/
|
||||
protected $endpoint = '';
|
||||
/**
|
||||
* Property: verb
|
||||
* An optional additional descriptor about the endpoint, used for things that can
|
||||
* not be handled by the basic methods. eg: /files/process.
|
||||
*/
|
||||
protected $verb = '';
|
||||
/**
|
||||
* Property: args
|
||||
* Any additional URI components after the endpoint and verb have been removed, in our
|
||||
* case, an integer ID for the resource. eg: /<endpoint>/<verb>/<arg0>/<arg1>
|
||||
* or /<endpoint>/<arg0>.
|
||||
*/
|
||||
protected $args = array();
|
||||
/**
|
||||
* Property: file
|
||||
* Stores the input of the PUT request.
|
||||
*/
|
||||
protected $file = null;
|
||||
|
||||
/**
|
||||
* Whether API authentication is needed before interacting with the API.
|
||||
*/
|
||||
protected $requireApiKey = true;
|
||||
|
||||
/**
|
||||
* Constructor: __construct
|
||||
* Allow for CORS, assemble and pre-process the data.
|
||||
*/
|
||||
public function __construct($request)
|
||||
{
|
||||
header('Access-Control-Allow-Orgin: *');
|
||||
header('Access-Control-Allow-Methods: *');
|
||||
header('Content-Type: application/json');
|
||||
|
||||
// Return layout data as string
|
||||
Layout::setEngine('JSON');
|
||||
Layout::returnAsString(false);
|
||||
|
||||
$this->args = explode('/', rtrim($request, '/'));
|
||||
$this->endpoint = array_shift($this->args);
|
||||
if (array_key_exists(0, $this->args) && !is_numeric($this->args[0])) {
|
||||
$this->verb = array_shift($this->args);
|
||||
}
|
||||
|
||||
$this->method = $_SERVER['REQUEST_METHOD'];
|
||||
if ($this->method == 'POST' && array_key_exists('HTTP_X_HTTP_METHOD', $_SERVER)) {
|
||||
if ($_SERVER['HTTP_X_HTTP_METHOD'] == 'DELETE') {
|
||||
$this->method = 'DELETE';
|
||||
} elseif ($_SERVER['HTTP_X_HTTP_METHOD'] == 'PUT') {
|
||||
$this->method = 'PUT';
|
||||
} else {
|
||||
throw new Exception('Unexpected Header');
|
||||
}
|
||||
}
|
||||
|
||||
switch ($this->method) {
|
||||
case 'DELETE':
|
||||
case 'POST':
|
||||
$this->request = $this->_cleanInputs($_POST);
|
||||
break;
|
||||
case 'GET':
|
||||
$this->request = $this->_cleanInputs($_GET);
|
||||
break;
|
||||
case 'PUT':
|
||||
$this->request = $this->_cleanInputs($_GET);
|
||||
$this->file = file_get_contents('php://input');
|
||||
break;
|
||||
default:
|
||||
$this->_response('Invalid Method', 405);
|
||||
break;
|
||||
}
|
||||
|
||||
// And afterwards process the data
|
||||
echo $this->processAPI();
|
||||
|
||||
// Halter for when the RestApi is used by a controller
|
||||
$this->halt = true;
|
||||
Layout::reset();
|
||||
}
|
||||
|
||||
/**
|
||||
* Process an API request when retrieving.
|
||||
*
|
||||
* @return string JSON encoded response
|
||||
*/
|
||||
public function processAPI()
|
||||
{
|
||||
if (method_exists($this, $this->endpoint)) {
|
||||
return $this->_response($this->{$this->endpoint}($this->args));
|
||||
}
|
||||
|
||||
return $this->_response("No Endpoint: $this->endpoint", 404);
|
||||
}
|
||||
|
||||
private function _response($data, $status = 200)
|
||||
{
|
||||
header('HTTP/1.1 '.$status.' '.$this->_requestStatus($status));
|
||||
|
||||
return json_encode($data);
|
||||
}
|
||||
|
||||
private function _cleanInputs($data)
|
||||
{
|
||||
$clean_input = array();
|
||||
if (is_array($data)) {
|
||||
foreach ($data as $k => $v) {
|
||||
$clean_input[$k] = $this->_cleanInputs($v);
|
||||
}
|
||||
} else {
|
||||
$clean_input = trim(strip_tags($data));
|
||||
}
|
||||
|
||||
return $clean_input;
|
||||
}
|
||||
|
||||
private function _requestStatus($code)
|
||||
{
|
||||
$status = array(
|
||||
200 => 'OK',
|
||||
404 => 'Not Found',
|
||||
405 => 'Method Not Allowed',
|
||||
500 => 'Internal Server Error',
|
||||
);
|
||||
|
||||
return ($status[$code]) ? $status[$code] : $status[500];
|
||||
}
|
||||
}
|
|
@ -1,55 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* FuzeWorks.
|
||||
*
|
||||
* The FuzeWorks MVC PHP FrameWork
|
||||
*
|
||||
* Copyright (C) 2015 TechFuze
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* @author TechFuze
|
||||
* @copyright Copyright (c) 2013 - 2016, Techfuze. (http://techfuze.net)
|
||||
* @copyright Copyright (c) 1996 - 2015, Free Software Foundation, Inc. (http://www.fsf.org/)
|
||||
* @license http://opensource.org/licenses/GPL-3.0 GPLv3 License
|
||||
*
|
||||
* @link http://fuzeworks.techfuze.net
|
||||
* @since Version 0.0.1
|
||||
*
|
||||
* @version Version 0.0.1
|
||||
*/
|
||||
|
||||
return array(
|
||||
|
||||
'module_class' => 'Module\Api\Main',
|
||||
'module_file' => 'class.main.php',
|
||||
'module_name' => 'Api',
|
||||
|
||||
'abstract' => false,
|
||||
'dependencies' => array(),
|
||||
'events' => array(),
|
||||
'sections' => array(),
|
||||
'aliases' => array(),
|
||||
|
||||
'name' => 'FuzeWorks Api Module',
|
||||
'description' => 'A Controller server for multiple types of API\'s like REST and SOAP',
|
||||
'author' => 'core',
|
||||
'version' => '1.0.0',
|
||||
'website' => 'http://fuzeworks.techfuze.net/',
|
||||
|
||||
'date_created' => '03-05-2015',
|
||||
'date_updated' => '06-09-2015',
|
||||
|
||||
'enabled' => true,
|
||||
);
|
|
@ -1,143 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* FuzeWorks.
|
||||
*
|
||||
* The FuzeWorks MVC PHP FrameWork
|
||||
*
|
||||
* Copyright (C) 2015 TechFuze
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* @author TechFuze
|
||||
* @copyright Copyright (c) 2013 - 2016, Techfuze. (http://techfuze.net)
|
||||
* @copyright Copyright (c) 1996 - 2015, Free Software Foundation, Inc. (http://www.fsf.org/)
|
||||
* @license http://opensource.org/licenses/GPL-3.0 GPLv3 License
|
||||
*
|
||||
* @link http://fuzeworks.techfuze.net
|
||||
* @since Version 0.0.1
|
||||
*
|
||||
* @version Version 0.0.1
|
||||
*/
|
||||
|
||||
namespace Module\Example;
|
||||
|
||||
use FuzeWorks\Module;
|
||||
use FuzeWorks\Event;
|
||||
use FuzeWorks\EventPriority;
|
||||
use FuzeWorks\Events;
|
||||
use FuzeWorks\Logger;
|
||||
|
||||
/**
|
||||
* Example module.
|
||||
*
|
||||
* Use this is a reference to create new modules.
|
||||
*
|
||||
* @author Abel Hoogeveen <abel@techfuze.net>
|
||||
* @copyright Copyright (c) 2013 - 2016, Techfuze. (http://techfuze.net)
|
||||
*/
|
||||
class Main
|
||||
{
|
||||
use Module;
|
||||
|
||||
/**
|
||||
* Loads the module and registers the events.
|
||||
*
|
||||
* Every main moduleclass needs an onLoad method. This method is called first before anything else and cam be used to do some global actions.
|
||||
*/
|
||||
public function onLoad()
|
||||
{
|
||||
// Here we register an eventListener for the ExampleEvent. See ExampleListener for more info
|
||||
Events::addListener(array($this, 'exampleListener'), 'ExampleEvent', EventPriority::NORMAL);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test method that can be called.
|
||||
*
|
||||
* @return string Example text
|
||||
*/
|
||||
public function test()
|
||||
{
|
||||
return 'It works!';
|
||||
}
|
||||
|
||||
/**
|
||||
* An example listener that introduces you to the basics of event handling.
|
||||
*
|
||||
* @param ExampleEvent $event The event to listen for
|
||||
*
|
||||
* @return ExampleEvent The event after it has been handled
|
||||
*/
|
||||
public function exampleListener($event)
|
||||
{
|
||||
Logger::log('Called the eventListener. This listener can now handle the event and change some data');
|
||||
// For this listener, we only change one variable
|
||||
$event->setVariable('New Value');
|
||||
|
||||
// And then we return it
|
||||
return $event;
|
||||
}
|
||||
|
||||
/**
|
||||
* In this example we create a simple event. This event will be created, passed around and then received in the example listener.
|
||||
*/
|
||||
public function createEvent()
|
||||
{
|
||||
// First we log some data
|
||||
Logger::log('Now creating a test event.');
|
||||
|
||||
// First we create the event object and some variables to assign to it
|
||||
$eventObject = new ExampleEvent();
|
||||
$variable = 'Test Variable';
|
||||
|
||||
// Then we fire the event by parsing the event object and the variables into the fireEvent function.
|
||||
$event = Events::fireEvent($eventObject, $variable);
|
||||
|
||||
// Here we can read some variables from the event
|
||||
$result = $event->getVariable();
|
||||
|
||||
// And now we can do things with the data. For now we just return it
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets called when the path matches the regex of this module.
|
||||
*
|
||||
* @param array Regex matches
|
||||
*/
|
||||
public function route($matches = array())
|
||||
{
|
||||
// Just print the inputted data:
|
||||
echo '<h3>Input data: '.$matches['data'].'</h3>';
|
||||
}
|
||||
}
|
||||
|
||||
class ExampleEvent extends Event
|
||||
{
|
||||
private $var1;
|
||||
|
||||
public function init($variable)
|
||||
{
|
||||
$this->var1 = $variable;
|
||||
}
|
||||
|
||||
public function getVariable()
|
||||
{
|
||||
return $this->var1;
|
||||
}
|
||||
|
||||
public function setVariable($var)
|
||||
{
|
||||
$this->var1 = $var;
|
||||
}
|
||||
}
|
|
@ -1,91 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* FuzeWorks.
|
||||
*
|
||||
* The FuzeWorks MVC PHP FrameWork
|
||||
*
|
||||
* Copyright (C) 2015 TechFuze
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* @author TechFuze
|
||||
* @copyright Copyright (c) 2013 - 2016, Techfuze. (http://techfuze.net)
|
||||
* @copyright Copyright (c) 1996 - 2015, Free Software Foundation, Inc. (http://www.fsf.org/)
|
||||
* @license http://opensource.org/licenses/GPL-3.0 GPLv3 License
|
||||
*
|
||||
* @link http://fuzeworks.techfuze.net
|
||||
* @since Version 0.0.1
|
||||
*
|
||||
* @version Version 0.0.1
|
||||
*/
|
||||
|
||||
return array(
|
||||
|
||||
// The class name of the module. This class will be loaded upon requesting the module
|
||||
'module_class' => 'Module\Example\Main',
|
||||
|
||||
// The file that will be loaded upon requesting the module
|
||||
'module_file' => 'class.main.php',
|
||||
|
||||
// The name of the module; Appended into Modules::get('namespace/module_name');
|
||||
'module_name' => 'Example',
|
||||
|
||||
// whether this module is an abstract. Making this abstract will only load the file, but not the class.
|
||||
'abstract' => false,
|
||||
|
||||
// Other names for this module. Setting an alias will allow you to load the module with a different name.
|
||||
'aliases' => array(),
|
||||
|
||||
// Array of modules that should be loaded before this module
|
||||
'dependencies' => array(),
|
||||
|
||||
// Events that this module listens for. When the exampleEvent is fired, this module will be loaded so the module can handle the event
|
||||
'events' => array('exampleEvent'),
|
||||
|
||||
// Routes that this module listens on. Any URL that matches this pattern will load this module
|
||||
// If the URL /example/ gets called, this module will be loaded
|
||||
// Everything after /example/ will be sent to the route() function in the matches array under the, in this example, 'data' key
|
||||
'routes' => array('example(|\/(?P<data>.*?))$'),
|
||||
|
||||
// Advertises some data with the key 'exampleAdvertisement'. This data will be sent to a module which listens for this key.
|
||||
// This allows for some data to be sent to a module which listens to this key.
|
||||
'advertise' => array('exampleAdvertisement' => array('exampleData')),
|
||||
|
||||
// Tells the module engine that this module would like all the data with the key 'exampleAdvertisement'.
|
||||
'listenFor' => array('exampleAdvertisement'),
|
||||
|
||||
// The name of the module as it will be logged. This does not affect usage of the module in any way
|
||||
'name' => 'FuzeWorks Example Module',
|
||||
|
||||
// A description of the module.
|
||||
'description' => 'A descriptive module that functions as an example',
|
||||
|
||||
// The author of the module. The author is the first part of the module name used for requesting. eg mycorp/example
|
||||
'author' => 'MyCorp',
|
||||
|
||||
// The current version of the module. Will be used for looking for updates
|
||||
'version' => '1.0.0',
|
||||
|
||||
// The website to look at for the module update
|
||||
'website' => 'http://fuzeworks.techfuze.net/',
|
||||
|
||||
// The initial creation of the module.
|
||||
'date_created' => '29-04-2015',
|
||||
|
||||
// The last update of this module
|
||||
'date_updated' => '29-04-2015',
|
||||
|
||||
// whether the module is enabled or not. If it is disabled, it can not be loaded.
|
||||
'enabled' => true,
|
||||
);
|
|
@ -1,15 +1,36 @@
|
|||
{
|
||||
"name": "fuzeworks/core",
|
||||
"description": "FuzeWorks Framework Core",
|
||||
"homepage": "https://techfuze.net/fuzeworks",
|
||||
"license": ["GPL-3.0"],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Abel Hoogeveen",
|
||||
"homepage": "https://myfuze.net"
|
||||
},
|
||||
{
|
||||
"name": "FuzeWorks Community",
|
||||
"homepage": "https://techfuze.net/fuzeworks/contributors"
|
||||
}
|
||||
],
|
||||
"require": {
|
||||
"php": ">=5.4.0",
|
||||
"php": ">=5.6.0",
|
||||
"ext-curl": "*",
|
||||
"ext-json": "*",
|
||||
"ext-json": "*"
|
||||
},
|
||||
"suggest": {
|
||||
"smarty/smarty": "Allows using Smarty in templates",
|
||||
"latte/latte": "Allows using Latte in templates"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "5.3.*",
|
||||
"apigen/apigen": "^4.1",
|
||||
"mikey179/vfsStream": "1.1.*",
|
||||
"smarty/smarty": "~3.1",
|
||||
"tracy/tracy": "*",
|
||||
"latte/latte": "*"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "5.3.*",
|
||||
"apigen/apigen": "^4.1",
|
||||
"mikey179/vfsStream": "1.1.*"
|
||||
}
|
||||
}
|
||||
"autoload": {
|
||||
"classmap": ["Core/System/"]
|
||||
}
|
||||
}
|
44
index.php
44
index.php
|
@ -1,44 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* FuzeWorks.
|
||||
*
|
||||
* The FuzeWorks MVC PHP FrameWork
|
||||
*
|
||||
* Copyright (C) 2015 TechFuze
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* @author TechFuze
|
||||
* @copyright Copyright (c) 2013 - 2016, Techfuze. (http://techfuze.net)
|
||||
* @copyright Copyright (c) 1996 - 2015, Free Software Foundation, Inc. (http://www.fsf.org/)
|
||||
* @license http://opensource.org/licenses/GPL-3.0 GPLv3 License
|
||||
*
|
||||
* @link http://fuzeworks.techfuze.net
|
||||
* @since Version 0.0.1
|
||||
*
|
||||
* @version Version 0.0.1
|
||||
*/
|
||||
use FuzeWorks\Core;
|
||||
use FuzeWorks\Factory;
|
||||
|
||||
define('ENVIRONMENT', 'PRODUCTION');
|
||||
|
||||
// Include framework
|
||||
require_once dirname(__FILE__).'/Core/System/class.core.php';
|
||||
|
||||
// Load it
|
||||
Core::init();
|
||||
|
||||
$router = Factory::getInstance()->router;
|
||||
$router->route();
|
|
@ -0,0 +1,15 @@
|
|||
<?php
|
||||
|
||||
require_once('../vendor/autoload.php');
|
||||
|
||||
$configurator = new FuzeWorks\Configurator();
|
||||
|
||||
//$configurator->setDebugMode('23.75.345.200'); // enable for your remote IP
|
||||
//$configurator->enableDebugger(__DIR__ . '/../log');
|
||||
|
||||
$configurator->setTimeZone('Europe/Amsterdam');
|
||||
$configurator->setTempDirectory(__DIR__ . '/temp');
|
||||
|
||||
$container = $configurator->createContainer();
|
||||
|
||||
return $container;
|
|
@ -29,18 +29,19 @@
|
|||
*
|
||||
* @version Version 0.0.1
|
||||
*/
|
||||
// Load the abstract
|
||||
|
||||
use FuzeWorks\Config;
|
||||
use FuzeWorks\Core;
|
||||
use FuzeWorks\Logger;
|
||||
|
||||
// Load the FuzeWorks container
|
||||
$container = require('bootstrap.php');
|
||||
|
||||
// Load the test abstract
|
||||
require_once 'abstract.coreTestAbstract.php';
|
||||
require_once 'Core/System/class.core.php';
|
||||
|
||||
// Reset error and exception handlers
|
||||
ob_start();
|
||||
Core::init();
|
||||
|
||||
restore_error_handler();
|
||||
restore_exception_handler();
|
||||
|
||||
|
@ -51,14 +52,10 @@ error_reporting(E_ALL | E_STRICT);
|
|||
// Set localhost "remote" IP
|
||||
isset($_SERVER['REMOTE_ADDR']) OR $_SERVER['REMOTE_ADDR'] = '127.0.0.1';
|
||||
|
||||
// Load the vfsStream class either through PEAR installed library or through composer
|
||||
if ( ! class_exists('vfsStream') && file_exists('vendor/autoload.php'))
|
||||
{
|
||||
include_once 'vendor/autoload.php';
|
||||
class_alias('org\bovigo\vfs\vfsStream', 'vfsStream');
|
||||
class_alias('org\bovigo\vfs\vfsStreamDirectory', 'vfsStreamDirectory');
|
||||
class_alias('org\bovigo\vfs\vfsStreamWrapper', 'vfsStreamWrapper');
|
||||
}
|
||||
// Alias vfsStream
|
||||
class_alias('org\bovigo\vfs\vfsStream', 'vfsStream');
|
||||
class_alias('org\bovigo\vfs\vfsStreamDirectory', 'vfsStreamDirectory');
|
||||
class_alias('org\bovigo\vfs\vfsStreamWrapper', 'vfsStreamWrapper');
|
||||
|
||||
Logger::setLoggerTemplate('logger_cli');
|
||||
|
||||
|
|
|
@ -0,0 +1,20 @@
|
|||
<?php
|
||||
|
||||
require_once(dirname(__DIR__) . '/vendor/autoload.php');
|
||||
|
||||
$configurator = new FuzeWorks\Configurator();
|
||||
|
||||
// Set directories
|
||||
$parameters = array(
|
||||
'appDir' => dirname(__FILE__) . '/application',
|
||||
'wwwDir' => dirname(__FILE__) . '/www'
|
||||
);
|
||||
$configurator->setParameters($parameters);
|
||||
|
||||
$configurator->setTimeZone('Europe/Amsterdam');
|
||||
$configurator->setTempDirectory(__DIR__ . '/temp');
|
||||
$configurator->setLogDirectory(__DIR__ . '/temp');
|
||||
|
||||
$container = $configurator->createContainer();
|
||||
|
||||
return $container;
|
|
@ -145,7 +145,7 @@ class layoutTest extends CoreTestAbstract
|
|||
|
||||
// Test for default values
|
||||
$this->assertFalse(Layout::getTitle());
|
||||
$this->assertEquals('Application/Views', Layout::getDirectory());
|
||||
$this->assertTrue(strpos(Layout::getDirectory(), 'application/Views') !== false);
|
||||
}
|
||||
|
||||
public function testGetEngineFromExtension()
|
||||
|
|
|
@ -68,11 +68,11 @@ class layoutLoadViewEventTest extends CoreTestAbstract
|
|||
{
|
||||
|
||||
// This controller should not exist
|
||||
$this->assertEquals('Application/Views/view.home.php', $event->file);
|
||||
$this->assertEquals('Application/Views/', $event->directory);
|
||||
$this->assertTrue(strpos($event->file, 'application/Views/view.home.php') !== false);
|
||||
$this->assertTrue(strpos($event->directory, 'application/Views/') !== false);
|
||||
|
||||
// It should exist now
|
||||
$event->file = 'Application/Views/view.test.not_found';
|
||||
$event->file = $event->directory . 'view.test.not_found';
|
||||
|
||||
return $event;
|
||||
}
|
||||
|
|
|
@ -0,0 +1,2 @@
|
|||
*
|
||||
!.gitignore
|
Loading…
Reference in New Issue