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