view() public method

Load a module view *
public view ( $view, $vars = [], $return = FALSE )
Exemplo n.º 1
0
 /**
  *	Overloading this method so that if a view is supplied with the prefix of '/' then we
  *	load that view directly rather than try and do anythign clever with the path
  *
  **/
 public function view($view, $vars = array(), $return = FALSE)
 {
     if (strpos($view, '/') === 0) {
         //	The supplied view is an absolute path, so use it.
         //	Add on EXT if it's not there (so pathinfo() works as expected)
         if (substr($view, -4) != EXT) {
             $view .= EXT;
         }
         //	Get path information about the view
         $_pathinfo = pathinfo($view);
         $_path = $_pathinfo['dirname'] . '/';
         $_view = $_pathinfo['filename'];
         //	Set the view path so the loader knows where to look
         $this->_ci_view_paths = array($_path => TRUE) + $this->_ci_view_paths;
         //	Load the view
         return $this->_ci_load(array('_ci_view' => $_view, '_ci_vars' => $this->_ci_object_to_array($vars), '_ci_return' => $return));
     } else {
         //	Try looking in the application folder second - prevents Nails views being loaded
         //	over an application view.
         $_view = FCPATH . APPPATH . 'views/' . $view;
         if (substr($_view, -4) != EXT) {
             $_view .= EXT;
         }
         if (file_exists($_view)) {
             //	Try again with this view
             return $this->view($_view, $vars, $return);
         } else {
             //	Fall back to the old method
             return parent::view($view, $vars, $return);
         }
     }
 }