/** * Is the layout valid? * * @param string $value Page to validate * * @return bool */ public function isValid($value) { $this->setValue($value); if (!$this->layoutManager->isLayoutValid($this->currentSite, $value)) { $this->error(self::MAIN_LAYOUT); return false; } return true; }
/** * Initialize the form * * @return void * @SuppressWarnings(PHPMD.ExcessiveMethodLength) */ public function init() { $pageList = $this->pageRepo->getAllPageIdsAndNamesBySiteThenType($this->currentSite->getSiteId(), 't'); $pageList['blank'] = 'Blank Page (Experts Only)'; $filter = new InputFilter(); $this->add(['name' => 'url', 'options' => ['label' => 'Page Url'], 'type' => 'text']); $filter->add(['name' => 'url', 'required' => true, 'filters' => [['name' => 'StripTags'], ['name' => 'StringTrim', 'options' => ['charlist' => '-_']]], 'validators' => [$this->pageValidator]]); $this->add(['name' => 'title', 'options' => ['label' => 'Page Title'], 'type' => 'text']); $filter->add(['name' => 'title', 'required' => true, 'filters' => [['name' => 'StripTags'], ['name' => 'StringTrim']], 'validators' => [['name' => '\\Zend\\I18n\\Validator\\Alnum', 'options' => ['allowWhiteSpace' => true]]]]); $this->add(['name' => 'page-template', 'options' => ['label' => 'Page Template', 'value_options' => $pageList], 'type' => 'Zend\\Form\\Element\\Select']); $filter->add(['name' => 'page-template', 'required' => true, 'filters' => [['name' => 'StripTags'], ['name' => 'StringTrim']], 'validators' => [$this->templateValidator]]); $this->add(['name' => 'main-layout', 'options' => ['label' => 'Main Layout', 'layouts' => $this->layoutManager->getSiteThemeLayoutsConfig($this->currentSite->getTheme())], 'type' => 'mainLayout']); $filter->add(['name' => 'main-layout', 'filters' => [['name' => 'StripTags'], ['name' => 'StringTrim']], 'validators' => [$this->layoutValidator]]); $this->setInputFilter($filter); }
/** * prepLayoutView * * @param Site $site * @param Page $page * @param $requestedPageData * @param $layoutOverRide * * @return void */ protected function prepLayoutView(Site $site, Page $page, $requestedPageData, $layoutOverRide) { /** @var ViewModel $layoutView */ $layoutView = $this->layout(); if (!empty($layoutOverRide)) { $layoutTemplatePath = $this->layoutManager->getSiteLayout($page->getSite(), $layoutOverRide); $layoutView->setTemplate('layout/' . $layoutTemplatePath); } if ($this->pageInfo['currentRevisionId'] != $this->pageInfo['revision']['revisionId']) { $layoutView->setVariable('rcmDraft', true); } $layoutView->setVariable('page', $page); $layoutView->setVariable('site', $site); $layoutView->setVariable('requestedPageData', $requestedPageData); }