isPagePreviewMode() || $this->getAuthIdentity()) && $this->_hasNavigationBlock) { $this->_initNavigationBlock(); $this->_initQuestionForm(); } return $this; } public function hasNavigationBlock($value) { $this->_hasNavigationBlock = (bool) $value; return $this; } protected function _initQuestionForm() { $view = new App_Form_Question_View(); $view->setDoc($this); $view->addFormItem(); return $this; } protected function _initNavigationBlock() { $item = [ 'menu' => $this->_getUserNavigationList(), 'active' => $this->getOption('id'), 'tpl' => $this->getTemplate('navigation-block.tpl'), ]; $item['activeItems'] = []; $this->_getActiveIds($item['menu'], $item['activeItems']); $this->addItem($item, 'LEFT_ITEMS'); return $this; } protected function _getActiveIds(array $menu, array &$ids) { $currentId = $this->getOption('id'); foreach ($menu as $item) { if (!empty($item['sub'])) { if ($this->_getActiveIds($item['sub'], $ids)) { $ids[] = $item['id']; return true; } } if ($item['id'] == $currentId) { $ids[] = $currentId; return true; } } return false; } }