<!--{template 'head'}-->
<script type="text/javascript">
setSubject("{$channelname} => {$channeltitle}专题管理");
</script>
<table cellpadding="2" cellspacing="1" border="0" align=center class="tableborder" width=100%>
	<tr>
		<td class="tablerow">
			<b>管理选项：</b>
			<a href="system.php?sys=special&channelid={$channelid}&action=manage">专题管理</a> | 
			<!--{loop $cate $val}-->
				<a href="system.php?sys=special&channelid={$channelid}&action=add&mid={$val['id']}">添加{$val['name']}</a> | 
			<!--{/loop}-->
		</td>
	</tr>
</table>
<!--{if $action=='add' or $action=='edit'}-->
<script language=JavaScript>
function doCheck()
{
	if (document.myform.subject.value=='')
	{
		alert('专题名称不能为空。');
		document.myform.subject.focus();
		return false;
	}
	if (document.myform.thumb.value=="") 
	{
		alert("专题图片不能为空！");
		document.myform.thumb.focus();
		return false;
	}
	$('submit').disabled = true;
	$('divProcessing').style.display="";
	return true;
}
</script>
<form action="system.php?sys=special&channelid={$channelid}&action={$action}&mid={$mid}" method="post" name="myform" onsubmit="return doCheck();">
<table cellpadding="0" cellspacing="1" class="tableborder border">
	<tr>
		<th colspan=2>专题添加</th>
	</tr>
	<tr>
		<!--{if $action=='add'}-->
			<input type='hidden' name='mid' value="{$mid}">
		<!--{else}-->
			<input type='hidden' name='mid' value="{$special['mid']}">
			<input type='hidden' name='sid' value="{$special['sid']}">
		<!--{/if}-->
		<td class="tablerowl" width=20%>专题名称</td>
		<td class="tablerow" width=80%>
			<input size=50 name="subject" type=text class="f-text"  value="{$special[subject]}">
		</td>
	</tr>
	<tr>
		<td class="tablerowl">专题图片</td>
		<td class="tablerow">
			<input size=40 name="thumb" id='thumb' type='text' class="f-text"  value="{$special[thumb]}">
			<input type="button" value="上传图片" onclick="qmeCms.dialogView.iframe('上传图片','system.php?sys=upload&id=thumb&channelid={$channelid}&thumb=1&path=attachment/special/<!--{echo qbase::formatTime('Y');}-->',{type:'abs'});">
		</td>
	</tr>
	<tr>
		<td class="tablerowl">专题说明</td>
		<td class="tablerow">
			<textarea name='description' style="display:none">{$special[description]}</textarea>
			<script language=javascript>
				document.write("<iframe id=\"FCKeditor1___Frame\" src=\"{$_SET[webpath]}images/fck/editor/fckeditor.html?InstanceName=description&amp;Toolbar=Standard&amp;channelid={$channelid}\" width=\"100%\" height=\"300\" frameborder=\"0\" scrolling=\"no\"></iframe>");
			</script>
		</td>
	</tr>
	<tr>
		<td class="tablerowl">专题模板</td>	
		<td class="tablerow">
		<!--{if $action=='edit'}-->
			<input type=text class="f-text"  size=40 name='showphp' value='{$special[showphp]}' id="showphp">
		<!--{else}-->
			<input  name="showphp" type=text class="f-text" size=40  value=""  id="showphp">
		<!--{/if}-->
			 <input type="button" value="选择模版" onclick="SelectBrowse('{W_P}admin/images/browse.html?type=read&channelid=-1&callback=getDir','showphp',550,360);"/> (为空则使用系统默认)
		</td>
	</tr>
	<tr>
		<td class="tablerowl">自定义文件名</td>	
		<td class="tablerow">
			<input type=text class="f-text" size=40 name='filename' value='{$special[filename]}' id="filename" /> 自定义生成静态文件名，只能由英文字母和-_组成
		</td>
	</tr>	
	<tr>
		<td class="tablerowl">是否开启</td>
		<!--{if $action=='edit'}-->
			<td class="tablerow">
				<input type='radio' name='status' id="status-1" value='1'<!--{if $special[status]==1}--> checked<!--{/if}-->> <label for="status-1">是</label> <input type='radio' name='status' id="status-0" value='0'<!--{if $special[status]==0}--> checked<!--{/if}-->> <label for="status-0">否</label>
			</td>
		<!--{else}-->
			<td class="tablerow">
				<input type='radio' name='status' id="status-1" value='1'> <label for="status-1">是</label> <input type='radio' id="status-0" name='status' value='0' checked> <label for="status-0">否</label>
			</td>
		<!--{/if}-->
	</tr>
	
	<!--{loop $extends $val}-->
	<tr>            
		<td class=tablerowl width=120 <!--{if $val['need']}--> style="color:red"<!--{/if}-->>{$val['name']}</td>
		<td class=tablerow>
			<table border=0 width=100%>
				<tr>
					<td width=70%>
						<!--{eval echo extend::get_instance()->build($val, $_output['ext_' . $val['ext']], $action);}-->
					</td>
					<td width=30%>{$val['description']}</td>
				</tr>
			</table>
		</td>
	</tr>
	<!--{/loop}-->
	
	<tr>
		<td class="tablerowl" colspan=2>
			<input type='hidden' name='myFormAc' value="update">
			<input type="Submit" name="submit" id="submit" value="确定"  class="f-button" />
		</td>
	</tr>
</table>
</form>
<!--{/if}-->

<!--{if $action=='manage'}-->
<script type="text/javascript">
function createSpecialHtml(ids){
	if(ids.length == 0) return;
	var sid = ids.shift();
	qmeCms.dialogView.ajaxGet(config.url + "index.php?ac=special&id="+sid, function(resp){
		var json = evaljson(resp);
		var x = $('ids_'+sid);
		if(x != null) colorFocus(x.parentNode.parentNode, cs, ce, 'backgroundColor', function(){
			x.checked = false;
			x.parentNode.parentNode.removeAttribute('style');
			return createSpecialHtml(ids);
		});		
	});
	return false;
}
</script>
	<table cellpadding="0" align=center cellspacing="0" class="tableborder" id='mytable'>
		<tr>
			<th colspan=6>专题管理</th>	
		</tr>
		<tr align=center>
			<td width="30" class="tablerowhighlight"></td>
			<td width="50" class="tablerowhighlight">ID</td>
			<td class="tablerowhighlight">专题名称</td>
			<td width="40" class="tablerowhighlight"></td>
			<td width="60" class="tablerowhighlight">状态</td>	
			<td width="250" class="tablerowhighlight">管理操作</td>
		</tr>
		<!--{if $specials }-->
		<!--{loop $specials $k $special}-->
		<tr id='item-{$special[sid]}' height=24 class="item">
			<td class="tablerowl" align="center">
				<input type=checkbox name='ids[]' id="ids_{$special['sid']}" value="{$special['sid']}" />
			</td>
			<td class="tablerowl" align=center>{$special['sid']}</td>
			<td style="padding-left:15px;"><a href="{$special['url']}" target="_blank">{$special['subject']}</a></td>
			<td align=center>
				<a href="javascript:picEdit('{$special['pic']}', config.url, config.channelid);"><img src="images/viewpic.gif" width="18" height="18" border=0 ></a>
			</td>
			<td align=center><!--{if $special['status']}-->开启<!--{else}--><font color=red>关闭</font><!--{/if}--></td>
			<td align=center>
				<a href="###" onclick="return createSpecialHtml([{$special['sid']}])">生成静态</a> | 
				<a href="{$special['preview_url']}" target="_blank">预览</a> | 
				<a href="system.php?sys=special&channelid={$channelid}&action=content&sid={$special['sid']}">数据管理</a> | 
				<a href="system.php?sys=special&channelid={$channelid}&action=edit&sid={$special['sid']}">修改</a> | 
				<a onclick="return makeSure()" href="system.php?sys=special&channelid={$channelid}&action=del&sid={$special['sid']}">删除</a>
			</td>
		</tr>
		<!--{/loop}-->
		<!--{else}-->
		<tr>
			<td  class="tablerow" colspan="6">
				<p style="padding:15px;text-align:center">没有专题</p>
			</td>
		</tr>
		<!--{/if}-->
		<tr>
			<td  class="tablerowl">
				<input type="checkbox" value="checkbox" onclick="checkall()" id="chkall" name="chkall">
			</td>
			<td  class="tablerowl" colspan=5 style="text-align:left;padding-left:15px;">
				<input class="f-button"  type='button' value='生成HTML文件' onClick="createSpecialHtml(getInputIds())">
			</td>
		</tr>
	</table>
<!--{/if}-->

<!--{if $action == 'content'}-->
<script type="text/javascript">
function contentCheck(){
	$('submit').disabled = true;
	$('divProcessing').style.display = '';
	return true;
}
</script>
<form action="system.php?sys=special&channelid={$channelid}&action=content&sid={$sid}" method="post" name="myform" onsubmit="return contentCheck();">
<table cellpadding="1" align=center cellspacing="1" class="tableborder">
   <!--{template 'element/related'}-->
   <tr>
	<td class="tablerowl" colspan="2">
		<input type="hidden" value="update" name="myFormAc" />
		<input type="submit" value=" 提交专题内容 " id="submit" class="f-button" />
	</td>
   </tr>
</table>
</form>
<!--{/if}-->

<!--{template 'foot'}-->