diff --git a/README.md b/README.md index d4e49e6..2182076 100644 --- a/README.md +++ b/README.md @@ -3,26 +3,16 @@ miniMVC is a minimalistic Modular MVC framework, with built-in minifier, and pure-PHP templating system. ### Requirements -* PHP 5.4+ +* PHP 5.3+ * PDO extensions for databases you wish to use -* Webserver that correctly handles REQUEST_URI, such as: +* Webserver that correctly handles PATH_INFO, such as: * Apache * IIS * Lighttpd + * Resin/Quercus * SimpleTest library for running unit tests ### Unique features -#### Extensive use of PHP's magic methods on the base class -* `__toString()` method allows a view of the current class object when the current class object is used as a string. If you prefer `var_dump()` or `var_export()`, you can pass the name of that function if you call the `__toString` method directly. - - Eg. `$this . "string"`, `$this->__toString()`, `echo $this`; - -* `__call()` method allows the dynamic addition of callable closure objects - - Eg. `$this->foo = function($baz){}` is callable as `$this->foo()`, with the current object as the last argument - -* `MM` class extends ArrayObject, and all the main classes extend this class. Functions begining with `array_` are callable on object from this class. E.g. `$this->array_keys()` will return a list of the class properties. - #### Database class is an extension of PHP's PDO class. Database class uses [Query](https://github.com/aviat4ion/Query) as a database abstraction layer and query builder. diff --git a/app/config/db.php b/app/config/db.php index 299c1e2..751b9ad 100644 --- a/app/config/db.php +++ b/app/config/db.php @@ -22,16 +22,16 @@ // -------------------------------------------------------------------------- -$db_conf = [ - 'default' => [ +$db_conf = array( + 'default' => array( 'type' => '', 'host' => '', 'user' => '', 'pass' => '', - 'port' => '' + 'port' => '', 'database' => '', 'file' => '', - ] -]; + ) +); // End of db.php \ No newline at end of file diff --git a/app/config/routes.php b/app/config/routes.php index 72c8ed3..efe86dd 100644 --- a/app/config/routes.php +++ b/app/config/routes.php @@ -29,11 +29,11 @@ // -------------------------------------------------------------------------- -return [ +return array( // Default Paths 'default_controller' => 'welcome', 'default_module' => 'welcome', '404_route' => '', -]; +); // End of routes.php \ No newline at end of file diff --git a/assets/config/css_groups.php b/assets/config/css_groups.php old mode 100755 new mode 100644 index 1899765..e2cc3b8 --- a/assets/config/css_groups.php +++ b/assets/config/css_groups.php @@ -16,13 +16,13 @@ /** * This is the config array for css files to concatenate and minify */ -return [ +return array( /*----- Css -----*/ - 'css' => [ + 'css' => array( 'message.css' - ], + ), /* For each group create an array like so @@ -32,5 +32,5 @@ return [ 'path/to/css/file2.css' ], */ -]; +); // End of css_groups.php \ No newline at end of file diff --git a/assets/css.php b/assets/css.php old mode 100755 new mode 100644 index a44f76a..ff017e7 --- a/assets/css.php +++ b/assets/css.php @@ -44,7 +44,7 @@ function compress($buffer) { //Remove tabs, spaces, newlines, etc. $buffer = preg_replace('`\s+`', ' ', $buffer); - $replace = [ + $replace = array( ' )' => ')', ') ' => ')', ' }' => '}', @@ -54,7 +54,7 @@ function compress($buffer) { ', ' => ',', ': ' => ':', '; ' => ';', - ]; + ); //Eradicate every last space! $buffer = trim(strtr($buffer, $replace)); @@ -84,7 +84,7 @@ while($i < $pia_len) }; $css = ''; -$modified = []; +$modified = array(); if (isset($groups[$_GET['g']])) { diff --git a/docs/classes.svg b/docs/classes.svg index 0e13a25..7e223d1 100644 --- a/docs/classes.svg +++ b/docs/classes.svg @@ -4,371 +4,332 @@ - - + + G - + cluster_default - - - - - - - - + + + + + + + + cluster_miniMVC - - - - - - - - -miniMVC + + + + + + + + +miniMVC \\DB_SQL - -«abstract» -DB_SQL + +«abstract» +DB_SQL \\DB_PDO - -«abstract» -DB_PDO + +«abstract» +DB_PDO -\\PDO - -\PDO +\\PDO + +\PDO \\DB_PDO->\\PDO - - + + \\Query_Builder - -Query_Builder + +Query_Builder \\DB_Util - -«abstract» -DB_Util + +«abstract» +DB_Util \\PgSQL_SQL - -PgSQL_SQL + +PgSQL_SQL \\PgSQL_SQL->\\DB_SQL - - + + \\PgSQL_Util - -PgSQL_Util + +PgSQL_Util \\PgSQL_Util->\\DB_Util - - + + \\PgSQL - -PgSQL + +PgSQL \\PgSQL->\\DB_PDO - - + + \\ODBC_Util - -ODBC_Util + +ODBC_Util \\ODBC_Util->\\DB_Util - - + + \\ODBC_SQL - -ODBC_SQL + +ODBC_SQL \\ODBC_SQL->\\DB_SQL - - + + \\ODBC - -ODBC + +ODBC \\ODBC->\\DB_PDO - - + + \\MySQL_Util - -MySQL_Util + +MySQL_Util \\MySQL_Util->\\DB_Util - - + + \\MySQL - -MySQL + +MySQL \\MySQL->\\DB_PDO - - + + \\MySQL_SQL - -MySQL_SQL + +MySQL_SQL \\MySQL_SQL->\\DB_SQL - - + + \\SQLite_Util - -SQLite_Util + +SQLite_Util \\SQLite_Util->\\DB_Util - - + + \\SQLite - -SQLite + +SQLite \\SQLite->\\DB_PDO - - + + \\SQLite_SQL - -SQLite_SQL + +SQLite_SQL \\SQLite_SQL->\\DB_SQL - - + + \\Firebird_SQL - -Firebird_SQL + +Firebird_SQL \\Firebird_SQL->\\DB_SQL - - + + \\Firebird_Result - -Firebird_Result + +Firebird_Result -\\PDOStatement - -\PDOStatement +\\PDOStatement + +\PDOStatement \\Firebird_Result->\\PDOStatement - - + + \\Firebird - -Firebird + +Firebird \\Firebird->\\DB_PDO - - + + \\Firebird_Util - -Firebird_Util + +Firebird_Util \\Firebird_Util->\\DB_Util - - + + + + +\\Bcrypt + + +Bcrypt + -\\miniMVC\\Page +\\miniMVC\\Page - -Page + +Page - -\\miniMVC\\Output - - -Output - - - -\\miniMVC\\Page->\\miniMVC\\Output - - - -\\miniMVC\\Model +\\miniMVC\\Model - -Model + +Model - -\\miniMVC\\miniMVC - - -miniMVC - + +\\ArrayObject + +\ArrayObject - -\\miniMVC\\Model->\\miniMVC\\miniMVC - - + +\\miniMVC\\Model->\\ArrayObject + + -\\miniMVC\\Controller +\\miniMVC\\Controller - -Controller + +Controller - -\\miniMVC\\Controller->\\miniMVC\\miniMVC - - - -\\miniMVC\\DB +\\miniMVC\\DB - -DB + +DB -\\miniMVC\\DB->\\Query_Builder - - - - -\\miniMVC\\MM - - -MM - - - -\\miniMVC\\miniMVC->\\miniMVC\\MM - - - - -\\ArrayObject - -\ArrayObject - - -\\miniMVC\\MM->\\ArrayObject - - - - -\\miniMVC\\Output->\\miniMVC\\MM - - +\\miniMVC\\DB->\\Query_Builder + + -\\miniMVC\\Session +\\miniMVC\\Session - -Session + +Session -\\miniMVC\\Data_Store +\\miniMVC\\Data_Store - -Data_Store + +Data_Store diff --git a/docs/classes/Bcrypt.html b/docs/classes/Bcrypt.html new file mode 100644 index 0000000..1666afb --- /dev/null +++ b/docs/classes/Bcrypt.html @@ -0,0 +1,203 @@ + + + + + +miniMVC » \Bcrypt + + + + + + + + + + +
+ +
+ +
+
+

Class to simplify dealing with bcrypt for password handling

+
+

+ + + + + + + + + + + + + +
see
packageminiMVC
subpackagelibraries
+

+ Methods

+
+

Create a new Bcrypt object

+
__construct(int $rounds) 
+
+
+

+

Parameters

+
+

$rounds

+int +
+
+
+
+

Returns a has for the input string

+
hash($input) : string
+
+
+

+

Parameters

+
+

$input

+

string

+

Returns

+
string
+
+
+
+

Check if a password hash is valid

+
verify($input, $existingHash) : bool
+
+
+

+

Parameters

+
+

$input

+

string

+
+

$existingHash

+

string

+

Returns

+
bool
+
+
+
+

Further randomizes salt?

+
encodeBytes($input) : string
+
+
+

+

Parameters

+
+

$input

+

string

+

Returns

+
string
+
+
+
+

Private method to generate random characters for salt

+
getRandomBytes($count) : string
+
+
+

+

Parameters

+
+

$count

+

int

+

Returns

+
string
+
+
+
+

Private function to generate the random salt

+
getSalt() : string
+
+
+

+

Returns

+
string
+
+
+

+ Properties

+ 
+

Stores random seed

+
$randomState : mixed
+
+

+
+ 
+

Number of times to recurse

+
$rounds : int
+
+

+
+
+
+
+
+
+
+ + diff --git a/docs/classes/DB_PDO.html b/docs/classes/DB_PDO.html index 3b29168..4c2e247 100644 --- a/docs/classes/DB_PDO.html +++ b/docs/classes/DB_PDO.html @@ -708,7 +708,7 @@ the connection/database
+ generated on 2012-07-03T13:29:41-04:00.
diff --git a/docs/classes/DB_SQL.html b/docs/classes/DB_SQL.html index a32d3aa..8f46b63 100644 --- a/docs/classes/DB_SQL.html +++ b/docs/classes/DB_SQL.html @@ -300,7 +300,7 @@ specified table
+ generated on 2012-07-03T13:29:41-04:00.
diff --git a/docs/classes/DB_Util.html b/docs/classes/DB_Util.html index df27ad8..36e5e25 100644 --- a/docs/classes/DB_Util.html +++ b/docs/classes/DB_Util.html @@ -211,7 +211,7 @@
+ generated on 2012-07-03T13:29:42-04:00.
diff --git a/docs/classes/Firebird.html b/docs/classes/Firebird.html index d318a4b..d5d5d51 100644 --- a/docs/classes/Firebird.html +++ b/docs/classes/Firebird.html @@ -870,7 +870,7 @@ the last query executed
+ generated on 2012-07-03T13:29:42-04:00.
diff --git a/docs/classes/Firebird_Result.html b/docs/classes/Firebird_Result.html index 217d472..73632f2 100644 --- a/docs/classes/Firebird_Result.html +++ b/docs/classes/Firebird_Result.html @@ -506,7 +506,7 @@ the query
+ generated on 2012-07-03T13:29:42-04:00.
diff --git a/docs/classes/Firebird_SQL.html b/docs/classes/Firebird_SQL.html index 6e57232..53413ba 100644 --- a/docs/classes/Firebird_SQL.html +++ b/docs/classes/Firebird_SQL.html @@ -310,7 +310,7 @@
+ generated on 2012-07-03T13:29:42-04:00.
diff --git a/docs/classes/Firebird_Util.html b/docs/classes/Firebird_Util.html index b8fe435..67119a4 100644 --- a/docs/classes/Firebird_Util.html +++ b/docs/classes/Firebird_Util.html @@ -214,7 +214,7 @@
+ generated on 2012-07-03T13:29:42-04:00.
diff --git a/docs/classes/MySQL.html b/docs/classes/MySQL.html index 9ec1231..c96ea22 100644 --- a/docs/classes/MySQL.html +++ b/docs/classes/MySQL.html @@ -906,7 +906,7 @@ the connection/database
+ generated on 2012-07-03T13:29:42-04:00.
diff --git a/docs/classes/MySQL_SQL.html b/docs/classes/MySQL_SQL.html index 8f2b1f5..11f6dcb 100644 --- a/docs/classes/MySQL_SQL.html +++ b/docs/classes/MySQL_SQL.html @@ -315,7 +315,7 @@
+ generated on 2012-07-03T13:29:42-04:00.
diff --git a/docs/classes/MySQL_Util.html b/docs/classes/MySQL_Util.html index b414dc1..862f1bd 100644 --- a/docs/classes/MySQL_Util.html +++ b/docs/classes/MySQL_Util.html @@ -210,7 +210,7 @@
+ generated on 2012-07-03T13:29:42-04:00.
diff --git a/docs/classes/ODBC.html b/docs/classes/ODBC.html index a4b6815..6a0162f 100644 --- a/docs/classes/ODBC.html +++ b/docs/classes/ODBC.html @@ -908,7 +908,7 @@ the connection/database
+ generated on 2012-07-03T13:29:42-04:00.
diff --git a/docs/classes/ODBC_SQL.html b/docs/classes/ODBC_SQL.html index ea477fe..69f8254 100644 --- a/docs/classes/ODBC_SQL.html +++ b/docs/classes/ODBC_SQL.html @@ -310,7 +310,7 @@
+ generated on 2012-07-03T13:29:42-04:00.
diff --git a/docs/classes/ODBC_Util.html b/docs/classes/ODBC_Util.html index e34830b..5536f11 100644 --- a/docs/classes/ODBC_Util.html +++ b/docs/classes/ODBC_Util.html @@ -205,7 +205,7 @@
+ generated on 2012-07-03T13:29:42-04:00.
diff --git a/docs/classes/PgSQL.html b/docs/classes/PgSQL.html index f862d96..ca78673 100644 --- a/docs/classes/PgSQL.html +++ b/docs/classes/PgSQL.html @@ -908,7 +908,7 @@ the connection/database
+ generated on 2012-07-03T13:29:42-04:00.
diff --git a/docs/classes/PgSQL_SQL.html b/docs/classes/PgSQL_SQL.html index 10e1caf..d607295 100644 --- a/docs/classes/PgSQL_SQL.html +++ b/docs/classes/PgSQL_SQL.html @@ -310,7 +310,7 @@
+ generated on 2012-07-03T13:29:42-04:00.
diff --git a/docs/classes/PgSQL_Util.html b/docs/classes/PgSQL_Util.html index 35533a8..71dc0dc 100644 --- a/docs/classes/PgSQL_Util.html +++ b/docs/classes/PgSQL_Util.html @@ -210,7 +210,7 @@
+ generated on 2012-07-03T13:29:42-04:00.
diff --git a/docs/classes/Query_Builder.html b/docs/classes/Query_Builder.html index 9a49294..30e1d18 100644 --- a/docs/classes/Query_Builder.html +++ b/docs/classes/Query_Builder.html @@ -1224,7 +1224,7 @@ for complex select queries
+ generated on 2012-07-03T13:29:41-04:00.
diff --git a/docs/classes/SQLite.html b/docs/classes/SQLite.html index 87f7092..3b92eb3 100644 --- a/docs/classes/SQLite.html +++ b/docs/classes/SQLite.html @@ -923,7 +923,7 @@ method if the database does not support 'TRUNCATE';
+ generated on 2012-07-03T13:29:42-04:00.
diff --git a/docs/classes/SQLite_SQL.html b/docs/classes/SQLite_SQL.html index 7ab05df..12310d5 100644 --- a/docs/classes/SQLite_SQL.html +++ b/docs/classes/SQLite_SQL.html @@ -310,7 +310,7 @@
+ generated on 2012-07-03T13:29:42-04:00.
diff --git a/docs/classes/SQLite_Util.html b/docs/classes/SQLite_Util.html index 6443714..e239c08 100644 --- a/docs/classes/SQLite_Util.html +++ b/docs/classes/SQLite_Util.html @@ -210,7 +210,7 @@
+ generated on 2012-07-03T13:29:42-04:00.
diff --git a/docs/classes/miniMVC.Controller.html b/docs/classes/miniMVC.Controller.html index fac7a80..58e2827 100644 --- a/docs/classes/miniMVC.Controller.html +++ b/docs/classes/miniMVC.Controller.html @@ -59,56 +59,9 @@
@@ -98,13 +95,6 @@
« More »
-
-

MM -

-

Class for standalone JSObject objects

-
-« More » -

Model

@@ -112,13 +102,6 @@
« More »
-
-

Output -

-

Class for displaying output and setting http headers

-
-« More » -

Page

@@ -126,20 +109,13 @@
« More »
-
-

miniMVC -

-

Base class for the framework

-
-« More » -
+ generated on 2012-07-03T13:29:41-04:00.
diff --git a/docs/packages/miniMVC.html b/docs/packages/miniMVC.html index 978dae7..a10c178 100644 --- a/docs/packages/miniMVC.html +++ b/docs/packages/miniMVC.html @@ -67,26 +67,24 @@
  • System
  • +
  • +libraries +
  • -
  • PHP magic method to facilitate dynamic methods
    __call
  • -
  • Magic function called when cloning an object
    __clone
  • -
  • Protected constructor for creating the one instance
    __construct
  • -
  • Constructor for creating the objects
    __construct
  • -
  • PHP magic method that is called when an object is treated as a function
    __invoke
  • -
  • PHP magic method that is called when an object is treated as a function
    __invoke
  • -
  • Prints out the contents of the object when used as a string
    __toString
  • Function to autoload system libraries
    _autoload
  • Returns routable methods for the specified controller class
    controller_methods
  • Array_map callback to load a folder of classes at once
    do_include
  • -
  • Singleton getter function
    get_instance
  • +
  • Returns the last segment of the current url
    get_last_segment
  • +
  • Gets an array of the segments of the current url
    get_segments
  • Load required classes for bootstraping
    init
  • Utility function to check if a variable is set, and is an array or object
    is_like_array
  • Custom error handler
    on_error
  • Custom exception handlererror_get_last
    on_exception
  • Calls the appropriate module/controller/function based on the url
    route
  • +
  • Instantiate the appropriate controller
    run
  • General 404 function
    show_404
  • Fatal Error page function
    show_error
  • Functions

    -
    -

    PHP magic method to facilitate dynamic methods

    -
    __call(string $name, array $params) 
    -
    -
    -

    -

    Parameters

    -
    -

    $name

    -string -
    -
    -

    $params

    -array -
    -
    -
    -
    -

    Magic function called when cloning an object

    -
    __clone() 
    -
    -

    -
    -
    -

    Protected constructor for creating the one instance

    -
    __construct() 
    -
    -

    -
    -
    -

    Constructor for creating the objects

    -
    __construct(array $members) : void
    -
    -
    -

    -

    Parameters

    -
    -

    $members

    -array -
    -
    -
    -
    -

    PHP magic method that is called when an object is treated as a function

    -
    __invoke(array $params) : \miniMVC\self
    -
    -
    -

    -

    Parameters

    -
    -

    $params

    -array -
    -

    Returns

    -
    \miniMVC\self
    -
    -
    -
    -

    PHP magic method that is called when an object is treated as a function

    -
    __invoke(array $args) 
    -
    -
    -

    -

    Parameters

    -
    -

    $args

    -array -
    -
    -
    -
    -

    Prints out the contents of the object when used as a string

    -
    __toString() : string
    -
    -
    -

    -

    Returns

    -
    string
    -
    -

    Function to autoload system libraries

    _autoload($name) 
    @@ -228,14 +146,24 @@ display them cleanly
    shutdown
  • -
    -

    Singleton getter function

    -
    get_instance() : \miniMVC\self
    +
    +

    Returns the last segment of the current url

    +
    get_last_segment() : string

    Returns

    -
    \miniMVC\self
    +
    string
    +
    +
    +
    +

    Gets an array of the segments of the current url

    +
    get_segments() : array
    +
    +
    +

    +

    Returns

    +
    array
    @@ -305,6 +233,27 @@ display them cleanly
    shutdown

    +
    +

    Instantiate the appropriate controller

    +
    run($module, $controller, $func, $args) 
    +
    +
    +

    +

    Parameters

    +
    +

    $module

    +

    string

    +
    +

    $controller

    +

    string

    +
    +

    $func

    +

    string

    +
    +

    $args

    +

    array

    +
    +

    General 404 function

    show_404() : void
    @@ -419,13 +368,6 @@ display them cleanly
    « More »
    -
    -

    MM -

    -

    Class for standalone JSObject objects

    -
    -« More » -

    Model

    @@ -433,13 +375,6 @@ display them cleanly
    « More »
    -
    -

    Output -

    -

    Class for displaying output and setting http headers

    -
    -« More » -

    Page

    @@ -447,12 +382,23 @@ display them cleanly
    « More »
    -
    -

    miniMVC +

    + +
    +

    + Classes and interfaces

    +
    +

    Bcrypt

    -

    Base class for the framework

    +

    Class to simplify dealing with bcrypt for password handling

    -« More » +« More »
    @@ -461,7 +407,7 @@ display them cleanly
    + generated on 2012-07-03T13:29:41-04:00.
    diff --git a/docs/packages/miniMVC.libraries.html b/docs/packages/miniMVC.libraries.html new file mode 100644 index 0000000..a8336db --- /dev/null +++ b/docs/packages/miniMVC.libraries.html @@ -0,0 +1,97 @@ + + + + + +miniMVC » miniMVC\libraries + + + + + + + + + + +
    + +
    +
    +
    + +
    + +
    +
    + +
    +

    + Classes and interfaces

    +
    +

    Bcrypt +

    +

    Class to simplify dealing with bcrypt for password handling

    +
    +« More » +
    +
    +
    +
    +
    +
    + + diff --git a/docs/structure.xml b/docs/structure.xml index 7006fd2..03e833e 100644 --- a/docs/structure.xml +++ b/docs/structure.xml @@ -5132,7 +5132,7 @@ the last query executed]]> - + Convention-based micro-framework for PHP

    ]]>
    @@ -5145,7 +5145,7 @@ the last query executed]]> Page \miniMVC\Page - \miniMVC\Output + All methods are chainable, with the exception of the constructor, @@ -5252,462 +5252,581 @@ build_header(), build_footer(), and _headers() methods.

    ]]>
    - + + $buffer + + + + + + string + + + + + $headers + + + + + + array + + + + __construct function - + - - + void - - $controller - - - - + __destruct function - - + + + + void + - + _headers function - + Also sets page mime type, based on if sent as html or xhtml, and what the target browser supports

    ]]>
    - + bool - + \miniMVC\Page
    - + $html5
    - + set_meta function - + Sets meta tags, with codeigniter native meta tag helper

    ]]>
    - + array - + \miniMVC\Page
    - + $meta
    - + set_head_js_group function - + - + string - + bool - + \miniMVC\Page - + $group - + $debug - + set_css_group function - + - + string - + \miniMVC\Page - + $group - + set_foot_js_group function - + - + string - + bool - + \miniMVC\Page - + $group - + $debug - + set_title function - + - + string - + \miniMVC\Page - + $title - + set_body_class function - + - + string - + \miniMVC\Page - + $class - + set_body_id function - + - + string - + \miniMVC\Page - + $id - + set_base function - + - + string - + \miniMVC\Page - + $href - + set_css_tag function - + - + string - + bool - + string - + \miniMVC\Page - + $name - + $domain - + $media - + set_head_tag function - + - + string - + \miniMVC\Page - + $tag - + build_header function - + - + bool - + \miniMVC\Page - + $html5 - + build_footer function - + - + script_tag function - + Helper function for making script tags

    ]]>
    - + string - + bool - + string
    - + $js - + $domain
    - + set_message function - + Adds a message to the page

    ]]>
    - + string - + string - + bool - + void
    - + $type - + $message - + $return
    - + redirect_303 function - + Shortcut function for 303 redirect

    ]]>
    - + string
    - + $url
    - + render function - + Shortcut function for building a page

    ]]>
    - + string - + array
    - + $view - + $data - +
    - + output_string function - + Similar to render(), this is a shortcut to output a string in the body of the page.

    ]]>
    - + string
    - + $string
    - + _meta function - + - + array - + string - + $params - + _link_tag function - + - + array - + string - + $params + + load_view + function + + + + + string + + + array + + + bool + + + mixed + + + + $file + + + + + $data + + array + + + $return + + + + + + set_header + function + + + + + string + + + string + + + + $key + + + + + $val + + + + + + append_output + function + + + + + string + + + + $string + + + + + + set_output + function + + + + + string + + + + $string + + + + + + flush_headers + function + + + + +
    - + Convention-based micro-framework for PHP

    ]]>
    @@ -5720,7 +5839,7 @@ page.

    ]]> Model \miniMVC\Model - \miniMVC\miniMVC + \ArrayObject @@ -5742,164 +5861,13 @@ page.

    ]]>
    $args - + array
    - - - - Convention-based micro-framework for PHP

    ]]>
    - - - - - -
    - Generic - - __construct - function - - - - - - - __invoke - function - - - - - array - - - \miniMVC\self - - - - $params - - - - - - get_instance - function - - - - - \miniMVC\self - - - - - __clone - function - - - - - -
    - - - - Convention-based micro-framework for PHP

    ]]>
    - - - - - -
    - Generic - - __construct - function - - - - - array - - - void - - - - $members - - - - - - __call - function - - - - - string - - - array - - - - $name - - - - - $params - - - - -
    - - - - Convention-based micro-framework for PHP

    ]]>
    - - - - - -
    - - __toString - function - - - - - string - - - - - __invoke - function - - - - - array - - - - $args - - - - -
    - + Convention-based micro-framework for PHP

    ]]>
    @@ -5912,7 +5880,7 @@ page.

    ]]> Controller \miniMVC\Controller - \miniMVC\miniMVC + @@ -5941,63 +5909,63 @@ page.

    ]]>
    - + load_model function - + - + string - + array - + void - + $file - + $args - + - + load_view function - + - + string - + array - + bool - + mixed - + $file - + $data - + array - + $return @@ -6005,7 +5973,7 @@ page.

    ]]>
    - + Convention-based micro-framework for PHP

    ]]>
    @@ -6025,13 +5993,13 @@ page.

    ]]>
    - + $instance - - + + - + array @@ -6059,7 +6027,7 @@ page.

    ]]> $options - + array @@ -6076,7 +6044,7 @@ page.

    ]]>
    - + Convention-based micro-framework for PHP

    ]]>
    @@ -6086,262 +6054,143 @@ page.

    ]]>
    - - miniMVC - \miniMVC\miniMVC - \miniMVC\MM - - + + Bcrypt + \Bcrypt + + + - - + + + - - __construct - function - - + + $rounds + + + - - array + + int - - $members - - - - - - unload - function - - + + + $randomState + + + - - string - - - - $name - - - - - - load_config - function - - - - - string - - - - $name - - - - - -
    - - - - Convention-based micro-framework for PHP

    ]]>
    - - - - - -
    - - MM - \miniMVC\MM - \ArrayObject - - - - - - - - __construct - function - - - - - - - $members - - - - - - __call - function - - - - - string - - - array - - + mixed - - $name - - - - - $params - - - - - -
    - - - - Convention-based micro-framework for PHP

    ]]>
    - - - - - -
    - - Output - \miniMVC\Output - \miniMVC\MM - - - - - - - - $buffer - - - - - - string - - - - $headers - - - - - - array - - - - + __construct function - - + + - - void + + int - - - __destruct - function - - - - - void - - - - - set_header - function - - - - - string - - - string - - - - $key - + + $rounds + - - $val + + + hash + function + + + + + + string + + + + $input - - append_output + + verify function - - + + - - string + + + + bool - - $string + + $input + + + + + $existingHash - - set_output + + getSalt function - - + + - + string - - $string + + + getRandomBytes + function + + + + + + string + + + + $count - - flush_headers + + encodeBytes function - - + + + + + string + + + $input + + +
    - + Convention-based micro-framework for PHP

    ]]>
    @@ -6361,82 +6210,112 @@ Used for outputing HTML]]>
    - + $sess - - + + - + array - + + $instance + + + + + + \miniMVC\Session + + + + __construct function - + - + __set function - + - + string - + mixed - + void - + $key - + $val - + __get function - + - + string - + mixed - + $key - + destroy function - + - + void + + get_instance + function + + + + + \miniMVC\self + + + + + __clone + function + + + + +
    @@ -6584,7 +6463,7 @@ of the singleton]]> - + Convention-based micro-framework for PHP

    ]]>
    @@ -6608,241 +6487,295 @@ of the singleton]]> - + shutdown function - + - + void - + on_error function - + - + int - + string - + string - + int - + \miniMVC\ErrorException - + $severity - + $message - + $filepath - + $line - + on_exception function - + - + \miniMVC\Exception - + void - + $exception - + show_404 function - + - + void - + show_error function - + - + string - + int - + $message - + $status_code - + is_like_array function - + - + mixed - + bool - + $var - + controller_methods function - + - + string - + array - + $controller - + site_url function - + - + string - + string - + $segment - + to_string function - + - + \miniMVC\object/array - + string - + string - + $data - + $method - + do_include function - + - + string - + void - + $path - + init function - + - + void - route + get_last_segment function + + + + string + + + + + get_segments + function + + + + + array + + + + + route + function + - + void + + run + function + + + + + + + + + + $module + + + + + $controller + + + + + $func + + + + + $args + + + +
    @@ -6890,6 +6823,7 @@ display them cleanly]]> + diff --git a/sys/common.php b/sys/common.php index 3669555..5e6d9c3 100644 --- a/sys/common.php +++ b/sys/common.php @@ -8,7 +8,7 @@ * @author Timothy J. Warren * @copyright Copyright (c) 2011 - 2012 * @link https://github.com/aviat4ion/miniMVC - * @license http://philsturgeon.co.uk/code/dbad-license + * @license http://philsturgeon.co.uk/code/dbad-license */ // -------------------------------------------------------------------------- @@ -21,7 +21,7 @@ */ namespace miniMVC; - + // -------------------------------------------------------------------------- // ! Autoloading // -------------------------------------------------------------------------- @@ -38,26 +38,21 @@ function _autoload($name) // strip off namespaces - they all go to the same folder $names = explode('\\', trim($name)); $name = end($names); - + // Paths to load from $sys_path = MM_SYS_PATH . "core/{$name}.php"; - $trait_path = MM_SYS_PATH . "core/traits/{$name}.php"; $lib_path = MM_SYS_PATH . "libraries/{$name}.php"; $class_path = MM_APP_PATH . "classes/{$name}.php"; - + if (is_file($sys_path)) { require_once($sys_path); } - elseif (is_file($trait_path)) - { - require_once($trait_path); - } elseif (is_file($lib_path)) { require_once($lib_path); } - + if (is_file($class_path)) { require_once($class_path); @@ -73,7 +68,7 @@ spl_autoload_register('miniMVC\_autoload'); /** * Function to run on script shutdown - * -used to catch most fatal errors, and + * -used to catch most fatal errors, and * display them cleanly * * @return void @@ -84,18 +79,18 @@ function shutdown() $error = error_get_last(); // types of errors that are fatal - $fatal = [E_ERROR, E_PARSE, E_RECOVERABLE_ERROR]; + $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 = "

    Fatal Error:

    {$error['message']}

    File: {$file}

    Line: {$error['line']}"; - + show_error($err_msg); } } @@ -128,12 +123,12 @@ 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; @@ -149,15 +144,15 @@ function on_exception($exception) function show_404() { @header('HTTP/1.1 404 Not Found', TRUE, 404); - + // Contain the content for buffering ob_start(); - + // This is passed to the error template $message = '404 Not Found'; - + include(MM_APP_PATH . '/views/errors/error_404.php'); - + $buffer = ob_get_contents(); ob_end_clean(); die($buffer); @@ -167,7 +162,7 @@ function show_404() /** * Fatal Error page function - * + * * @param string $message * @param int $status_code */ @@ -180,9 +175,9 @@ function show_error($message, $status_code=null) // Contain the content for buffering ob_start(); - + include(MM_APP_PATH . '/views/errors/error_general.php'); - + $buffer = ob_get_contents(); ob_end_clean(); die($buffer); @@ -237,14 +232,14 @@ function controller_methods($controller) */ function site_url($segment) { - return $url = BASEURL . URL_INDEX_FILE . $segment; + return $url = BASE_URL . URL_INDEX_FILE . $segment; } // -------------------------------------------------------------------------- /** * Prints out the contents of the object - * + * * @param object/array $data * @param string $method * @return string @@ -252,7 +247,7 @@ function site_url($segment) function to_string($data, $method='print_r') { $output = '
    ';
    -	
    +
     	if ($method == "var_dump")
     	{
     		ob_start();
    @@ -266,7 +261,7 @@ function to_string($data, $method='print_r')
     		var_export($data);
     		$output .= ob_get_contents();
     		ob_end_clean();
    -	}	
    +	}
     	else
     	{
     		$output .= print_r($data, TRUE);
    @@ -303,22 +298,66 @@ if ( ! function_exists('do_include'))
     function init()
     {
     	// Catch fatal errors, don't show them
    -	error_reporting((-1) & ~(E_ERROR | E_PARSE));
    -	register_shutdown_function('miniMVC\shutdown');
    -	
    +	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
     	require_once(MM_SYS_PATH . 'db/autoload.php');
    -	
    +
    +	// Load the page class
    +	$GLOBALS['page'] = new \miniMVC\Page();
    +
     	// Map to the appropriate module/controller/function
     	route();
     }
     
     // --------------------------------------------------------------------------
     
    +/**
    + * Returns the last segment of the current url
    + *
    + * @return string
    + */
    +function get_last_segment()
    +{
    +	$array = get_segments();
    +	return end($array);
    +}
    +
    +// --------------------------------------------------------------------------
    +
    +/**
    + * Gets an array of the segments of the current url
    + *
    + * @return array
    + */
    +function get_segments()
    +{
    +	$sn = $_SERVER['SCRIPT_NAME'];
    +	$ru = $_SERVER['REQUEST_URI'];
    +
    +	// Get the equivalent to path info
    +	$pi = (isset($_SERVER['PATH_INFO']))
    +		? str_replace($sn, '', $ru)
    +		: '/';
    +
    +	// Correct for being in a sub-directory
    +	if (strlen($sn) > strlen($ru))
    +	{
    +		$pi = '/';
    +	}
    +
    +	return explode('/', $pi);
    +}
    +
    +// --------------------------------------------------------------------------
    +
     /**
      * Calls the appropriate module/controller/function based on the url
      *
    @@ -326,14 +365,12 @@ function init()
      */
     function route()
     {
    -	$sn = $_SERVER['SCRIPT_NAME'];
    +
    +	// Get the path info
    +	$pi = $_SERVER['PATH_INFO'];
     	$ru = $_SERVER['REQUEST_URI'];
    -	
    -	// Get the equivalent to path info
    -	$pi = (isset($_SERVER['PATH_INFO'])) 
    -		? str_replace($sn, '', $ru) 
    -		: '/';
    -		
    +	$sn = $_SERVER['SCRIPT_NAME'];
    +
     	// Make sure the home page works when in a sub_directory
     	if (strlen($sn) > strlen($ru))
     	{
    @@ -354,39 +391,41 @@ function route()
     	{
     		//Remove trailing slash and begining slash
     		$pi = trim($pi, '/');
    -	
    +		$segments = explode("/", $pi);
    +
     		// URL matches the route exactly? Cool, that was easy
     		if (isset($routes[$pi]))
     		{
     			list($module, $controller, $func) = explode("/", $routes[$pi]);
    -			$route_set = TRUE;
    +			run($module, $controller, $func);
    +			return;
     		}
     		else
     		{
     			$custom_routes = $routes;
    -			
    +
     			// Skip required routes
     			unset($custom_routes['default_module']);
     			unset($custom_routes['default_controller']);
     			unset($custom_routes['404_handler']);
    -		
    -			foreach($custom_routes as $uri => &$map)
    +
    +			foreach($custom_routes as $uri => $map)
     			{
     				if (preg_match("`{$uri}`i", $pi))
     				{
     					list($module, $controller, $func) = explode("/", $map);
    -					$route_set = TRUE;
    -					break;
    +					run($module, $controller, $func);
    +					return;
     				}
     			}
     		}
    -		
    -		// Doesn't match a predefined route? 
    +
    +		// Doesn't match a predefined route?
     		// Match on module/controller/method, module/controller, controller/method, or method
     		if ( ! $route_set)
     		{
     			$num_segments = 0;
    -		
    +
     			if (strpos($pi, '/') === FALSE  &&  ! empty($pi))
     			{
     				$num_segments = 1;
    @@ -396,7 +435,7 @@ function route()
     				$segments = explode('/', $pi);
     				$num_segments = count($segments);
     			}
    -			
    +
     			// Determine route based on uri segments
     			if ($num_segments === 1)
     			{
    @@ -404,8 +443,9 @@ function route()
     			}
     			elseif ($num_segments === 2)
     			{
    +
     				list($module, $controller) = $segments;
    -				
    +
     				// If it's just controller/function
     				if ($controller == 'index')
     				{
    @@ -413,34 +453,53 @@ function route()
     					$module = $routes['default_module'];
     					$func = 'index';
     				}
    -				
    +
     			}
    -			elseif ($num_segments >= 3)
    +			else
     			{
     				list($module, $controller, $func) = $segments;
     			}
     		}
     	}
    -	
    +
    +	run($module, $controller, $func);
    +	return;
    +}
    +
    +// --------------------------------------------------------------------------
    +
    +/**
    + * Instantiate the appropriate controller
    + *
    + * @param string
    + * @param string
    + * @param string
    + * @param array
    + */
    +function run($module, $controller, $func, $args = array())
    +{
     	$path = MM_MOD_PATH . "{$module}/controllers/{$controller}.php";
    -	
    +
     	if (is_file($path))
     	{
     		require_once($path);
    -		
    +
     		// Get the list of valid methods for that controller
     		$methods = controller_methods($controller);
    -		
    +
     		if (in_array($func, $methods))
     		{
     			// Define the name of the current module for file loading
    -			define('MM_MOD', $module);
    -		
    +			if ( ! defined('MM_MOD'))
    +			{
    +				define('MM_MOD', $module);
    +			}
    +
     			$class = new $controller();
    -			return call_user_func([&$class, $func]);
    +			return call_user_func_array(array(&$class, $func), $args);
     		}
     	}
    -	
    +
     	// Function doesn't exist...404
     	show_404();
     }
    diff --git a/sys/core/Controller.php b/sys/core/Controller.php
    index 5a5e642..f9ca849 100644
    --- a/sys/core/Controller.php
    +++ b/sys/core/Controller.php
    @@ -8,7 +8,7 @@
      * @author 		Timothy J. Warren
      * @copyright	Copyright (c) 2011 - 2012
      * @link 		https://github.com/aviat4ion/miniMVC
    - * @license 	http://philsturgeon.co.uk/code/dbad-license 
    + * @license 	http://philsturgeon.co.uk/code/dbad-license
      */
     
     // --------------------------------------------------------------------------
    @@ -21,8 +21,8 @@ namespace miniMVC;
      * @package miniMVC
      * @subpackage System
      */
    -class Controller extends miniMVC {
    -	
    +class Controller {
    +
     	/**
     	 * Instance of Page class
     	 *
    @@ -37,45 +37,46 @@ class Controller extends miniMVC {
     	 */
     	public function __construct()
     	{
    -		parent::__construct();
    -		
     		// Create the page object
    -		$this->page = new Page($this);
    +		$this->page = $GLOBALS['page'];
     	}
    -	
    +
     	// --------------------------------------------------------------------------
    -	
    +
     	/**
     	 * Function for loading a model into the current class
     	 *
     	 * @param string $file
     	 * @param array $args
     	 * @return void
    -	 */	
    -	public function load_model($file, $args=[])
    +	 */
    +	public function load_model($file, $args=array())
     	{
    +		$segments = explode('\\', $file);
    +		$file_name = end($segments);
    +
     		// The module is set via the router
     		$module = strtolower(MM_MOD);
    -		$path = MM_MOD_PATH . "{$module}/models/{$file}.php";
    +		$path = MM_MOD_PATH . "{$module}/models/{$file_name}.php";
     
     		if (is_file($path))
     		{
     			require_once($path);
    -		}		
    -		
    +		}
    +
     		if ( ! empty($args))
     		{
    -		
    -			$this->$file = new $file($args);
    +
    +			$this->$file_name = new $file($args);
     		}
     		else
     		{
    -			$this->$file = new $file;
    +			$this->$file_name = new $file;
     		}
     	}
    -	
    +
     	// --------------------------------------------------------------------------
    -	
    +
     	/**
     	 * Function for loading a view
     	 *
    @@ -84,41 +85,9 @@ class Controller extends miniMVC {
     	 * @param bool $return
     	 * @return mixed
     	 */
    -	public function load_view($file, array $data=[], $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";
    -		}
    -		
    -		// 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->page->append_output($buffer);
    -		}
    +		return $this->page->load_view($file, $data, $return);
     	}
     }
     
    diff --git a/sys/core/MM.php b/sys/core/MM.php
    deleted file mode 100644
    index 0f2dd03..0000000
    --- a/sys/core/MM.php
    +++ /dev/null
    @@ -1,72 +0,0 @@
    - &$value)
    - 		{
    - 			$this->$name = $value;
    - 		}
    -	}
    -	
    -	// --------------------------------------------------------------------------
    -	
    -	/**
    -	 * Allow calling of array methods on the object and 
    -	 * dynamic methods
    -	 *
    -	 * @param string $name
    -	 * @param array $params
    -	 * @return mixed
    -	 */
    -	public function __call($name, $params = [])
    -	{
    -		// Allow array operations on the object
    -		if (substr($name, 0, 6) === 'array_' && is_callable($name))
    -		{
    -			$args = array_merge($this->getArrayCopy(), $args);
    -			return call_user_func_array($name, $args);
    -		}
    -		
    -		// Allow dynamic method calls
    -		if (is_callable($this->$name))
    -		{	
    -			//Call the dynamic function
    -			return call_user_func_array($this->$name, $params);
    -		}
    -	}
    -}
    -
    -// End of MM.php
    \ No newline at end of file
    diff --git a/sys/core/Model.php b/sys/core/Model.php
    index 477bfc6..d3778ee 100644
    --- a/sys/core/Model.php
    +++ b/sys/core/Model.php
    @@ -8,7 +8,7 @@
      * @author 		Timothy J. Warren
      * @copyright	Copyright (c) 2011 - 2012
      * @link 		https://github.com/aviat4ion/miniMVC
    - * @license 	http://philsturgeon.co.uk/code/dbad-license 
    + * @license 	http://philsturgeon.co.uk/code/dbad-license
      */
     
     // --------------------------------------------------------------------------
    @@ -21,7 +21,7 @@ namespace miniMVC;
      * @package miniMVC
      * @subpackage System
      */
    -class Model extends miniMVC {
    +class Model extends \ArrayObject {
     
     	/**
     	 * Initialize the model class
    @@ -29,9 +29,9 @@ class Model extends miniMVC {
     	 * @param array $args
     	 * @return void
     	 */
    -	public function __construct(array $args = [])
    +	public function __construct(array $args = array())
     	{
    -		parent::__construct($args);
    +		parent::__construct($args, \ArrayObject::STD_PROP_LIST | \ArrayObject::ARRAY_AS_PROPS);
     	}
     }
     
    diff --git a/sys/core/Output.php b/sys/core/Output.php
    deleted file mode 100644
    index 25ef038..0000000
    --- a/sys/core/Output.php
    +++ /dev/null
    @@ -1,154 +0,0 @@
    -buffer = "";
    -		$this->headers = [];
    -	}
    -	
    -	/**
    -	 * PHP magic method called when ending the script
    -	 * Used for outputing HTML
    -	 *
    -	 * @return void
    -	 */
    -	public function __destruct()
    -	{
    -		if ( ! empty($this->headers))
    -		{
    -			// Set headers
    -			foreach($this->headers as $key => $val)
    -			{
    -				if ( ! isset($val))
    -				{
    -					@header($key);
    -				}
    -				else
    -				{
    -					@header("$key: $val");
    -				}			
    -			}
    -		}
    -		
    -		if ( ! empty($this->buffer))
    -		{	
    -			if (is_null(error_get_last()))
    -			{
    -				// Compression is good! 
    -				ob_start("ob_gzhandler");
    -			}
    -			else
    -			{
    -				ob_start();
    -			}
    -
    -			echo $this->buffer;
    -			ob_end_flush();
    -		}
    -	}
    -	
    -	// --------------------------------------------------------------------------
    -	
    -	/**
    -	 * Sets a header for later output
    -	 *
    -	 * @param string $key
    -	 * @param string $val
    -	 */
    -	public function set_header($key, $val)
    -	{
    -		$this->headers[$key] = $val;
    -	}
    -	
    -	// --------------------------------------------------------------------------
    -	
    -	/**
    -	 * Adds text to the output buffer
    -	 * 
    -	 * @param string $string
    -	 */
    -	public function append_output($string)
    -	{
    -		$this->buffer .= $string;
    -	}
    -	
    -	// --------------------------------------------------------------------------
    -	
    -	/**
    -	 * Sets the output buffer
    -	 * 
    -	 * @param string $string
    -	 */
    -	public function set_output($string)
    -	{
    -		$this->buffer = $string;
    -	}
    -	
    -	// --------------------------------------------------------------------------
    -	
    -	/**
    -	 * Sends headers and then removes them
    -	 */
    -	public function flush_headers()
    -	{
    -		// Set headers
    -		foreach ($this->headers as $key => &$val)
    -		{
    -			if ( ! isset($val))
    -			{
    -				@header($key);
    -			}
    -			else
    -			{
    -				@header("{$key}: {$val}");
    -			}
    -		}
    -		
    -		// Empty headers
    -		$this->headers = [];
    -	}
    -}
    -
    -// End of Output.php
    \ No newline at end of file
    diff --git a/sys/core/Page.php b/sys/core/Page.php
    index 441a7b3..0ceba90 100644
    --- a/sys/core/Page.php
    +++ b/sys/core/Page.php
    @@ -8,9 +8,9 @@
      * @author 		Timothy J. Warren
      * @copyright	Copyright (c) 2011 - 2012
      * @link 		https://github.com/aviat4ion/miniMVC
    - * @license 	http://philsturgeon.co.uk/code/dbad-license 
    + * @license 	http://philsturgeon.co.uk/code/dbad-license
      */
    - 
    +
     // --------------------------------------------------------------------------
     
     namespace miniMVC;
    @@ -24,7 +24,7 @@ namespace miniMVC;
      * @package miniMVC
      * @subpackage System
      */
    -class Page extends Output {
    +class Page {
     
     	/**
     	 * Meta tags
    @@ -32,70 +32,83 @@ class Page extends Output {
     	 * @var string
     	 */
     	private $meta;
    -	
    +
     	/**
     	 * JS tags for the header
     	 *
     	 * @var string
     	 */
    -	private $head_js; 
    -	
    +	private $head_js;
    +
     	/**
     	 * JS tags for the footer
     	 *
     	 * @var string
     	 */
    -	private $foot_js; 
    -	
    +	private $foot_js;
    +
     	/**
     	 * CSS tags for the page
     	 *
     	 * @var string
     	 */
    -	private $css; 
    -	
    +	private $css;
    +
     	/**
     	 * Page title
     	 *
     	 * @var string
     	 */
    -	private $title; 
    -	
    +	private $title;
    +
     	/**
     	 * Additional header tags
     	 *
     	 * @var string
     	 */
    -	private $head_tags; 
    -	
    +	private $head_tags;
    +
     	/**
     	 * Class(es) to apply to the main body tag
     	 *
     	 * @var string
     	 */
    -	private $body_class; 
    -	
    +	private $body_class;
    +
     	/**
     	 * Id to apply to the body tag
     	 *
     	 * @var string
     	 */
    -	private $body_id; 
    -	
    +	private $body_id;
    +
     	/**
     	 * Base tag
     	 *
     	 * @var string
     	 */
     	private $base;
    -	
    +
    +	/**
    +	 * Content for outputting
    +	 *
    +	 * @var string
    +	 */
    +	private $buffer;
    +
    +	/**
    +	 * HTTP headers to send
    +	 *
    +	 * @var array
    +	 */
    +	private $headers;
    +
     	/**
     	 * Set up the page class
     	 *
    -	 * @param object
     	 * @return void
     	 */
    -	public function __construct(&$controller)
    +	public function __construct()
     	{
     		$this->meta       = "";
     		$this->head_js    = "";
    @@ -106,22 +119,61 @@ class Page extends Output {
     		$this->body_class = "";
     		$this->body_id    = "";
     		$this->base       = "";
    -		
    -		$this->mm = $controller;
    +		$this->buffer = "";
    +		$this->headers = array();
     	}
    -	
    +
     	// --------------------------------------------------------------------------
    -	
    +
     	/**
    -	 * call the parent destructor
    +	 * PHP magic method called when ending the script
    +	 * Used for outputing HTML
    +	 *
    +	 * @return void
     	 */
     	public function __destruct()
     	{
    -		parent::__destruct();
    +		if ( ! empty($this->headers))
    +		{
    +			// Set headers
    +			foreach($this->headers as $key => $val)
    +			{
    +				if ( ! isset($val))
    +				{
    +					@header($key);
    +				}
    +				else
    +				{
    +					@header("$key: $val");
    +				}
    +			}
    +		}
    +
    +		if ( ! empty($this->buffer))
    +		{
    +			// @todo Figure out how to adjust content compression for 5.4.4
    +			ob_start();
    +
    +			echo $this->buffer;
    +
    +			// Check if a buffer exists
    +			// so that it doesn't throw a notice
    +			if (ob_get_level() > 0)
    +			{
    +				ob_end_flush();
    +			}
    +
    +
    +		}
    +		else
    +		{
    +			echo 'No content';
    +		}
     	}
    -	
    +
    +
     	// --------------------------------------------------------------------------
    -	
    +
     	/**
     	 * Sets server headers and doctype
     	 *
    @@ -136,40 +188,40 @@ class Page extends Output {
     	{
     		$this->set_header("Cache-Control", "must-revalidate, public");
     		$mime = "";
    -		
    +
     		//Variable for accept keyword
     		$accept = ( ! empty($_SERVER['HTTP_ACCEPT'])) ? $_SERVER['HTTP_ACCEPT'] : "";
    -		
    +
     		//Predefine doctype
     		$doctype_string = ($html5 == TRUE) ? '' : '';
    -		
    +
     		//Predefine charset
     		$charset = "UTF-8";
    -		
    +
     		$mime = "text/html";
    -			
    +
     		if ($html5 == FALSE)
     		{
     			$doctype_string = '';
     		}
    -		
    +
     		$doctype_string .= "";
    -		
    +
     		// finally, output the mime type and prolog type
     		$this->set_header("Content-Type", "{$mime};charset={$charset}");
     		$this->set_header("X-UA-Compatible", "chrome=1, IE=edge");
     		$this->set_output($doctype_string);
    -		
    +
     		return $this;
     	}
    -	
    +
     	// --------------------------------------------------------------------------
    -	
    +
     	/**
     	 * Set Meta
     	 *
     	 * Sets meta tags, with codeigniter native meta tag helper
    -	 * 
    +	 *
     	 * @param array $meta
     	 * @return Page
     	 */
    @@ -178,9 +230,9 @@ class Page extends Output {
     		$this->meta .= $this->_meta($meta);
     		return $this;
     	}
    -	
    +
     	// --------------------------------------------------------------------------
    -	
    +
     	/**
     	 * Sets minified javascript group in header
     	 *
    @@ -194,15 +246,15 @@ class Page extends Output {
     		{
     			return $this;
     		}
    -		
    +
     		$file = SCRIPT_PATH . $group;
     		$file .= ($debug == TRUE) ? "/debug/1" : "";
     		$this->head_js .= $this->script_tag($file, FALSE);
     		return $this;
     	}
    -	
    +
     	// --------------------------------------------------------------------------
    -	
    +
     	/**
     	 * Sets a minified css group
     	 * @param string $group
    @@ -210,18 +262,18 @@ class Page extends Output {
     	 */
     	public function set_css_group($group)
     	{
    -		$link = [
    +		$link = array(
     			'href' => STYLE_PATH . $group,
     			'rel' => 'stylesheet',
     			'type' => 'text/css'
    -		];
    +		);
     		$this->css .= $this->_link_tag($link);
    -		
    +
     		return $this;
     	}
    -	
    +
     	// --------------------------------------------------------------------------
    -	
    +
     	/**
     	 * Sets a minified javascript group for the page footer
     	 *
    @@ -236,9 +288,9 @@ class Page extends Output {
     		$this->foot_js .= $this->script_tag($file, FALSE);
     		return $this;
     	}
    -	
    +
     	// --------------------------------------------------------------------------
    -	
    +
     	/**
     	 * Sets html title string
     	 *
    @@ -248,14 +300,14 @@ class Page extends Output {
     	public function set_title($title = "")
     	{
     		$title = ($title == "") ? DEFAULT_TITLE : $title;
    -		
    +
     		$this->title = $title;
    -		
    +
     		return $this;
     	}
    -	
    +
     	// --------------------------------------------------------------------------
    -	
    +
     	/**
     	 * Sets custom body class
     	 *
    @@ -267,9 +319,9 @@ class Page extends Output {
     		$this->body_class = $class;
     		return $this;
     	}
    -	
    +
     	// --------------------------------------------------------------------------
    -	
    +
     	/**
     	 * Sets custom body id
     	 *
    @@ -281,9 +333,9 @@ class Page extends Output {
     		$this->body_id = $id;
     		return $this;
     	}
    -	
    +
     	// --------------------------------------------------------------------------
    -	
    +
     	/**
     	 * Sets custom base href
     	 *
    @@ -295,9 +347,9 @@ class Page extends Output {
     		$this->base = $href;
     		return $this;
     	}
    -	
    +
     	// --------------------------------------------------------------------------
    -	
    +
     	/**
     	 * Sets custom css tags
     	 *
    @@ -310,24 +362,24 @@ class Page extends Output {
     	{
     		$path     = CONTENT_DOMAIN;
     		$css_file = "{$path}/css/{$name}.css";
    -		
    +
     		if ($domain == FALSE)
     		{
     			$css_file = $name;
     		}
    -		
    -		$this->css_tags .= $this->_link_tag([
    +
    +		$this->css_tags .= $this->_link_tag(array(
     			'rel' => 'stylesheet',
     			'type' => 'text/css',
     			'media' => $media,
     			'href' => $css_file,
    -		]);
    -		
    +		));
    +
     		return $this;
     	}
    -	
    +
     	// --------------------------------------------------------------------------
    -	
    +
     	/**
     	 * Sets a custom tag in the header
     	 *
    @@ -339,9 +391,9 @@ class Page extends Output {
     		$this->head_tags .= $tag;
     		return $this;
     	}
    -	
    +
     	// --------------------------------------------------------------------------
    -	
    +
     	/**
     	 * Sets custom page header
     	 *
    @@ -350,18 +402,18 @@ class Page extends Output {
     	 */
     	public function build_header($html5 = TRUE)
     	{
    -		$data = [];
    -		
    +		$data = array();
    +
     		//Set Meta Tags
    -		$this->meta   = ($html5 == TRUE) 
    -			? ''. $this->meta 
    -			: $this->_meta([
    +		$this->meta   = ($html5 == TRUE)
    +			? ''. $this->meta
    +			: $this->_meta(array(
     				'http-equiv' => 'Content-Type',
     				'content' => 'text/html; charset=utf-8',
    -			]) . $this->meta;
    -		
    +			)) . $this->meta;
    +
     		$data['meta'] = $this->meta;
    -		
    +
     		//Set CSS
     		if ($this->css !== "")
     		{
    @@ -373,50 +425,50 @@ class Page extends Output {
     			$this->set_css_group(DEFAULT_CSS_GROUP);
     			$data['css'] = $this->css;
     		}
    -		
    +
     		//Set head javascript
     		$data['head_js'] = ( ! empty($this->head_js)) ? $this->head_js : "";
    -		
    +
     		//Set Page Title
     		$data['title'] = ($this->title !== '') ? $this->title : DEFAULT_TITLE;
    -		
    +
     		//Set Body Class
     		$data['body_class'] = $this->body_class;
    -		
    +
     		//Set Body Id
     		$data['body_id'] = $this->body_id;
    -		
    +
     		//Set Base HREF
     		$data['base'] = $this->base;
    -		
    +
     		//Set individual head tags
     		$data['head_tags'] = $this->head_tags;
    -		
    +
     		//Set Server Headers and Doctype
     		$this->_headers($html5);
    -		
    +
     		//Output Header
    -		$this->mm->load_view('header', $data);
    -		
    +		$this->load_view('header', $data);
    +
     		return $this;
     	}
    -	
    +
     	// --------------------------------------------------------------------------
    -	
    +
     	/**
     	 * Builds common footer with any additional js
     	 */
     	public function build_footer()
     	{
    -		$data = [];
    -		
    +		$data = array();
    +
     		$data['foot_js'] = ($this->foot_js != "") ? $this->foot_js : '';
    -		
    -		$this->mm->load_view('footer', $data);
    +
    +		$this->load_view('footer', $data);
     	}
    -	
    +
     	// --------------------------------------------------------------------------
    -	
    +
     	/**
     	 * Script Tag
     	 *
    @@ -430,19 +482,19 @@ class Page extends Output {
     	{
     		$path    = CONTENT_DOMAIN;
     		$js_file = "{$path}/js/{$js}.js";
    -		
    +
     		if ($domain == FALSE)
     		{
     			$js_file = $js;
     		}
    -		
    +
     		$tag = '';
    -		
    +
     		return $tag;
     	}
    -	
    +
     	// --------------------------------------------------------------------------
    -	
    +
     	/**
     	 * Set Message
     	 *
    @@ -456,26 +508,26 @@ class Page extends Output {
     	{
     		$data['stat_class'] = $type;
     		$data['message']    = $message;
    -		
    -		return $this->mm->load_view('message', $data, $return);
    +
    +		return $this->load_view('message', $data, $return);
     	}
    -	
    +
     	// --------------------------------------------------------------------------
    -	
    +
     	/**
     	 * Redirect 303
     	 *
     	 * Shortcut function for 303 redirect
     	 * @param string $url
     	 */
    -	function redirect_303($url)
    +	public function redirect_303($url)
     	{
     		$this->set_header("HTTP/1.1 303 See Other");
     		$this->set_header("Location:" . $url);
     	}
    -	
    +
     	// --------------------------------------------------------------------------
    -	
    +
     	/**
     	 * Render
     	 *
    @@ -483,30 +535,30 @@ class Page extends Output {
     	 * @param string $view
     	 * @param array $data
     	 */
    -	function render($view, $data=[])
    +	public function render($view, $data=array())
     	{
     		$this->build_header();
    -		$this->mm->load_view($view, $data);
    +		$this->load_view($view, $data);
     		$this->build_footer();
     	}
    -	
    +
     	// --------------------------------------------------------------------------
    -	
    +
     	/**
     	 * Output String
     	 *
     	 * Similar to render(), this is a shortcut
    -	 * to output a string in the body of the 
    +	 * to output a string in the body of the
     	 * page.
     	 * @param string $string
     	 */
    -	function output_string($string)
    +	public function output_string($string)
     	{
     		$this->build_header();
     		$this->append_output($string);
     		$this->build_footer();
     	}
    -	
    +
     	// --------------------------------------------------------------------------
     
     	/**
    @@ -518,17 +570,17 @@ class Page extends Output {
     	private function _meta($params)
     	{
     		$string = " &$v)
     		{
     			$string .= $k.'="'.$v.'" ';
     		}
    -		
    +
     		$string .= " />";
    -		
    +
     		return $string;
     	}
    -	
    +
     	// --------------------------------------------------------------------------
     
     	/**
    @@ -536,20 +588,128 @@ class Page extends Output {
     	 *
     	 * @param array $params
     	 * @return string
    -	 */ 
    +	 */
     	private function _link_tag($params)
     	{
     		$string = " &$v)
     		{
     			$string .= $k . '="'.$v.'" ';
     		}
    -		
    +
     		$string .= "/>";
    -		
    +
     		return $string;
     	}
    +
    +	// --------------------------------------------------------------------------
    +
    +	/**
    +	 * Function for loading a view
    +	 *
    +	 * @param string $file
    +	 * @param array $data
    +	 * @param bool $return
    +	 * @return mixed
    +	 */
    +	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";
    +		}
    +
    +		// 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->append_output($buffer);
    +		}
    +	}
    +
    +	// --------------------------------------------------------------------------
    +
    +	/**
    +	 * Sets a header for later output
    +	 *
    +	 * @param string $key
    +	 * @param string $val
    +	 */
    +	public function set_header($key, $val)
    +	{
    +		$this->headers[$key] = $val;
    +	}
    +
    +	// --------------------------------------------------------------------------
    +
    +	/**
    +	 * Adds text to the output buffer
    +	 *
    +	 * @param string $string
    +	 */
    +	public function append_output($string)
    +	{
    +		$this->buffer .= $string;
    +	}
    +
    +	// --------------------------------------------------------------------------
    +
    +	/**
    +	 * Sets the output buffer
    +	 *
    +	 * @param string $string
    +	 */
    +	public function set_output($string)
    +	{
    +		$this->buffer = $string;
    +	}
    +
    +	// --------------------------------------------------------------------------
    +
    +	/**
    +	 * Sends headers and then removes them
    +	 */
    +	public function flush_headers()
    +	{
    +		// Set headers
    +		foreach ($this->headers as $key => &$val)
    +		{
    +			if ( ! isset($val))
    +			{
    +				@header($key);
    +			}
    +			else
    +			{
    +				@header("{$key}: {$val}");
    +			}
    +		}
    +
    +		// Empty headers
    +		$this->headers = array();
    +	}
     }
     
     // End of page.php
    \ No newline at end of file
    diff --git a/sys/core/db.php b/sys/core/db.php
    index af60d77..8037f16 100644
    --- a/sys/core/db.php
    +++ b/sys/core/db.php
    @@ -23,14 +23,14 @@ namespace miniMVC;
      */
     class DB extends \Query_Builder {
     
    -	use Generic;
    -
     	/**
     	 * DB connection instances
     	 *
     	 * @var array
     	 */
    -	private static $instance = [];
    +	private static $instance = array();
    +	
    +	// --------------------------------------------------------------------------
     	
     	/**
     	 * Indexed singleton method
    @@ -39,7 +39,7 @@ class DB extends \Query_Builder {
     	 * @param array $options
     	 * @return DB
     	 */
    -	public static function &get_instance($dbname="default", array $options=[])
    +	public static function &get_instance($dbname="default", array $options=array())
     	{
     		if ( ! isset(self::$instance[$dbname]))
     		{
    @@ -71,7 +71,7 @@ class DB extends \Query_Builder {
     	 */
     	public function get_last_error()
     	{
    -		$error = [];
    +		$error = array();
     
     		if (isset($this->statement))
     		{
    diff --git a/sys/core/miniMVC.php b/sys/core/miniMVC.php
    deleted file mode 100644
    index e540043..0000000
    --- a/sys/core/miniMVC.php
    +++ /dev/null
    @@ -1,72 +0,0 @@
    -$name))
    -		{
    -			unset($this->$name);
    -		}
    -	}
    -	
    -	// --------------------------------------------------------------------------
    -	
    -	/**
    -	 * Convenience function to load config files
    -	 *
    -	 * @param string $name
    -	 */
    -	public function load_config($name)
    -	{
    -		$path = MM_APP_PATH . "config/{$name}.php";
    -	
    -		if (is_file($path))
    -		{
    -			require_once($path);
    -		}
    -	}
    -}
    -
    -// End of miniMVC.php
    \ No newline at end of file
    diff --git a/sys/core/traits/Generic.php b/sys/core/traits/Generic.php
    deleted file mode 100644
    index d15f16c..0000000
    --- a/sys/core/traits/Generic.php
    +++ /dev/null
    @@ -1,87 +0,0 @@
    -';
    -			
    -			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 ''; - } - } - - // -------------------------------------------------------------------------- - - /** - * PHP magic method that is called when an object is treated as a function - * - * @param array $args - */ - public static function __invoke($args = []) - { - $class = __CLASS__; - return new $class($args); - } -} - -// End of Generic.php \ No newline at end of file diff --git a/sys/core/traits/JSObject.php b/sys/core/traits/JSObject.php deleted file mode 100644 index 6cce484..0000000 --- a/sys/core/traits/JSObject.php +++ /dev/null @@ -1,61 +0,0 @@ - &$value) - { - $this->$name = $value; - } - } - - // -------------------------------------------------------------------------- - - /** - * PHP magic method to facilitate dynamic methods - * - * @param string $name - * @param array $params - */ - public function __call($name, $params = []) - { - if (is_callable($this->$name)) - { - //Call the dynamic function - return call_user_func_array($this->$name, $params); - } - } -} - -// End of JSObject.php \ No newline at end of file diff --git a/sys/core/traits/Singleton.php b/sys/core/traits/Singleton.php deleted file mode 100644 index 82f5126..0000000 --- a/sys/core/traits/Singleton.php +++ /dev/null @@ -1,81 +0,0 @@ -rounds = $rounds; + } + + // -------------------------------------------------------------------------- + + /** + * Returns a has for the input string + * + * @param string + * @return string + */ + public function hash($input) + { + $hash = crypt($input, $this->getSalt()); + + if (strlen($hash) > 13) + return $hash; + + return false; + } + + // -------------------------------------------------------------------------- + + /** + * Check if a password hash is valid + * + * @param string + * @param string + * @return bool + */ + public function verify($input, $existingHash) + { + $hash = crypt($input, $existingHash); + + return $hash === $existingHash; + } + + // -------------------------------------------------------------------------- + + /** + * Private function to generate the random salt + * + * @return string + */ + private function getSalt() + { + $salt = sprintf('$2a$%02d$', $this->rounds); + + $bytes = $this->getRandomBytes(16); + + $salt .= $this->encodeBytes($bytes); + + return $salt; + } + + // -------------------------------------------------------------------------- + + /** + * Private method to generate random characters for salt + * + * @param int + * @return string + */ + private function getRandomBytes($count) + { + $bytes = ''; + + if (function_exists('openssl_random_pseudo_bytes') && (strtoupper(substr(PHP_OS, 0, 3)) !== 'WIN')) // OpenSSL slow on Win + { + $bytes = openssl_random_pseudo_bytes($count); + } + + if ($bytes === '' && is_readable('/dev/urandom') && ($hRand = @fopen('/dev/urandom', 'rb')) !== FALSE) + { + $bytes = fread($hRand, $count); + fclose($hRand); + } + + if (strlen($bytes) < $count) + { + $bytes = ''; + + if ($this->randomState === null) + { + $this->randomState = microtime(); + if (function_exists('getmypid')) + { + $this->randomState .= getmypid(); + } + } + + for ($i = 0; $i < $count; $i += 16) + { + $this->randomState = md5(microtime() . $this->randomState); + + if (PHP_VERSION >= '5') + { + $bytes .= md5($this->randomState, true); + } + else + { + $bytes .= pack('H*', md5($this->randomState)); + } + } + + $bytes = substr($bytes, 0, $count); + } + + return $bytes; + } + + // -------------------------------------------------------------------------- + + /** + * Further randomizes salt? + * + * @param string + * @return string + */ + private function encodeBytes($input) + { + // The following is code from the PHP Password Hashing Framework + $itoa64 = './ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'; + + $output = ''; + $i = 0; + do + { + $c1 = ord($input[$i++]); + $output .= $itoa64[$c1 >> 2]; + $c1 = ($c1 & 0x03) << 4; + if ($i >= 16) + { + $output .= $itoa64[$c1]; + break; + } + + $c2 = ord($input[$i++]); + $c1 |= $c2 >> 4; + $output .= $itoa64[$c1]; + $c1 = ($c2 & 0x0f) << 2; + + $c2 = ord($input[$i++]); + $c1 |= $c2 >> 6; + $output .= $itoa64[$c1]; + $output .= $itoa64[$c2 & 0x3f]; + } while (1); + + return $output; + } +} \ No newline at end of file diff --git a/sys/libraries/Session.php b/sys/libraries/Session.php index 0a7e8c7..b7b2d55 100644 --- a/sys/libraries/Session.php +++ b/sys/libraries/Session.php @@ -8,7 +8,7 @@ * @author Timothy J. Warren * @copyright Copyright (c) 2011 - 2012 * @link https://github.com/aviat4ion/miniMVC - * @license http://philsturgeon.co.uk/code/dbad-license + * @license http://philsturgeon.co.uk/code/dbad-license */ // -------------------------------------------------------------------------- @@ -23,33 +23,32 @@ namespace miniMVC; */ class Session { - // Combine traits for more dynamic behavior - // but use Singleton for __invoke, so calling - // that method does not create a new instance - use JSObject, Singleton - { - Singleton::__invoke insteadof JSObject; - } - /** * Reference to session superglobal * * @var array */ - protected $sess = []; + protected $sess = array(); + /** + * Reference to current instance + * + * @var Session + */ + protected static $instance; + /** * Start a session */ protected function __construct() { session_start(); - + // Save a reference to the session for later access - $_SESSION['MM_SESSION'] = (isset($_SESSION['MM_SESSION']) ?: []; + $_SESSION['MM_SESSION'] = (isset($_SESSION['MM_SESSION'])) ?: array(); $this->sess =& $_SESSION['MM_SESSION']; } - + // -------------------------------------------------------------------------- /** @@ -58,12 +57,12 @@ class Session { * @param string $key * @param mixed $val * @return void - */ + */ public function __set($key, $val) { $this->sess[$key] = $val; } - + // -------------------------------------------------------------------------- /** @@ -76,7 +75,7 @@ class Session { { return $this->sess[$key]; } - + // -------------------------------------------------------------------------- /** @@ -88,6 +87,35 @@ class Session { { sess_destroy(); } + + // -------------------------------------------------------------------------- + + /** + * Singleton getter function + * + * @return self + */ + public static function &get_instance() + { + if ( ! isset(self::$instance)) + { + $class = __CLASS__; + + self::$instance = new $class; + } + + return self::$instance; + } + + // -------------------------------------------------------------------------- + + /** + * Magic function called when cloning an object + */ + public function __clone() + { + trigger_error('Clone is not allowed.', E_USER_ERROR); + } } // End of session.php \ No newline at end of file diff --git a/tests/MMTest.php b/tests/MMTest.php deleted file mode 100644 index ee989c7..0000000 --- a/tests/MMTest.php +++ /dev/null @@ -1,37 +0,0 @@ -mm = new miniMVC\MM([ - 'foo' => 54, - 'bar' => 'baz', - ]); - } - - function tearDown() - { - unset($this->mm); - } - - function testToStringDevel() - { - // __toString produces same output as print_r by default - $this->assertIdentical($this->mm->__toString(), '
    '.print_r($this->mm, TRUE).'
    '); - } - - function testMMIsA() - { - $this->assertIsA($this->mm, 'ArrayObject'); - } - -} \ No newline at end of file diff --git a/tests/commonTest.php b/tests/commonTest.php index f7c35f8..a34ecbf 100644 --- a/tests/commonTest.php +++ b/tests/commonTest.php @@ -13,8 +13,8 @@ class commonTest extends UnitTestCase { function setUp() { $this->empty = array(); - $this->object = new miniMVC\MM(); - $this->array_like = new miniMVC\MM(['foo' => 'bar']); + $this->object = new stdClass(); + $this->array_like = new stdClass(array('foo' => 'bar')); } function tearDown() diff --git a/tests/index.php b/tests/index.php index 513119c..def129e 100644 --- a/tests/index.php +++ b/tests/index.php @@ -22,6 +22,4 @@ require_once(MM_SYS_PATH . 'common.php'); //Include test files require_once('commonTest.php'); -require_once('MMTest.php'); -require_once('miniMVCTest.php'); diff --git a/tests/miniMVCTest.php b/tests/miniMVCTest.php deleted file mode 100644 index a406d93..0000000 --- a/tests/miniMVCTest.php +++ /dev/null @@ -1,50 +0,0 @@ -mm = miniMVC\miniMVC::get_instance(); - } - - function tearDown() - { - unset($this->mm); - } - - function testNoClone() - { - // Expect an error trying to clone the miniMVC object - $this->expectError("Clone is not allowed."); - $mm2 = clone $this->mm; - } - - function testReferences() - { - // miniMVC::get_instance returns reference to latest miniMVC object - $this->assertReference($this->mm, miniMVC\miniMVC::get_instance()); - - // miniMVC extends MM, right? - $this->assertIsA($this->mm, 'miniMVC\MM'); - } - - function testInvoke() - { - // Invoke function should return the same reference than miniMVC::get_instance() does - $mm = $this->mm; - $this->assertIdentical($mm(), miniMVC\miniMVC::get_instance()); - $this->assertIdentical($this->mm->__invoke(), miniMVC\miniMVC::get_instance()); - } - -} - - -