function view($view_name, array $var_list = NULL, array $block_list = NULL)
    {
        if($var_list === NULL) {
            $var_list = array(); // Avoids notices.
        }
        $vars = (object)$var_list;
        $blocks = (object)$block_list;

        if($hook_data = $this->modules->preView($this->request, $view_name, $vars)) {
            return $hook_data;
        }

        $serv = $this->server;
        $me = $this;
        $parent_tpl = false;
        $current_block = false;
        $helpers = new \stdClass();

        // Little hack to access urls easier.
        $url = function($url) use($serv) {
            return $serv->siteUrl($url);
        };

        $load_helper = function($helper_name) use(&$helpers, &$me) {
            $helpers->{$helper_name} = $me->helper($helper_name);
        };

        $startblock = function($name) use(&$current_block) {
            $current_block = $name;
            ob_start();
        };

        $endblock = function() use(&$block_list, &$current_block) {
            $block_list[$current_block] = ob_get_clean();
            $current_block = false;
        };

        $inherit = function($template) use(&$parent_tpl) {
            $parent_tpl = $template;
        };
        
        $clean = function($val, $placeholder='-') {
            return \assegai\Utils::cleanFilename($val, $placeholder);
        };

        $template_path = false;

        // Shorthands
        $h = &$helpers;

        ob_start();

        $template_path = $this->server->getRelAppPath('views/' . $view_name . '.phtml');
        if(!file_exists($template_path)) {
            $template_path = $this->server->main->get('templates_path') . '/' . $view_name . '.phtml';
        }
        
        // Traditional PHP template.
        require($template_path);

        $data = ob_get_clean();

        if($hook_data = $this->modules->postView($this->request, $view_name, $vars, $data)) {
            return $hook_data;
        }

        if($parent_tpl) {
            return $this->view($parent_tpl, $var_list, $block_list);
        }

        return $data;
    }
function view($view_name, array $var_list = NULL, array $block_list = NULL)
    {
        if($var_list === NULL) {
            $var_list = array(); // Avoids notices.
        }
        $vars = (object)$var_list;
        $blocks = (object)$block_list;

        if($hook_data = $this->modules->preView($this->request, $view_name, $vars)) {
            return $hook_data;
        }

        $serv = $this->server;
        $me = $this;
        $parent_tpl = false;
        $current_block = false;
        $helpers = new \stdClass();

        // Little hack to access urls easier.
        $url = function($url) use($serv) {
            return $serv->siteUrl($url);
        };

        $load_helper = function($helper_name) use(&$helpers, &$me) {
            $helpers->{$helper_name} = $me->helper($helper_name);
        };

        $startblock = function($name) use(&$current_block) {
            $current_block = $name;
            ob_start();
        };

        $endblock = function() use(&$block_list, &$current_block) {
            $block_list[$current_block] = ob_get_clean();
            $current_block = false;
        };

        $inherit = function($template) use(&$parent_tpl) {
            $parent_tpl = $template;
        };
        
        $clean = function($val, $placeholder='-') {
            return \assegai\Utils::cleanFilename($val, $placeholder);
        };

        $template_path = false;

        // Shorthands
        $h = &$helpers;

        ob_start();

        $template_path = $this->server->getRelAppPath('views/' . $view_name . '.phtml');
        if(!file_exists($template_path)) {
            $template_path = $this->server->main->get('templates_path') . '/' . $view_name . '.phtml';
        }
        
        // Traditional PHP template.
        require($template_path);

        $data = ob_get_clean();

        if($hook_data = $this->modules->postView($this->request, $view_name, $vars, $data)) {
            return $hook_data;
        }

        if($parent_tpl) {
            return $this->view($parent_tpl, $var_list, $block_list);
        }

        return $data;
    }
function view ( $ view_name , array $ var_list = NULL , array $ block_list = NULL ) { if ( $ var_list === NULL ) { $ var_list = array ( ) ; // Avoids notices. } $ vars = ( object ) $ var_list ; $ blocks = ( object ) $ block_list ; if ( $ hook_data = $ this -> modules -> preView ( $ this -> request , $ view_name , $ vars ) ) { return $ hook_data ; } $ serv = $ this -> server ; $ me = $ this ; $ parent_tpl = false ; $ current_block = false ; $ helpers = new \ stdClass ( ) ; // Little hack to access urls easier. $ url = function ( $ url ) use ( $ serv ) { return $ serv -> siteUrl ( $ url ) ; } ; $ load_helper = function ( $ helper_name ) use ( & $ helpers , & $ me ) { $ helpers -> { $ helper_name } = $ me -> helper ( $ helper_name ) ; } ; $ startblock = function ( $ name ) use ( & $ current_block ) { $ current_block = $ name ; ob_start ( ) ; } ; $ endblock = function ( ) use ( & $ block_list , & $ current_block ) { $ block_list [ $ current_block ] = ob_get_clean ( ) ; $ current_block = false ; } ; $ inherit = function ( $ template ) use ( & $ parent_tpl ) { $ parent_tpl = $ template ; } ; $ clean = function ( $ val , $ placeholder = '-' ) { return \ assegai \ Utils :: cleanFilename ( $ val , $ placeholder ) ; } ; $ template_path = false ; // Shorthands $ h = & $ helpers ; ob_start ( ) ; $ template_path = $ this -> server -> getRelAppPath ( 'views/' . $ view_name . '.phtml' ) ; if ( ! file_exists ( $ template_path ) ) { $ template_path = $ this -> server -> main -> get ( 'templates_path' ) . '/' . $ view_name . '.phtml' ; } // Traditional PHP template. require ( $ template_path ) ; $ data = ob_get_clean ( ) ; if ( $ hook_data = $ this -> modules -> postView ( $ this -> request , $ view_name , $ vars , $ data ) ) { return $ hook_data ; } if ( $ parent_tpl ) { return $ this -> view ( $ parent_tpl , $ var_list , $ block_list ) ; } return $ data ; }
Loads a view.
Loads a view .