/** * 列表页 */ public function action_list() { $this->_add_css('styles/album/my_library.css'); $this->_add_script('scripts/dtree.js'); $tag = new Tags(); $cate = new Bookcategory(); $position = trim($this->getQuery('position')); switch ($position) { case 'is_hot': $pageTitle = '热门文章'; break; case 'is_recommend': $pageTitle = '美文推荐'; break; default: $pageTitle = '最新文章'; break; } $this->template->position = $pageTitle; $select = DB::select('a.*', 'cate.cate_name', 'u.username')->from(array('articles', 'a'))->join(array('article_categories', 'cate'))->on('cate.cate_id', '=', 'a.cate_id')->join(array('users', 'u'))->on('u.uid', '=', 'a.uid')->where('a.recycle', '=', 0)->where('a.is_show', '=', 1)->order_by('a.article_id', 'DESC'); if (!empty($position) && $position != 'is_new') { $select->where('a.' . $position, '=', 1); } $this->template->cate_id = $cate_id = trim($this->getQuery('cate_id')); if ($cate_id > 0) { $select->where('a.cate_id', '=', $cate_id); } $this->template->pagination = $pagination = Pagination::factory(array('total_items' => count($select->execute()->as_array()), 'items_per_page' => 30)); $this->template->results = $select->limit($pagination->items_per_page)->offset($pagination->offset)->execute(); $this->template->tags = $tags = $tag->getHotTags('article'); if ($this->auth) { $this->template->categories = $categories = $cate->getCates($this->auth['uid']); } }
public function action_edit() { $article_id = (int) $this->getQuery('id'); $rows = DB::select()->from('articles')->where('article_id', '=', $article_id)->execute()->current(); $this->template->listInfo = $rows; $this->template->article_id = $article_id; //数组否与是; $arr_yesOrNo = array("否", "是"); $this->template->arr_yesOrNo = $arr_yesOrNo; //获取分类信息 $cate = new Bookcategory(); $this->template->type = $categories = $cate->getCates($rows['uid']); if ($this->isPost()) { $set = array('title' => trim($this->getPost('title')), 'cate_id' => (int) $this->getPost('cate_id'), 'channel_top' => $this->getPost('channel_top'), 'index_top' => $this->getPost('index_top'), 'index_recommend' => trim($this->getPost('index_recommend')), 'is_show' => (int) $this->getPost('is_show'), 'allow_comment' => $this->getPost('allow_comment'), 'excerpt' => trim($this->getPost('excerpt')), 'content' => trim($this->getPost('content'))); $set['edit_username'] = $this->auth['username']; $set['edit_date'] = time(); if ($article_id > 0) { DB::update('articles')->set($set)->where('article_id', '=', $article_id)->execute(); $links[] = array('text' => '返回列表', 'href' => '/admin/article/list'); $this->show_message('修改资料成功', 1, $links, true); } } }