/** * @brief Load and display a view * * */ static function load($view, $ctl = null) { if (!headers_sent()) { response::contentType("text/html; charset=utf-8"); } if (!self::$_primaryview) { if (config::get(self::KEY_EMBED_EXCEPTION, false) == true) { ob_start(); } self::$_primaryview = $view; } // Go over the registered handlers and see which one match the file name foreach ((array) View::$_handlers as $handler => $match) { if (preg_match('%' . $match . '%', $view)) { $vc = new $handler(); // If controller is specified, get its state if ($ctl && count($ctl->getState()) > 0) { $vc->setViewData($ctl->getState()); } $vc->setViewData(View::$_viewdata); $vc->loadView($view); $vc->display(); return true; } } // If we end up here, no handler could be found. throw new ViewHandlerNotFoundException("No matching handler found for requested view"); }