Code style consistency improvements

This commit is contained in:
Timothy Warren 2012-05-18 13:52:12 -04:00
parent 134d1091a9
commit 8e97f37fe0
13 changed files with 96 additions and 96 deletions

View File

@ -130,4 +130,6 @@ define('DEFAULT_CSS_GROUP', "css");
| Default js group
|
*/
define('DEFAULT_JS_GROUP', "js");
define('DEFAULT_JS_GROUP', "js");
// End of config.php

View File

@ -32,4 +32,6 @@ $db_conf = [
'database' => '',
'file' => '',
]
];
];
// End of db.php

View File

@ -18,7 +18,7 @@
*
* Routes work on simple/regex matching.
*
* For a route mapping [http://example.com/]blog to the blog controller in the blog module:
* For a route mapping http://example.com/blog to the blog controller in the blog module:
* 'blog' => 'blog/blog/index'
*
* To route a special 404 page, set '404_route' to the "module/controller/method" you wish to use
@ -34,4 +34,6 @@ return [
'default_controller' => 'welcome',
'default_module' => 'welcome',
'404_route' => '',
];
];
// End of routes.php

View File

@ -55,4 +55,5 @@ class Welcome extends MM_Controller {
$this->page->set_output($output);
}
}
// End of welcome.php

View File

@ -27,4 +27,6 @@ class Welcome_Model extends MM_Model{
{
parent::__construct();
}
}
}
// End of welcome_model.php

View File

@ -88,7 +88,7 @@ $modified = [];
if (isset($groups[$_GET['g']]))
{
foreach($groups[$_GET['g']] as &$file)
foreach ($groups[$_GET['g']] as &$file)
{
$new_file = $css_root.$file;
$css .= file_get_contents($new_file);
@ -103,7 +103,7 @@ $modified[] = filemtime($this_file);
rsort($modified);
$last_modified = $modified[0];
$requested_time=(isset($_SERVER['HTTP_IF_MODIFIED_SINCE']))
$requested_time= (isset($_SERVER['HTTP_IF_MODIFIED_SINCE']))
? strtotime($_SERVER['HTTP_IF_MODIFIED_SINCE'])
: time();

View File

@ -45,7 +45,7 @@ function get_files()
$js = '';
foreach($groups[$_GET['g']] as &$file)
foreach ($groups[$_GET['g']] as &$file)
{
$new_file = realpath($js_root.$file);
$js .= file_get_contents($new_file);
@ -84,7 +84,7 @@ $pia = explode('/', $pi);
$pia_len = count($pia);
$i = 1;
while($i < $pia_len)
while ($i < $pia_len)
{
$j = $i+1;
$j = (isset($pia[$j])) ? $j : $i;
@ -104,7 +104,7 @@ if (isset($groups[$_GET['g']]))
{
$cache_file = $js_root.'cache/'.$_GET['g'];
foreach($groups[$_GET['g']] as &$file)
foreach ($groups[$_GET['g']] as &$file)
{
$new_file = realpath($js_root.$file);
$modified[] = filemtime($new_file);
@ -159,7 +159,7 @@ if ($cache_modified < $last_modified)
die("Cache file was not created. Make sure you have the correct folder permissions.");
}
}
else if (isset($_GET['debug']))
elseif (isset($_GET['debug']))
{
$js = get_files();
}
@ -184,4 +184,5 @@ header("Expires: ".gmdate('D, d M Y H:i:s', (filemtime($this_file) + 691200))."
echo $js;
ob_end_flush();
//end of js.php

View File

@ -213,7 +213,7 @@ function to_string($data, $method='print_r')
$output .= ob_get_contents();
ob_end_clean();
}
else if ($method == "var_export")
elseif ($method == "var_export")
{
ob_start();
var_export($data);

View File

@ -33,7 +33,7 @@ class MM extends ArrayObject {
parent::__construct($members);
// Add the passed parameters to the object
foreach($members as $name => &$value)
foreach ($members as $name => &$value)
{
$this->$name = $value;
}
@ -59,7 +59,7 @@ class MM extends ArrayObject {
}
// Allow dynamic method calls
if(is_callable($this->$name))
if (is_callable($this->$name))
{
//Call the dynamic function
return call_user_func_array($this->$name, $params);

View File

@ -21,7 +21,7 @@
*/
class DB extends Query_Builder {
use JSObject;
use Generic;
/**
* DB connection instances
@ -60,33 +60,6 @@ class DB extends Query_Builder {
return self::$instance[$dbname];
}
// --------------------------------------------------------------------------
/**
* Constructor to override JSObject trait
*
* @param array $params
*/
public function __construct(array $params=[])
{
// Let's try connecting now!
parent::__construct($params);
}
// --------------------------------------------------------------------------
/**
* Override __call in trait to call __call in Query Builder...lol
*
* @param string $name
* @param array $params
* @return mixed
*/
public function __call($name, $params=[])
{
return parent::__call($name, $params);
}
// --------------------------------------------------------------------------
/**

View File

@ -131,7 +131,7 @@ class MM_Output extends MM {
public function flush_headers()
{
// Set headers
foreach($this->headers as $key => &$val)
foreach ($this->headers as $key => &$val)
{
if ( ! isset($val))
{

View File

@ -420,7 +420,9 @@ class MM_Page extends MM_Output {
$js_file = "{$path}/js/{$js}.js";
if ($domain == FALSE)
{
$js_file = $js;
}
$tag = '<script src="' . $js_file . '"></script>';
@ -505,7 +507,7 @@ class MM_Page extends MM_Output {
{
$string = "<meta ";
foreach($params as $k => &$v)
foreach ($params as $k => &$v)
{
$string .= $k.'="'.$v.'" ';
}
@ -527,7 +529,7 @@ class MM_Page extends MM_Output {
{
$string = "<link ";
foreach($params as $k => &$v)
foreach ($params as $k => &$v)
{
$string .= $k . '="'.$v.'" ';
}

View File

@ -11,6 +11,66 @@
* @license http://philsturgeon.co.uk/code/dbad-license
*/
// --------------------------------------------------------------------------
// ! Generic Trait
// --------------------------------------------------------------------------
/**
* Simple Trait to include the toString() magic method
*
* @package miniMVC
* @subpackage System
*/
trait Generic {
/**
* Prints out the contents of the object when used as a string
*
* @return string
*/
public function __toString()
{
if (ENVIRONMENT == 'DEVELOPMENT')
{
$args = func_get_args();
$method = ( ! empty($args)) ? $args[0] : "print_r";
$data = (isset($args[1])) ? $args[1] : [];
if (empty($data))
{
$data =& $this;
}
$output = '<pre>';
if ($method == "var_dump")
{
ob_start();
var_dump($data);
$output .= ob_get_contents();
ob_end_clean();
}
elseif ($method == "var_export")
{
ob_start();
var_export($data);
$output .= ob_get_contents();
ob_end_clean();
}
else
{
$output .= print_r($data, TRUE);
}
return $output . '</pre>';
}
else
{
return '';
}
}
}
// --------------------------------------------------------------------------
// ! JSObject Trait
// --------------------------------------------------------------------------
@ -23,6 +83,8 @@
*/
trait JSObject {
use Generic;
/**
* Constructor for creating the objects
*
@ -48,62 +110,13 @@ trait JSObject {
*/
public function __call($name, $params = [])
{
if(is_callable($this->$name))
if (is_callable($this->$name))
{
//Call the dynamic function
return call_user_func_array($this->$name, $params);
}
}
// --------------------------------------------------------------------------
/**
* Prints out the contents of the object when used as a string
*
* @return string
*/
public function __toString()
{
if(ENVIRONMENT == 'DEVELOPMENT')
{
$args = func_get_args();
$method = ( ! empty($args)) ? $args[0] : "print_r";
$data = (isset($args[1])) ? $args[1] : [];
if(empty($data))
{
$data =& $this;
}
$output = '<pre>';
if($method == "var_dump")
{
ob_start();
var_dump($data);
$output .= ob_get_contents();
ob_end_clean();
}
else if($method == "var_export")
{
ob_start();
var_export($data);
$output .= ob_get_contents();
ob_end_clean();
}
else
{
$output .= print_r($data, TRUE);
}
return $output . '</pre>';
}
else
{
return '';
}
}
// --------------------------------------------------------------------------
/**
@ -130,6 +143,8 @@ trait JSObject {
*/
trait Singleton {
use Generic;
/**
* Singleton object
*