Exemple #1
0
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);
}
Exemple #2
0
 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;
 }