More simplification
This commit is contained in:
parent
140fef2cda
commit
906bec446f
@ -1,37 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* meta
|
||||
*
|
||||
* Hierarchial data tool
|
||||
*
|
||||
* @package meta
|
||||
* @author Timothy J. Warren
|
||||
* @copyright Copyright (c) 2012
|
||||
* @link https://github.com/aviat4ion/meta
|
||||
* @license http://philsturgeon.co.uk/code/dbad-license
|
||||
*/
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
namespace meta;
|
||||
|
||||
/**
|
||||
* Base controller class to hold common functionality
|
||||
*
|
||||
* @param package meta
|
||||
*/
|
||||
abstract class Controller extends \miniMVC\Controller {
|
||||
|
||||
/**
|
||||
* Create the controller and build page header
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->load_model('meta\data_model');
|
||||
$db = \miniMVC\db::get_instance();
|
||||
|
||||
$this->page->queries =& $db->queries;
|
||||
}
|
||||
|
||||
}
|
@ -18,7 +18,7 @@
|
||||
*
|
||||
* @package meta
|
||||
*/
|
||||
class category extends meta\controller {
|
||||
class category extends \miniMVC\Controller {
|
||||
|
||||
/**
|
||||
* Initialize the Controller
|
@ -18,7 +18,7 @@
|
||||
*
|
||||
* @package meta
|
||||
*/
|
||||
class genre extends meta\controller {
|
||||
class genre extends \miniMVC\Controller {
|
||||
|
||||
/**
|
||||
* Default controller method
|
@ -18,7 +18,7 @@
|
||||
*
|
||||
* @package meta
|
||||
*/
|
||||
class section extends meta\controller {
|
||||
class section extends \miniMVC\Controller {
|
||||
|
||||
/**
|
||||
* Constructor
|
@ -7,6 +7,7 @@
|
||||
<?= $head_tags ?>
|
||||
<?php if (!empty($base)) { ?><base href="<?=$base ?>" /><?php } ?>
|
||||
<?= $head_tags ?>
|
||||
<script src="<?= SCRIPT_PATH.'wysiwyg'; ?>"></script>
|
||||
<?= $head_js ?>
|
||||
</head>
|
||||
<body<?= (!empty($body_class)) ? "class=\"" . $body_class . "\"" : ""; ?><?= (!empty($body_id)) ? " id=\"" . $body_id . "\"" : ""; ?>>
|
||||
|
@ -4,7 +4,6 @@
|
||||
<a href="<?= miniMVC\site_url('category/detail/'.$p['category_id']) ?>"><?= $p['category'] ?></a> >
|
||||
<?= $section ?>
|
||||
</p>
|
||||
<script src="<?= SCRIPT_PATH.'wysiwyg'; ?>"></script>
|
||||
<form class="add" action="<?= miniMVC\site_url("section/add_data") ?>" method="post" onsubmit="window.edit_wysiwyg.toggle()">
|
||||
<fieldset>
|
||||
<legend>Add Data</legend>
|
@ -1,5 +1,7 @@
|
||||
{
|
||||
"require": {
|
||||
"aura/router": "2.0.*@dev"
|
||||
"filp/whoops": "1.1.*",
|
||||
"aura/router": "2.2.*",
|
||||
"aviat4ion/query": "2.0.*"
|
||||
}
|
||||
}
|
@ -24,13 +24,15 @@
|
||||
|
||||
namespace miniMVC;
|
||||
|
||||
use \Whoops\Handler\PrettyPageHandler;
|
||||
use \Whoops\Handler\JsonResponseHandler;
|
||||
|
||||
error_reporting(-1);
|
||||
|
||||
// Set the default paths
|
||||
define('MM_BASE_PATH', __DIR__);
|
||||
define('MM_SYS_PATH', __DIR__.'/sys/');
|
||||
define('MM_APP_PATH', __DIR__.'/app/');
|
||||
define('MM_MOD_PATH', MM_APP_PATH.'modules/');
|
||||
|
||||
// Autoload vendors
|
||||
require(MM_BASE_PATH . '/vendor/autoload.php');
|
||||
@ -44,6 +46,11 @@ require(MM_SYS_PATH . 'common.php');
|
||||
// Start the autoloader
|
||||
spl_autoload_register('miniMVC\autoload');
|
||||
|
||||
// Setup error handling
|
||||
$whoops = new \Whoops\Run();
|
||||
$defaultHandler = new PrettyPageHandler();
|
||||
$whoops->pushHandler($defaultHandler);
|
||||
|
||||
// And away we go!
|
||||
init();
|
||||
|
||||
|
@ -61,77 +61,7 @@ function autoload($name)
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// ! Error handling / messages
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Function to run on script shutdown
|
||||
* -used to catch most fatal errors, and
|
||||
* display them cleanly
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function shutdown()
|
||||
{
|
||||
// Catch the last error
|
||||
$error = error_get_last();
|
||||
|
||||
// types of errors that are fatal
|
||||
$fatal = array(E_ERROR, E_PARSE, E_RECOVERABLE_ERROR);
|
||||
|
||||
// Display pretty error page
|
||||
if (in_array($error['type'], $fatal))
|
||||
{
|
||||
$file = str_replace(MM_BASE_PATH, "", $error['file']);
|
||||
|
||||
$err_msg = "<h2>Fatal Error: </h2>
|
||||
{$error['message']}<br /><br />
|
||||
<strong>File:</strong> {$file}<br /><br />
|
||||
<strong>Line:</strong> {$error['line']}";
|
||||
|
||||
show_error($err_msg);
|
||||
}
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Custom error handler
|
||||
*
|
||||
* @param int $severity
|
||||
* @param string $message
|
||||
* @param string $filepath
|
||||
* @param int $line
|
||||
* @return ErrorException
|
||||
*/
|
||||
function on_error($severity, $message, $filepath, $line)
|
||||
{
|
||||
throw new \ErrorException($message, 0, $severity, $filepath, $line);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Custom exception handlererror_get_last
|
||||
*
|
||||
* @param Exception $exception
|
||||
* @return void
|
||||
*/
|
||||
function on_exception($exception)
|
||||
{
|
||||
// This is passed to the error template
|
||||
$message = $exception->getMessage();
|
||||
|
||||
// Contain the content for buffering
|
||||
ob_start();
|
||||
|
||||
include(MM_APP_PATH . '/views/errors/error_php_exception.php');
|
||||
|
||||
$buffer = ob_get_contents();
|
||||
ob_end_clean();
|
||||
echo $buffer;
|
||||
}
|
||||
|
||||
// ! Messages
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
@ -295,16 +225,6 @@ if ( ! function_exists('do_include'))
|
||||
*/
|
||||
function init()
|
||||
{
|
||||
// Catch fatal errors, don't show them
|
||||
if (function_exists('error_get_last'))
|
||||
{
|
||||
register_shutdown_function('miniMVC\shutdown');
|
||||
}
|
||||
|
||||
//Set error handlers
|
||||
set_error_handler('miniMVC\on_error');
|
||||
set_exception_handler('miniMVC\on_exception');
|
||||
|
||||
// Load Database classes
|
||||
require_once(MM_SYS_PATH . 'db/autoload.php');
|
||||
|
||||
@ -418,7 +338,7 @@ function route()
|
||||
*/
|
||||
function run($controller, $func, $args = array())
|
||||
{
|
||||
$path = MM_MOD_PATH . "meta/controllers/{$controller}.php";
|
||||
$path = MM_APP_PATH . "controllers/{$controller}.php";
|
||||
|
||||
if (is_file($path))
|
||||
{
|
||||
|
@ -42,6 +42,11 @@ class Controller {
|
||||
{
|
||||
$this->page = new Page();
|
||||
}
|
||||
|
||||
$this->load_model('meta\data_model');
|
||||
$db = \miniMVC\db::get_instance();
|
||||
|
||||
$this->page->queries =& $db->queries;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
@ -59,8 +64,7 @@ class Controller {
|
||||
$file_name = end($segments);
|
||||
|
||||
// The module is set via the router
|
||||
$module = strtolower(MM_MOD);
|
||||
$path = MM_MOD_PATH . "{$module}/models/{$file_name}.php";
|
||||
$path = MM_APP_PATH . "models/{$file_name}.php";
|
||||
|
||||
if (is_file($path))
|
||||
{
|
||||
|
@ -614,18 +614,7 @@ class Page {
|
||||
*/
|
||||
public function load_view($file, array $data=array(), $return=FALSE)
|
||||
{
|
||||
$path = "";
|
||||
|
||||
// The module is set via the router
|
||||
$module = strtolower(MM_MOD);
|
||||
$path = MM_MOD_PATH . "{$module}/views/{$file}.php";
|
||||
|
||||
// If it's not a module, or doesn't exist in the module view folder
|
||||
// look in the app view folder
|
||||
if ( ! is_file($path))
|
||||
{
|
||||
$path = MM_APP_PATH . "views/{$file}.php";
|
||||
}
|
||||
$path = MM_APP_PATH . "views/{$file}.php";
|
||||
|
||||
// Contain the content for buffering
|
||||
ob_start();
|
||||
|
Loading…
Reference in New Issue
Block a user