public function getViewer($action) { if (empty($action)) { throw new ControllerTest_SubController_Exception("Null action passed, getViewer will break"); } return parent::getViewer($action); }
/** * Return an SSViewer object to render the template for the current page. * * @param $action string * * @return SSViewer */ public function getViewer($action) { // Manually set templates should be dealt with by Controller::getViewer() if (isset($this->templates[$action]) && $this->templates[$action] || isset($this->templates['index']) && $this->templates['index'] || $this->template) { return parent::getViewer($action); } // Prepare action for template search if ($action == "index") { $action = ""; } else { $action = '_' . $action; } $templates = array_merge(SSViewer::get_templates_by_class(get_class($this->dataRecord), $action, "SiteTree"), SSViewer::get_templates_by_class(get_class($this), $action, "Controller"), SSViewer::get_templates_by_class(get_class($this->dataRecord), "", "SiteTree"), SSViewer::get_templates_by_class(get_class($this), "", "Controller")); return new SSViewer($templates); }
/** * Return an SSViewer object to render the template for the current page. * * @param $action string * * @return SSViewer */ public function getViewer($action) { // Manually set templates should be dealt with by Controller::getViewer() if (isset($this->templates[$action]) && $this->templates[$action] || isset($this->templates['index']) && $this->templates['index'] || $this->template) { return parent::getViewer($action); } // Prepare action for template search if ($action == "index") { $action = ""; } else { $action = '_' . $action; } // Find templates by dataRecord $templates = SSViewer::get_templates_by_class(get_class($this->dataRecord), $action, "SiteTree"); // Next, we need to add templates for all controllers $templates += SSViewer::get_templates_by_class(get_class($this), $action, "Controller"); // Fail-over to the same for the "index" action $templates += SSViewer::get_templates_by_class(get_class($this->dataRecord), "", "SiteTree"); $templates += SSViewer::get_templates_by_class(get_class($this), "", "Controller"); return new SSViewer($templates); }
/** * Custom templates for each of the sections. */ function getViewer($action) { // count the number of parameters after the language, version are taken // into account. This automatically includes ' ' so all the counts // are 1 more than what you would expect if ($this->ModuleName || $this->Remaining) { $paramCount = count($this->Remaining); if ($paramCount == 0) { return parent::getViewer('folder'); } else { if ($module = $this->getModule()) { $params = $this->Remaining; $path = implode('/', array_unique($params)); if (is_dir($module->getPath() . $path)) { return parent::getViewer('folder'); } } } } else { return parent::getViewer('home'); } return parent::getViewer($action); }
/** * Custom templates for each of the sections. */ function getViewer($action) { // count the number of parameters after the language, version are taken // into account. This automatically includes ' ' so all the counts // are 1 more than what you would expect if ($this->entity || $this->Remaining) { $paramCount = count($this->Remaining); if ($paramCount == 0) { return parent::getViewer('folder'); } else { if ($entity = $this->getEntity()) { // if this is a folder return the folder listing if ($this->locationExists() == 2) { return parent::getViewer('folder'); } } } } else { return parent::getViewer('home'); } return parent::getViewer($action); }