public static function renderView($viewFile, $template, $variables, $script, $function) { /* API (for example) needs to disable view rendering */ if (defined("MVC_DISABLE_VIEW_RENDERING")) { return; } /* * See which channel we should be using. If the configuration file contains the AUTO_CHANNEL_SELECTION * configuration, we set the channel accordingly using the host name. */ $channel = "web"; if (property_exists('AppConfiguration', 'AUTO_CHANNEL_SELETION')) { if (AppConfiguration::$AUTO_CHANNEL_SELECTION[$_SERVER['HTTP_HOST']]) { $channel = AppConfiguration::$AUTO_CHANNEL_SELECTION[$_SERVER['HTTP_HOST']]; } } $view = new View(WEBAPP_ROOT . "/views/{$channel}/{$script}/{$viewFile}.php", $channel); if (!file_exists($view->path)) { ControllerErrors::missingView($script, $function, "WEBAPP_ROOT/views/{$channel}/" . $script . "/" . $viewFile . ".php"); } /* * Render the view using the variable set by the controller */ $content_for_template = $view->render($variables, $script, $function); /* * Get the template that we're using */ if (empty($template)) { $template = "default"; } $layoutFile = WEBAPP_ROOT . "/templates/" . $template . ".phtml"; if (!file_exists($layoutFile)) { controllerErrors::missingTemplate("webapp/templates/" . $template . ".phtml"); } /* * Include the layoutfile */ $view->showTemplate($layoutFile); }