Example #1
0
 public function approve()
 {
     $identity = Zend_Auth::getInstance()->getIdentity();
     $db = Zend_Registry::get('db');
     $approved = array('approved' => 1, 'reviewer_id' => $identity->getId(), 'date_revised' => new Zend_Db_Expr('NOW()'));
     $db->update('PageRev', $approved, 'revision_id = ' . $this->getId());
     $page = new SxCms_Page();
     $page->setId($this->getPageId())->loadState();
     $page->setLanguage($this->getLanguage())->setTitle($this->getTitle())->setTitleFallback($this->hasTitleFallback())->setSummary($this->getSummary())->setSummaryFallback($this->hasSummaryFallback())->setContent($this->getContent())->setContentFallback($this->hasContentFallback())->setSource($this->getSource())->setSourceFallback($this->hasSourceFallback())->setLink($this->getLink())->setInvisible($this->getInvisible())->setSeoTitle($this->getSeoTitle())->setSeoTags($this->getSeoTags())->setSeoDescription($this->getSeoDescription());
     $page->publish();
 }
Example #2
0
 /**
  * Returns a list of comments for a specific page
  * 
  * @param SxCms_Page $page
  * @return array
  */
 public function getCommentsByPage(SxCms_Page $page)
 {
     $id = (int) $page->getId();
     $db = Zend_Registry::get('db');
     $select = $db->select()->from('PageComment', array('*'))->where('page_id = ?', $id)->where('approved = 1')->order('datePosted DESC');
     $stmt = $db->query($select);
     $result = $stmt->fetchAll();
     $comments = array();
     foreach ($result as $row) {
         $comment = $this->toObject($row);
         $comments[$comment->getId()] = $comment;
     }
     return $comments;
 }
Example #3
0
 public function map($page, $map = null)
 {
     if (!$page) {
         return new SxCms_Page();
     }
     $pageObject = $map ? $map : new SxCms_Page();
     $pageObject->setId($page['page_id'])->setLayout($page['layout'])->setType($page['type'])->setLocked($page['locked_by'], $page['date_locked'])->setDateCreated($page['date_created'])->setDatePublished($page['date_published'])->setDateExpired($page['date_expired'])->setLanguage($page['language'])->setTitle($page['title'])->setTitleFallback($page['title_fb'])->setSummary($page['summary'])->setSummaryFallback($page['summary_fb'])->setContent($page['content'])->setContentFallback($page['content_fb'])->setSource($page['source'])->setSourceFallback($page['source_fb'])->setLink($page['link'])->setLinkFallback($page['link_fb'])->setThumb($page['thumb'])->setNavigation($page['navigation'])->setSitemap($page['sitemap'])->setAllowComments($page['comments'])->setInvisible($page['invisible'])->setSeoTitle($page['seotitle'])->setSeoTags($page['seotags'])->setSeoDescription($page['seodescription']);
     if ($page['final']) {
         $pageObject->markTranslationInvalid();
     }
     $parentPage = new SxCms_Page();
     $parentPage->setId($page['parent_id']);
     $parentPage->setLanguage($page['language']);
     $pageObject->setParent($parentPage);
     return $pageObject;
 }
Example #4
0
 public function save()
 {
     $cache = Zend_Registry::get('cache');
     $cache->clean(Zend_Cache::CLEANING_MODE_ALL);
     $db = Zend_Registry::get('db');
     if ($this->getType() == self::EXTERNAL) {
         $this->setLayout(null)->setSource(null)->setContent(null);
     }
     if ($this->getType() == self::ARTICLE) {
         $this->setLayout('default');
     }
     $identity = Zend_Auth::getInstance()->getIdentity();
     $pageData = array('parent_id' => (int) $this->getParent()->getId(), 'author_id' => $identity->getId(), 'layout' => $this->getLayout(), 'navigation' => (int) $this->isInNavigation(), 'type' => (int) $this->getType(), 'sitemap' => (int) $this->isInSitemap(), 'comments' => (int) $this->allowComments(), 'locked_by' => 0, 'date_locked' => '0000-00-00 00:00:00', 'date_published' => $this->getDatePublished(), 'date_expired' => $this->getDateExpired(), 'date_updated' => new Zend_Db_Expr('NOW()'));
     if (null !== $this->getThumb()) {
         $pageData['thumb'] = $this->getThumb();
     }
     if ($this->getId() !== false) {
         // strict checking, ID can be 0 (homepage)
         $db->delete('PageAcl', 'page_id = ' . $this->getId());
         foreach ($this->_permissions as $group) {
             $gData = array('page_id' => $this->_id, 'group_id' => $group->getId());
             $db->insert('PageAcl', $gData);
         }
         $orig = new SxCms_Page();
         $orig->setId($this->getId())->loadState();
         $x = $orig->getParent()->getId() !== $this->getParent()->getId();
         if ($x or $this->getLeft() xor $this->getRight()) {
             if ($this->getType() != self::ARTICLE) {
                 $this->getXmlMapper()->move($this->getId(), $this->getParent()->getId(), $this->getLeft(), $this->getLeft() ? true : false)->save();
             }
         }
         if ($this->getType() != self::EXTERNAL && $this->_id != 0) {
             $this->setLink($this->_createUrl($this->getLanguage()));
         }
         return $db->update('Page', $pageData, 'page_id = ' . $this->_id);
     }
     $pageData['date_created'] = new Zend_Db_Expr('NOW()');
     $db->insert('Page', $pageData);
     $this->setId($db->lastInsertId());
     foreach ($this->_permissions as $group) {
         $gData = array('page_id' => $this->_id, 'group_id' => $group->getId());
         $db->insert('PageAcl', $gData);
     }
     if ($this->getType() != self::ARTICLE) {
         $this->getXmlMapper()->add($this->getId(), $this->getParent()->getId(), $this->_cleanTitle($this->getTitle()), $this->getLeft(), $this->getLeft() ? true : false)->save();
     }
     $this->publish();
     return true;
 }
Example #5
0
 public function previewAction()
 {
     SxCms_Acl::requireAcl('page', 'page.preview');
     $pageId = (int) $this->_getParam('id');
     $page = new SxCms_Page();
     $page->setId($pageId)->loadState(SxCms_Page::STATE_LIVE);
     $this->_helper->actionStack('content', 'index', 'default', array('url' => $page->getLink()));
 }