/** * Действие для отображения определённой статьи из категории */ public function action_view($id = NULL) { is_null($id) and \Response::redirect(''); $data['article'] = \Model_Article::query()->where('id', '=', $id)->where('category_id', '=', 5)->order_by('id', 'DESC')->limit(1)->get_one(); $this->template->page_title = 'Клуб :: ' . $data['article']->title; $this->template->content = \View::forge('club/view', $data, FALSE); }
/** * Действие для отображения главной страницы */ public function action_index() { // Три последних новости $data['contacts'] = \Model_Article::query()->where('category_id', '=', 2)->order_by('id', 'DESC')->limit(1)->get_one(); $this->template->page_title = 'Контакты'; $this->template->content = \View::forge('contacts/index', $data, FALSE); }
/** * 自身の書き込みに対するコメント数を得る * @param type $board Model_Board * @param type $threadId スレッド元(Model_Article)のID * @return int コメント数 */ public function getCountOfComments() { $query = Model_Article::query(); $query->and_where_open(); $query->where('commentOf', '=', $this->id); $query->and_where_close(); return $query->count(); }
/** * Действие для просмотра новости * * @param int $news_id */ public function action_view($news_id) { is_null($news_id) and \Response::redirect(''); // Получаем новость $data['news'] = \Model_Article::query()->where('category_id', 1)->where('id', $news_id)->get_one(); // Если такой статьи нет, то отображаем страницу 404 if (is_null($data['news'])) { throw new \HttpNotFoundException(); } // Передаем данные в вид $this->template->content = \View::forge('news/view', $data, FALSE); }
/** * Get article from keyword of name * * @params string $k keyword of name to search * @params int $offset Offset * @params int $offset Limit * * @return array objects of articles * * @access public * @author Nguyen Van hiep * * @version 1.0 * @since 1.0 */ public static function get_arts_from_keyword($k, $offset = null, $limit = null) { if ($offset != null or $limit != null) { $arts = Model_Article::query()->where('name', 'LIKE', "%{$k}%")->order_by('created_at', 'desc')->rows_offset($offset)->rows_limit($limit)->get(); return $arts; } $count = Model_Article::query()->where('name', 'LIKE', "%{$k}%")->count(); return $count; }
public function deleteArticle() { $query = Model_Article::query()->where('bbsId', $this->id); $ars = $query->get(); foreach ($ars as $ar) { $ar->delete(); } }
/** * Действие для отображения главной страницы */ public function action_index() { // Статьи на главной $data['news'] = \Model_Article::query()->where('on_main_page', '=', 1)->order_by('id', 'DESC')->limit(6)->get(); $this->template->content = \View::forge('main/index', $data, FALSE); }
/** * Get Number of articles of a category * * params int $cat_id Category-ID * @return int Number of articles of a category * * @version 1.0 * @since 1.0 * @access public * @author Nguyen Van hiep * @author Dao Anh Minh */ public static function count_arts_in_cat($cat_id = '', $lang = '') { if (empty($cat_id)) { if (empty($lang)) { $count = Model_Article::query()->count(); } else { $count = Model_Article::query()->where('lang', $lang)->count(); } } else { if (empty($lang)) { $count = Model_ArtCat::query()->where('cat_id', $cat_id)->count(); } else { $count = Model_ArtCat::query()->related('ac2a')->where('cat_id', $cat_id)->where('ac2a.lang', $lang)->count(); } } return $count; }
/** * 書き込みを削除 * @param type $ar 書き込み */ public function deleteArticle($ar) { //書き込み本体 $articleId = $ar->id; $commentOf = $ar->commentOf; $this->deleteAttach($ar); $ar->delete(); //スレッド元の総コメント数修正 if ($commentOf != 0) { $masterPost = Model_Article::find($commentOf); if ($masterPost != null) { $masterPost->commentCount--; $masterPost->save(); } } //レス $query = Model_Article::query()->where('commentOf', $articleId); $comments = $query->get(); foreach ($comments as $comment) { $this->deleteAttach($comment); $comment->delete(); } }