2011-12-27 13:24:28 -05:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Base class for the framework
|
|
|
|
*/
|
|
|
|
class miniMVC extends JSObject {
|
|
|
|
|
2011-12-27 16:47:27 -05:00
|
|
|
protected $buffer;
|
|
|
|
protected $headers;
|
|
|
|
|
2011-12-27 13:24:28 -05:00
|
|
|
function __construct()
|
|
|
|
{
|
|
|
|
$this->buffer = "";
|
|
|
|
$this->headers = array();
|
|
|
|
|
|
|
|
parent::__construct(array(
|
|
|
|
'output' => array(
|
|
|
|
'set_header' => function($key, $val)
|
|
|
|
{
|
|
|
|
$this->headers[$key] = $val;
|
|
|
|
},
|
|
|
|
'append_output' => function($string)
|
|
|
|
{
|
|
|
|
$this->buffer .= $string;
|
|
|
|
},
|
|
|
|
'set_output' => function($string)
|
|
|
|
{
|
|
|
|
$this->buffer = $string;
|
|
|
|
}
|
|
|
|
),
|
|
|
|
));
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* PHP magic method called when ending the script
|
|
|
|
* Used for outputing HTML
|
|
|
|
*/
|
|
|
|
function __destruct()
|
|
|
|
{
|
|
|
|
// Set headers
|
|
|
|
foreach($this->headers as $key => $val)
|
|
|
|
{
|
2011-12-27 16:47:27 -05:00
|
|
|
if( ! isset($val))
|
|
|
|
{
|
|
|
|
@header($key);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
@header("$key: $val");
|
|
|
|
}
|
|
|
|
|
2011-12-27 13:24:28 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* PHP magic method to facilitate dynamic class loading
|
|
|
|
*
|
|
|
|
* @param string $name
|
|
|
|
*/
|
|
|
|
function __get($name)
|
|
|
|
{
|
|
|
|
$path = SYS_PATH."{$name}.php";
|
|
|
|
$class = "MM_{$key}";
|
|
|
|
|
2011-12-27 16:47:27 -05:00
|
|
|
load_file($name, 'sys');
|
2011-12-27 13:24:28 -05:00
|
|
|
|
|
|
|
if(class_exists($class, FALSE))
|
|
|
|
{
|
|
|
|
$this->$name = new $class();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// --------------------------------------------------------------------------
|
|
|
|
|
|
|
|
class MM_Model extends miniMVC {
|
|
|
|
|
|
|
|
function __construct()
|
|
|
|
{
|
|
|
|
parent::__construct();
|
|
|
|
}
|
|
|
|
|
|
|
|
function __destruct()
|
|
|
|
{
|
|
|
|
parent::__destruct();
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
// --------------------------------------------------------------------------
|
|
|
|
|
|
|
|
class MM_Controller extends miniMVC {
|
|
|
|
|
|
|
|
function __construct()
|
|
|
|
{
|
|
|
|
parent::__construct();
|
|
|
|
}
|
|
|
|
|
|
|
|
function __destruct()
|
|
|
|
{
|
|
|
|
parent::__destruct();
|
|
|
|
}
|
|
|
|
}
|