/** * * @return string $viewTemplatePath */ public function render() { $viewTemplatePath = $this->app->getConfig('app.path') . DIRECTORY_SEPARATOR . 'templates' . DIRECTORY_SEPARATOR . $this->name . '.btmp'; if (!file_exists($viewTemplatePath)) { $this->app->log("ViewTemplateDoesNotExistException thrown\n\tThe template {$this->name} does not exist or is not readable", 'cache'); throw new bikes_ViewTemplateDoesNotExistException('The template ' . $this->name . ' does not exist or is not readable'); } return $viewTemplatePath; }
/** * Turns on output buffering, loads the main template into the buffer and iterates * through the views and renders them. Each rendered view is stored in an output buffer, * then the main template buffer regions are string replaced with the view content. * * @return string $layoutBuffer */ public function render() { $bikesFlash = $this->app->getFlash(); $title = $this->pageTitle; $this->loadHelpers(); if (!empty($this->loadedHelpers)) { foreach (array_keys($this->loadedHelpers) as $helper) { $helper_lower = strtolower($helper); ${$helper_lower} = $this->loadedHelpers[$helper]; } } $this->startOutputBuffer(); if (empty($this->useLayout)) { $templateName = $this->app->getConfig('layout.default'); } else { $templateName = $this->useLayout . '.btmp'; } $template = $this->app->getConfig('app.path') . DS . 'templates' . DS . $templateName; if (!file_exists($template)) { $this->app->log("Template is not readable or the file does not exist.\n\tPlease set a correct template name in the config.ini value `layout.default`", 'cache'); throw new bikes_TemplateIsNotThereException('Template ' . $templateName . ' does not exist.'); } include $template; $layoutBuffer = $this->getAndCleanOutputBuffer(); if (!empty($this->viewData)) { extract($this->viewData); } foreach ($this->views as $region => $view) { include $view->render(); $viewBuffer = $this->getAndCleanOutputBuffer(); $layoutBuffer = str_replace('<--{' . $region . '}-->', $viewBuffer, $layoutBuffer); unset($content); } $this->endOutputBuffer(); return $layoutBuffer; }