Chinaunix首页 | 论坛 | 博客
  • 博客访问: 5119958
  • 博文数量: 921
  • 博客积分: 16037
  • 博客等级: 上将
  • 技术积分: 8469
  • 用 户 组: 普通用户
  • 注册时间: 2006-04-05 02:08
文章分类

全部博文(921)

文章存档

2020年(1)

2019年(3)

2018年(3)

2017年(6)

2016年(47)

2015年(72)

2014年(25)

2013年(72)

2012年(125)

2011年(182)

2010年(42)

2009年(14)

2008年(85)

2007年(89)

2006年(155)

分类:

2007-10-25 01:12:34

/*****************************
   文件功能:生成控制器
   更新日期:2007-01-23
   文件版本:v1.0.0.0
   文件作者:phpox
*****************************/

class Helper_Createhtml extends FLEA_Controller_Action  {
 var $_modelChannel;
 var $_modelClass;
 var $_modelArticle;
 var $smarty;
 function Helper_Createhtml(){
  $this->_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 "返回首页";
 }
}

阅读(1016) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~