_db->select(); $select->from($this->_getTableName("{$this->_tableAlias}2Page"), 'idPage') ->where('`idRightBlock` = ' . $this->_db->quote($data['id'], 'integer')); $data['idPage'] = $this->db->fetchCol($select); if (!is_array($data['idPage'])) { $data['idPage'] = array(); } return $this; } protected function _prepareList(&$list) { parent::_prepareList($list); $sitePage = $this->getSitePage(0); foreach ($list as &$item) { $page_list = array(); $select = $this->_db->select(); $select->from($this->_getTableName("{$this->_tableAlias}2Page"), 'idPage') ->where('idRightBlock = ' . $this->_db->quote($item['id'])); $pageIds = $this->db->fetchCol($select); foreach ($pageIds as $v) { if (empty($sitePage[$v])) { continue; } $page_list[] = $sitePage[$v]; } sort($page_list); $item['pageList'] = $page_list; if ($item['blockType'] == 'news') { $item['news'] = $this->getNewsList(); } } return $this; } protected function _insertDependency() { $this->_updateDependency(); } protected function _updateDependency() { $this->_updateIds( $this->_getTableName("{$this->_tableAlias}2Page"), 'idRightBlock', 'idPage', $this->_data['idPage'] ); return $this; } public function delete() { $this->_deleteIds($this->_getTableName("{$this->_tableAlias}2Page"), 'idRightBlock'); return parent::delete(); } public function getSitePage($level = 1) { $cmsObj = new App_Cms_Obj; $select = $cmsObj->getSelect4SiteMap(); $select->where("`Page`.`id` > 1 AND `Page`.`id` <> " . (int) $cmsObj->getPrimaryKey()); $select->where("`Page`.`hasBlocks` = 'y'"); $select->where("`Page`.`handler` = 'site'"); $siteMap = $cmsObj->getSiteMap(array('select' => $select)); $options = $this->_prepareParentOptions($siteMap, $level); return $options; } protected function _prepareParentOptions($siteMap, $level = 0) { $options = array(); foreach ($siteMap as $page) { $options[$page['id']] = $page['menuTitle']; if (isset($page['sub'])) { $subOptions = $this->_prepareParentOptions($page['sub']); $options = Qs_Array::mergeAssoc($options, $subOptions); } } return $options; } }