{if $task eq 'list' || $task eq 'add' || $task eq 'edit' || $task eq 'search'}
{include file="header.tpl" page_name=$page_name sys_name=$sys_name}
<!--处理文章 下载等模型的添加删除编辑等页面-->
<div align="center">
{$admin_nav}
{/if}
{if $task eq 'list' || $task eq 'search'}
{literal}
<script type="text/javascript">
	$(document).ready(function(){
		$("#se_key").keyup(function(e){
			var k = e.keyCode;
			if(k=='13'){
				var val = $.trim($(this).val());
				if(val!=''){
					window.location.href='admincp.php?action=model_operate&task=search&channel_type='+$("#channel_types").val()+'&key='+val;
				}
			}
		})
	})
	function sub_form(){
		var key = $("#se_key").val();
		if($.trim(key)!=''){
			var url = 'admincp.php?action=model_operate&task=search&channel_type='+$("#channel_types").val()+'&key='+key;
			window.location.href=url;	
		}else{
			alert('请输入要搜索的关键字.');	
		}
	}
</script>
{/literal}
<div style="width:98%; background-color:#FFF; margin:3px 0px; padding:5px 0px; text-align:left; text-indent:25px;">
	<input type="hidden" value="{$channel_type}" id="channel_types" />
    搜索:
    <input type="text" value=""  id="se_key" /> 
    <input   type="button"  onclick="sub_form(this);" value="搜索" />
</div>
    {if $data.total>0}
    {literal}
    	<script type="text/javascript">
        	$(document).ready(function(){
				checkAllFormData('check','slelected');
			})
        </script>
    {/literal}
    <form method="post" action="">
    <input  type="hidden" value="operation"  name="task"/>
    <table width="98%" border="0" cellpadding="0" cellspacing="0" class="tableborder tableborder_line">
    <thead>
        <tr class="header">
        <td style="text-align:center"><input type="checkbox" value=""  id="check"/></td>
        <td nowrap="nowrap">序号</td>
        <td nowrap="nowrap">标题</td>
        <td nowrap="nowrap">分类</td>
        <td nowrap="nowrap">频道</td>
        <td nowrap="nowrap">审核?</td>
        <td nowrap="nowrap">顶?</td>
        <td nowrap="nowrap">新?</td>
        <td nowrap="nowrap">热?</td>
        <td nowrap="nowrap">图文?</td>
        <td nowrap="nowrap">时间</td>
        <td  nowrap="nowrap">管理选项</td>
        </tr>
        </thead>
        <tbody>
        {foreach from=$data.data item=list}
        	<tr>
            	<td align="center" style="text-align:center;" class="center"><input type="checkbox" name="ids[]" value="{$list.c_id}" class="slelected" /></td>
                <td class="center">{$list.c_id}</td>
                <td nowrap="nowrap">{$list.long_title|truncate:15:''}</td>
                <td class="center" nowrap="nowrap">{if $is_recycle eq 'recycle'}{$list.category_name}{else}<a href="admincp.php?action=model_operate&task=list&channel_type={$list.channel_model}&category_id={$list.category_id}">{$list.category_name}</a>{/if}</td>
                <td class="center" nowrap="nowrap"><a href="admincp.php?action=model_operate&task=list&channel_type={$list.channel_model}&channel_id={$list.channel_id}">{$list.channel_name}</a></td>
                <td class="center">{if $list.is_show eq '1'}是{else}<font class="red">否</font>{/if}</td>
                <td class="center" nowrap="nowrap">{if $list.is_top eq '1'}分类置顶{elseif $list.is_top eq '2'}全局置顶{else}<font class="red">否</font>{/if}</td>
                <td class="center">
                	{if $list.is_new eq '1'}<a href="admincp.php?action=model_operate&task=list&channel_type={$list.channel_model}&type=new">是</a>{else}<font class="red">否</font>{/if}
                </td>
                <td class="center">{if $list.is_hot eq '1'}<a href="admincp.php?action=model_operate&task=list&channel_type={$list.channel_model}&type=hot">是</a>{else}<font class="red">否</font>{/if}</td>
                 <td class="center">{if $list.is_pic eq '1'}<a href="admincp.php?action=model_operate&task=list&channel_type={$list.channel_model}&type=pic">是</a>{else}<font class="red">否</font>{/if}</td>
                <td class="center" nowrap="nowrap">{$list.edit_time|date_format:"%Y-%m-%d %H:%M:%S"}</td>
                <td class="center" nowrap="nowrap"><a href="admincp.php?action=model_operate&task=edit&channel_type={$list.channel_model}&id={$list.c_id}&channel_id={$list.channel_id}">编辑</a> &nbsp; <a href="{$list.privew_link}" target="_blank">预览</a></td>
            </tr>
            {/foreach}
        </tbody>
        </table>
        <br  class="clear"/>
        <div id="page_list" style="background-color:#FFF; width:98%;" align="left">
        	{$data.page}
        </div>
        <div style="background-color:#FFF; width:98%; text-align:left; text-indent:25px;">
        	  批量操作<select name="mo_opt">
            	{if $is_recycle eq 'recycle'}
                	<option value="to_common">恢复正常</option>
                    <option value="delete_f">彻底删除</option>
                	{else}
               <option value="set_new">设置为最新</option>
                <option value="to_cat_top">批量设置为分类置顶</option>
                <option value="to_all_top">批量设置为总置顶</option>
                <option  value="set_pass">批量设置通过</option>
                <option  value="to_hot">批量设置最热</option>
                <option  value="to_unhot">批量取消最热</option>
                <option  value="set_unpass">批量设置为未审核</option>
                <option value="set_unnew">取消为最新</option>
                  <option value="delete">移动到回收站</option>
                {/if}
            </select>
            	<input type="hidden" value="{$model}" name="model" />
            <input type="submit" value="提交" />
           <input type="button" onclick="window.location.href='admincp.php?action=model_operate&task=list&channel_type={$channel_type}&type=top_all'" value="全局置顶" />
           <input type="button" onclick="window.location.href='admincp.php?action=model_operate&task=list&channel_type={$channel_type}&type=top_part'"  value="分类置顶" />
           <input type="button" onclick="window.location.href='admincp.php?action=model_operate&task=list&channel_type={$channel_type}&type=latest'"  value="最新" />
               <input type="button" onclick="window.location.href='admincp.php?action=model_operate&task=list&channel_type={$channel_type}&type=pic'"  value="图文" />
           <input type="button" onclick="window.location.href='admincp.php?action=model_operate&task=list&channel_type={$channel_type}&type=passed'"  value="已审?" />
           <input type="button"  onclick="window.location.href='admincp.php?action=model_operate&task=list&channel_type={$channel_type}&type=need_check'"  value="待审?" />
           
           </div>
        </form>
        {else}
        <div class="showNotice">无可用数据</div>
        {/if}
 {/if}<!--列表结束-->
{if $task eq 'add' || $task eq 'edit'}
<form method="post" action="admincp.php?action=model_operate&channel_type={$channel_type}" autocomplete="off">
<input type="hidden" value="{$task}" name="task" />
<input type="hidden" value="{$channel_type}" name="channel_type" />
{if $task eq 'edit'}
	<input type="hidden" value="{$id}" name="id" />
{/if}
<input type="hidden" value="{$model}"  name="model"/>
<script type="text/javascript">
	var extend_id = '{$data.type_id}';
	var id = '{if $data.c_id}{$data.c_id}{else}0{/if}';
	var aj_url = 'admincp.php?action=model_operate&task=ajax_call_types&channel_type={$channel_type}&type_id='+extend_id+'&id='+id;
	{literal}
	$(document).ready(function(){
		if($.trim(extend_id)!=''){
			$.get(aj_url,function(d){$("#ajax_call_extend_info").html(d);})	
		}
		var tab = $("#channel_extend_menu").find('.menu li a');
		$('.table_item').hide();
		$("#g_base").show();
		$(tab).each(function(j){
			$(this).focus(function(){
				$(this).blur();
			})
			$(this).click(function(){
					var name = $(this).attr('name');
					var c_id = '#'+$(this).attr('name');
					$('.table_item').hide();
					$(".wintable_curent").removeAttr('class');
					$(this).addClass('wintable_curent');
					$(c_id).show();	
				if(name=='all'){
					$(this).addClass('wintable_curent');
					$('.table_item').show();	
				}
			})
		});
	})
</script>
{/literal}
<div class="table_scroll" id="channel_extend_menu">
<div class="menu">
	<li><a name="all" href="javascript:void(0);">全部信息</a></li><li><a class="wintable_curent" href="javascript:void(0);" name="g_base">基本信息</a></li>
    <li><a name="g_extend" href="javascript:void(0);">扩展属性</a></li>
    <li><a name="g_seo" href="javascript:void(0);">SEO优化</a></li>
    </div>
</div>
<div class="table_item" id="g_base">
<h1 class="table_msg">基本信息</h1>
    <table width="98%" border="0" cellpadding="0" cellspacing="0" class="tableborder">
    <tr>
    	<td width="13%" class="one">长标题:</td>
        <td width="87%"><input type="text" value="{$data.long_title}"  style="width:250px;" name="long_title"/> <span class="red">*</span></td>
    </tr>
    <tr>
    <td class="one">短标题:</td>
    <td>
    	<input type="text" value="{$data.short_title}"  name="short_title" style="width:250px;"/> 文章显示时会先尝试读取短标题,若不存在使用长标题.
    </td>
    </tr>
    <tr>
    	<td class="one">所属分类:</td>
        <td>
        <select name="category_id" style="width:150px;">
        	<option value="0">请选择分类</option>
            {foreach from=$categories key=key item=cate}
            <optgroup label="{$key}">
            	{foreach from=$cate item=c}
            	<option value="{$c.category_id}" {if $data.category_id eq $c.category_id} selected="selected"{/if}>{$c.spacer}{$c.category_name}</option>
                {/foreach}
            </optgroup>
            {/foreach}
        </select> <span class="red">*</span>
        </td>
    </tr>
    <tr>
    	<td class="one">文章密码:</td>
        <td><input type="text" value="{$data.passwords}"  name="passwords"/>若填写了密码则访问该文章需要密码</td>
    </tr>
    <tr>
    	<td class="one">外部链接:</td>
       <td> <input type="text" value="{$data.out_link}" name="out_link" />
       若填写了外部链接则访问时直接跳转到您指定的链接上</td>
    </tr>
    <tr>
    	<td class="one">缩略图</td>
        <td>
        {literal}
        <script type="text/javascript">
		$(document).ready(function(){
			$("#sec1").click(function(){
				window.parent.show_window($("#thumbs"),'admincp.php?action=file&a=default&type=pic&f='+$("#thumbs").val())
			});
			
		})
        </script>
        {/literal}
        <div style=" float:left; padding-top:5px;"><input type="text" value="{$data.thumb}" id="thumbs" name="thumb" /></div>{if $data.thumb}<a href="{$data.thumb}" class="block_button" target="_blank">查看</a>{/if}<a href="javascript:void(0);" class="block_button"  id="sec1">选择</a></td>
    </tr>
    {if $model eq 'picture' || $model eq 'product'}
    	<tr>
        	<td class="one">{if $model eq 'picture'}请选择大图:{else}商品详情图:{/if}</td>
            <td>
        {literal}
        <script type="text/javascript">
		$(document).ready(function(){
			$("#sec2").click(function(){
				var obj = $("#big_pic");
				window.parent.show_window(obj,'admincp.php?action=file&a=default&type=pic&f='+$(obj).val())
			});
			
		})
        </script>
        {/literal}
            <div style=" float:left; padding-top:5px;"><input type="text" value="{$data.big_pic}" id="big_pic" name="big_pic" /></div>{if $data.big_pic}<a href="{$data.big_pic}" class="block_button" target="_blank">查看</a>{/if}<a href="javascript:void(0);" class="block_button" id="sec2">选择</a></td>
        </tr>
    {/if}
    <tr>
    	<td class="one">来源:</td>
        <td><input type="text" value="{if $data.source}{$data.source}{else}phpwms{/if}" name="source" /></td>
    </tr>
    {if $model eq 'product'}
    	<tr>
        	<td class="one">产品价格</td>
            <td><input type="text"  name="product_price" value="{if $data.product_price}{$data.product_price}{else}0{/if}" /> 元</td>
        </tr>
    {/if}
{*}    <tr>
    	<td class="one">分类标志:</td>
        <td><input type="text" value="{$data.cate_sign}"  name="cate_sign"/></td>
    </tr>
    {*}
    <tr>
    	<td class="one">其他设置:</td>
        <td>
        <input type="checkbox"  {if $data.is_show eq '1'} checked="checked" {/if} value="1" name="is_show" />
          通过审核&nbsp;<input  type="checkbox" value="1" name="is_hot"  {if $data.is_hot eq '1'} checked="checked"{/if}/>
          热门&nbsp;<input type="checkbox" value="1"  name="is_new" {if $data.is_new eq '1'} checked="checked"{/if} />
          最新
          <input  type="checkbox" value="1" name="is_pic" {if $data.is_pic eq '1'} checked="checked" {/if} />
            图文
            <!--<input type="checkbox" value="1"  name="is_index_slide" {if $data.is_index_slide} checked="checked" {/if} />
            首页幻灯-->
       置顶方式:<select  name="is_top">
        <option value="0">请选择置顶方式</option>
        <option value="1"{if $data.is_top eq '1'} selected="selected"{/if}>分类置顶</option>
        <option value="2" {if $data.is_top eq '2'} selected="selected"{/if}>全局总置顶</option>
        </select>
        &nbsp;
        </td>
    </tr>
    <tr>
    	<td class="one">点击:</td>
        <td><input type="text" value="{$data.hits}"  name="hits" /></td>
    </tr>
    <tr>
    	<td class="one">发布者:</td>
        <td><input type="text" value="{$data.post_user}" name="post_user" /></td>
    </tr>
        {if $model eq 'download'}
    	<tr>
        	<td class="one">文件大小</td>
            <td><input type="text" name="attach_size"  value="{$data.attach_size}" /></td>
        </tr>
        <tr>
        	<td class="one">下载地址一:</td>
            <td>
         {literal}
        <script type="text/javascript">
		$(document).ready(function(){
			$("#sec3").click(function(){
				var obj = $("#a_1");
				window.parent.show_window(obj,'admincp.php?action=file&a=default&type=pic&f='+$(obj).val())
			});
			
			$("#sec4").click(function(){
				var obj = $("#a_2");
				window.parent.show_window(obj,'admincp.php?action=file&a=default&f='+$(obj).val())
			});
			
			$("#sec5").click(function(){
				var obj = $("#a_3");
				window.parent.show_window(obj,'admincp.php?action=file&a=default&f='+$(obj).val())
			});
		})
		
        </script>
        {/literal}
            <input type="text" name="attach_link_1"  style="display:block; float:left; margin-top:5px;" id="a_1" value="{$data.attach_link_1}" /><a href="javascript:void(0);" class="block_button" id="sec3">选择</a></td>
        </tr>
            <tr>
        	<td class="one">下载地址二:</td>
            <td><input type="text" name="attach_link_2" style="display:block; float:left; margin-top:5px;" id="a_2" value="{$data.attach_link_2}" /><a href="javascript:void(0);" class="block_button" id="sec4">选择</a></td>
        </tr>
                <tr>
        	<td class="one">下载地址三:</td>
            <td><input type="text" name="attach_link_3" style="display:block; float:left; margin-top:5px;" id="a_3" value="{$data.attach_link_3}" /><a href="javascript:void(0);" class="block_button" >选择</a></td>
        </tr>
    {/if}
      <tr>
    	<td class="one">
        	简短描述:
        </td>
        <td>
        	{$simple_content}</td>
    </tr>
    <tr>
    	<td class="one">内容<span class="red">*</span></td>
        <td style=" width:100%;" class="c">
        <div class="red">若在页面中添加 [-page-] ,前台内容显示按分页显示</div>
        	{$editor} 
        </td>
    </tr>
    </table>
</div>

<div class="table_item" id="g_seo">
<h1 class="table_msg">SEO信息</h1>
	   <table width="98%" border="0" cellpadding="0" cellspacing="0" class="tableborder">
       <tr>
       	<td class="one" style="width:100px;">页面关键字(keywords):</td>
        <td><textarea style="height:120px; width:350px;" name="seo[keywords]">{$data.seo.keywords}</textarea></td>
       </tr>
       <tr>
       	<td class="one" style="width:100px;">页面描述(description)</td>
        <td><textarea style="height:120px; width:350px;" name="seo[description]">{$data.seo.description}</textarea></td>
       </tr>
       </table>
</div>
<div class="table_item" id="g_extend">
<h1 class="table_msg">扩展属性</h1>
{literal}
	<script type="text/javascript">
    	function ajax_call_extend(obj,url){
			var val = $(obj).val();
			if(val!=0){
				$.get(url+'&type_id='+val,function(d){$("#ajax_call_extend_info").html(d);})
			}
		}
    </script>
{/literal}
    <table width="98%" border="0" cellpadding="0" cellspacing="0" class="tableborder">
    	<tr>
        	<td width="17%" class="one">请选择所属扩展属性组:</td>
            <td width="83%" align="left">
            	<select name="type_id" style="width:150px;" onchange="ajax_call_extend(this,'admincp.php?action=model_operate&task=ajax_call_types&channel_type={$channel_type}&id={$data.c_id}');">
                	<option value="0">请选择...</option>
                    {foreach from=$extend_type item=ext}
                    	<option value="{$ext.type_id}" {if $data.type_id eq $ext.type_id} selected="selected" {/if}>{$ext.type_name}</option>
                    {/foreach}
                </select>
            </td>
        </tr>
    </table>
    <div id="ajax_call_extend_info">

    </div>
</div>
<div align="center" style="padding:5px;">
<input type="hidden" value="{$channel_id}"  name="channel_id"/>
<input type="submit" value="保存" />
</div>
    </form>
</div>
{/if}
{if $task eq 'ajax_call_types'}
	{if $extend_data}
	    <table width="98%" border="0" cellpadding="0" cellspacing="0" class="tableborder tableborder_line">
        {foreach from=$extend_data item=ext}
    	<tr>
        	<td width="17%" class="one">{$ext.attr_name}</td>
            <td width="">
            	{if $ext.input_model eq '1'}<input type="text" value="{$ext.value}" name="extend_val[{$ext.attr_id}]"/>{/if}
                {if $ext.input_model eq '2'}
                <select name="extend_val[{$ext.attr_id}]"  style="width:150px;">
                <option value="0">请选择...</option>
                	{foreach from=$ext.attr_extend_val item=val}
                        	<option value="{$val}" {if $ext.attr_value eq $val} selected="selected" {/if}>{$val}</option>
                    {/foreach}
                         </select>
                {/if}
            </td>
        </tr>
        {/foreach}
        </table>
        {else}
        <div class="notice_msg">无可用数据.</div>
        {/if}
{/if}
{if $task eq 'list' || $task eq 'add' || $task eq 'edit' || $task eq 'search'}
	{include file="footer.tpl"}
{/if}