public function items_by_new($filter = array(), $limit = 20) { if ($filter['cat_id']) { $filter['cat_id'] = K::M('article/cate')->children_ids($cat_id); } return parent::items_by_new($filter, $limit); }
protected function _check($data, $article_id = null) { $oText = K::M('content/text'); $oHtml = K::M('content/html'); $article_ext = array(); if (!$article_id || isset($data['title'])) { if (empty($data['title'])) { $this->err->add('标题不能为空', 431); return false; } else { $data['title'] = $oHtml->encode($data['title']); } } if (!$article_id || isset($data['content'])) { if (empty($data['content'])) { $this->err->add('内容不能为空', 432); return false; } $this->text = $oHtml->text($data['content']); if ($article_id || isset($data['desc'])) { if (empty($data['desc'])) { $data['desc'] = preg_replace('/\\s+/', '', $oText->substr($this->text, 0, 200)); } else { $data['desc'] = $oHtml->encode($data['desc']); } } $article_ext['content'] = $oHtml->filter($data['content']); } else { if (isset($data['desc'])) { $data['desc'] = $oHtml->encode($data['desc']); } } if (isset($data['from'])) { if (!in_array($data['from'], array('article', 'about', 'help', 'page'))) { $data['from'] = 'article'; } } if (isset($data['views'])) { $data['views'] = (int) $data['views']; } if (isset($data['favorites'])) { $data['favorites'] = (int) $data['favorites']; } if (isset($data['comments'])) { $data['comments'] = (int) $data['comments']; } if (isset($data['photos'])) { $data['photos'] = (int) $data['photos']; } if (isset($data['orderby'])) { $data['orderby'] = (int) $data['orderby']; } else { if (!$article_id) { $data['orderby'] = 50; } } if (isset($data['hidden'])) { $data['hidden'] = $data['hidden'] ? 1 : 0; } if (isset($data['closed'])) { $data['closed'] = $data['closed'] ? 1 : 0; } if (isset($data['seo_title'])) { $article_ext['seo_title'] = $oHtml->encode($data['seo_title']); } if (isset($data['seo_keywords'])) { $article_ext['seo_keywords'] = $oHtml->encode($data['seo_keywords']); } if (isset($data['seo_description'])) { $article_ext['seo_description'] = $oHtml->encode($data['seo_description']); } $this->article_ext = $article_ext; unset($data['content'], $data['seo_title'], $data['seo_keywords'], $data['seo_description']); return parent::_check($data, $article_id); }