db->select(); $select->from($this->_getTableName("{$this->_tableAlias}2Page"), 'idPage') ->where('`idAppFile` = ' . $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('idAppFile = ' . $this->_db->quote($item['id'], 'integer')); $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; } return $this; } protected function _insertDependency() { $this->_updateDependency(); } protected function _updateDependency() { $this->_updateIds( $this->_getTableName("{$this->_tableAlias}2Page"), 'idAppFile', 'idPage', $this->_data['idPage'] ); return $this; } public function delete() { $this->_deleteIds($this->_getTableName("{$this->_tableAlias}2Page"), 'idAppFile'); return parent::delete(); } public function getSitePage($level = 1) { $cmsObj = new App_Cms_Obj(); $select = $cmsObj->getSelect4SiteMap(); $select->where("`Page`.`isRoot` = 'n'"); $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) { if ($page['handler'] == 'site') { $options[$page['id']] = str_repeat('    ', $level) . htmlspecialchars($page['menuTitle']); if (isset($page['sub'])) { $subOptions = $this->_prepareParentOptions($page['sub'], $level + 1); $options = Qs_Array::mergeAssoc($options, $subOptions); } } } return $options; } }