<?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" href="<?php echo (THEME_PATH_ABS); ?>/css/unicorn.grey.css" class="skin-color" />	
		<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); ?>/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>
		<script type="text/javascript" src="/wublog/Public/ueditor/ueditor.config.js"></script>
		<script type="text/javascript" src="/wublog/Public/ueditor/lang/zh-cn/zh-cn.js"></script>
		<script type="text/javascript" src="/wublog/Public/ueditor/ueditor.all.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>
<div class="container-fluid">
<div class="row-fluid">
					<div class="span12">
						<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">
								<form action="?" method="post" id="form1" name="form1" class="form-horizontal" />
									<div class="control-group">
										<label class="control-label">文章标题</label>
										<div class="controls">
											<input name="title" type="text" value="<?php if(($_GET['id']) != ""): echo ($data["archive"]["title"]); endif; ?>" />
										</div>
									</div>

									<div class="control-group">
										<label class="control-label">文章类型</label>
										<div class="controls">
											<select name="category"> 
												<?php if(($data["category"]) == "1"): ?><option value='1' selected />未分类
													<?php else: ?>
														<option value='1'  />未分类<?php endif; ?>
												<?php if(is_array($data["category"])): $i = 0; $__LIST__ = $data["category"];if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$vo): $mod = ($i % 2 );++$i; if(($vo["id"]) == $data["archive"]["category"]): ?><option value='<?php echo ($vo["id"]); ?>' selected /><?php echo ($vo["catename"]); ?>
													<?php else: ?>
														<option value='<?php echo ($vo["id"]); ?>' /><?php echo ($vo["catename"]); endif; endforeach; endif; else: echo "" ;endif; ?>
											</select>
										</div>
									</div>

									<div class="control-group">
										<label class="control-label">浏览级别</label>
										<div class="controls">
											<select name="showid">
												<option value="-1"	<?php if(($data["archive"]["showid"]) == "-1"): ?>selected<?php endif; ?> />全部可见
												<option value="0"	<?php if(($data["archive"]["showid"]) == "0"): ?>selected<?php endif; ?> />好友可见
												<option value="1"	<?php if(($data["archive"]["showid"]) == "1"): ?>selected<?php endif; ?> />自己可见
											</select><span class="help-block">设置对应浏览权限</span>
										</div>
									</div>
									<div class="control-group">
										<label class="control-label">tag标签</label>
										<div class="controls">
											<input id="tagsHide" name="tagsHide" type="hidden" value="" />
											<select id="tags" name="tags" style="width:30%" multiple onchange="getTags()">
											<?php if(is_array($data["tag"])): $i = 0; $__LIST__ = $data["tag"];if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$vo): $mod = ($i % 2 );++$i; if(in_array(($vo["id"]), is_array($data["selectedtag"])?$data["selectedtag"]:explode(',',$data["selectedtag"]))): ?><option selected value='<?php echo ($vo["id"]); ?>' /><?php echo ($vo["tag"]); ?>
											<?php else: ?>
											<option value='<?php echo ($vo["id"]); ?>' /><?php echo ($vo["tag"]); endif; endforeach; endif; else: echo "" ;endif; ?>
											</select>
										</div>
									</div>
								<div class="control-group">
										<label class="control-label">固定连接</label>
										<div class="controls">
											<input style='width:200px' name="url" type="text" value="<?php if(($_GET['id']) != ""): echo ($data["archive"]["url"]); endif; ?>" />
										<span class="help-block">方便搜索引擎搜索，输入simplepage，结果为http://localhost/wusx/simplepage.html</span>
										</div>
									</div>
    							<script type="text/javascript">
 								$(function(){
        						var url="<?php echo U('Admin/Ueditor/Index');?>";
        						var ue = UE.getEditor('myEditor',
        							{
            							serverUrl :url
            							,enableAutoSave:true
        							}
        						);
    							});
								</script>
									<div class="control-group">
										<label class="control-label">内容</label>
										<div class="controls">
										<div id="AutoSaveMsg"></div>
											<script type="text/plain" id="myEditor" style="width:90%;height:400px;">
    										<?php if(($_GET['id']) != ""): echo ($data["archive"]["content"]); endif; ?>
											</script>
										</div>
									</div>
									<div class="control-group">
										<label class="control-label">是否预览</label>
										<div class="controls">
										<label><input type="checkbox" name="radios" onclick="showpreeditor(this)" checked /></label>
										<script type="text/plain" id="preEditor" name="preContent" style="width:90%;height:240px;">
    										<?php if(($_GET['id']) != ""): echo ($data["archive"]["precontent"]); endif; ?>
											</script>
										</div>
										
										<script type="text/javascript">var um2 = UE.getEditor('preEditor'
											,{toolbars:[['Source', 'Undo', 'Redo','bold','imagenone', 'imageleft', 'imageright', 'imagecenter','|','simpleupload', 'insertimage']]}
											);	
										</script>
									</div>
									<div class="form-actions">
										<button type="button" class="btn btn-primary" onclick="ajaxSave('1')">仅保存为草稿</button>
										<button type="button" class="btn btn-primary" onclick="ajaxSave('0')">保存并发布</button>
									</div>

								</form>
							</div>
						</div>						
					</div>
				</div>
</div>	
</div>
<div id="myAlert" class="modal hide">
<div class="modal-header">
<button data-dismiss="modal" class="close hide" type="button">×</button>
<h3 id='modal-title'>提示</h3>
</div>
<div class="modal-body">
<p id="modal-msg"></p>
</div>
<div class="modal-footer">
<a data-dismiss="modal" id="modal-enter" class="btn btn-primary" href="#">确认</a>
<a data-dismiss="modal" id='modal-cancel' class="btn btn-warning" href="#">删除草稿</a>
</div>
</div>
<script type="text/javascript">	//不同提交路径
	function showpreeditor(obj)
	{
		if(obj.checked==false)
			UE.getEditor('preEditor').setHide();
		else
		UE.getEditor('preEditor').setShow();	
	}
	function getTags()
	{
		var obj=document.getElementById('tags');
		var hide=document.getElementById('tagsHide');
		hide.value="";
		for(var i=0;i<obj.options.length;i++) {
			if(obj.options[i].selected)
			{
				hide.value+=(obj.options[i].value+",");
			}										 		
		}  
	}
	function ajaxSave(option)
	{		
		var type='<?php echo ($data["edittype"]); ?>'
		var typeStr='';
		var optionStr='';
		if(option==1)
		{
			optionStr='草稿';
		}
		else
		{
			optionStr='发布';
		}
		if(type=='editArchive')
		{
			var path='/wublog/index.php/Admin/Archive/'+type+'/id/<?php echo ($_GET['id']); ?>/publish/'+option;
			typeStr='编辑';
		}
		else
		{
			var path='/wublog/index.php/Admin/Archive/'+type+'/publish/'+option;
			typeStr='新增';
		}

		$.ajax({
		type:'post',
		url:path,
		datatype:'json',
		data:$('#form1').serialize(),
		success:function(data)
		{

			UE.getEditor('myEditor').execCommand( "clearlocaldata" );
			var obj = eval('(' + data + ')'); 
			$('#modal-msg').html('已经成功'+typeStr+'《'+obj.title+'》，是否继续编辑？');
    		$('#modal-enter').html('是');
    		$('#modal-cancel').html('否');
    		$('#modal-enter').attr('href', '/wublog/index.php/Admin/Index/archive/id/'+obj.archiveId);
    		$('#modal-cancel').attr('href', '/wublog/index.php/Admin/Index/archivelists');
    		$('#modal-cancel').removeAttr('data-dismiss');
    		$('#modal-enter').removeAttr('data-dismiss');
			$("#myAlert").modal();
		},
		error:function(){
		}
		});

	}
    setTimeout(function(){
    	var draf=UE.getEditor('myEditor').execCommand( "getlocaldata" );
    	if(draf!='')
    	{
    		$('#modal-msg').html('草稿箱发现一份未完成的文稿，是否继续完成');
    		$('#modal-enter').html('是');
    		$('#modal-cancel').html('否，删除草稿');
    		$('#modal-enter').attr('onclick', '').click(function(){UE.getEditor('myEditor').setContent(draf)});
    		$('#modal-cancel').attr('onclick', '').click(function(){UE.getEditor('myEditor').execCommand( "clearlocaldata" )});
    		$("#myAlert").modal();
    	}
    },500);
    /*
$(document).ready(function(){ 
  $(window).keydown(function(e){ 
      if(e.keyCode==83&&e.ctrlKey){ 
            e.preventDefault(); 
            ajaxSave(1);
      } 
  }); 
  var e = jQuery.Event("keydown"); 
  e.keyCode=83,e.ctrlKey=true; 
  $("button").click(function(){ 
    $(window).trigger(e); 
  }); 
});*/
</script>