diff --git a/app/config/config.php b/app/config/config.php index b63da9f..2fef449 100644 --- a/app/config/config.php +++ b/app/config/config.php @@ -130,4 +130,6 @@ define('DEFAULT_CSS_GROUP', "css"); | Default js group | */ -define('DEFAULT_JS_GROUP', "js"); \ No newline at end of file +define('DEFAULT_JS_GROUP', "js"); + +// End of config.php \ No newline at end of file diff --git a/app/config/db.php b/app/config/db.php index 4d19c37..1ce4d05 100644 --- a/app/config/db.php +++ b/app/config/db.php @@ -32,4 +32,6 @@ $db_conf = [ 'database' => '', 'file' => '', ] -]; \ No newline at end of file +]; + +// End of db.php \ No newline at end of file diff --git a/app/config/routes.php b/app/config/routes.php index 7dd7001..cc6124e 100644 --- a/app/config/routes.php +++ b/app/config/routes.php @@ -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' => '', -]; \ No newline at end of file +]; + +// End of routes.php \ No newline at end of file diff --git a/app/modules/welcome/controllers/welcome.php b/app/modules/welcome/controllers/welcome.php index 27756ff..699f6ba 100644 --- a/app/modules/welcome/controllers/welcome.php +++ b/app/modules/welcome/controllers/welcome.php @@ -55,4 +55,5 @@ class Welcome extends MM_Controller { $this->page->set_output($output); } } + // End of welcome.php \ No newline at end of file diff --git a/app/modules/welcome/models/welcome_model.php b/app/modules/welcome/models/welcome_model.php index 0743e38..9c42f81 100644 --- a/app/modules/welcome/models/welcome_model.php +++ b/app/modules/welcome/models/welcome_model.php @@ -27,4 +27,6 @@ class Welcome_Model extends MM_Model{ { parent::__construct(); } -} \ No newline at end of file +} + +// End of welcome_model.php \ No newline at end of file diff --git a/assets/css.php b/assets/css.php index f66a381..5a7a7e0 100755 --- a/assets/css.php +++ b/assets/css.php @@ -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(); diff --git a/assets/js.php b/assets/js.php index 2e0d61a..3c95be6 100755 --- a/assets/js.php +++ b/assets/js.php @@ -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 \ No newline at end of file diff --git a/sys/common.php b/sys/common.php index 206d77c..dd1390d 100644 --- a/sys/common.php +++ b/sys/common.php @@ -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); diff --git a/sys/core/MM.php b/sys/core/MM.php index 16fa685..1fe2dc0 100644 --- a/sys/core/MM.php +++ b/sys/core/MM.php @@ -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); diff --git a/sys/core/db.php b/sys/core/db.php index 03e34e2..a28be40 100644 --- a/sys/core/db.php +++ b/sys/core/db.php @@ -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); - } - // -------------------------------------------------------------------------- /** diff --git a/sys/core/output.php b/sys/core/output.php index f4e1a46..7762f59 100644 --- a/sys/core/output.php +++ b/sys/core/output.php @@ -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)) { diff --git a/sys/core/page.php b/sys/core/page.php index da65d7f..8bd5fef 100644 --- a/sys/core/page.php +++ b/sys/core/page.php @@ -420,7 +420,9 @@ class MM_Page extends MM_Output { $js_file = "{$path}/js/{$js}.js"; if ($domain == FALSE) + { $js_file = $js; + } $tag = ''; @@ -505,7 +507,7 @@ class MM_Page extends MM_Output { { $string = " &$v) + foreach ($params as $k => &$v) { $string .= $k.'="'.$v.'" '; } @@ -527,7 +529,7 @@ class MM_Page extends MM_Output { { $string = " &$v) + foreach ($params as $k => &$v) { $string .= $k . '="'.$v.'" '; } diff --git a/sys/core/traits.php b/sys/core/traits.php index ed5be53..20b4fa1 100644 --- a/sys/core/traits.php +++ b/sys/core/traits.php @@ -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 = '
';
+			
+			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 . '
'; + } + 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 = '
';
-			
-			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 . '
'; - } - else - { - return ''; - } - } - + // -------------------------------------------------------------------------- /** @@ -130,6 +143,8 @@ trait JSObject { */ trait Singleton { + use Generic; + /** * Singleton object *