More simplification

This commit is contained in:
Timothy Warren 2015-06-04 15:46:30 -04:00
parent 140fef2cda
commit 906bec446f
19 changed files with 39 additions and 155 deletions

View File

@ -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;
}
}

View File

View File

@ -18,7 +18,7 @@
* *
* @package meta * @package meta
*/ */
class category extends meta\controller { class category extends \miniMVC\Controller {
/** /**
* Initialize the Controller * Initialize the Controller

View File

@ -18,7 +18,7 @@
* *
* @package meta * @package meta
*/ */
class genre extends meta\controller { class genre extends \miniMVC\Controller {
/** /**
* Default controller method * Default controller method

View File

@ -18,7 +18,7 @@
* *
* @package meta * @package meta
*/ */
class section extends meta\controller { class section extends \miniMVC\Controller {
/** /**
* Constructor * Constructor

View File

@ -7,6 +7,7 @@
<?= $head_tags ?> <?= $head_tags ?>
<?php if (!empty($base)) { ?><base href="<?=$base ?>" /><?php } ?> <?php if (!empty($base)) { ?><base href="<?=$base ?>" /><?php } ?>
<?= $head_tags ?> <?= $head_tags ?>
<script src="<?= SCRIPT_PATH.'wysiwyg'; ?>"></script>
<?= $head_js ?> <?= $head_js ?>
</head> </head>
<body<?= (!empty($body_class)) ? "class=\"" . $body_class . "\"" : ""; ?><?= (!empty($body_id)) ? " id=\"" . $body_id . "\"" : ""; ?>> <body<?= (!empty($body_class)) ? "class=\"" . $body_class . "\"" : ""; ?><?= (!empty($body_id)) ? " id=\"" . $body_id . "\"" : ""; ?>>

View File

@ -4,7 +4,6 @@
<a href="<?= miniMVC\site_url('category/detail/'.$p['category_id']) ?>"><?= $p['category'] ?></a> > <a href="<?= miniMVC\site_url('category/detail/'.$p['category_id']) ?>"><?= $p['category'] ?></a> >
<?= $section ?> <?= $section ?>
</p> </p>
<script src="<?= SCRIPT_PATH.'wysiwyg'; ?>"></script>
<form class="add" action="<?= miniMVC\site_url("section/add_data") ?>" method="post" onsubmit="window.edit_wysiwyg.toggle()"> <form class="add" action="<?= miniMVC\site_url("section/add_data") ?>" method="post" onsubmit="window.edit_wysiwyg.toggle()">
<fieldset> <fieldset>
<legend>Add Data</legend> <legend>Add Data</legend>

View File

@ -1,5 +1,7 @@
{ {
"require": { "require": {
"aura/router": "2.0.*@dev" "filp/whoops": "1.1.*",
"aura/router": "2.2.*",
"aviat4ion/query": "2.0.*"
} }
} }

View File

@ -24,13 +24,15 @@
namespace miniMVC; namespace miniMVC;
use \Whoops\Handler\PrettyPageHandler;
use \Whoops\Handler\JsonResponseHandler;
error_reporting(-1); error_reporting(-1);
// Set the default paths // Set the default paths
define('MM_BASE_PATH', __DIR__); define('MM_BASE_PATH', __DIR__);
define('MM_SYS_PATH', __DIR__.'/sys/'); define('MM_SYS_PATH', __DIR__.'/sys/');
define('MM_APP_PATH', __DIR__.'/app/'); define('MM_APP_PATH', __DIR__.'/app/');
define('MM_MOD_PATH', MM_APP_PATH.'modules/');
// Autoload vendors // Autoload vendors
require(MM_BASE_PATH . '/vendor/autoload.php'); require(MM_BASE_PATH . '/vendor/autoload.php');
@ -44,6 +46,11 @@ require(MM_SYS_PATH . 'common.php');
// Start the autoloader // Start the autoloader
spl_autoload_register('miniMVC\autoload'); spl_autoload_register('miniMVC\autoload');
// Setup error handling
$whoops = new \Whoops\Run();
$defaultHandler = new PrettyPageHandler();
$whoops->pushHandler($defaultHandler);
// And away we go! // And away we go!
init(); init();

View File

@ -61,77 +61,7 @@ function autoload($name)
} }
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
// ! Error handling / messages // ! 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;
}
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
/** /**
@ -295,16 +225,6 @@ if ( ! function_exists('do_include'))
*/ */
function init() 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 // Load Database classes
require_once(MM_SYS_PATH . 'db/autoload.php'); require_once(MM_SYS_PATH . 'db/autoload.php');
@ -418,7 +338,7 @@ function route()
*/ */
function run($controller, $func, $args = array()) 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)) if (is_file($path))
{ {

View File

@ -42,6 +42,11 @@ class Controller {
{ {
$this->page = new Page(); $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); $file_name = end($segments);
// The module is set via the router // The module is set via the router
$module = strtolower(MM_MOD); $path = MM_APP_PATH . "models/{$file_name}.php";
$path = MM_MOD_PATH . "{$module}/models/{$file_name}.php";
if (is_file($path)) if (is_file($path))
{ {

View File

@ -613,19 +613,8 @@ class Page {
* @return mixed * @return mixed
*/ */
public function load_view($file, array $data=array(), $return=FALSE) 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 // Contain the content for buffering
ob_start(); ob_start();

1
sys/db
View File

@ -1 +0,0 @@
/var/www/htdocs/dev.timshomepage.net/github/Query/