_db->select(); $select->from($this->_getTableName($this->_tableAlias . '2Page'), 'idPage') ->where('`idSideBlock` = ' . $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); $sitePages = $this->getSitePages(0); $blocksPages = $this->_getBlocksPages(); foreach ($list as &$block) { if (App_SideBlock_Obj::TYPE_HTML !== $block['blockType']) { $block['content'] = Qs_Array::get(App_SideBlock_View::$blockTypeTitles, $block['blockType'], ''); } $block['pageList'] = array(); foreach ($blocksPages as $blockPage) { if ($blockPage['idSideBlock'] == $block['id']) { $block['pageList'][] = str_replace(' ', '', $sitePages[$blockPage['idPage']]); } } sort($block['pageList']); } return $this; } protected function _insertDependency() { $this->_updateDependency(); } protected function _updateDependency() { $this->_updateIds( $this->_getTableName($this->_tableAlias . '2Page'), 'idSideBlock', 'idPage', $this->_data['idPage'] ); return $this; } public function delete() { $this->_deleteIds($this->_getTableName($this->_tableAlias . '2Page'), 'idSideBlock'); return parent::delete(); } public function getSitePages() { $cmsObj = new App_Cms_Obj; $list = $cmsObj->getPages4Select(); foreach ($list as &$row) { $row = str_replace(' ', '', $row); } return $list; } protected function _getBlocksPages() { $select = $this->_db->select(); $select->from($this->_getTableName($this->_tableAlias . '2Page'), '*'); return $this->_db->fetchAll($select); } public function getBlockCountByType($type, $id = null) { $select = $this->_db->select(); $select->from($this->_getPair(), array('count' => 'COUNT(*)')); $select->where('`blockType` = ?', $type); if (null !== $id) { $select->where('`id` != ?', $id); } $select->limit(1); return $this->_db->fetchOne($select); } }