/** * Page reparsen und updaten * * @param Cms\Data\Page $page * @param Cms\Data\Template $template * @param string $reparseType */ public static function reparseAndUpdatePage(Page &$page, Template $template, $reparseType = self::TYPE_REPARSE) { // Content reparsen $newPageContent = array(); $newPageContent = self::reparseContent($page->getWebsiteid(), $page->getContent(), $page->getTemplatecontent(), $template->getContent(), $reparseType); // Page mit den neuen Werten updaten $page->setContent(\Zend_Json::encode($newPageContent)); $page->setTemplatecontent($template->getContent()); $page->setTemplatecontentchecksum($template->getContentchecksum()); // Page speichern $pageBusiness = new \Cms\Business\Page('Page'); $pageBusiness->update($page->getId(), $page->getWebsiteId(), array('content' => \Zend_Json::encode($newPageContent), 'templatecontent' => $template->getContent(), 'templatecontentchecksum' => $template->getContentchecksum())); return true; }
/** * Content einer Page anhand eines Templates durch Reparsen erzeugen * * @param Cms\Data\Template $template */ public function generateNewPageContent(\Cms\Data\Template $template) { try { $newPageContent = Reparser::reparseContent($template->getWebsiteid(), '', '', $template->getContent(), Reparser::TYPE_NEW); } catch (\Exception $e) { $newPageContent = array(); $data = method_exists($e, 'getData') ? $e->getData() : array(); \Cms\ExceptionStack::addException(new \Cms\Exception(803, __METHOD__, __LINE__, $data, $e)); } return $newPageContent; }
/** * @param \Cms\Data\Template $data */ protected function setValuesFromData(TemplateData $data) { $this->setId($data->getId()); $this->setWebsiteId($data->getWebsiteId()); $this->setName($data->getName()); $this->setContent($data->getContent()); $this->setPageType($data->getPageType()); $this->setScreenshot(); }