public function index()
 {
     global $G, $lang;
     $id = intval($_GET['id']);
     $this->id = $id;
     $this->t('post_title')->where(array('id' => $id))->update('viewnum=viewnum+1');
     $article = $this->t('post_title')->where(array('id' => $id))->selectOne();
     $article['tags'] = $article['tags'] ? unserialize($article['tags']) : array();
     if (!in_array($article['type'], array('image', 'video', 'music', 'goods', 'active'))) {
         $article['type'] = 'article';
     }
     $this->catid = $article['catid'];
     $content = $this->t('post_content')->where(array('aid' => $id, 'pageorder' => $G['page']))->selectOne();
     $articlecat = $this->t('category')->where(array('catid' => $article['catid']))->selectOne();
     $cat = new CategoryModel();
     $cat->catid = $this->catid;
     $siblings = $cat->fetchSiblings();
     $childs = $cat->fetchChilds();
     $patharray = $cat->fetchPathArray();
     $sitepath = $cat->getPath();
     $G['title'] = $article['title'] . ' - ' . $articlecat['cname'];
     $relateds = $this->fetchRelatedArticles();
     if ($article['type'] == 'article') {
         include template('detail_article');
     }
     if ($article['type'] == 'image') {
         $piclist = unserialize($content['content']);
         include template('detail_image');
     }
     if ($article['type'] == 'video') {
         $videocontent = unserialize($content['content']);
         include template('detail_video');
     }
     if ($article['type'] == 'goods') {
         $attributes = $this->t('post_goods_attribute')->where(array('aid' => $id))->select();
         include template('detail_goods');
     }
     if ($article['type'] == 'active') {
         $active = $this->t('post_active')->where(array('aid' => $id))->selectOne();
         include template('detail_active');
     }
 }
 public function index()
 {
     if ($this->checkFormSubmit()) {
         $this->save();
     } else {
         global $G, $lang;
         $navlist = M('nav')->order('displayorder ASC,nid')->select();
         if ($navlist) {
             $newlist = array();
             foreach ($navlist as $list) {
                 $newlist[$list['position']][] = $list;
             }
             $navlist = $newlist;
             unset($newlist);
         }
         $category = new CategoryModel();
         $categoryoptions = $category->fetchAllOptions();
         include template('nav');
     }
 }
 public function index()
 {
     global $G, $lang;
     $pagesize = 20;
     $catid = intval($_GET['catid']);
     $where = array('catid' => $catid);
     $totalnum = M('post_title')->where($where)->count();
     $pagecount = $totalnum < $pagesize ? 1 : ceil($totalnum / $pagesize);
     $articlelist = M('post_title')->where($where)->page($G['page'], $pagesize)->select();
     if (is_array($articlelist) && !empty($articlelist)) {
         $newarticlelist = array();
         foreach ($articlelist as $list) {
             $list['pubtime'] = @date($G['setting']['dateformat'], $list['pubtime']);
             $list['modified'] = @date($G['setting']['dateformat'], $list['modified']);
             $newarticlelist[$list['id']] = $list;
         }
         $articlelist = $newarticlelist;
         unset($newarticlelist);
     } else {
         $articlelist = array();
     }
     $pages = $this->showPages($G['page'], $pagecount, "catid={$catid}", $totalnum);
     $category = $this->t('category')->where(array('catid' => $catid))->selectOne();
     $G['title'] = $category['cname'];
     $cat = new CategoryModel();
     $cat->catid = $catid;
     $sitepath = $cat->getPath();
     $category = $cat->getCategory();
     $sibling = $cat->fetchSiblings();
     $childs = $cat->fetchChilds();
     if ($category['template']) {
         include template($category['template']);
     } else {
         include template('list');
     }
 }
 /**
  * 编辑文章
  */
 public function edit()
 {
     if ($this->checkFormSubmit()) {
         $this->update();
     } else {
         global $G, $lang;
         $id = intval($_GET['id']);
         $article = $this->t('post_title')->where(array('id' => $id))->selectOne();
         if (!in_array($article['type'], array('image', 'video', 'music', 'goods', 'active'))) {
             $article['type'] = 'article';
         }
         $G['title'] = $lang['edit'];
         $caitd = $article['catid'];
         $pic = $article['pic'] ? $GLOBALS['config']['output']['attachurl'] . $article['pic'] : '';
         $category = new CategoryModel();
         $categoryoptions = $category->fetchAllOptions($caitd);
         if ($article['type'] == 'article') {
             $content = $pagebreak = '';
             $contentlist = $this->t('post_content')->where(array('aid' => $id))->order('pageorder', 'ASC')->select();
             if ($contentlist) {
                 foreach ($contentlist as $con) {
                     $content .= $pagebreak . $con['content'];
                     $pagebreak = '###Pagebreak###';
                 }
             }
             include template('post_article');
         }
         if ($article['type'] == 'image') {
             $content = $this->t('post_content')->where(array('aid' => $id, 'pageorder' => 1))->selectOne();
             $piclist = unserialize($content['content']);
             include template('post_image');
         }
         if ($article['type'] == 'video') {
             $content = $this->t('post_content')->where(array('aid' => $id, 'pageorder' => 1))->selectOne();
             $videocontent = unserialize($content['content']);
             include template('post_video');
         }
         if ($article['type'] == 'music') {
             $content = $this->t('post_content')->where(array('aid' => $id, 'pageorder' => 1))->selectOne();
             $musiccontent = unserialize($content);
             include template('post_music');
         }
         if ($article['type'] == 'goods') {
             $content = $this->t('post_content')->where(array('aid' => $id, 'pageorder' => 1))->selectOne();
             $attributes = $this->t('post_goods_attribute')->where(array('aid' => $id))->select();
             include template('post_goods');
         }
     }
 }