function app_event_test_page($values) { global $config; $m = function ($page) { $page->body->write("here2"); }; rea_app_controller::on("default_page_commit", $m); $files = rea_app::bundle(); //lets create a bundle helper $page = rea_views::default_page(); $page->set("title", "Testing Views"); $page->body->write("this is the body<br>"); $page->css->addfile($files->css->child("test_view1.css")->url); //add one file $page->header->write($files->css->all()); //use all to add all the files in a folder $page->js->addfile($files->child("test_view1.js")->url); $page->js->write("console.log('hello');"); //inline js //we could insert files like this //$page->body->insert($files->child("test_view1.html")->path); //rea_view::setViewsPath( REA_SELF_DIRECTORY ); //$part = rea_template::create("nav_bar.part"); $page->set("part_test", $part); }
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; }
global $rea_route, $config, $rea_controller; //rea_app::on("rea_end", array("rea_app_controller", "commit")); if (function_exists('app_start')) { app_start($rea_route->details['values']); } $rea_controller->dispatchEvent('app_start', array($rea_route->details['values'])); global $app_extended_view_helpers; if (count($app_extended_view_helpers) > 0) { foreach ($app_extended_view_helpers as $a) { $a = '' . $a . '_extended_view_start'; if (function_exists($a)) { $a($rea_route->details['values']); } } } $fn = 'app_event_' . $rea_route->details['action']; if (function_exists($fn)) { $data = $fn($rea_route->details['values']); } $rea_controller->dispatchEvent($fn, array($rea_route->details['values'])); if (function_exists('app_end')) { app_end($rea_route->details['values']); } $rea_controller->dispatchEvent('app_end', array($rea_route->details['values'])); self::commit(); } } //find a better way to do this if (isset($rea_config['application_use_model']) && $rea_config['application_use_model']) { rea_app_controller::run(); }