Exemplo n.º 1
0
 public function __construct()
 {
     $mdlPage = new Model_Page();
     $mdlContentNode = new Model_ContentNode();
     $select = $mdlPage->select();
     $select->where("namespace = 'content'");
     $pages = $mdlPage->fetchAll($select);
     if ($pages->count() > 0) {
         foreach ($pages as $page) {
             $contentNodes = $mdlContentNode->fetchContentObject($page->id);
             if (isset($contentNodes->content)) {
                 //if the page does not have content it doesnt belong in the index (eg blocks)
                 $title = $mdlPage->getPageTitle($page->id);
                 $link = Digitalus_Toolbox_Page::getUrl($page);
                 $link = strtolower(Digitalus_Toolbox_String::addHyphens($link));
                 $contentNodes = $mdlContentNode->fetchContentObject($page->id);
                 if (isset($contentNodes->teaser)) {
                     $teaser = $contentNodes->teaser;
                 } else {
                     $teaser = Digitalus_Toolbox_String::truncateText($contentNodes->content);
                 }
                 $content = $contentNodes->content;
                 $this->_addPage($link, $title, $teaser, $content);
             }
         }
     }
 }
Exemplo n.º 2
0
 public function updatePage($id, $data)
 {
     // find the page
     $row = $this->find($id)->current();
     if ($row) {
         // clear any cache records which are tagged to this page
         $cache = Zend_Registry::get('cache');
         $tag = 'page_' . $id;
         $cache->clean(Zend_Cache::CLEANING_MODE_MATCHING_TAG, array($tag));
         // update each of the columns that are stored in the pages table
         $row->name = $data['name'];
         $row->parent_id = $data['parent_id'];
         $row->save();
         // unset each of the fields that are set in the pages table
         unset($data['id']);
         unset($data['name']);
         unset($data['parent_id']);
         // set each of the other fields in the content nodes table
         if (count($data) > 0) {
             $mdlContentNode = new Model_ContentNode();
             foreach ($data as $key => $value) {
                 $mdlContentNode->setNode($id, $key, $value);
             }
         }
     } else {
         throw new Zend_Exception('Could not open page to update!');
     }
 }
Exemplo n.º 3
0
 public function deletePageById($pageId)
 {
     $this->_flushCache();
     $where[] = $this->_db->quoteInto('id = ?', $pageId);
     $this->delete($where);
     //delete content nodes
     unset($where);
     $mdlNodes = new Model_ContentNode();
     $where[] = $this->_db->quoteInto('parent_id = ?', 'page_' . $pageId);
     $mdlNodes->delete($where);
     //delete meta data
     $mdlMeta = new Model_MetaData();
     $mdlMeta->deleteByPageId($pageId);
 }
Exemplo n.º 4
0
 /**
  * Insert new ContentNode record
  * @param Garp_Util_Configuration $contentNodeData
  * @return Int The primary key
  */
 protected function _insertContentNode(Garp_Util_Configuration $contentNodeData)
 {
     $contentNodeModel = new Model_ContentNode();
     $contentNodeId = $contentNodeModel->insert(array('columns' => $contentNodeData['columns'], 'classes' => $contentNodeData['classes'], 'type' => $contentNodeData['type'], 'chapter_id' => $contentNodeData['chapter_id']));
     return $contentNodeId;
 }