<?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.cookie.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); ?>/unicorn.form_common.js"></script>
		<script type="text/javascript" src="<?php echo (THEME_PATH_ABS); ?>/js/jquery.dataTables.min.js"></script>
		<script type="text/javascript" src="<?php echo (THEME_PATH_ABS); ?>/js/unicorn.tables.js"></script>
<script type="text/javascript" src="/wublog/Public/js/js-md5.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(in_array(($data["PageFun"]), explode(',',"myfiles,myimages"))): ?><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"]) == "myfiles"): ?><li class="active">
															<?php else: ?>		
															<li><?php endif; ?>
															<a href="/wublog/index.php/Admin/Index/myfiles/filter/all">我的文档</a>
														</li>
														<?php if(($data["PageFun"]) == "myimages"): ?><li class="active">
																<?php else: ?>		
																<li><?php endif; ?>
																<a href="/wublog/index.php/Admin/Index/myimages/filter/all">我的图片</a>
															</li>
														</ul>
													</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>

 <script type="text/javascript">


        

    </script>

<div class="container-fluid">


<div class="row-fluid">
<div id='alert'></div>
<div>
<div class="span12">
<div class="widget-box">
							<div class="widget-title">
							
								<h5>所有评论列表</h5>
							</div>
							<div class="widget-content nopadding">
								<table class="table table-bordered data-table">
									<thead style="display:none">
									<tr>
									<th>Rendering engine</th>

									</tr>
									</thead>
									<tbody  id="comment-list">
									<?php if(is_array($data["Comments"])): $i = 0; $__LIST__ = $data["Comments"];if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$vo): $mod = ($i % 2 );++$i;?><tr class="gradeX">
									<td>
									<div id="all_edit_<?php echo ($vo["id"]); ?>">
										<div class="user-thumb">
											<img width="40" height="40" alt="User" src="<?php echo (getgravatar($vo["email"])); ?>" />
										</div>
										<div class="article-post">
											<span class="user-info"> By:<a href="http://<?php echo ($vo["url"]); ?>#"><?php echo ($vo["author"]); ?></a> on <?php echo ($vo["commtime"]); ?>, IP: <?php echo ($vo["ip"]); ?> 
											Comment:<a href='/wublog/<?php echo (session('username')); ?>/p/<?php echo ($vo["archive"]); ?>#comment-<?php echo ($vo["id"]); ?>'><?php echo ($vo["title"]); ?></a>
											</span>
											<p id="all_content_<?php echo ($vo["id"]); ?>">
												<?php echo ($vo["comment"]); ?>
											</p>
											<div id='all_btn_bar_<?php echo ($vo["id"]); ?>'> 
											<a href="#" onclick="edit('all','<?php echo ($vo["id"]); ?>','<?php echo ($vo["author"]); ?>','<?php echo ($vo["email"]); ?>','<?php echo ($vo["url"]); ?>')" class="btn btn-primary btn-mini">编辑</a> 
											<a href="#" onclick="reply('all','<?php echo ($vo["id"]); ?>','<?php echo ($vo["author"]); ?>','<?php echo (session('username')); ?>','<?php echo (session('email')); ?>','<?php echo (session('url')); ?>','<?php echo (setreply($vo["reply"],$vo['id'])); ?>','<?php echo ($vo["userid"]); ?>','<?php echo ($vo["archive"]); ?>')" class="btn btn-success btn-mini">回复</a>  
											<a href="#" onclick="del_ajax(<?php echo ($vo["id"]); ?>)" class="btn btn-danger btn-mini">删除</a>
											</div>
										</div>
										<div id="all_replyform_<?php echo ($vo["id"]); ?>">

										</div>
									</div>
									</td></tr><?php endforeach; endif; else: echo "" ;endif; ?>
									
									
									
									</tbody>
									</table>  
							</div>
						</div>

</div>
</div>
<script type="text/javascript">

commentEditor = new Array();

 function submit(pre,vid)
 {
 $('#'+pre+'_form_'+vid).submit();
 }
function canceledit(pre,vid)
{
id="#"+pre+"_edit_"+vid;
$(id).html(commentEditor[vid]);
delete commentEditor[vid];
//$.cookie('content'+vid,null);
}
function edit(pre,vid,author,email,url)
{
		
		id="#"+pre+"_edit_"+vid;
		content_id="#"+pre+"_content_"+vid;
		var inval=$(content_id).html();
		commentEditor[vid]=$(id).html();
		inval=inval.replace(/(^\s*)|(\s*$)/g, "");
        var addText="<div class='widget-box'><div class='widget-title'><h5>编辑窗口</h5></div><div class='widget-content nopadding'><br/>用户：<input type='text' style='width:15%' name='author' id='"+pre+"author"+vid+"'  value='"+author+"' />email：<input type='text' id='"+pre+"email"+vid+"' style='width:15%'  name='email' value='"+email+"' />url：<input id='"+pre+"url"+vid+"'  type='text' style='width:15%'  name='url' value='"+url+"' /><textarea id='"+pre+"comment"+vid+"' name='comment' style='width:95%'>"+inval+"</textarea><br/><a href='#' type='button' class='btn btn-primary btn-mini' onclick='edit_ajax(\""+pre+"\","+vid+")' >提交修改</a> <a href='#' onclick='canceledit(\""+pre+"\","+vid+")' class='btn btn-warning btn-mini'>取消</a><br/></div></div>"
        //alert($(id).html());
        $(id).html(addText);
        
}



function cancelreply(pre,vid)
{
	
	$("#"+pre+"_btn_bar_"+vid).show();
	$("#"+pre+"_replyform_"+vid).html(''); 
}
 function reply(pre,vid,author,name,email,url,reply,uid,archive){
        id="#"+pre+"_replyform_"+vid;
       	$("#"+pre+"_btn_bar_"+vid).hide();
        var obj=$(id);
        var addText="<div class='widget-box'><div class='widget-title'><h5>回复窗口</h5></div><div class='widget-content nopadding'><form style='padding-left:10px'><br/>用户：<input type='text' style='width:15%' name='author' id='"+pre+"author"+vid+"'  value='"+name+"' />email：<input type='text' style='width:15%' id='"+pre+"email"+vid+"'  name='email' value='"+email+"' />url：<input type='text' id='"+pre+"url"+vid+"' style='width:15%'  name='url' value='"+url+"' /><textarea id='"+pre+"comment"+vid+"' name='comment' style='width:95%'><a href='#comment-"+vid+"'>@"+author+"</a></textarea><input id='"+pre+"reply"+vid+"' name='reply' type='hidden' value='"+reply+"'/><input id='"+pre+"userid"+vid+"' name='userid' type='hidden' value='"+uid+"'/><input id='"+pre+"archive"+vid+"' name='archive' type='hidden' value='"+archive+"'/><p><a href='#' type='button' class='btn btn-primary btn-mini' onclick=reply_ajax(\""+pre+"\","+vid+")>提交回复</a> <a href='#' onclick='cancelreply(\""+pre+"\","+vid+")' class='btn btn-warning btn-mini'>取消</a></p></form><br/></div></div>"


        $(id).html(addText);  
         //略：post表单提交
}
function edit_ajax(pre,id)
{
	//alert($("#"+pre+"comment"+id).text());
	$.ajax({
		type:'post',
		url:'/wublog/index.php/Admin/Comment/editComment/id/'+id,
		datatype:'json',
		data:{
			author:$("#"+pre+"author"+id).val(),
			email:$("#"+pre+"email"+id).val(),
			comment:$("#"+pre+"comment"+id).val(),
			url:$("#"+pre+"url"+id).val(),
			reply:$("#"+pre+"reply"+id).val(),
			userid:$("#"+pre+"userid"+id).val(),
			archive:$("#"+pre+"archive"+id).val(),			
		},
		success:function(data)
		{
			var obj = eval('(' + data + ')'); 
			var addText="<tr class='gradeX'><td><div id='all_edit_"+obj.id+"'><div class='user-thumb'><img width='40' height='40' alt='User' src='http://www.gravatar.com/avatar/"+hex_md5(obj.email)+"?s=80&d=mm&r=g' /></div><div  class='article-post'><span class='user-info'> By:<a href='http://"+obj.url+"#'>"+obj.author+"</a> on "+obj.commtime+", IP: "+obj.ip+" ,Comment:<a href='/wublog/<?php echo (session('username')); ?>/p/"+obj.archive+"#comment-"+obj.id+"'>"+obj.title+"</a></span><div> <p id='all_content_"+obj.id+"'>"+obj.comment+"</p></div><div id='all_btn_bar_"+obj.id+"'> <a href='#' onclick='edit('all','"+obj.id+"','"+obj.author+"','"+obj.email+"','"+obj.url+"')' class='btn btn-primary btn-mini'>编辑</a>  <a href='#' onclick='reply('all','"+obj.id+"','"+obj.author+"','<?php echo (session('username')); ?>','<?php echo (session('email')); ?>','<?php echo (session('url')); ?>','"+obj.reply+"','"+obj.userid+"','"+obj.archive+"')' class='btn btn-success btn-mini'>回复</a> <a href='/wublog/index.php/Admin/Comment/delComment/id/"+obj.id+"' class='btn btn-danger btn-mini'>删除</a></div></div></td></tr>";
			var html="<div class='alert-success'><button class='close' data-dismiss='alert'>×</button><strong>成功编辑一条回复</strong></div>";
			var vid="#"+pre+"_edit_"+id;
			$(vid).html(addText);
			$("#alert").html($("#alert").html()+html);
		},
	});
}
function del_ajax(id)
{
	$.ajax({
		type:'post',
		url:'/wublog/index.php/Admin/Comment/delComment/id/'+id,
		datatype:'json',
		data:{
		},
		success:function(data)
		{
			var html="<div class='alert'><button class='close' data-dismiss='alert'>×</button><strong>成功删除一条回复</strong></div>";
			$("#all_edit_"+id).empty();
			$("#alert").html($("#alert").html()+html).delay(3000).slideUp(500);
		},
		error:function(data)
		{
			alert("回调函数错误！");
		},
	});
}
function reply_ajax(pre,id)
{

	$.ajax({
		type:'post',
		url:'/wublog/index.php/Admin/Comment/replyComment',
		datatype:'json',
		data:{
			author:$("#"+pre+"author"+id).val(),
			email:$("#"+pre+"email"+id).val(),
			comment:$("#"+pre+"comment"+id).text(),
			url:$("#"+pre+"url"+id).val(),
			reply:$("#"+pre+"reply"+id).val(),
			userid:$("#"+pre+"userid"+id).val(),
			archive:$("#"+pre+"archive"+id).val(),
		},
		success:function(data)
		{
			var obj = eval('(' + data + ')'); 
			var addText="<tr class='gradeX'><td><div id='all_edit_"+obj.id+"'><div class='user-thumb'><img width='40' height='40' alt='User' src='http://www.gravatar.com/avatar/"+hex_md5(obj.email)+"?s=80&d=mm&r=g' /></div><div  class='article-post'><span class='user-info'> By:<a href='http://"+obj.url+"#'>"+obj.author+"</a> on "+obj.commtime+", IP: "+obj.ip+" ,Comment:<a href='/wublog/<?php echo (session('username')); ?>/p/"+obj.archive+"#comment-"+obj.id+"'>"+obj.title+"</a></span><div> <p id='all_content_"+obj.id+"'>"+obj.comment+"</p></div><div id='all_btn_bar_"+obj.id+"'> <a href='#' onclick='edit('all','"+obj.id+"','"+obj.author+"','"+obj.email+"','"+obj.url+"')' class='btn btn-primary btn-mini'>编辑</a>  <a href='#' onclick='reply('all','"+obj.id+"','"+obj.author+"','<?php echo (session('username')); ?>','<?php echo (session('email')); ?>','<?php echo (session('url')); ?>','"+obj.reply+"','"+obj.userid+"','"+obj.archive+"')' class='btn btn-success btn-mini'>回复</a> <a href='/wublog/index.php/Admin/Comment/delComment/id/"+obj.id+"' class='btn btn-danger btn-mini'>删除</a></div></div></td></tr>";
			var html="<div class='alert-success'><button class='close' data-dismiss='alert'>×</button><strong>成功添加一条回复</strong></div>";
			$("#comment-list").prepend(addText);
			cancelreply(pre,id);
			$("#alert").html($("#alert").html()+html).delay(3000).slideUp(500);
		},
		error:function(data)
		{
			alert("回调函数错误！");
		},
	});
}
</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>