<?php include $this->admin_tpl('meta');?>
<title>添加内容 - YzmCMS内容管理系统</title>
<script type="text/javascript" src="<?php echo STATIC_URL;?>plugin/laydate/1.1/laydate.js"></script>
<script type="text/javascript" charset="utf-8" src="<?php echo STATIC_URL;?>plugin/ueditor/ueditor.config.js"></script>
<script type="text/javascript" charset="utf-8" src="<?php echo STATIC_URL;?>plugin/ueditor/ueditor.all.min.js"> </script>
<script type="text/javascript" charset="utf-8" src="<?php echo STATIC_URL;?>plugin/ueditor/lang/zh-cn/zh-cn.js"></script>
<style>
	.date{height:30px;padding:4px;width:265px;font-size:14px}.Hui-tags-token{color:#353535;}
	#colors{position:absolute;top:9px;right:23px;cursor:pointer;}
</style>
</head>
<body>
<article class="page-container">
	<form class="form form-horizontal mb-20" onsubmit="return checkall()" method="post">
		<div class="row cl">
			<label class="form-label col-xs-4 col-sm-2"><span class="c-red">*</span>标题：</label>
			<div class="formControls col-xs-8 col-sm-9">
				<input type="text" class="input-text" value=""  name="title" onblur="get_seotitle()">
				<input type="hidden" name="color" id="color">
				<img src="<?php echo STATIC_URL;?>images/colors.png" title="设置颜色" id="colors">
			</div>
		</div>
		<div class="row cl">
			<label class="form-label col-xs-4 col-sm-2"><span class="c-red">*</span>SEO标题：</label>
			<div class="formControls col-xs-8 col-sm-9">
				<input type="text" class="input-text" value=""  name="seo_title">
			</div>
		</div>
		<div class="row cl">
			<label class="form-label col-xs-4 col-sm-2">属性：</label>
			<div class="formControls col-xs-8 col-sm-9 skin-minimal">
				<label>置顶[1] <input name="flag[]" type="checkbox" value="1" onclick="set_top()" id="settop"></label>&nbsp;&nbsp;
				<label>头条[2] <input name="flag[]" type="checkbox" value="2"/></label>&nbsp;&nbsp;
				<label>特荐[3] <input name="flag[]" type="checkbox" value="3"/></label>&nbsp;&nbsp;
				<label>推荐[4] <input name="flag[]" type="checkbox" value="4"/></label>&nbsp;&nbsp;
				<label>热点[5] <input name="flag[]" type="checkbox" value="5"/></label>&nbsp;&nbsp;
				<label>幻灯[6] <input name="flag[]" type="checkbox" value="6"/></label>&nbsp;&nbsp;
				<label>跳转[7] <input name="flag[]" type="checkbox" value="7" onclick="toggle()"/></label>&nbsp;&nbsp;
			</div>
		</div>
		<div class="row cl" style="display:none;" id="url">
			<label class="form-label col-xs-4 col-sm-2">跳转URL：</label>
			<div class="formControls col-xs-8 col-sm-9">
				<input type="text" class="input-text" value=""  name="url" placeholder="格式为“http://开头”">
			</div>
		</div>
		<div class="row cl">
			<label class="form-label col-xs-4 col-sm-2"><span class="c-red">*</span>栏目：</label>
			<div class="formControls col-xs-8 col-sm-9"> 
				<?php if(!isset($_GET['catid'])){ ?>
				<span class="select-box"><?php echo select_category('catid', $catid, '≡ 请选择栏目 ≡', 0, '', true, true, $modelid); ?></span>
				<?php }else{ ?>
				<input type="hidden" name="page_content" value="1">
				<span class="select-box">
					<select id="select" name="catid" class="select">
						<option value="<?php echo $catid;?>"><?php echo get_catname($catid);?></option>
					</select>
				</span>
				<?php } ?> 
			</div>
		</div>
		<div class="row cl">
			<label class="form-label col-xs-4 col-sm-2">TAG标签：</label>
			<div class="formControls col-xs-8 col-sm-9 skin-minimal">
			<div class="Hui-tags" style="width:88%;float:left;margin-right:5px;">
				<div class="Hui-tags-editor cl" style="padding: 5px 0 5px 24px;">
				<i class="Hui-tags-icon Hui-iconfont" style="top:5px">&#xe64b;</i>
					<div id="tag_default"></div>
					<div class="Hui-tags-iptwrap" style="width:50%">
						<input type="text" class="Hui-tags-input" maxlength="20" value="" id="tag_input" onblur="change_keyword()">
						<label class="Hui-tags-label">添加标签，用空格或回车分隔</label>
					</div>
				</div>
				<input type="hidden" class="Hui-tags-val" name="tag" value="" id="taglist">
			</div>
			 <a href="javascript:;" onclick="yzm_open('TAG标签选择','<?php echo U('tag/public_select');?>','650','400')" class="btn btn-primary radius">选择</a>
			</div>
		</div>
		<div class="row cl">
			<label class="form-label col-xs-4 col-sm-2">关键词：</label>
			<div class="formControls col-xs-8 col-sm-9">
				<input type="text" class="input-text" value=""  name="keywords" placeholder="每个关键字之间用“,”分隔">
			</div>
		</div>
		<div class="row cl">
			<label class="form-label col-xs-4 col-sm-2">内容摘要：</label>
			<div class="formControls col-xs-8 col-sm-9">
				<textarea name="description" class="textarea"  placeholder="如不填写，则自动提取文章前200字符" datatype="*10-100" dragonfly="true" nullmsg="文章摘要不能为空！" onKeyUp="textarealength(this,200)"></textarea>
				<p class="textarea-numberbar"><em class="textarea-length">0</em>/200</p>
			</div>
		</div>		
		<div class="row cl">
			<label class="form-label col-xs-4 col-sm-2">发布时间：</label>
			<div class="formControls col-xs-8 col-sm-9">
				<input type="text" class="input-text laydate-icon" style="width:265px;height:30px;" name="inputtime" value="<?php echo date('Y-m-d H:i:s'); ?>" onclick="laydate({istime: true, format: 'YYYY-MM-DD hh:mm:ss'})">
			</div>
		</div>
		<div class="row cl">
			<label class="form-label col-xs-4 col-sm-2">阅读权限：</label>
			<div class="formControls col-xs-8 col-sm-9">
				<span class="select-box"  style="width:265px">
				<select id="select" name="groupids_view" class="select">
				<option value="0">开放浏览</option>
			    <?php 
				foreach($member_group as $val){
					echo '<option value="'.$val['groupid'].'">'.$val['name'].'</option>';
				}
			    ?>	
				</select>
				</span>  
				<span class="yzmcms_small">
					阅读收费：<input type="text" class="input-text" style="width:150px" value="0"  name="readpoint" onfocus="layer.tips('vip会员可免费查看', this, {tips:[1,'#666']});">
					<label class="mr-5"><input type="radio" name="paytype" value="1" checked>点</label> 
					<label><input type="radio" name="paytype" value="2">元</label>
				</span>  
			</div>
		</div>
		<div class="row cl">
			<label class="form-label col-xs-4 col-sm-2">缩 略 图：</label>
			<div class="formControls col-xs-8 col-sm-9" style="height:31px;">
				<div class="uploader-thum-container">
				<?php echo form::image('thumb', '', 'width:370px', true);?> <img src="<?php echo STATIC_URL;?>images/nopic.jpg" class="thumb" id="thumb_src">
				</div>
			</div>
		</div>
		<div class="row cl">
			<label class="form-label col-xs-4 col-sm-2">来源：</label>
			<div class="formControls col-xs-8 col-sm-9">
				<input type="text" class="input-text" value="原创"  name="copyfrom" style="width:150px">
				<span class="yzmcms_small">点击量：<input type="text" class="input-text" style="width:150px" value="0"  name="click"></span>  
				<span class="yzmcms_small">作者昵称：<input type="text" class="input-text" style="width:150px" value="<?php echo $_SESSION['admininfo']['nickname'] ? $_SESSION['admininfo']['nickname'] : '管理员'; ?>"  name="nickname"></span>  
			</div>
		</div>
        <?php echo $string;?>
		<div class="row cl">
			<label class="form-label col-xs-4 col-sm-2"><span class="c-red">*</span>内容：</label>
			<div class="formControls col-xs-8 col-sm-9"> 
			<?php echo form::editor('content', '', 'width:100%;height:400px', false);?>
			<label title="提取内容第一张图片为缩略图"><input name="auto_thum" type="checkbox" id="readpact" value="1" />提取内容第一张图片为缩略图</label>
			</div>
		</div>
		<div class="row cl">
			<div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-2">
				<input type="hidden" name="status" value="1">
				<button name="dosubmit" class="btn btn-primary radius" type="submit" onclick="set_status(1)"><i class="Hui-iconfont">&#xe603;</i> 保存发布</button>
				<button name="dosubmit" class="btn btn-secondary radius" type="submit" onclick="set_status(0)"><i class="Hui-iconfont">&#xe632;</i> 保存草稿</button>
				<button name="continuity" class="btn btn-success radius" type="submit" onclick="set_status(1)"><i class="Hui-iconfont">&#xe603;</i> 保存后继续发布</button>
				<?php if(!isset($_GET['catid'])){ ?>
				<button onclick="yzm_content_close()" class="btn btn-default radius" type="button">&nbsp;&nbsp;关闭&nbsp;&nbsp;</button>
				<?php }else{ ?>
				<a href="<?php echo U('category/init');?>" class="btn btn-default radius">&nbsp;&nbsp;关闭&nbsp;&nbsp;</a>
				<?php } ?>
			</div>
		</div>
		<input type="hidden"  value="10"  name="listorder">
	</form>
</article>

<?php include $this->admin_tpl('footer');?>
<script type="text/javascript" src="<?php echo STATIC_URL;?>js/jquery.colorpicker.js"></script>
<script type="text/javascript">
	function set_top(){
		if($('#settop').get(0).checked){
			$("input[name='listorder']").val('1');
		}else{
			$("input[name='listorder']").val('10');
		}	
	}
	
	function set_status(s){
		$("input[name='status']").val(s);	
	}
	
	function toggle(){ 
        $("#url").toggle();
    }
	
	function get_seotitle(){
		var title = $("input[name='title']").val();
		var seo_title = $("input[name='seo_title']").val();
		if(title == '') {
			layer.msg('标题不能为空！', {icon:2,time: 2000});
			return false;
		}
		if(seo_title == ''){
			$("input[name='seo_title']").val(title+'_<?php echo get_config('site_name');?>');
		}
	}
	
	function yzm_content_close(){
		if(UE.getEditor('content').getContent()!=''){
			layer.confirm('内容未保存，确定要关闭吗？',function(index){
				yzmcms_close();
			});
		}else{
			yzmcms_close();
		}
	}
	
	function checkall(){
		if($("input[name='title']").val()==''||$("input[name='seo_title']").val()==''){
			layer.msg('标题或SEO标题不能为空！', {icon:2,time: 2000});
			return false;
		}
		if($("select[name='catid']").val()=='0'){
			layer.msg('请选择栏目！', {icon:2,time: 2000});
			return false;
		}
		var check = true;
		$(".required").each(function(){
			if($(this).val() == ''){
			  layer.msg($(this).attr('errortips'), {icon:2,time: 2000});
			  $(this).focus();
			  check = false;
			  return false;
			}
		})
		if(!check) return false;
		if(UE.getEditor('content').getContent()==''){
			layer.msg('内容不能为空！', {icon:2,time: 2000});
			return false;
		}
		return true;
	}
	
	function change_keyword() {
		var v = $("#taglist").val();
		if(v != '') v = v.substr(0,v.length-1);
		$("[name=keywords]").val(v);
	}

	$("#colors").colorpicker({
	    fillcolor:true,
	    success:function(o,color){
	        $("input[name='title']").css("color",color);
	        $("#color").val(color);
	    },
		reset:function(o){
			$("input[name='title']").css("color","");
			$("#color").val('');
		}
	});
</script>

</body>
</html>