<!--<?php
if($action !='add' && $action !='edit') {
	include_once PrintEot('left');
}
print <<<EOT
-->

<!--
EOT;
if(empty($action)) {print <<<EOT
-->
<div class="admin_info mb10">
	<h3 class="h1">提示信息</h3>
    <div class="legend">
    	<ol>
    		<li>如果需要新增模板，請將模板文件上傳至mode/area/themes下</li>
			<li>頻道創建後，需要手動更新一下頻道靜態頁</li>
        	<li>英文別名只允許英文字母和數字</li>
        	<li>對于已經創建的頻道模板路徑是︰html/channel/{頻道別名}</li>
        	<li>刪除頻道之後，相應的數據均會被刪除</li>
			<li>可以通過創建一個blank風格的頻道來制作新的風格</li>
        </ol>
    </div>
</div>
<form action="$basename" method="post">
<h2 class="h1"><span class="mr5 fl">頻道管理</span><a href="javascript:;" class="btn_add" onclick="sendmsg('$addUrl','','this.id')"><i>添加頻道</i></a></h2>
<div class="admin_table mb10">
	<table width="100%">
    	<tr class="tr2">
    		<td>順序</td>
        	<td>頻道名稱</td>
            <td>英文別名</td>
            <td>綁定域名</td>
            <td>默認首頁</td>
            <td><span>操作</span><span style="margin-left:30px"><a href="javascript:;" onclick="updateAllStatic();return false;" title="更新頁面緩存">更新全部頁面</a></span></td>
        </tr>
<!--
EOT;
foreach($channel_list as $val){
$checked = $val['alias'] == $area_default_alias ? 'checked="checked"' : '';
print <<<EOT
-->
        <tr class="tr1">
        	<td class="td2"><input name="channels[$val[id]][queue]" type="text" class="input input_wd mr5" value="$val[queue]" /></td>
        	<td class="td2">$val[name]</td>
            <td class="td2">$val[alias]</td>
            <td class="td2"><input name="channels[$val[id]][domain_band]" type="text" class="input input_wa" value="$val[domain_band]" /></td>
            <td class="td2"><input name="defaultalias" $checked value="$val[alias]" type="radio" /></td>
            <td class="td2">
				<a href="javascript:;" class="mr10" onclick="sendmsg('{$editUrl}&id=$val[id]','','this.id')">[編輯]</a>
				<a href="index.php?m=area&alias=$val[alias]" target="_blank" class="mr10">[訪問]</a>
				<a href="javascript:;" onclick="parent.PW.Dialog({'id': 'area_module','name': '模塊管理','url': '$admin_file?adminjob=mode&admintype=area_module&alias=$val[alias]','max': false});return false;" class="mr10">[模塊管理]</a>
				<a href="javascript:;" class="mr10" onclick="updateCache('$val[alias]');return false;" title="更新頁面緩存">[更新靜態]</a>
				<a href="javascript:;" onclick="delChannel($val[id]);" class="mr10">[刪除]</a>
			</td>
        </tr>
<!--
EOT;
}print <<<EOT
-->
    </table>
</div>
<div class="tac mb10">
    <span class="btn"><span><button type="submit">提 交</button></span></span>
</div>
<input name="default_step" type="hidden" value=1>
<div class="c"></div>
</form>
<!--
EOT;
}elseif($action =='add') {print <<<EOT
-->
<!--下面這個是設置屬性的彈窗-->
<form action="$actionUrl" method="post" onsubmit="return false;">
<div class="admin_table" style="width:380px;">
	<h2 class="h1" style="cursor:move" onmousedown="read.move(event);"><a href="javascript:closep();" class="del_img fr" title="關閉">關閉</a>添加頻道</h2>
	<table width="100%" class="mb10">
        <tr class="tr1">
        	<td class="td1">頻道名稱</td>
            <td class="td2"><input name="channel_name" maxlength="20" type="text" class="input input_wa" value="" /></td>
        </tr>
        <tr class="tr1">
        	<td class="td1">風格模板</td>
            <td class="td2"><select name="channel_theme" class="select_wa">
<!--
EOT;
foreach($themes_array as $val){
$selected=($val=='default')?'selected':'';
print <<<EOT
-->
			<option value="$val" $selected>$val</option>
<!--
EOT;
}print <<<EOT
-->
			</select></td>
        </tr>
        <tr class="tr1">
        	<td class="td1">英文別名</td>
            <td class="td2"><input name="channel_alias" type="text" class="input input_wa" value="" /></td>
        </tr>
        <tr class="tr1">
        	<td class="td1">域名綁定</td>
            <td class="td2"><input name="channel_domain" type="text" class="input input_wa" /></td>
        </tr>
    </table>
    <div class="tac mb10">
	<input name="action" type="hidden" value="add">
	<input name="add_step" type="hidden" value="1">
	<input name="ifreplace" type="hidden" value="0">
    	<span class="btn2"><span><button type="button" onclick="checkReplace(this.form)">提 交</button></span></span>
    </div>
</div>
</form>
<!--
EOT;
}elseif($action =='edit') {print <<<EOT
-->
<!--下面這個是設置屬性的彈窗-->
<form action="$actionUrl" method="post">
<div class="admin_table" style="width:480px;">
	<h2 class="h1" style="cursor:move" onmousedown="read.move(event);"><a href="javascript:closep();" class="del_img fr" title="關閉">關閉</a>編輯頻道</h2>
	<table width="100%" class="mb10">
        <tr class="tr1">
        	<td class="td1">頻道名稱</td>
            <td class="td2"><input name="channel_name" type="text" class="input input_wa" value="$channel_info[name]" /></td>
        </tr>
        <tr class="tr1">
        	<td class="td1">風格模板</td>
            <td class="td2"><input type="text" class="input input_wa" readonly disabled value="$channel_info[relate_theme]" />
            
            </td>
        </tr>
        <tr class="tr1">
        	<td class="td1">英文別名</td>
            <td class="td2"><input name="channel_alias" type="text" class="input input_wa" value="$channel_info[alias]" disabled readonly /></td>
        </tr>
        <tr class="tr1">
        	<td class="td1">域名綁定</td>
            <td class="td2"><input name="channel_domain" type="text" class="input input_wa" value="$channel_info[domain_band]" /></td>
        </tr>
        <tr class="tr1">
        	<td class="td1">動態地址</td>
            <td class="td2"><a href="{$channel_info[activeUrl]}" target="_blank">{$channel_info[activeUrl]}</a></td>
        </tr>
        <tr class="tr1">
        	<td class="td1">靜態地址</td>
            <td class="td2"><a href="{$channel_info[url]}" target="_blank">{$channel_info[url]}</a></td>
        </tr>
    </table>
    <div class="tac mb10">
    	<span class="btn2"><span><button type="submit">提 交</button></span></span>
    </div>
	<input name="edit_step" type="hidden" value=1>
	<input name="id" type="hidden" value="$channel_info[id]">
	<input name="action" type="hidden" value="edit">
	<div class="c"></div>
</div>
</form>
<!--
EOT;
}print <<<EOT
-->
</form>
<script>
<!--
	function delChannel(id) {
		if(!confirm('刪除頻道將同時刪除下屬模塊和歷史推送數據，不可恢復，是否確認刪除？')) {
			return false;
		}
		setTimeout(function(){
			window.location.href = '{$delUrl}&id='+id;
		},0);
	}
	//更新靜態
	function updateCache(alias) {
		var url = '$actionUrl';
		ajax.send(url,'action=static&alias='+alias,ajax.get);
	}
	function updateAllStatic() {
		var url = '$actionUrl';
		ajax.send(url,'action=static_all',ajax.get);
	}

	function checkReplace(form) {
		var url = '$actionUrl';
		var channel = form.channel_alias.value;
		var channelName = form.channel_name.value;
		if (!channelName) {
			alert('頻道名稱不能為空');
			return false;
		}
		if (!channel) {
			alert('頻道別名不能為空');
			return false;
		}
		ajax.send(url,'action=addcheck&ckalias='+channel,function() {
				var text = ajax.request.responseText;
				if (text=='error') {
					if (confirm('頻道模板文件已經存在，是否覆蓋?')) {
						form.ifreplace.value=1;
						form.submit();
					}
					return false;
				} else if (text=='havechannel') {
					alert('英文別名重復');
					return false;
				}
				form.submit();
			}
		);
		return false;
		
	}
	function countlen(element,num) {
		var temp = strlen(element.value);
		if (temp>num){
			alert('超過字數限制');
			element.value = substr(element.value,num);
		}
		return true;
	}
//-->
</script>
<!--
EOT;
if($action !='add' && $action !='edit') {
	include_once PrintEot('adminbottom');
}
?>-->