/** * Displays the view after (optionally) render function in a presenter has been executed. * @param string $viewName View name to display * @param string $contentType Specifies optional content type for the view * @param string $extraParam Extra parameter to find the view by */ public function render($viewName) { assert('strlen($viewName) > 0; // view name cannot be empty'); // form views path $path = BASEPATH . '/' . APP_DIR . '/views/'; // create template file path $viewFile = $path . $viewName . self::VIEW_SUFFIX; // check if view exists $this->isViewValid($viewFile); // are we using a @layout file? $temp = explode('/', $viewName); assert('count($temp) == 2; // $viewName needs to consist of "presenter/file"'); // define presenter name for easy access Fari_ApplicationViewHelper::setPresenter($temp[0]); // custom layout named after our presenter if (file_exists($layout = $path . '@' . strtolower($temp[0]) . self::VIEW_SUFFIX)) { $this->includeLayoutAndView($layout, $viewFile); // application level layout } else { if (file_exists($layout = $path . '@application' . self::VIEW_SUFFIX)) { $this->includeLayoutAndView($layout, $viewFile); } else { // import key:value array into symbol table extract($this->values, EXTR_SKIP); // no soup for you! $devMode = Fari_ApplicationEnvironment::isDevelopment(); if ($devMode) { echo "\n<!-- begin {$viewFile} -->\n"; } include $viewFile; if ($devMode) { echo "\n<!-- end {$viewFile} -->\n"; } } } }
/** * Set presenter name. * @param string $presenterName */ public static function setPresenter($presenterName) { self::$presenter = $presenterName; }