diff --git a/app/controller/common/404.php b/app/controller/common/404.php index a7d229a..c85599f 100644 --- a/app/controller/common/404.php +++ b/app/controller/common/404.php @@ -1,12 +1,11 @@ -view('common/404'); - } - -} +view('common/404'); + } + +} ?> \ No newline at end of file diff --git a/app/controller/common/home.php b/app/controller/common/home.php index bb3162a..a8fc34e 100644 --- a/app/controller/common/home.php +++ b/app/controller/common/home.php @@ -1,14 +1,11 @@ "Rex is cool" - ); - $this->view('common/home',$data); + $data['rex'] = "Rex is cool"; + $this->view('common/home', $data); + $this->helper('lk'); } } diff --git a/app/language/en.tpl b/app/language/en.tpl index 0426cfa..3e8e581 100644 --- a/app/language/en.tpl +++ b/app/language/en.tpl @@ -1,3 +1,2 @@ # global site information -site.title = Website Performance | CSS Sprite Generator -heading = CSS Sprite Generator \ No newline at end of file +site.title = Rex PHP Framework diff --git a/app/view/theme/default/template/common/404.tpl b/app/view/theme/default/template/common/404.tpl index ac97b7e..c2016ad 100644 --- a/app/view/theme/default/template/common/404.tpl +++ b/app/view/theme/default/template/common/404.tpl @@ -1,3 +1,3 @@ +OOOOOOPSS! - -This is the 404 page located at \ No newline at end of file +This is the 404 page located at \ No newline at end of file diff --git a/app/view/theme/default/template/common/footer.tpl b/app/view/theme/default/template/common/footer.tpl index 1921fa2..b8364be 100644 --- a/app/view/theme/default/template/common/footer.tpl +++ b/app/view/theme/default/template/common/footer.tpl @@ -1,6 +1,6 @@ -This is the footer page located at +
This is the footer page located at

diff --git a/app/view/theme/default/template/common/header.tpl b/app/view/theme/default/template/common/header.tpl index 3e515d9..901a4a3 100644 --- a/app/view/theme/default/template/common/header.tpl +++ b/app/view/theme/default/template/common/header.tpl @@ -5,9 +5,9 @@ Rez PHP Framework - + - - This is the header page located at \ No newline at end of file +


+
This is the header page located at

\ No newline at end of file diff --git a/app/view/theme/default/template/common/home.tpl b/app/view/theme/default/template/common/home.tpl index 95b5741..97b52d2 100644 --- a/app/view/theme/default/template/common/home.tpl +++ b/app/view/theme/default/template/common/home.tpl @@ -1,4 +1,4 @@ -This is the home page located at - - +
This is the home page located at

+ + diff --git a/engine/RexPHP.class.php b/engine/RexPHP.class.php index 937996c..943c71f 100644 --- a/engine/RexPHP.class.php +++ b/engine/RexPHP.class.php @@ -1,83 +1,107 @@ db() // initialize the db class + * $this->db->query("select * from table"); @see the root/driver/drivername.ext file * - * @return \rex + * @access public + * @see root/config.php file for the database_type constant + * @return DB object */ public function db() { include_once ROOT . DS . 'driver' . DS . database_type . '.php'; @@ -87,9 +111,19 @@ public function db() { } /** + * Call the model method. + * + * Seeks : root/app/model/path/to/modelname.ext * - * @param type $model - * @return \rex + * Usage : $this->model('dir/file'); + * $this->model_dir_file->method(); + * + * Example : $this->model('user/user'); + * $this->model_user_user->get_users(); + * + * @access public + * @param string $model example : 'user/user' + * @return object Returns the model object */ public function model($model) { $model_exp = explode('/', $model); @@ -120,12 +154,15 @@ public function model($model) { } /** + * Render the template with header and footer pages * - * @global type $data - * @param type $view - * @param type $datas + * @access public + * @global array $data + * @param string $template The template file without extension + * @param array $datas Viewbag + * @return string as HTML */ - public function view($template = null, $datas = null) { + public function view($template = null, $datas = array()) { $this->headerFile = ROOT . DS . 'app' . DS . 'view' . DS . 'theme' . DS . THEME_NAME . DS . 'template' . DS . str_replace('/', DS, HEADER_FILE) . TEMPLATE_EXTENSION; $this->footerFile = ROOT . DS . 'app' . DS . 'view' . DS . 'theme' . DS . THEME_NAME . DS . 'template' . DS . str_replace('/', DS, FOOTER_FILE) . TEMPLATE_EXTENSION; @@ -143,19 +180,7 @@ public function view($template = null, $datas = null) { $getFileName = &$trace[$count - 2]; /* * ***************************************************** */ if ($template == null || $template == '') - $template = $getFileName; // $template'i direk cagir - - - - - - - - - - -//$viewExplode = explode('/', $view); - + $template = $getFileName; if (isset($datas)) { global $data; @@ -205,12 +230,14 @@ public function view($template = null, $datas = null) { } /** + * Render the template without header and footer pages * - * @global type $data - * @param type $view - * @param type $datas + * @access public + * @global array $data + * @param string $template The template file without extension + * @param array $datas Viewbag */ - public function partial_view($view = null, $datas = null) { + public function partial_view($view = null, $datas = array()) { @@ -249,9 +276,19 @@ public function partial_view($view = null, $datas = null) { } /** + * Call the helper + * + * Seeks : root/helper/helpername.ext + * + * Usage : $this->helper('helper_name'); + * $this->helper_name->method(); * - * @param type $helper_name - * @return \rex + * Example : $this->helper('str'); + * $this->str->format('Hello {0}','world'); // outputs Hello world + * + * @access public + * @param string $helper_name the helper name to be called + * @return object usage : $this->helper_name->method(); */ public function helper($helper_name) { if (strpos($helper_name, ',') !== false) { @@ -327,9 +364,19 @@ private function create_instance_without_constructor($class) { } /** + * Call the library + * + * Seeks : root/library/libraryname.ext + * + * Usage : $this->import('import_name'); + * $this->import_name->method(); * - * @param type $library_name - * @return \rex + * Example : $this->import('lex'); + * $this->lex->render('common/home'); + * + * @access public + * @param string $library_name the library name to be called + * @return object usage : $this->library_name->method(); */ public function import($library_name) { if (strpos($library_name, ',') !== false) { @@ -364,9 +411,19 @@ public function import($library_name) { } /** + * Call the controller method.This is just like the calling a method in PHP + * + * Seeks : root/app/controller/path/to/controllername.ext * - * @param type $controller - * @param type $args + * Usage : $this->call('dir/file',array('id'=>6); + * + * Example : $this->call('common/home',array('id'=>6); + * //goes to the route -> common/home/6 or index.php?trace=common/home/6 + * $this->lex->render('common/home'); + * + * @access public + * @param string $controller example : 'common/home' + * @param array $args post and get parameters as string */ public function call($controller, $args = array()) { $gets = explode('/', $controller); @@ -419,20 +476,30 @@ public function call($controller, $args = array()) { } /** - * + * @access public + * SILENCE IS GOLDEN */ public function rex() { + $this->ladies_first(); + } + + /** + * Load the initial helpers or etc. + * Rex looks here firstly + * @access public + */ + public function ladies_first() { register_shutdown_function("fatal_handler"); - if (file_exists(ROOT . DS . 'init.php')) + if (file_exists(ROOT . DS . 'init.php')) { include ROOT . DS . 'init.php'; + } } } -//end class - /** - * + * + * @internal Custom error handler */ function fatal_handler() { $errorFile = "unknown file"; @@ -455,12 +522,13 @@ function fatal_handler() { } /** - * - * @param type $errorMessage - * @param type $file - * @param type $line - * @param type $error - * @return type + * @internal Custom error handling + * This is used in Rex + * @param string $errorMessage + * @param string $file + * @param string $line + * @param string $error + * @return string */ function format_error($errorMessage, $file, $line, $error) { if (SHOW_ERROR) { diff --git a/library/lex.class.php b/library/lex.class.php index 4cff7d5..e6ea0f3 100644 --- a/library/lex.class.php +++ b/library/lex.class.php @@ -2,7 +2,7 @@ /** * Lex Template Parser and REXPHP combination. - * If you want to use Lex Template Engine you can call this from REXPHP + * If you want to use Lex Template Parser, you can call this from Rex * Usage : $this->import('lex'); * $this->lex->render('common/home'); * @author Dan Horrigan