public function index() { $s = doSafe($_GET['s']); $p = !empty($_GET['p']) ? (int) doSafe($_GET['p']) : 1; $article = new ArticleModel(); //合计文章数目 $total = $article->getTotal($s); //输出首页数据 if ($total == 0) { if ($p < 1) { $this->display("Error/index.tpl"); exit; } } else { if ($p < 1 || $p > ceil($total / $this->pageNum)) { $this->display("Error/index.tpl"); exit; } } $articleList = $article->getArticle($p, $this->pageNum, $s); // 获取分页条 $getPage = new Page(); $this->assign(array('total' => $total, 'page' => $getPage->getPage(APP . '/search/?s=' . $s . '&p=', $total, $this->pageNum, $p), 'articleList' => $articleList)); $this->display('Search/index.tpl'); }
public function shareWeibo() { $weiboConfig = $this->_WBconfig; $id = (int) doSafe($_POST['id']); $article = new ArticleModel(); $res = $article->getArticleById($id); $url = array(); $url['url'] = $weiboConfig['HOSTURL'] . $id; $url['content'] = 'utf-8'; $url['pic'] = $weiboConfig['LOCALHOST'] . rtrim($res['title_img'], '.'); $url['title'] = $res['description']; $url['searchPic'] = 'false'; $ajaxReturn = $weiboConfig['APPKEY'] . http_build_query($url); echo json_encode(array($ajaxReturn)); }
public function index() { $id = $_GET['id']; $p = !empty($_GET['p']) ? (int) doSafe($_GET['p']) : 1; if ($id === '') { //400页面 $this->display("Error/index.tpl"); exit; } //根据接受信息查询 $tag = new TagModel(); $tagInfo = $tag->getIdByInfo($id); if (empty($tagInfo)) { $this->display("Error/index.tpl"); exit; } //通过tag_id找到article_id $article = new ArticleModel(); $articletag = new ArticletagModel(); $articleIds = $articletag->getArticleIdByTagId($id); //合计文章数目 $total = count($articleIds); //输出首页数据 if ($total == 0) { if ($p < 1) { $this->display("Error/index.tpl"); exit; } } else { if ($p < 1 || $p > ceil($total / $this->pageNum)) { $this->display("Error/index.tpl"); exit; } } if (empty($articleIds)) { //该分类下无文章 $articleList = array(); } else { //根据ID去查找文章 $articleList = $article->getArticleByIds($articleIds, $p, $this->pageNum); } $getPage = new Page(); $this->assign(array('total' => $total, 'id' => $id, 'page' => $getPage->getPage(APP . '/tag/index/id/' . $id . '/p/', $total, $this->pageNum, $p), 'articleList' => $articleList)); // 获取分页条 $this->display('Tag/index.tpl'); }
public function index() { $article = new ArticleModel(); //合计文章数目 $total = $article->getTotal(); //输出首页数据 $p = !empty($_GET['p']) ? (int) doSafe($_GET['p']) : 1; // $p = $p < 1 ? 1 : $p; // $p = $p > ceil($total/$this->pageNum) ? ceil($total/$this->pageNum) : $p; if ($p < 1 || $p > ceil($total / $this->pageNum)) { $this->display("Error/index.tpl"); exit; } $articleList = $article->getArticle($p, $this->pageNum); // 获取分页条 $getPage = new Page(); $this->assign(array('page' => $getPage->getPage(APP . '/index/index/p/', $total, $this->pageNum, $p), 'articleList' => $articleList, 'APP' => APP)); $this->display('Index/index.tpl'); }
public function index() { $id = empty($_GET['id']) ? 1 : (int) doSafe($_GET['id']); $article = new ArticleModel(); $articleDetail = $article->getArticleById($id); if (empty($articleDetail)) { $this->display("Error/index.tpl"); exit; } //每次点击阅读量+1 $article->addClicked($id); $comment = new CommentModel(); $commentNums = $comment->getCommentNumsById($id); //查询标签内容 $tag = new TagModel(); $tags = $tag->getTagsById($id); //上一页,下一页 //根据ID查出文章发表时间 $articleTime = $article->getArticleTimeById($id); //根据时间查询最接近文章时间的上或下一个文章 $articlePre = $article->getArticleByTime($articleTime, 'pre'); $articleNext = $article->getArticleByTime($articleTime, 'next'); $this->assign(array('detail' => $articleDetail, 'nums' => $commentNums, 'tags' => $tags, 'articleId' => $id, 'articlePre' => $articlePre, 'articleNext' => $articleNext)); $this->display('Article/index.tpl'); }
private function getHotArticle() { $obj = new ArticleModel(); $hot = $obj->getHotArticle(); $this->assign(array('hot' => $hot)); }