public static function default_view($view = null) { ///N:create a default template and prints its content on commit ///P:$view:An optional string with a view's name or an instance of rea_view or rea_template, if non is given the 'default_page' will be loaded. global $rea_app_controller_page, $rea_views_path; if ($rea_app_controller_page == null) { if ($view == null) { $rea_app_controller_page = rea_view::createWithSource('default_page', file_get_contents(REA_ENGINE_PATH . 'views/default.view.html')); } elseif (is_object($view) && is_a($view, 'rea_template')) { $rea_app_controller_page = $view; } else { $rea_app_controller_page = rea_view::create($view); } $m = function () { global $rea_app_controller_page; global $rea_controller; $rea_controller->dispatchEvent("default_view_commit", array($rea_app_controller_page)); print $rea_app_controller_page->getHTML(); }; rea_app_controller::on('app_commit_web', $m); rea_app_controller::on('default_view_commit', 'rea_views::attachJSBToView'); } return $rea_app_controller_page; }
function app_event_test_view($values) { global $config; // //rea_views::setViewsPath( REA_SELF_DIRECTORY ); $page = rea_views::default_view("bootstrap.view"); $page->set("title", "Testin Views"); $page->body->write("<p>Welcome to REASG</p>"); //For this example lets override where we look for views and templates //in a regular setup we do not need to do this if our files are in the views folder rea_views::setViewsPath(REA_SELF_DIRECTORY); $view_name = isset($values['view']) ? $values['view'] : 'view_test3'; $view = rea_view::create($view_name); //$view->body->write("this is the body<br>"); //$out = $view->getHTML(); //print htmlentities($out); $page->body->write($view); }