_doc) { $this->_doc = Zend_Registry::get('doc'); } return $this->_doc; } public function getRootFullAlias() { if (empty($this->_rootFullAlias)) { $this->_rootFullAlias = Qs_SiteMap::findFirst($this->getSitemapSelector(true), 'fullAlias'); } return $this->_rootFullAlias; } public function setRestAlias($params) { $this->_restAlias = $params; return $this; } /** * @param string $sitemapSelector Qs_SiteMap string selector * @return App_ECommerce_Order_Admin_Tab */ public function setSitemapSelector($sitemapSelector) { $this->_sitemapSelector = $sitemapSelector; return $this; } public function getSitemapSelector($forceException = false) { if ($forceException && empty($this->_sitemapSelector)) { throw new Qs_Exception('Sitemap selector for root full alias is not set.'); } return $this->_sitemapSelector; } public function getDefaultTabAlias() { $tabs = $this->getTabs(); if ($tabs) { return current(array_keys($tabs)); } return $tabs; } /** * Return tabs items * * @return array|bool */ public function getTabs() { if (null === $this->_tabs) { $rootAlias = $this->getRootFullAlias(); $page = Qs_SiteMap::getPage($rootAlias); $this->_tabs = (!empty($page['sub']) ? $page['sub'] : false); } return $this->_tabs; } public function getNextTabAlias() { $breakNext = false; $result = false; foreach ($this->getTabs() as $tab) { if ($breakNext) { $result = $tab['fullAlias'] . '/' . $this->getRestAlias(); break; } if ($tab['fullAlias'] == CURRENT_PAGE_FINAL) { $breakNext = true; } } return $result; } /** * Initializing tabs * * @return App_ECommerce_Order_Admin_Tab */ public function addTabs() { $tabs = $this->getTabs(); if ($tabs) { foreach ($tabs as &$pageSub) { $this->_prepareTab($pageSub); $pageSub += array('restAlias' => $this->getRestAlias()); } $item = array( 'tpl' => $this->_getTemplate('tabs.tpl'), 'items' => $tabs, 'currentTab' => ($parts = explode('/', CURRENT_PAGE_FINAL)) ? end($parts) : null, ); $this->_getDoc()->addItem($item, self::TAB_ITEM); } return $this; } protected function _prepareTab(array &$tab) { if (!empty($tab['items'])) { foreach ($tab['items'] as $pageSubItem) { $class = 'App_' . $pageSubItem['type'] . 'Obj'; if (class_exists($class)) { $classObj = new $class(); if (method_exists($classObj, 'isValidTab')) { if (!$classObj->isValidTab($this->getRestAlias())) { unset($tab['url']); } } } } } return $this; } public function getRestAlias() { if (empty($this->_restAlias)) { return str_replace($this->_getDoc()->getOption('fullAlias') . '/', '', CURRENT_PAGE); } return $this->_restAlias; } public function setTemplatePath($patch) { $this->_templatePatch = $patch; return $this; } public function getTemplatePath() { if (!empty($this->_templatePatch)) { return $this->_templatePatch; } return false; } /** * Return template patch * * @param string $template * @return string */ protected function _getTemplate($template) { if (false !== ($templatePath = $this->getTemplatePath())) { return Qs_SiteMap::getTemplate($template, $this->getTemplatePath()); } return $this->_getDoc()->getTemplate($template); } }