Exemple #1
0
 /**
  * 返回对象 ...
  * @return ArticleDbModel
  */
 public static function getInstance()
 {
     if (is_null(self::$dbModelObj) || !isset(self::$dbModelObj)) {
         self::$dbModelObj = new ArticleDbModel();
     }
     return self::$dbModelObj;
 }
Exemple #2
0
 /**
  * 分类页面
  */
 public function main()
 {
     //获取当前页码
     $page = 1;
     if (isset($this->param['page'])) {
         $page = $this->param['page'];
     }
     //获取分类Id
     $mid = $this->param['mid'];
     //获取该分类下的文章
     $articleList = ArticleBusiness::getArticleByMid($mid, $page);
     $pageNav = $articleList['page_nav'];
     $articleList = $articleList['data'];
     foreach ($articleList as $k => $article) {
         //整理数据
         $articleList[$k]['author'] = $article['author'];
         $articleList[$k]['title'] = $article['title'];
         $articleList[$k]['description'] = $article['description'];
         $articleList[$k]['ctime'] = date('Y-m-d H:i:s', $article['ctime']);
         $articleList[$k]['tag'] = explode('|', $article['tag']);
         if (empty($article['description'])) {
             $articleList[$k]['description'] = mb_substr($article['content'], 0, 300, 'UTF-8');
         } else {
             $articleList[$k]['description'] = mb_substr($article['description'], 0, 300, 'UTF-8');
         }
     }
     //获取该分类下热门文章
     $articleHotList = ArticleBusiness::getHotListByMid($mid);
     foreach ($articleHotList as $k => $article) {
         $articleHotList[$k]['title'] = mb_substr($article['title'], 0, 30, 'UTF-8') . '...';
     }
     //获取该分类下最新评论
     $commentNewList = CommentBusiness::getNewListByMid($mid);
     foreach ($commentNewList as $key => $comment) {
         $commentNewList[$key]['content'] = mb_substr($comment['content'], 0, 30, 'UTF-8') . '...';
     }
     //获取Tag
     $tags = TagBusiness::getRandList(ParamConstant::PARAM_TAG_LIST_NUM);
     //SEO的title,keywords,description
     $seo_title = $this->menuList[$mid]['seo_title'];
     $seo_description = $this->menuList[$mid]['seo_description'];
     $seo_keywords = $this->menuList[$mid]['seo_keywords'];
     View::assign('seo_title', $seo_title);
     View::assign('seo_description', $seo_description);
     View::assign('seo_keywords', $seo_keywords);
     View::assign('tags', $tags);
     View::assign('commentNewList', $commentNewList);
     View::assign('articleHotList', $articleHotList);
     View::assign('pageNav', $pageNav);
     View::assign('articleList', $articleList);
     View::showFrontTpl('menu');
 }
Exemple #3
0
 /**
  * @descrpition 首页
  */
 public function main()
 {
     //获取文章列表
     $articleList = ArticleBusiness::getNewList();
     foreach ($articleList as $k => $article) {
         //整理数据
         $articleList[$k]['author'] = $article['author'];
         $articleList[$k]['title'] = $article['title'];
         $articleList[$k]['description'] = $article['description'];
         $articleList[$k]['ctime'] = date('Y-m-d H:i:s', $article['ctime']);
         $articleList[$k]['tag'] = explode('|', $article['tag']);
         if (empty($article['description'])) {
             $articleList[$k]['description'] = mb_substr($article['content'], 0, 300, 'UTF-8');
         } else {
             $articleList[$k]['description'] = mb_substr($article['description'], 0, 300, 'UTF-8');
         }
     }
     //获取最热门文章
     $articleHotList = ArticleBusiness::getHotList();
     foreach ($articleHotList as $k => $article) {
         $articleHotList[$k]['title'] = mb_substr($article['title'], 0, 30, 'UTF-8') . '...';
     }
     //获取全站推荐文章
     $articleAllSiteRecommend = ArticleBusiness::getListByRecommendType(ParamConstant::PARAM_ARTICLE_RECOMMEND_TYPE_ALL_SITE, '0, 5');
     foreach ($articleAllSiteRecommend as &$article) {
         $article['title'] = mb_substr($article['title'], 0, 30, 'UTF-8') . '...';
     }
     //获取首页推荐
     $articleIndexRecommend = ArticleBusiness::getListByRecommendType(ParamConstant::PARAM_ARTICLE_RECOMMEND_TYPE_INDEX, '0, 5');
     foreach ($articleIndexRecommend as &$article) {
         $article['title'] = mb_substr($article['title'], 0, 30, 'UTF-8') . '...';
     }
     //获取最新评论
     $commentNewList = CommentBusiness::getNewList();
     foreach ($commentNewList as $key => $comment) {
         $commentNewList[$key]['content'] = mb_substr($comment['content'], 0, 30, 'UTF-8') . '...';
     }
     //获取Tag
     $tags = TagBusiness::getRandList(ParamConstant::PARAM_TAG_LIST_NUM);
     //获取友情链接
     $friendLinkList = FriendLinkBusiness::getFriendLinkList();
     View::assign('friendLinkList', $friendLinkList);
     View::assign('tags', $tags);
     View::assign('articleHotList', $articleHotList);
     View::assign('articleAllSiteRecommend', $articleAllSiteRecommend);
     View::assign('articleIndexRecommend', $articleIndexRecommend);
     View::assign('commentNewList', $commentNewList);
     View::assign('articleList', $articleList);
     View::showFrontTpl('index');
 }
Exemple #4
0
 /**
  * Description: 评分
  */
 public function score()
 {
     $articleId = Request::getRequest('article_id', 'int', 58);
     $score = Request::getRequest('score', 'int', 1);
     //判断参数
     if ($score != 1 && $score != 2) {
         View::showErrorMessage(GAME_URL, '非法操作');
     }
     //返回
     $data = array();
     //判断是否24小时内已经投过了。cookie判断,伪验证。
     $addScore = Request::getCookie('add_score');
     if (!empty($addScore) && $addScore - time() <= 86400) {
         $data['status'] = -2;
         $data['msg'] = '<p class="text-center">说你呢-.-</p><p class="text-center">不要贪得无厌哦</p><p class="text-center">24小时内只能顶一次';
         return json_encode($data);
     }
     Response::setCookie('add_score', time(), time() + 86400);
     //更新数据库
     if ($score == 1) {
         $result = ArticleBusiness::goodNum($articleId);
     } else {
         if ($score == 2) {
             $result = ArticleBusiness::badNum($articleId);
         }
     }
     //整理返回值
     if ($result) {
         $data['status'] = 0;
         $data['msg'] = 1;
     } else {
         $data['status'] = -1;
         $data['msg'] = '不明所以的失败了,请重新。';
     }
     return json_encode($data);
 }
Exemple #5
0
    /**
     * Description: 生成sitemap.xml 空行请不要删除
     */
    public function buildSitemap()
    {
        $f = fopen(ROOT_PATH . 'sitemap.xml', 'w+');
        $content = <<<EOF
<?xml version="1.0" encoding="UTF-8" ?>
<urlset>
EOF;
        //获取分类列表
        $menuList = MenuBusiness::getMenuList();
        foreach ($menuList as $menu) {
            $menuXml = <<<EOF

    <url>
        <loc>%s</loc>
        <lastmod>%s</lastmod>
        <changefreq>daily</changefreq>
        <priority>1.0</priority>
    </url>
EOF;
            $content .= sprintf($menuXml, GAME_URL . 'menu/main/mid-' . $menu['id'], date('Y-m-d'));
        }
        //获取文章列表
        $articleList = ArticleBusiness::getAllList();
        foreach ($articleList as $article) {
            $articleXML = <<<EOF

    <url>
        <loc>%s</loc>
        <lastmod>%s</lastmod>
        <changefreq>daily</changefreq>
        <priority>1.0</priority>
    </url>
EOF;
            $content .= sprintf($articleXML, GAME_URL . 'article/main/aid-' . $article['id'], date('Y-m-d', $article['ctime']));
        }
        $content .= '
</urlset>';
        $result = fwrite($f, $content);
        fclose($f);
    }