<?php defined('APP_NAME') || exit('Access Denied'); 
?><!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="utf-8">
<meta name="Author" content="QQ:401421567" />
<link rel="stylesheet" href="<?php echo(isset($C['admin_static']) ? $C['admin_static'] : ''); ?>admin/css/bootstrap.min.css" />
<link rel="stylesheet" href="<?php echo(isset($C['admin_static']) ? $C['admin_static'] : ''); ?>admin/css/me.css" />
<script>var admin_static = "<?php echo(isset($C['admin_static']) ? $C['admin_static'] : ''); ?>" , cookie_pre = "<?php echo(isset($C['cookie_pre']) ? $C['cookie_pre'] : ''); ?>",_vip_key = "<?php echo(isset($vip['_key']) ? $vip['_key'] : ''); ?>",api_url = "<?php echo(isset($vip['api_url']) ? $vip['api_url'] : ''); ?>",_control = "<?php echo(isset($_GET['control']) ? $_GET['control'] : ''); ?>",_action = "<?php echo(isset($_GET['action']) ? $_GET['action'] : ''); ?>",version = '<?php echo(isset($vip['version']) ? $vip['version'] : ''); ?>',release = '<?php echo(isset($vip['release']) ? $vip['release'] : ''); ?>',vip_key = _vip_key;</script>
<script src="<?php echo(isset($C['admin_static']) ? $C['admin_static'] : ''); ?>admin/js/jquery.js"></script>
<script src="<?php echo(isset($C['admin_static']) ? $C['admin_static'] : ''); ?>admin/js/bootstrap.min.js"></script>
<script src="<?php echo(isset($C['admin_static']) ? $C['admin_static'] : ''); ?>js/layer/layer.js"></script>
<script src="<?php echo(isset($C['admin_static']) ? $C['admin_static'] : ''); ?>admin/js/global.js"></script>
<!--[if lt IE 9]>
  <script src="<?php echo(isset($C['admin_static']) ? $C['admin_static'] : ''); ?>admin/js/html5.js"></script>
  <script src="<?php echo(isset($C['admin_static']) ? $C['admin_static'] : ''); ?>admin/js/respond.min.js"></script>
<![endif]-->
<script type="text/javascript">
	var webdir = '<?php echo(isset($pp['webdir']) ? $pp['webdir'] : ''); ?>';
	layer.config({
		extend: 'extend/layer.ext.js',
		shift: -1
	});
	var pKey = "<?php echo(isset($_pkey) ? $_pkey : ''); ?>", urlKey = "<?php echo(isset($_ukey) ? $_ukey : ''); ?>", place = "<?php echo(isset($_place) ? $_place : ''); ?>";
	//全选与全不选
	function selectall(name,obj) {
		if ($(obj).is(':checked')) {
			$("input[name='"+name+"']").each(function() {
				$(this).prop('checked', true);
			});
		} else {
			$("input[name='"+name+"']").each(function() {
				$(this).prop('checked', false);
			});
		}
	}
</script>
<title><?php echo(isset($_title) ? $_title : ''); ?></title>
</head>
<body>
<div class="container-fluid">
	<div class="panel panel-default">
		<div class="panel-heading"><a id="add" class="btn btn-info btn-xs pull-right" href="javascript:;"><span class="glyphicon glyphicon-plus"></span> 增加分类</a><strong class="panel-title">分类管理</strong> <span class="clearfix"></span></div>
		<?php if (!empty($category_arr)) { ?>
			<table class="table table-condensed">
			<?php if(isset($category_arr) && is_array($category_arr)) { foreach($category_arr as $mid=>&$arr) { ?>
			<tbody class="category">
				<tr>
					<th><?php  echo $mod_name[$mid]; ?>分类</th>
					<th>分类别名</th>
					<th>分类排序</th>
					<th>数量</th>
					<th>管理</th>
				</tr>
				<?php if(isset($arr) && is_array($arr)) { foreach($arr as &$v) { ?>
				<?php 
					$v['prestr'] = str_repeat("　　", $v['pre']-1);
					$v['url'] = $_ENV['_category_class']->category_url($v['cid'], $v['alias']);
				 ?>
				<tr class="cat_col cate" cid="<?php echo(isset($v['cid']) ? $v['cid'] : ''); ?>" mid="<?php echo(isset($v['mid']) ? $v['mid'] : ''); ?>" ur1="<?php echo(isset($v['url']) ? $v['url'] : ''); ?>">
					<td>
						<div class="c_name">
							　<?php echo(isset($v['prestr']) ? $v['prestr'] : ''); ?>
							<?php if ($v['mid'] == 1) { ?>
								<span class="label label-success">单页</span>
							<?php }elseif($v['type'] == 1) { ?>
								<span class="label label-default">频道</span>
							<?php }else{ ?>
								<span class="label label-info">列表</span>
							<?php } ?>
							<?php echo(isset($v['name']) ? $v['name'] : ''); ?> <small class="text-muted">(CID:<?php echo(isset($v['cid']) ? $v['cid'] : ''); ?>)</small>
						</div>
					</td>
					<td> <?php echo(isset($v['alias']) ? $v['alias'] : ''); ?></td>
					<td class="reorder"><input name="orderby" value="<?php echo(isset($v['orderby']) ? $v['orderby'] : ''); ?>" type="number" class="wnum" autocomplete="off"></td>
					<td><?php if ($v['mid'] != 1 && $v['type'] != 1) { echo(isset($v['count']) ? $v['count'] : ''); } ?></td>
					<td><div class="more_but"><a class="text-info" href="javascript:edit(<?php echo(isset($v['cid']) ? $v['cid'] : ''); ?>);">编辑</a> <a href="<?php echo(isset($v['url']) ? $v['url'] : ''); ?>" target="_blank">查看</a> <a class="text-danger" href="javascript:del(<?php echo(isset($v['cid']) ? $v['cid'] : ''); ?>);">删除</a></div></td>
				</tr>
				<?php }} ?>
			</tbody>
			<?php }} ?>
			</table>
		<?php } ?>
	</div>
</div>
<script type="text/javascript">
$(document).ready(function(){
	load_order();
});
$("#add").click(function () {
	parent.oneTab("添加分类","category-set-cid-0","category");
});
function edit(cid){
	parent.oneTab("编辑分类","category-set-cid-" + cid,"category");
}
function load_order(){
	$(".reorder input[name='orderby']").focusin(function() {
		$(this).attr("v", $(this).val());
	}).focusout(function() {
		var orderby = $(this).val();
		var old_orderby = $(this).attr("v");
		if (orderby == old_orderby) return;
		var cid = $(this).parent().parent().attr("cid");
		ppajax.postd("index.php?u=category-edit_orderby-ajax-1", {cid: cid,orderby: orderby},function(data) {
			var data = tojson(data);
			if (window.ppExit) return;
			if (data.err == 0) window.location.reload();
		});
	});
}
function getAllCate() {
	setTimeout(function() {
		ppajax.get("index.php?u=category-get_category_content&r=" + time(),
		function(html) {
			window.location.reload();
		});
	},
	500);
}
function del(cid) {
	ppajax.confirm("删除不可恢复，确定删除？",function() {
		ppajax.postd("index.php?u=category-del-ajax-1", {
			cid: cid
		},
		function(data) {
			ppajax.alert(data);
			if (window.ppdata.err == 0) $(".category tr[cid='" + cid + "']").remove();
			ppajax.remove();
		});
	});
}
</script>
</body>
</html>