<?php include $this->admin_tpl('meta');?>
<title>内容管理 - YzmCMS内容管理系统</title>
<link href="<?php echo STATIC_URL;?>plugin/editable/css/jquery-editable.css" rel="stylesheet"/>
</head>
<body>
<nav class="breadcrumb"><i class="yzm-iconfont yzm-iconai-home"></i> 首页 <span class="c-gray en">&gt;</span> 内容管理 <span class="c-gray en">&gt;</span> 内容列表 <a class="btn btn-success radius r" style="line-height:1.6em;margin-top:3px" href="javascript:location.replace(location.href);" title="刷新" ><i class="yzm-iconfont yzm-iconshuaxin"></i></a></nav>
<div class="page-container">
  <div> 
    <form action="<?php echo U('search');?>" method="get" id="search">
	 <input type="hidden" value="<?php echo ROUTE_M;?>" name="m">
	 <input type="hidden" value="<?php echo ROUTE_C;?>" name="c">
	 <input type="hidden" value="search" name="a">
     <span class="select-box inline">
		<select name="modelid" class="select" onchange="change_model()">
			<?php 
				foreach($modelinfo as $val){
					$str = $val['modelid']==$modelid ? 'selected' : '';
					echo '<option value="'.$val['modelid'].'" '.$str.'>'.$val['name'].'</option>';
				}
			?>
		</select>
	 </span>
	 <span class="select-box inline"><?php echo select_category('catid', $catid, '内容分类', 0, '', true, true, $modelid); ?></span>
     更新时间：<input type="text" class="input-text laydate-icon" style="width:110px;height:30px;" id="start" name="start" <?php if(isset($_GET['start']) && $_GET['start']) echo 'value="'.$_GET['start'].'"'; ?>>
     至 <input type="text" class="input-text laydate-icon" style="width:110px;height:30px;" id="end" name="end" value="<?php if(isset($_GET['end']) &&  $_GET['end']) echo $_GET['end']; else echo date('Y-m-d'); ?>">
     <span class="select-box inline">
		<select name="flag" class="select">
		<option value="0">内容属性</option>
		<option <?php if(isset($_GET["flag"]) && $_GET["flag"]=='1'){echo 'selected';} ?> value="1">置顶[1]</option>
		<option <?php if(isset($_GET["flag"]) && $_GET["flag"]=='2'){echo 'selected';} ?> value="2">头条[2]</option>
		<option <?php if(isset($_GET["flag"]) && $_GET["flag"]=='3'){echo 'selected';} ?> value="3">特荐[3]</option>
		<option <?php if(isset($_GET["flag"]) && $_GET["flag"]=='4'){echo 'selected';} ?> value="4">推荐[4]</option>
		<option <?php if(isset($_GET["flag"]) && $_GET["flag"]=='5'){echo 'selected';} ?> value="5">热点[5]</option>
		<option <?php if(isset($_GET["flag"]) && $_GET["flag"]=='6'){echo 'selected';} ?> value="6">幻灯[6]</option>
		<option <?php if(isset($_GET["flag"]) && $_GET["flag"]=='7'){echo 'selected';} ?> value="7">跳转[7]</option>
		</select>
	</span>
    <span class="select-box inline">
		<select name="status" class="select">
        <option value="99">状态</option>
		<option <?php if(isset($_GET["status"]) && $_GET["status"]=='0'){echo 'selected';} ?> value="0">草稿</option>
		<option <?php if(isset($_GET["status"]) && $_GET["status"]=='1'){echo 'selected';} ?> value="1">正常</option>
		<option <?php if(isset($_GET["status"]) && $_GET["status"]=='2'){echo 'selected';} ?> value="2">已退稿</option>
		</select>
	</span>
	<span class="select-box inline">
		<select name="readpoint" class="select">
        <option value="99">阅读收费</option>
		<option <?php if(isset($_GET["readpoint"]) && $_GET["readpoint"]=='0'){echo 'selected';} ?> value="0">免费</option>
		<option <?php if(isset($_GET["readpoint"]) && $_GET["readpoint"]=='1'){echo 'selected';} ?> value="1">付费</option>
		</select>
	</span>
    <span class="select-box inline">
		<select name="type" class="select">
			<option value="1" <?php if(isset($_GET['type']) && $_GET['type']==1) echo 'selected';?>>标题</option>
			<option value="2" <?php if(isset($_GET['type']) && $_GET['type']==2) echo 'selected';?>>发布人</option>
			<option value="3" <?php if(isset($_GET['type']) && $_GET['type']==3) echo 'selected';?>>关键词</option>
			<option value="4" <?php if(isset($_GET['type']) && $_GET['type']==4) echo 'selected';?>>摘要</option>
			<option value="5" <?php if(isset($_GET['type']) && $_GET['type']==5) echo 'selected';?>>内容ID</option>
		</select>
	</span>
     <input type="text" name="searinfo" class="input-text search" value="<?php if(isset($_GET['searinfo'])) echo $_GET['searinfo'];?>"><button name="dosubmit" class="btn btn-success btn-search" type="submit" value="1"><i class="yzm-iconfont yzm-iconsousuo"></i> 搜索</button>
     <a href="<?php echo U('init');?>" class="btn btn-primary radius"><i class="yzm-iconfont yzm-iconshuaxin"></i> 重置</a>
	 </form>	
  </div>
  <div class="cl mt-15 tb-top"> 
  <span class="l">
  <a href="javascript:;" onclick="yzm_open_full('添加内容','<?php echo U('add', array('modelid'=>$modelid));?>')" class="btn btn-primary radius"><i class="yzm-iconfont yzm-icontianjia"></i> 添加内容</a>
  <a href="javascript:;" onclick="yzm_dels('ids', 1)" class="btn btn-danger radius"><i class="yzm-iconfont yzm-iconshanchu2"></i> 批量删除</a> 
  <a href="javascript:;" onclick="baidu_push()" class="btn btn-secondary radius"><i class="yzm-iconfont yzm-iconfabusekuai"></i> 推送至百度</a> 
  <a href="javascript:;" onclick="attribute_operation('移动分类', '<?php echo U('remove', array('modelid' => $modelid))?>')" class="btn btn-primary radius"><i class="yzm-iconfont yzm-iconyidong"></i> 移动分类</a> 
  <a href="javascript:;" onclick="attribute_operation('复制内容', '<?php echo U('copy', array('modelid' => $modelid))?>')" class="btn btn-primary radius"><i class="yzm-iconfont yzm-iconfuzhi"></i> 复制内容</a> 
  <a href="javascript:;" onclick="attribute_operation('属性变更', '<?php echo U('attribute_operation', array('modelid' => $modelid))?>')" class="btn btn-success radius"><i class="yzm-iconfont yzm-icontags"></i> 属性变更</a> 
  <a href="javascript:;" onclick="attribute_operation('状态变更', '<?php echo U('status_operation', array('modelid' => $modelid))?>')" class="btn btn-warning radius"><i class="yzm-iconfont yzm-iconshezhi1"></i> 状态变更</a> 
  </span> <span class="r">共有数据：<strong><?php echo $total?></strong> 条</span> </div>
  <form method="post" action="<?php echo U('del');?>" id="myform">
  <input type="hidden" name="modelid" value="<?php echo $modelid;?>">
  <table class="table table-border table-bg table-hover yzm-table-sort">
    <thead>
      <tr class="text-c">
        <th width="25"><input type="checkbox"></th>
		<th width="50">ID<?php echo field_order('id');?></th>
		<th>标题</th>
		<th width="120">内容分类<?php echo field_order('catid');?></th>
		<th width="65">点击量<?php echo field_order('click');?></th>
		<th width="120">发布人<?php echo field_order('username');?></th>
		<th width="135">更新时间<?php echo field_order('updatetime');?></th>
		<th width="50">状态<?php echo field_order('status');?></th>
		<th width="50">推送<?php echo field_order('is_push');?></th>
		<th width="55">管理操作</th>
      </tr>
    </thead>
    <tbody>
		<?php 
		foreach($data as $val){
		?>
		  <tr class="text-c">
			<td><input type="checkbox" value="<?php echo $val['id']?>" name="ids[]"></td>
			<td><?php echo $val['id']?></td>
			<td class="text-l">
			<?php 
			if($val['thumb']){
				echo '<span style="color:#0a6999;font-size:14px;vertical-align:middle;" onmouseover="yzm_img_browse(this, \''.$val['thumb'].'\')" onmouseout="layer.closeAll(\'tips\')" class="yzm-iconfont yzm-icontupian1 pointer"></span>';
			}
			?>
			<a href="<?php echo $val['url'] ? $val['url'] : U('admin_content/public_preview', array('catid'=>$val['catid'],'id'=>$val['id']));?>" target="_blank" ><?php echo title_color($val['title'], $val['color']);?></a>
			<?php
			if(strpos($val['flag'], '1') !== false){
				echo '<span class="yzm-font-style" title="置顶">顶</span>';
			}
			if(strpos($val['flag'], '2') !== false){
				echo '<span class="yzm-font-style" title="头条">头</span>';
			}
			if(strpos($val['flag'], '3') !== false){
				echo '<span class="yzm-font-style" title="特荐">特</span>';
			}
			if(strpos($val['flag'], '4') !== false){
				echo '<span class="yzm-font-style" title="推荐">推</span>';
			}
			if(strpos($val['flag'], '5') !== false){
				echo '<span class="yzm-font-style" title="热点">热</span>';
			}
			if(strpos($val['flag'], '6') !== false){
				echo '<span class="yzm-font-style" title="幻灯">幻</span>';
			}
			if(strpos($val['flag'], '7') !== false){
				echo '<span class="yzm-font-style" title="跳转">跳</span>';
			}
			if($val['readpoint']){
				echo '<span class="yzm-font-style" title="付费">付</span>';
			}			
			?>		
			</td>
			<td><?php echo get_catname($val['catid']);?></td>
			<td>
				<span class="click" data-pk="<?php echo $val['id']?>" onmouseover="yzm_tips=layer.tips('点击修改数据', this)" onmouseout="layer.close(yzm_tips);"><?php echo $val['click']?></span>
			</td>
			<td>
				<span title="作者昵称：<?php echo $val['nickname']; ?>"><?php echo $val['username']; ?></span>
				<?php if(!$val['issystem']){ ?>
				<span style="color:blue;" onmouseover="yzm_tips=layer.tips('会员发布', this)" onmouseout="layer.close(yzm_tips);"><i class="yzm-iconfont yzm-iconyonghu"></i><span>
				<?php } ?>
			</td>
			<td><span title="<?php echo '发布时间：'.date('Y-m-d H:i:s', $val['inputtime'])."\r\n更新时间：".date('Y-m-d H:i:s', $val['updatetime'])?>"><?php echo date('Y-m-d H:i:s', $val['updatetime'])?></span></td>
			<td>
				<?php echo $val['status']=='0' ? '<span class="label radius">草稿</span>' : ($val['status']=='1' ? '<span class="label label-success radius">正常</span>' :'<span class="label label-danger radius">已退稿</span>');?>
			</td>
			<td><?php echo $val['is_push'] ? '已推送' : '<span class="c-red">未推送</span>';?></td>
			<td>
				<a title="编辑" href="javascript:;" onclick="yzm_open_full('编辑内容','<?php echo U('edit',array('modelid'=>$modelid,'id'=>$val['id']));?>')" class="ml-5" style="text-decoration:none"><i class="yzm-iconfont yzm-iconbianji2"></i></a> 
				<a title="预览" href="<?php echo $val['url'];?>" class="ml-5" target="_blank" style="text-decoration:none"><i class="yzm-iconfont yzm-iconyulan2"></i></a>
			</td>
		  </tr>		
		<?php 
		}
		?>
    </tbody>
  </table>
  <?php if(!$data){ ?><div class="yzm_no_data"><i class="yzm-iconfont yzm-iconshuoming"></i> 暂无数据</div><?php } ?>
  </form>
  <div id="page"><span class="page_left">共<?php echo $total?>条记录，共<?php echo $page->total()?>页，当前显示第<?php echo $page->getpage()?>页</span>
  <span class="page_right"><?php echo $page->getfull();?></span></div>
</div>
<?php include $this->admin_tpl('footer');?>
<script type="text/javascript" src="<?php echo STATIC_URL;?>plugin/laydate/1.1/laydate.js"></script>
<script type="text/javascript" src="<?php echo STATIC_URL;?>plugin/editable/js/jquery.poshytip.js"></script>
<script type="text/javascript" src="<?php echo STATIC_URL;?>plugin/editable/js/jquery-editable-poshytip.min.js"></script>
<script type="text/javascript">

	$('.click').editable({
	    url: '<?php echo U('public_fast_edit');?>',
	    name: 'click',
	    title: '修改数据',
	    params: {"modelid":"<?php echo $modelid?>"},
	    dataType: "json", 
	    validate:function (value) {
	        if(value=='' || isNaN(value) || value < 0){
	            return '点击量必须为数字且不能小于0！';
	        }
	    },
	    success: function(msg, newvalue) {
	        if(!msg.status){
	        	return msg.message; 
		    }
	    }
	});

	function attribute_operation(s, url){
		var ids = $("input[name='ids[]']:checked");
		if (ids.length<1){
		   layer.alert('请选择要操作的内容！');
		   return false;
		}

		var str = '';
		$.each(ids,function(){
			if(this.checked){
				str += $(this).val() + ',';
			}
		 });
		str = str.substr(0,str.length-1);
		layer.open({  
	        type: 2,  
	        title: s,  
	        shadeClose: true,  
	        shade: 0.2,  
	        area: ['500px', '250px'],  
	        content: url,
			success: function(layero, index){
				var body = layer.getChildFrame('body', index);
				body.find('#ids').val(str);
			}
		})  
					
	}

	function baidu_push() {
		var ids = $("input[name='ids[]']:checked");
		if (ids.length<1){
		   layer.alert('请选择要操作的内容！');
		   return false;
		}

		layer.msg('正在推送中...', { icon: 16, shade: 0.21, time:false });
	    $.ajax({
			type: 'POST',
			url: '<?php echo U('baidu_push');?>', 
			data: $("#myform").serialize(),
			dataType: "json", 
			success: function (msg) {
				if(msg.status == 1){
					layer.msg(msg.message, {icon:1, time:1000}, function(){
						location.reload();
					});
			    }else{
					layer.msg(msg.message, {icon:2});
				}
			}
	    })		
	}

	function change_model(){
		$("#search").submit();
	}

	var start = {elem:'#start',format:'YYYY-MM-DD',min:'1999-01-01',max:'2099-01-01',istime:false,istoday:false,choose:function(datas){end.min = datas;end.start = datas}
	};
	var end = {elem:'#end',format:'YYYY-MM-DD',min:'1999-01-01',max:'2099-01-01',istime:false,istoday:false,choose:function(datas){start.max = datas;}};
	laydate(start);
	laydate(end);
</script>

</body>
</html>