array('title', 'excerpt', 'rawContent')); protected $_nullableFields = ['author']; protected $_action = null; public function initFromForm(array $data) { if (!$this->getPrimaryKey()) { $data['createdById'] = $this->getUserInfo('createdById'); } return parent::initFromForm($data); } 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; } protected function _updateDependency() { Qs_Event_Dispatcher::getInstance()->dispatch('postPublish', null, $this); self::cleanCache(); return $this; } protected function _insertDependency() { Qs_Event_Dispatcher::getInstance()->dispatch('postPublish', null, $this); self::cleanCache(); return $this; } protected function _deleteDependency() { Qs_Event_Dispatcher::getInstance()->dispatch('postDelete', null, $this); self::cleanCache(); return $this; } public function changeEnumOption($name) { Qs_Event_Dispatcher::getInstance()->dispatch('postPublish', null, $this); self::cleanCache(); return parent::changeEnumOption($name); } }