文章详情

  • 游戏榜单
  • 软件榜单
关闭导航
热搜榜
热门下载
热门标签
php爱好者> php文档>生成静态页的类

生成静态页的类

时间:2007-10-25  来源:yueming


_modelChannel=& get_singleton('Model_Channel');
  $this->_modelClass=& get_singleton('Model_Class');
  $this->_modelArticle=& get_singleton('Model_Article');
  $this->smarty=& $this->_getView();
}
function createIndex(){
  //$smarty =& $this->_getView();
  $articles=$this->_modelArticle->findAll(null,'created DESC','10');
  $articles1=$this->_modelArticle->findAll("%MT%.classid=1",'created DESC','10');
  $articles4=$this->_modelArticle->findAll("%MT%.classid=4",'created DESC','10');
  //dump($articles1);
     @ob_start();
  $this->smarty->assign('articles',$articles);
  $this->smarty->assign('articles1',$articles1);
  $this->smarty->assign('articles4',$articles4);
     $this->smarty->display('index.html');
     $htmlcontent=ob_get_contents();
     ob_end_clean();
  $filename="index.html";
     if (create_htmlfile($filename,$htmlcontent,'./','')){
      $infos=array('title'=>'恭喜您!','content'=>'生成网站首页成功!','link'=>'','clew'=>'返回上一页');
         $this->smarty->assign('infos',$infos);
         $this->smarty->display('register.html');
     }else {
      $infos=array('title'=>'提示信息!','content'=>'生成网站首页失败!','link'=>'','clew'=>'返回上一页');
            $this->smarty->assign('infos',$infos);
         $this->smarty->display('register.html');
     }
     
}
function createArticlelist($classid=''){
  $htmldir=get_app_inf('htmldir');
  if ($classid==''){
   $classes=$this->_modelClass->findAll(null,'created DESC');
   foreach ($classes as $row){
    $articles=$row['articles'];
    //dump($row);
             @ob_start();
             $this->smarty->assign('channelname',$row['channels']['channelname']);
             $this->smarty->assign('channelid',$row['channels']['channelid']);
             $this->smarty->assign('classname',$row['classname']);
             $this->smarty->assign('articlelist',$articles);
             $this->smarty->display('article_list.html');
             $htmlcontent=ob_get_contents();
                ob_end_clean();
                $filename="{$row['classid']}.html";
                if (create_htmlfile($filename,$htmlcontent,$htmldir,'article_list/')){
                 echo "生成第{$row['classid']}个新闻列表成功!
";
                }else {
                 echo "生成第{$row['classid']}个新闻列表失败!
";
                }
   }
  }else {
   $articles=$this->_modelArticle->findAll("%MT%.classid={$classid}");
   //dump($articles);
         @ob_start();
         $this->smarty->assign('articlelist',$articles);
         $this->smarty->display('article_list.html');
         $htmlcontent=ob_get_contents();
            ob_end_clean();
            $filename="{$classid}.html";
            if (create_htmlfile($filename,$htmlcontent,$htmldir,'article_list/')){
            echo "生成第{$classid}个新闻列表成功!
";
            }else {
             echo "生成第{$classid}个新闻列表失败!
";
            }
  }
  echo "返回首页";
}
function createArticle($articleid=''){
  $htmldir=get_app_inf('htmldir');
  if ($articleid==''){
   $articles=$this->_modelArticle->findAll(null,'created DESC');
   foreach ($articles as $row){
    @ob_start();
             $this->smarty->assign('articles',$row);
             $this->smarty->display('showarticle.html');
             $htmlcontent=ob_get_contents();
                ob_end_clean();
                $filename="{$row['articleid']}.html";
                if (create_htmlfile($filename,$htmlcontent,$htmldir,'article/')){
                 echo "生成第{$row['articleid']}条新闻成功!
";
                }else {
                 echo "生成第{$row['articleid']}条新闻失败!
";
                }
   }
  }else {
   $articles=$this->_modelArticle->find((int)$articleid);
   @ob_start();
         $this->smarty->assign('articles',$articles);
         $this->smarty->display('showarticle.html');
         $htmlcontent=ob_get_contents();
            ob_end_clean();
            $filename="{$articles['articleid']}.html";
            if (create_htmlfile($filename,$htmlcontent,$htmldir,'article/')){
             echo "生成第{$articles['articleid']}条新闻成功!
";
            }else {
             echo "生成第{$articles['articleid']}条新闻失败!
";
            }
  }
  echo "返回首页";
}
}


相关阅读 更多 +
排行榜 更多 +
泡龙大闯关安卓版

泡龙大闯关安卓版

冒险解谜 下载
割草派对安卓版

割草派对安卓版

飞行射击 下载
堡垒攻防战安卓版

堡垒攻防战安卓版

飞行射击 下载