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