array('title', 'excerpt', 'rawContent')); protected $_action = null; protected function _getCommentsCountSelect($status = null) { $tableAlias = 'pc'; if (null !== $status) { $tableAlias .= '_' . $status; } $select = $this->_db->select(); $select->from( array($tableAlias => $this->_getTableName($this->_tableAlias . 'Comment')), 'COUNT(`' . $tableAlias . '`.`id`)' ); $select->where("`{$tableAlias}`.`idPost` = `{$this->_tableAlias}`.`id`"); if (null !== $status) { $select->where("`{$tableAlias}`.`status` = ?", $status); } return $select; } protected function _getFromColumns() { $columns = parent::_getFromColumns(); $columns['comments'] = new \Zend_Db_Expr('(' . $this->_getCommentsCountSelect() . ')'); $columns['commentsPending'] = new \Zend_Db_Expr('(' . $this->_getCommentsCountSelect('pending') . ')'); $countTags = $this->_db->select(); $countTags->from(array('pt' => $this->_getTableName($this->_tableAlias . '2Tag')), 'COUNT(id)'); $countTags->where("pt.idPost = {$this->_tableAlias}.id"); $columns['tags']= new \Zend_Db_Expr('(' . $countTags . ')'); return $columns; } public function setAction($action) { $this->_action = $action; return $this; } public function initFromForm(array $data) { parent::initFromForm($data); if ('insert' == $this->_action && !empty($this->_userInfo)) { $this->_data['author'] = $this->_userInfo['author']; $this->_data['authorType'] = $this->_userInfo['authorType']; $this->_data['authorId'] = $this->_userInfo['authorId']; } return $this; } protected function _updateDependency() { self::cleanCache(); return $this; } protected function _insertDependency() { self::cleanCache(); return $this; } protected function _deleteDependency() { self::cleanCache(); return $this; } public function changeEnumOption($name) { self::cleanCache(); return parent::changeEnumOption($name); } }