diff --git a/assets/config/config.php b/assets/config/config.php index 2953829..e88b3ca 100755 --- a/assets/config/config.php +++ b/assets/config/config.php @@ -13,7 +13,7 @@ | you will need to add that folder to the document root. | */ -$document_root = realpath("../".__DIR__); +$document_root = './'; /* |-------------------------------------------------------------------------- diff --git a/index.php b/index.php index 137ebd3..347ac40 100644 --- a/index.php +++ b/index.php @@ -33,7 +33,11 @@ require(APP_PATH.'config/config.php'); require(SYS_PATH . "common.php"); //Set error handlers -register_shutdown_function('shutdown'); +// Quercus doesn't define error_get_last... +if(function_exists('error_get_last')) +{ + register_shutdown_function('shutdown'); +} set_error_handler('on_error'); set_exception_handler('on_exception'); diff --git a/modules/welcome/controllers/welcome.php b/modules/welcome/controllers/welcome.php index 2cbe222..993161f 100644 --- a/modules/welcome/controllers/welcome.php +++ b/modules/welcome/controllers/welcome.php @@ -5,7 +5,6 @@ class Welcome extends MM_Controller { function __construct() { parent::__construct(); - } function index() diff --git a/sys/db.php b/sys/db.php index b662c90..5f56100 100644 --- a/sys/db.php +++ b/sys/db.php @@ -22,7 +22,7 @@ class db extends PDO { private $statement; private static $instance; - public static function get_instance($dbname="default", $options=array()) + public static function &get_instance($dbname="default", $options=array()) { if ( ! isset(self::$instance[$dbname])) { diff --git a/sys/miniMVC.php b/sys/miniMVC.php index 6c4b301..c9e55fa 100644 --- a/sys/miniMVC.php +++ b/sys/miniMVC.php @@ -199,7 +199,7 @@ class miniMVC extends JSObject{ * * @return miniMVC object */ - public static function get_instance() + public static function &get_instance() { if( ! isset(self::$count)) { @@ -306,66 +306,14 @@ class miniMVC extends JSObject{ */ class MM_Controller extends miniMVC { + public $output, $page; + function __construct() { parent::__construct(); - $this->output = new Output; - $this->page = new Page; - } - - /** - * Function for loading a view - * - * @param string $file - * @param array $data - * @return mixed - */ - function load_view($file, $data, $return=FALSE) - { - $path = ""; - - // The module is the lower of the class name - // need to figure out a way to allow multiple controllers - // in one module - $module = strtolower(get_class($this)); - - $not_modules = array('miniMVC', 'page', 'db', 'output'); - - // If it's a module, look in the module view folder - if( ! in_array($module, $not_modules)) - { - $path = 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 = APP_PATH . "views/{$file}.php"; - } - - // Contain the content for buffering - ob_start(); - - // Extract the data array - extract($data); - - // Include the file - include($path); - - $buffer = ob_get_contents(); - ob_end_clean(); - - if($return == TRUE) - { - return $buffer; - } - else - { - $this->output->append_output($buffer); - } - + $this->output = new Output(); + $this->page = new Page(); } /** diff --git a/sys/output.php b/sys/output.php index 7bd679a..7b9c51c 100644 --- a/sys/output.php +++ b/sys/output.php @@ -15,16 +15,16 @@ /** * Class for displaying output and setting http headers * - * @extends miniMVC + * @extends JSObject */ -class Output extends miniMVC { +class Output extends JSObject{ private $buffer, $headers; function __construct() { // Compression is good! - ob_start("ob_gzhandler"); + //ob_start("ob_gzhandler"); $this->buffer = ""; $this->headers = array(); @@ -56,7 +56,7 @@ class Output extends miniMVC { if( ! empty($this->buffer)) { echo $this->buffer; - ob_end_flush(); + //ob_end_flush(); } } diff --git a/sys/page.php b/sys/page.php index 4dc09a2..41316a1 100644 --- a/sys/page.php +++ b/sys/page.php @@ -34,7 +34,8 @@ class Page $this->body_id = ""; $this->base = ""; - $this->mm = miniMVC::get_instance(); + $mm =& miniMVC::get_instance(); + $this->output =& $mm->output; } // -------------------------------------------------------------------------- @@ -52,7 +53,7 @@ class Page */ private function _headers($xhtml, $html5) { - $this->mm->output->set_header("Cache-Control", "must-revalidate, public"); + $this->output->set_header("Cache-Control", "must-revalidate, public"); $mime = ""; //Variable for accept keyword @@ -120,9 +121,9 @@ class Page } // finally, output the mime type and prolog type - $this->mm->output->set_header("Content-Type", "{$mime};charset={$charset}"); - $this->mm->output->set_header("X-UA-Compatible", "chrome=1, IE=edge"); - $this->mm->output->set_output($doctype_string); + $this->output->set_header("Content-Type", "{$mime};charset={$charset}"); + $this->output->set_header("X-UA-Compatible", "chrome=1, IE=edge"); + $this->output->set_output($doctype_string); return $this; } @@ -351,7 +352,7 @@ class Page $this->_headers($xhtml, $html5); //Output Header - $this->mm->load_view('header', $data); + $this->load_view('header', $data); return $this; } @@ -368,7 +369,7 @@ class Page $data['foot_js'] = ($this->foot_js != "") ? $this->foot_js : ''; - $this->mm->load_view('footer', $data); + $this->load_view('footer', $data); } // -------------------------------------------------------------------------- @@ -410,7 +411,7 @@ class Page $data['stat_class'] = $type; $data['message'] = $message; - return $this->mm->load_view('message', $data, $return); + return $this->load_view('message', $data, $return); } // -------------------------------------------------------------------------- @@ -423,8 +424,8 @@ class Page */ function redirect_303($url) { - $this->mm->output->set_header("HTTP/1.1 303 See Other"); - $this->mm->output->set_header("Location:" . $url); + $this->output->set_header("HTTP/1.1 303 See Other"); + $this->output->set_header("Location:" . $url); } // -------------------------------------------------------------------------- @@ -439,7 +440,7 @@ class Page function render($view, $data=array()) { $this->build_header(); - $this->mm->load_view($view, $data); + $this->load_view($view, $data); $this->build_footer(); } @@ -456,7 +457,7 @@ class Page function output_string($string) { $this->build_header(); - $this->mm->output->append_output($string); + $this->output->append_output($string); $this->build_footer(); } @@ -501,6 +502,60 @@ class Page return $string; } + + /** + * Function for loading a view + * + * @param string $file + * @param array $data + * @return mixed + */ + function load_view($file, $data, $return=FALSE) + { + $path = ""; + + // The module is the lower of the class name + // need to figure out a way to allow multiple controllers + // in one module + $module = strtolower(get_class($this)); + + $not_modules = array('miniMVC', 'page', 'db', 'output'); + + // If it's a module, look in the module view folder + if( ! in_array($module, $not_modules)) + { + $path = 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 = APP_PATH . "views/{$file}.php"; + } + + // Contain the content for buffering + ob_start(); + + // Extract the data array + extract($data); + + // Include the file + include($path); + + $buffer = ob_get_contents(); + ob_end_clean(); + + if($return == TRUE) + { + return $buffer; + } + else + { + $this->output->append_output($buffer); + } + + } } // End of page.php \ No newline at end of file