<?php
if(!defined('MOD'))  die("access die");
if(($channel[$channelid]['is_html']<1) &&($channel[$channelid]['is_html_content']<1) )  qbase::purviewCheckDie("频道被禁止生成静态页面");
$channel_html_dir = R_P . DIRECTORY_SEPARATOR . $channel[$channelid]['channeldir'];
if(!is_dir($channel_html_dir)){
	qbase::createdir($channel_html_dir);
	clearstatcache();
}
if(!is_dir($channel_html_dir)) qbase::showmsg("出错了，频道目录{$param['channeldir']}不存在，且无法成功创建，请更先通过FTP改服务器目录权限");
if(!qbase::writeable($channel_html_dir)) qbase::showmsg("出错了，频道目录{$param['channeldir']}不可写，无法生成静态文件，请更先通过FTP更改服务器目录权限");
$action = $_GET['action'];
$type   = $_GET['type'];
if( $action == 'tohtml'){
	$strall = '';
	if( $admin_info['groupid'] < 3 || in_array( $channelid, $manage_channel)){
		foreach( $menus as $val){
			$static = getCIdInfoHtml($val['cid']);
			$strall.="<tr class='item' id='item-{$val['cid']}'><td align=center class='tablerowl'><input type=checkbox onclick=\"try{event.cancelBubble=true;}catch(e){event.stopPropagation();}\"  name=cid[] id=ids_{$val['cid']} value=".$val['cid']." /></td><td style='padding:0;'><div class='relative' style='padding-left:20px'><div class='c-loading' id='loading-{$val['cid']}'></div><div class='name'>".$val['pre'].$val['title']."</div></div></td><td height=20 align=center>".$val['cid']."</td><td align=center>".($static['category'] ? "动态" : "<font color='green'><b>静态</b></font>")."</td><td align=center>".($static['html'] ? "动态" : "<font color='green'><b>静态</b></font>")."</td></tr>";
		}
	}else{
		foreach( $menus as $val){
			$static = getCIdInfoHtml($val['cid']);
			if ( in_array($val['cid'], $manage_category[$channelid])){
				$strall.="<tr class='item' id='item-{$val['cid']}'><td align=center class='tablerowl'><input type=checkbox onclick=\"try{event.cancelBubble=true;}catch(e){event.stopPropagation();}\"  name=cid[] id=ids_{$val['cid']}  value=".$val['cid']." /></td><td style='padding:0;'><div class='relative' style='padding-left:20px'><div class='c-loading' id='loading-{$val['cid']}'></div><div class='name'>".$val['pre'].$val['title']."</div></div></td><td height=20 align=center>".$val['cid']."</td><td align=center>".($static['category'] ? "动态" : "<font color='green'><b>静态</b></font>")."</td><td align=center>".($static['html'] ? "动态" : "<font color='green'><b>静态</b></font>")."</td></tr>";
			}else{
				$strall.="<tr class='item' id='item-{$val['cid']}'><td align=center class='tablerowl'><input type=checkbox onclick=\"try{event.cancelBubble=true;}catch(e){event.stopPropagation();}\"  name=cid[] id=ids_{$val['cid']} value=".$val['cid']." disabled></td><td style='padding:0;'><div class='relative' style='padding-left:20px'><div class='c-loading' id='loading-{$val['cid']}'></div><div class='name'>".$val['pre'].$val['title']."</div></div></td><td height=20 align=center>".$val['cid']."</td><td align=center>".($static['category'] ? "动态" : "<font color='green'><b>静态</b></font>")."</td><td align=center>".($static['html'] ? "动态" : "<font color='green'><b>静态</b></font>")."</td></tr>";
			}
		}
	}
}
$mod = $_MODULE[$channel[$channelid]['channelselect']]['table_name'];
$listphp = $_MODULE[$channel[$channelid]['channelselect']]['user_list_php'];
$contentphp = $_MODULE[$channel[$channelid]['channelselect']]['user_content_php'];
$index_html = $channel[$channelid]['is_html'];
$preview_hash = qbase::createHashParam();

include qbase::template($path . 'tohtml');

function getCIdInfoHtml($cid)
{
	$temp = qdb::queryFirst("select pur_browse, html, category_html from ".TABLEPRE."acategory where cid = '{$cid}' ");
	return array(
		'category'=>$temp['pur_browse'] || $temp['category_html'],
		'html'=>$temp['html'] 
	);
}
?>
