select()->from($this->_name, array('Month' => 'DATE_FORMAT(pubDate,"%Y %M")', 'Date' => 'DATE_FORMAT(pubDate,"%Y-%M")')) ->group('Month') ->query() ->fetchAll(); return $posts; } public function findByAuthor($user) { if ($user instanceof User) { } else if (is_integer($user)) { } } public function findByTag($tag) { // Is this right? $tags = new ModelTag(); $row = $tags->fetchRow("name = 'Linux'"); $posts = $row->findManyToManyRowset('ModelBlogPost', 'ModelPostTag'); return $posts; } public function findByDate($date, $format) { // This is a joke, FIXIT! $date = new Fiktiv_Date($date,$format); $where = $this->quoteInto('DATE_FORMAT(pubDate,"%Y %M") LIKE ?', $date->toString('Y MMMM')); return $this->fetchAll($where); } public function findByPermlink($permlink) { return $this->fetchRow($this->quoteInto('permlink', $permlink)); } public function createPost($data, $id = null) { $myTags = explode(',', $data['tags']); unset($data['tags']); $data['userId'] = Zend_Auth::getInstance()->getIdentity()->id; $data['pubDate'] = Zend_Date::now()->getIso(); $data['isPublished'] = 1; if ($id) { $row = $this->find($id)->current(); $row->setFromArray($data); $row->save(); } else { $row = $this->find($this->insert($data))->current(); } if ($myTags) { $tags = new ModelTag(); $tags->tagsToPost($myTags, $row->id); } } protected function generatePermalink() { $permalink = $this->_data['title']; // All to lowercase $permalink = strtolower($permalink); // Remove special characters $permalink = filter_var($permalink, FILTER_SANITIZE_SPECIAL_CHARS); // Replace stuff $replace = array( ' ' => '-', 'å' => 'a', 'ä' => 'a', 'ö' => 'o', '_' => '-', '!' => '', '?' => '', '.' => '', ',' => '', ); foreach($replace as $char => $value) { $permalink = str_replace($char,$value,$permalink); } $this->_data['permalink'] = $permalink; } }