<?php if (!defined('THINK_PATH')) exit();?><!DOCTYPE html>
<html lang="en">
	<head>
		<title></title>
		<meta charset="UTF-8" />
        <meta name="viewport" content="width=device-width, initial-scale=1.0" />

		<link rel="stylesheet" type="text/css" href="<?php echo (THEME_PATH_ABS); ?>/css/bootstrap.min.css" />
		<link rel="stylesheet" type="text/css" href="<?php echo (THEME_PATH_ABS); ?>/css/bootstrap-responsive.min.css" />
        <link rel="stylesheet" type="text/css" href="<?php echo (THEME_PATH_ABS); ?>/css/colorpicker.css" />
        <link rel="stylesheet" type="text/css" href="<?php echo (THEME_PATH_ABS); ?>/css/datepicker.css" />
		<link rel="stylesheet" type="text/css" href="<?php echo (THEME_PATH_ABS); ?>/css/uniform.css" />
		<link rel="stylesheet" type="text/css" href="<?php echo (THEME_PATH_ABS); ?>/css/select2.css" />		
		<link rel="stylesheet" type="text/css" href="<?php echo (THEME_PATH_ABS); ?>/css/unicorn.main.css" />
		<link rel="stylesheet" type="text/css" href="<?php echo (THEME_PATH_ABS); ?>/css/unicorn.grey.css" />
		<link rel="stylesheet" type="text/css" href="<?php echo (THEME_PATH_ABS); ?>/css/select2.css" />


		<script type="text/javascript" src="<?php echo (THEME_PATH_ABS); ?>/umeditor/umeditor.config.js"></script>
		<script type="text/javascript" src="<?php echo (THEME_PATH_ABS); ?>/js/jquery.min.js"></script>
		<script type="text/javascript" src="<?php echo (THEME_PATH_ABS); ?>/js/jquery.ui.custom.js"></script>
		<script type="text/javascript" src="<?php echo (THEME_PATH_ABS); ?>/js/bootstrap.min.js"></script>
		<script type="text/javascript" src="<?php echo (THEME_PATH_ABS); ?>/js/bootstrap-colorpicker.js"></script>
		<script type="text/javascript" src="<?php echo (THEME_PATH_ABS); ?>/js/bootstrap-datepicker.js"></script>
		<script type="text/javascript" src="<?php echo (THEME_PATH_ABS); ?>/js/jquery.uniform.js"></script>
		<script type="text/javascript" src="<?php echo (THEME_PATH_ABS); ?>/js/select2.min.js"></script>
		<script type="text/javascript" src="<?php echo (THEME_PATH_ABS); ?>/js/unicorn.js"></script>
		<script type="text/javascript" src="<?php echo (THEME_PATH_ABS); ?>/js/unicorn.form_common.js"></script>


	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /></head>
	<body>
		
		
		<div id="header">

			<h1><a href="./dashboard.html">Unicorn Admin</a></h1>	
		</div>
		<!--
		<div id="search">
			<input type="text" placeholder="Search here..." /><button type="submit" class="tip-right" title="Search"><i class="icon-search icon-white"></i></button>
		</div>-->
		<div id="user-nav" class="navbar navbar-inverse">
            <ul class="nav btn-group">

                <!--<li class="btn btn-inverse"><a title="" href="#"><i class="icon icon-user"></i> <span class="text">Profile</span></a></li>
                <!--
                <li class="btn btn-inverse dropdown" id="menu-messages"><a href="#" data-toggle="dropdown" data-target="#menu-messages" class="dropdown-toggle"><i class="icon icon-envelope"></i> <span class="text">Messages</span> <span class="label label-important">5</span> <b class="caret"></b></a>
                    <ul class="dropdown-menu">
                        <li><a class="sAdd" title="" href="#">new message</a></li>
                        <li><a class="sInbox" title="" href="#">inbox</a></li>
                        <li><a class="sOutbox" title="" href="#">outbox</a></li>
                        <li><a class="sTrash" title="" href="#">trash</a></li>
                    </ul>-->
                </li>
                <li class="btn btn-inverse"><a title="" href="/wublog/index.php/index.php/Admin/Index/profile"><i class="icon icon-cog"></i> <span class="text"><?php echo ($_SESSION['username']); ?>设置</span></a></li>

                <li class="btn btn-inverse"><a title="" href="/wublog/index.php/Admin/Login/do_logout/"><i class="icon icon-share-alt"></i> <span class="text">注销</span></a></li>
            </ul>
        </div>
		<div id="sidebar">
			<a href="#" class="visible-phone"><i class="icon icon-home"></i> Dashboard</a>
			<ul>
			<?php if(($data["PageFun"]) == "index"): ?><li class="active"> <?php else: ?> <li><?php endif; ?>
				<a href="/wublog/index.php/Admin/Index"><i class="icon icon-home"></i> <span>首页</span></a></li>
				<?php if(in_array(($data["PageFun"]), explode(',',"archive,items,archivelists,archivelists"))): ?><li class="submenu open active"><?php else: ?><li class="submenu"><?php endif; ?>			
					<a href="#"><i class="icon icon-th-list"></i> <span>内容管理</span> <span class="label"></span></a>
					<ul>
						<?php if(($data["PageFun"]) == "items"): ?><li class="active"> <?php else: ?> <li><?php endif; ?><a href="/wublog/index.php/Admin/Index/items">我的栏目</a></li>
						<?php if(($data["PageFun"]) == "archivelists"): ?><li class="active"> <?php else: ?> <li><?php endif; ?><a href="/wublog/index.php/Admin/Index/archivelists">所有文章</a></li>
						<?php if(($data["PageFun"]) == "archive"): ?><li class="active"> <?php else: ?> <li><?php endif; ?><a href="/wublog/index.php/Admin/Index/archive">内容发布</a></li>
						
					</ul>
				</li>
				<?php if(($data["PageFun"]) == "mycomment"): ?><li class="active"> <?php else: ?> <li><?php endif; ?><a href="/wublog/index.php/Admin/Index/mycomment"><i class="icon icon-pencil"></i>我的评论</a></li>
				<?php if(($data["PageFun"]) == "myfiles"): ?><li class="active"> <?php else: ?> <li><?php endif; ?><a href="/wublog/index.php/Admin/Index/myfiles/filter/all"><i class="icon icon-pencil"></i> <span>我的上传</span></a></li>

				
				<?php if(in_array(($data["PageFun"]), explode(',',"profile,link"))): ?><li class="submenu open active"><?php else: ?><li class="submenu"><?php endif; ?>
				<a href="#"><i class="icon icon-th-list"></i> <span>设置</span> <span class="label"></span></a>
				<ul>
				<?php if(($data["PageFun"]) == "profile"): ?><li class="active"> <?php else: ?> <li><?php endif; ?><a href="/wublog/index.php/Admin/Index/profile"><i class="icon icon-pencil"></i> <span>常规选项</span></a></li>
				<?php if(($data["PageFun"]) == "link"): ?><li class="active"> <?php else: ?> <li><?php endif; ?><a href="/wublog/index.php/Admin/Index/mylink"><i class="icon icon-pencil"></i> <span>友情链接</span></a></li>
				</ul>




				
			</ul>
		
		</div>
		
<div id="content">
			<div id="content-header">
			<h1><?php echo ($data["PageName"]); ?></h1>
			</div>


			<div id="breadcrumb">
				<a href="#" title="Go to Home" class="tip-bottom"><i class="icon-home"></i> Home</a>
				<a href="#" class="current"><?php echo ($data["PageName"]); ?></a>
			</div>
			<div id="style-switcher">
			<i class="icon-arrow-left icon-white"></i>
			<span>Style:</span>
			<a href="#grey" style="background-color: #555555;border-color: #aaaaaa;"></a>
			<a href="#blue" style="background-color: #2D2F57;"></a>
			<a href="#red" style="background-color: #673232;"></a>
		</div>

<div class="container-fluid">
<div class="row-fluid">
<div class="span6">
<div id='alert'></div>
				<div class="widget-box">
							<div class="widget-title">
								<span class="icon">
									<i class="icon-file"></i>
								</span>
								<h5>友情链接汇总</h5>
							</div>
							<div class="widget-content nopadding">
							<table  class="table table-bordered data-table">
									<thead>
									<tr>
									<th style="width:25px"></th>
									<th>描述</th>
									<th>链接</th>
									<th>状态</th>
									<th  style="width:40px">操作</th>
									</tr>
									</thead>
									<tbody >
									<?php if(is_array($data["links"])): $i = 0; $__LIST__ = $data["links"];if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$vo): $mod = ($i % 2 );++$i;?><tr id='tr1<?php echo ($vo["id"]); ?>' class="gradeX">
									<td><input type="checkbox" id='sel<?php echo ($vo["id"]); ?>' /></td>
									<td id="desc-lable-<?php echo ($vo["id"]); ?>"><?php echo ($vo["description"]); ?></td>
									<td id="link-lable-<?php echo ($vo["id"]); ?>">http://<span id="link-text-<?php echo ($vo["id"]); ?>"><?php echo ($vo["link"]); ?></span></td>
									<td id="approve-lable-<?php echo ($vo["id"]); ?>">
									<?php if(($vo["approve"]) == "0"): ?><span style="color:green">接受</span>
									<?php else: ?>
									<span style="color:red">拒绝</span><?php endif; ?>

									</td>
									<td>
										<div class="btn-group">
									  <button data-toggle="dropdown" class="btn btn-primary dropdown-toggle">操作 <span class="caret"></span></button>
									  <ul class="dropdown-menu">
										<li><a href="#" onclick="edit('<?php echo ($vo["id"]); ?>')"><i class="icon-pencil icon-black"></i>编辑</a></li>
										<?php if(($vo["approve"]) == "0"): ?><li><a href="#" onclick="ajax_audit(<?php echo ($vo["id"]); ?>,1)"><i class="icon-file icon-black"></i>拒绝</a></li>
										<?php else: ?>
										<li><a href="#" onclick="ajax_audit(<?php echo ($vo["id"]); ?>,0)"><i class="icon-file icon-black"></i>同意</a></li><?php endif; ?>
										<li class="divider"></li>
										<li><a href="#" onclick="ajax_del(<?php echo ($vo["id"]); ?>)"><i class="icon-remove icon-black"></i>删除</a></li>
									  </ul>
									</div>
									</td>
									</tr><?php endforeach; endif; else: echo "" ;endif; ?>
									</tbody>
							</table>  
							</div>
						</div>		
</div>
		<div class="span6">
				<div class="widget-box">
							<div class="widget-title">
								<span class="icon">
									<i class="icon-file"></i>
								</span>
								<h5>新增友情链接</h5>
							</div>
							<div class="widget-content nopadding">
								<form action="/wublog/index.php/Admin/Link/addLink" method="post" class="form-horizontal" />
									<div class="control-group">
										<label class="control-label">链接描述</label>
										<div class="controls">
											<input name="description" type="text" />
										</div>
									</div>


									<div class="control-group">
										<label class="control-label">链接</label>
										<div class="controls">
											<input name="link" type="text" /><span class="help-block">只需填入链接，无需填入"Http://"。如：www.baidu.com</span>
										</div>
									</div>
									

									<div class="control-group">
										<label class="control-label">审批</label>
										<div class="controls">
											<select name="audit">
											<option value='0' />接受
											<option value='1' />拒绝
											</select>
										</div>
									</div>
									<input type="hidden" name="userid" value="<?php echo (session('userid')); ?>" />
									<div class="form-actions">
										<button type="submit" class="btn btn-primary">保存</button>
									</div>



								</form>
							</div>
						</div>		
						<div class="widget-box">
							<div class="widget-title">
								<span class="icon">
									<i class="icon-align-justify"></i>								
								</span>
								<h5>尚未通过</h5>
							</div>
							<div class="widget-content nopadding">
							<table  class="table table-bordered data-table">
									<thead>
									<tr>
									<th>描述</th>
									<th>链接</th>
									<th  style="width:40px">操作</th>
									</tr>
									</thead>
									<tbody >
									<tr class="gradeX">
									<td>百度搜索</td>
									<td><a href="http://www.baidu.com">http://www.baidu.com</a></td>
									<td>
										<div class="btn-group">
									  <button data-toggle="dropdown" class="btn btn-primary dropdown-toggle">操作 <span class="caret"></span></button>
									  <ul class="dropdown-menu">
										<li><a href="#"><i class="icon-file icon-black"></i>接受</a></li>
										<li class="divider"></li>
										<li><a href="#" ><i class="icon-remove icon-black"></i>删除</a></li>
									  </ul>
									</div>
									</td>
									</tr>
									</tbody>
							</table>  
							</div>
						</div>	
		</div>
<script type="text/javascript">
tmplink = new Array();
function canceledit(id)
{
vid="#tr1"+id;
$(vid).html(tmplink[id]);
delete tmplink[id];
//$.cookie('content'+vid,null);
}
function edit(id)
{

		vid="#tr1"+id;
		var description=$("#desc-lable-"+id).html();
		var link=$("#link-text-"+id).html();
		tmplink[id]=$(vid).html();
        var addText="<td></td><td><input id='desc-"+id+"' type='text' value='"+description+"' /></td><td><input id='link-"+id+"' type='text' value='"+link+"' /></td><td></td><td><div class='btn-group'><button data-toggle='dropdown' class='btn btn-primary dropdown-toggle'>操作 <span class='caret'></span></button><ul class='dropdown-menu'><li><a href='#' onclick='ajax_edit("+id+")'><i class='icon-file icon-black' ></i>更新</a></li><li class='divider'></li><li><a href='#'  onclick='canceledit("+id+")'><i class='icon-remove icon-black'></i>取消</a></li></ul></div></td>"
        //alert($(id).html());
        $(vid).html(addText);
}
function ajax_edit(id)
{
$.ajax({
		type:'post',
		url:'/wublog/index.php/Admin/Link/editLink/id/'+id,
		datatype:'json',
		data:{
			description:$("#desc-"+id).val(),
			link:$("#link-"+id).val(),
		},
		success:function(data)
		{
			var alerthtml="<div class='alert alert-success'><button class='close' data-dismiss='alert'>×</button><strong>成功的编辑了!</strong> </div>";
			var obj = eval('(' + data + ')'); 
			$("#tr1"+id).html(tmplink[id]);
			$("#desc-lable-"+id).html(obj.description);
			$("#link-text-"+id).html(obj.link);
			$("#alert").html($("#alert").html()+alerthtml).delay(5000).slideUp(500);
		},
	});
}
function ajax_audit(id,audit)
{
$.ajax({
		type:'post',
		url:'/wublog/index.php/Admin/Link/auditLink/id/'+id+'/audit/'+audit,
		datatype:'json',
		data:{
		},
		success:function(data)
		{
			var auditText;
			if(audit==0)
				auditText="<span style='color:green'>接受</span>";
			else
				auditText="<span style='color:red'>拒绝</span>";
			var alerthtml="<div class='alert alert-success'><button class='close' data-dismiss='alert'>×</button><strong>成功更改审核状态!</strong> </div>";
			$("#approve-lable-"+id).html(auditText);
			$("#alert").html($("#alert").html()+alerthtml).delay(5000).slideUp(500);
		},

	});
}
function ajax_del(id)
{
$.ajax({
		type:'post',
		url:'/wublog/index.php/Admin/Link/delLink/id/'+id,
		datatype:'json',
		data:{
		},
		success:function(data)
		{
			var alerthtml="<div class='alert alert-success'><button class='close' data-dismiss='alert'>×</button><strong>成功的删除了!</strong> </div>";
			$("#tr1"+id).remove();
			$("#alert").html($("#alert").html()+alerthtml).delay(5000).slideUp(500);
		},

	});
}		
			
</script>

			</div>
			
            <script type="text/javascript">
$('#style-switcher a').click(function()
      {
            var pub="/wublog/Public";
            var style = $(this).attr('href').replace('#','');
            $('.skin-color').attr('href',pub+'/css/unicorn.'+style+'.css');
            $(this).siblings('a').css({'border-color':'transparent'});
            $(this).css({'border-color':'#aaaaaa'});
      });
            </script>
	</body>
</html>