Implemented renewed unit tests.
These now work in the new construction
This commit is contained in:
parent
b0f73d5537
commit
7fc7d63179
|
@ -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>
|
|
@ -93,9 +93,11 @@ class Configurator
|
|||
* Adds new parameters. The %params% will be expanded.
|
||||
* @return self
|
||||
*/
|
||||
public function addParameters(array $params)
|
||||
public function setParameters(array $params)
|
||||
{
|
||||
$this->parameters = DI\Config\Helpers::merge($params, $this->parameters);
|
||||
foreach ($params as $key => $value) {
|
||||
$this->parameters[$key] = $value;
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
|
|
@ -72,7 +72,7 @@ class Helpers
|
|||
|
||||
public function __construct()
|
||||
{
|
||||
$this->helperPath = [
|
||||
$this->helperPaths = [
|
||||
Core::$appDir . DS . 'Helpers',
|
||||
Core::$coreDir . DS . 'Helpers'
|
||||
];
|
||||
|
|
|
@ -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,
|
||||
);
|
|
@ -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,19 @@
|
|||
<?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');
|
||||
|
||||
$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;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue