public function __construct() { $mdlPage = new Model_Page(); $mdlContentNode = new Model_PageNode(); $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($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); } } } }
/** * Constructor * * @param object $item A Zend_Db_Table_Row object */ public function __construct(Zend_Db_Table_Row $item) { $this->_innerItem = $item; $this->label = Digitalus_Toolbox_Page::getLabel($item); $this->link = Digitalus_Toolbox_Page::getUrl($item); $this->id = $this->_innerItem->id; if ($item->show_on_menu) { $this->visible = true; } else { $this->visible = false; } $page = new Model_Page(); if ($page->hasChildren($item)) { $this->hasSubmenu = true; } else { $this->hasSubmenu = false; } }
/** * Get Page data as array * * @return array Returns an array of the page data, otherwise an empty array */ protected function _getPageAsArray($item = null) { if (empty($item)) { $item = $this->getItem(); } $baseUrl = $this->view->baseUrl(); $mdlMenu = new Model_Menu(); $page = array('active' => $this->isActive(false), 'class' => 'menuItem', 'id' => $item->id, 'label' => Digitalus_Toolbox_Page::getLabel($item), 'name' => $item->name, 'resource' => strtolower(Digitalus_Toolbox_String::replaceEmptySpace($item->name)), 'title' => Digitalus_Toolbox_Page::getLabel($item), 'uri' => $baseUrl . '/' . Digitalus_Toolbox_String::replaceEmptySpace(Digitalus_Toolbox_Page::getUrl($item)), 'visible' => $this->isVisible($item)); $subPages = array(); if ($mdlMenu->hasChildren($this->id)) { $children = $mdlMenu->getChildren($this->id); foreach ($children as $child) { $subPages[] = new Digitalus_Menu_Item(null, $child); } $page['pages'] = $subPages; } return $page; }