Exemple #1
0
 /**
  * @param  \Cms\Data\Page $result
  * @param string          $expectedData
  */
 protected function assertResultSuccess($result, $expectedData = '')
 {
     $this->assertInstanceOf('Cms\\Data\\Page', $result);
     $this->assertSame($result->getName(), $expectedData);
     $this->assertNotSame($result->getId(), $this->testEntry->getId());
     $this->assertSame($result->getWebsiteId(), $this->testEntry->getWebsiteId());
     $this->assertEquals($result->getPageType(), $this->testEntry->getPageType());
     $this->assertEquals($result->getPageAttributes(), $this->testEntry->getPageAttributes());
 }
Exemple #2
0
 /**
  * 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;
 }
Exemple #3
0
 /**
  * @param mixed          $content
  * @param string         $websiteId
  * @param string         $pageId
  * @param string         $mode
  * @param array          $globalContent
  * @param \Cms\Data\Page $page
  * @param null           $codeType
  */
 public function renderPageContent($content, $websiteId, $pageId, $mode, $globalContent, $page, $codeType = null)
 {
     // Check page content and stop/break nicely
     $content = $this->convertContentToArray($content);
     if (empty($content)) {
         return;
     }
     // create item meta data
     $currentItemInfo = array('id' => $pageId, 'websiteId' => $websiteId, 'name' => $page->getName(), 'pageType' => $page->getPageType(), 'description' => $page->getDescription(), 'date' => $page->getDate(), 'inNavigation' => $page->getInnavigation(), 'navigationTitle' => $page->getNavigationtitle(), 'globalContent' => $globalContent);
     $this->renderWithNewRenderer($content, $websiteId, $pageId, $mode, $currentItemInfo, $codeType, false);
 }
Exemple #4
0
 /**
  * @test
  * @group library
  */
 public function success()
 {
     $attributes = array('name' => 'new name', 'pageType' => 'the_new_page_type_id', 'pageAttributes' => (object) array('newKey' => 'newValue'));
     $this->assertNotEquals($attributes['name'], $this->testEntry->getName());
     $this->assertNotEquals($attributes['pageType'], $this->testEntry->getPageType());
     $this->assertNotEquals($attributes['pageAttributes'], json_decode($this->testEntry->getPageAttributes()));
     $lastUpdateBeforUpdate = $this->testEntry->getLastupdate();
     // kurz warten, damit updateTime geprueft werden kann (sonst ist Zeit zu kurz)
     sleep(1);
     $this->service->update($this->testEntry->getId(), $this->websiteId, $attributes);
     $page = $this->service->getById($this->testEntry->getId(), $this->websiteId);
     $this->assertEquals($attributes['name'], $page->getName());
     $this->assertEquals($attributes['pageType'], $page->getPageType());
     $this->assertEquals($attributes['pageAttributes'], json_decode($page->getPageAttributes()));
     // Timestamp der letzten Aenderung darf nicht aelter sein als ein paar Sekunden
     $this->assertNotNull($page->getLastupdate());
     $this->assertNotEquals($lastUpdateBeforUpdate, $page->getLastupdate());
     $currentTime = time();
     $this->assertLessThanOrEqual($currentTime, $page->getLastupdate());
     $this->assertGreaterThan($currentTime - 2, $page->getLastupdate());
 }
Exemple #5
0
 protected function setValuesFromData(PageData $data)
 {
     $this->setId($data->getId());
     $this->setWebsiteId($data->getWebsiteid());
     $this->setTemplateId($data->getTemplateid());
     $this->setMediaId($data->getMediaId());
     $this->setName($data->getName());
     $this->setDescription($data->getDescription());
     $this->setInNavigation($data->getInnavigation());
     $this->setDate($data->getDate());
     $this->setNavigationTitle($data->getNavigationtitle());
     $this->setContent($data->getContent());
     $this->setPageType($data->getPageType());
     $this->setPageAttributes($data->getPageAttributes());
     $this->setScreenshot();
 }
Exemple #6
0
 public function addPageToNavigation(Data\Page $page, $websiteId, $parentId, $insertBeforeId)
 {
     $dataPage = array('id' => $page->getId());
     $website = $this->getById($websiteId);
     $navigation = \Zend_Json::decode($website->getNavigation());
     $data = new \Seitenbau\ArrayData();
     $result = $data->insert($navigation, $dataPage, $parentId, $insertBeforeId);
     if ($result == false) {
         throw new CmsException(752, __METHOD__, __LINE__);
     }
     $result = \Zend_Json::encode($result);
     $attributes = array('navigation' => $result);
     $this->update($websiteId, $attributes);
     $result = array('id' => $page->getId(), 'navigation' => $result);
     return $result;
 }
Exemple #7
0
 /**
  * @param \Cms\Data\Page $result
  */
 protected function assertResultSuccess($result)
 {
     $this->assertInstanceOf('Cms\\Data\\Page', $result);
     $this->assertEquals($this->testEntry->toArray(), $result->toArray());
 }
Exemple #8
0
 /**
  * Fuegt in der Website-Navigation eine Page hinter eine andere angegebene
  * Page-ID ein
  *
  * @param \Orm\Entity\Page $insertPage
  * @param string $pageId
  * @return array  Neue Navigation
  */
 public function addPageToNavigationAfterPageId(Data\Page $insertPage, $pageId)
 {
     $dataPage = array('id' => $insertPage->getId());
     $website = $this->getService()->getById($insertPage->getWebsiteid());
     $navigation = \Zend_Json::decode($website->getNavigation());
     $data = new \Seitenbau\ArrayData();
     $newNavigation = $data->insertAfter($navigation, $dataPage, $pageId);
     $newNavigation = \Zend_Json::encode($newNavigation);
     $attributes = array('navigation' => $newNavigation);
     $this->getService()->update($insertPage->getWebsiteid(), $attributes);
     return $newNavigation;
 }
Exemple #9
0
 /**
  * @param  Data\Page $page
  * @return string
  */
 private function getPageJson(Data\Page $page)
 {
     $pageColumnsAndValues = $page->getExportColumnsAndValues();
     $pageJson = json_encode($pageColumnsAndValues);
     $this->extendingColorIds($page->getWebsiteid(), $pageJson);
     return $pageJson;
 }
 /**
  * @param string $pageId
  *
  * @throws \Exception
  * @return DataPage
  */
 protected function getDataPageObject($pageId)
 {
     $pageData = $this->getPageData($pageId);
     $page = new DataPage();
     $page->setWebsiteid($this->websiteId)->setId($pageId)->setName($pageData['name'])->setDescription($pageData['description'])->setNavigationtitle($pageData['navigationTitle'])->setInnavigation($pageData['inNavigation'] ? 1 : 0)->setDate($pageData['date'])->setGlobalContent(\json_encode($pageData['global']))->setPageType($pageData['pageType'])->setPageAttributes(\json_encode($pageData['pageAttributes']));
     return $page;
 }
Exemple #11
0
 /**
  * reparsing the page unsing specific template
  *
  * @param \Cms\Data\Page      $page
  * @param \Cms\Data\Template  $template
  * @return boolean
  */
 private function doReparsePage(\Cms\Data\Page $page, \Cms\Data\Template $template)
 {
     if ($page->getTemplatecontentchecksum() != $template->getContentchecksum()) {
         try {
             if (Reparser::reparseAndUpdatePage($page, $template)) {
                 return true;
             }
         } catch (\Exception $e) {
             $data = method_exists($e, 'getData') ? $e->getData() : array();
             $data['pageId'] = $page->getId();
             $data['pageName'] = $page->getName();
             throw new \Cms\Exception(801, __METHOD__, __LINE__, $data, $e);
         }
     }
     return false;
 }