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'); }
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)); }