<script language="javascript" src="<?=BASEURL?>public/admin/js/jquery.tablesorter.js"></script>
<script language="javascript">
$(
	function (){
		$(".adminlist").tablesorter({ headers: { 0: { sorter: false}, 1: {sorter: false} } });
	}
);
</script>
<input type="hidden" name="channel_id" value="<?=$channel_id?>" />
<table border="0" class="search" cellspacing="0">
   	<tr>
    	<td class="searchlogo"></td>
     	<td width="10%" style="padding-left:10px;">当前站点:</td>
        <td width="12%" align="left"><?=$dropdowncChannel?></td>
     	<td width="5%">分类</td>
     	<td ><?=$treeCategory?></td>
        <td>关键字</td>
        <td><input type="text" class="text" name='search[keywords]' /></td>
        <td><input type="submit" name="sb" value="搜索" class="submit"></td>
    </tr>
</table>
<table class="adminlist" cellpadding="0" cellspacing="0">
  <thead>
    <tr>
      <th width="2%" class="title">#</th>
      <th width="3%" class="title"><input type="checkbox" id="toggle" value="all"></th>
      <th class="title">标题</th>
      <th class="title" width="5%">状态</th>
      <th class="title" width="10%">作者(会员)</th>
      <th class="title" width="10%">分类</th>
      <th class="title">文章发布时间</th>
      <th class="title"><?=Kohana::lang("content_lang.control")?></th>
    </tr>
  </thead>
  <tbody>
    <?php foreach($contents as $tmp_content){?>
    <tr class="row0">
      <td><?php  if(isset($a)){echo ++$a;}else{echo $a=1;}?></td>
      <td><input type="checkbox" class="checkbox" id="cb<?=$a?>" name="select_id[]" value="<?=$tmp_content->content_id?>" /></td>
      <td><a href="<?=$tmp_content->url?>"><?=$tmp_content->title?></a></td>
      <td><?php if($tmp_content->status){?>已审核<?php }else{?>待审核<?php }?></td>
      <td><?=$tmp_content->user_name?$tmp_content->user_name:"后台管理员"?></td>
      <td><?=$tmp_content->cat_name?$tmp_content->cat_name:$channel_name?></td>
      <td><?=date("Y-m-d H:i:s",$tmp_content->publish_date)?></td>
      <td><a href="<?=BASEURI?>model_content/edit/<?=$channel_id?>/<?=$tmp_content->content_id?>">
        <?=Kohana::lang("content_lang.edit");?>
        </a> <a href="<?=BASEURI?>model_content/delete/<?=$channel_id?>/<?=$tmp_content->content_id?>" class="deletecontent">
        <?=Kohana::lang("content_lang.delete");?>
        </a> </td>
    </tr>
    <?php }?>
  </tbody>
  <tfoot>
    <tr>
      <td colspan="3" height="25">
      <input type="button" value="添加" name="sb" class="submit" onclick="button_location('<?=BASEURI?>model_content/add/<?=$channel_id?>')" accesskey="N">
      <input type="button" value="删除" name="sbc" class="submit" onclick="select_control('<?=BASEURI?>model_content/delete','请确认是否执行些操作')" accesskey="D">
      <select name="audit" onchange="select_control('<?=BASEURI?>model_content/auditing','请确认是否执行些操作')">
      	<option value="">审核文档
      	<option value="1">通过审核
      	<option value="0">待审核
      </select>
      </td>
      <td colspan="4">
		<?=$this->pagination->render('digg')?>
      </td>
    </tr>
  </tfoot>
</table>
<script language="javascript">
$(document).ready(
	function (){
		$(".deletecontent").click(
			function (){
				if(confirm('请确认是否删除')){
					var href	=	$(this).attr("href");
					$(this).parent().parent().filter('tr').remove();
					//ajax删除内容
					$.get(href,null,function(html){
						if(html!=''){
							parent.reporting('删除内容成功','success');
						}
					});
					$("body").ajaxError(function(event,request, settings){
						parent.reporting('删除内容失败<br>出错页面:' + settings.url,'error');
						window.location=settings.url;
					}); 	
				}
				return false;
			}
		);
	}
);
</script>