全部博文(921)
分类:
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 "返回首页";
}
}