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; }