<?php include $this->admin_tpl('meta');?>
<title>编辑栏目 - YzmCMS内容管理系统</title>
</head>
<body>
<div class="page-container">
	<form class="form form-horizontal" method="" action="" onsubmit="return dosub(this)">
		<div id="tab_system" class="HuiTab">
			<div class="tabBar cl"><span>基本选项</span><span>模板设置</span><span>SEO设置</span><span>其他设置</span></div>
			<div class="tabCon">
				<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">
						<span class="select-box">
						 <?php echo select_category('parentid', $data['parentid'], '', 0, '', false, false); ?>
						</span>
					</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">
						<input type="text" name="catname" value="<?php echo $data['catname']; ?>" class="input-text"  placeholder="例如：关于我们"  onblur="yzmcms_pinyin()">
					</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">
						<input type="text" name="catdir" value="<?php echo $data['catdir']; ?>" class="input-text" placeholder="支持多级目录，如： qita/guanyu">
						<i class="yzm-iconfont yzm-iconshuaxin" style="position:absolute;top:5px;right:23px;cursor:pointer;" title="继承父级目录" onclick="change_dir()"></i>
					</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 class="input-text" type="text" name="catimg" style="width:400px" id="uploadfile"  value="<?php echo $data['catimg']; ?>" onmouseover="yzm_img_preview('uploadfile', this.value)"  onmouseout="layer.closeAll();">
						<a href="javascript:;" onclick="yzm_upload_att('<?php echo U('attachment/api/upload_box', array('module'=>ROUTE_M));?>')" class="btn btn-primary radius upload-btn"><i class="yzm-iconfont yzm-iconshangchuan"></i> 浏览文件</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">
						<label class="label_radio"><input name="target" type="radio" value="_self" <?php echo $data['target']=='_self' ? 'checked="checked"' : ''; ?>> 本窗口打开</label>
						<label class="label_radio"><input name="target" type="radio" value="_blank" <?php echo $data['target']=='_blank' ? 'checked="checked"' : ''; ?>> 新窗口打开</label>
					</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">
						<label class="label_radio"><input name="display" type="radio" value="1" <?php echo $data['display']==1 ? 'checked="checked"' : ''; ?>> 是</label>
						<label class="label_radio"><input name="display" type="radio" value="0" <?php echo $data['display']==0 ? 'checked="checked"' : ''; ?>> 否</label>
					</div>
				</div>		
			</div>
			<div class="tabCon">
				<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 yzm-explain-box">
						<span class="select-box" style="width:400px">
						<select name="category_template" id="category_template" class="select">
						  <?php 
						      foreach($category_temp as $key => $val){
									$str = $key==$data['category_template'] ? ' selected="selected" ' : '';
									echo '<option value="'.$key.'"'.$str.'>'.$val.'('.$key.')</option>';
							  }
							  if(!$category_temp) echo '<option value="">暂无模板</option>';
						  ?>
						</select>
						</span>
						<span class="yzm-explain">单页模板命名规则：<br>category_<i class="model_table"><?php echo $tablename;?></i>.html<br> 或 category_<i class="model_table"><?php echo $tablename;?></i>_*.html</span>
					</div>
				</div>						
			</div>
			<div class="tabCon">
				<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" name="seo_title" value="<?php echo $data['seo_title']; ?>" placeholder="栏目SEO标题，一般不超过80个字符" class="input-text">
					</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" name="seo_keywords" value="<?php echo $data['seo_keywords']; ?>" placeholder="一般不超过100个字符，多个关键词用英文逗号“,”隔开" class="input-text">
					</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 class="textarea" name="seo_description" placeholder="栏目SEO描述，一般不超过200个字符"><?php echo $data['seo_description']; ?></textarea>
					</div>
				</div>
			</div>
			<div class="tabCon">
				<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" name="entitle" value="<?php echo $data['entitle']; ?>" placeholder="英文标题可留空" class="input-text">
					</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" name="subtitle" value="<?php echo $data['subtitle']; ?>" placeholder="栏目副标题可留空" class="input-text">
					</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" name="mobname" value="<?php echo $data['mobname']; ?>" placeholder="手机版栏目名称，为空则与电脑端一致" class="input-text">
					</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" name="domain" value="<?php echo $data['domain']; ?>" placeholder="域名格式以http开头" class="input-text">
					</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" name="listorder" value="<?php echo $data['listorder']; ?>" class="input-text">
					</div>
				</div>					
			</div>

		</div>
		<div class="footer_btn_large">
			<input type="hidden" name="type" value="<?php echo $type;?>">
			<input type="hidden" name="catid" value="<?php echo $catid;?>">
			<input type="hidden" name="cpath" value="<?php echo $data['arrparentid'];?>">
			<input type="hidden" name="dosubmit" value="1">
			<input class="btn btn-primary radius" type="submit" value="提 交">
			<input class="btn btn-default radius" type="button" value="取 消" onclick="yzmcms_close()">	
		</div>
	</form>
</div>

<?php include $this->admin_tpl('footer');?>

<script type="text/javascript" src="<?php echo STATIC_URL;?>js/yzm-pinyin.js"></script> 

<script type="text/javascript">
function yzmcms_pinyin(){
	var catdir = $("input[name='catdir']").val();
	if(catdir == ''){
		var pinyin = codefans_net_CC2PY($("input[name='catname']").val());
		$("input[name='catdir']").val(pinyin.toLowerCase());
	}
	$("input[name='mobname']").val($("input[name='catname']").val());
}

var s = 1;
function change_dir(){
	var pinyin = codefans_net_CC2PY($("input[name='catname']").val());
	pinyin = pinyin.toLowerCase();
	if(s){
		s = 0;
		$("input[name='catdir']").val('<?php echo $parent_dir;?>'+pinyin);	
	}else{
		s = 1;
		$("input[name='catdir']").val(pinyin);	
	}
}

function dosub(obj){
	var reg = /^[a-zA-Z]{1}([a-zA-Z0-9]|[-/]){0,29}$/;
	if($("input[name='catname']").val()==''){
		layer.msg('栏目名称不能为空！', {icon:2});
		return false;
	}
	if($("input[name='catdir']").val()==''){
		layer.msg('栏目目录不能为空！', {icon:2});
		return false;
	}
	if(!reg.test($("input[name='catdir']").val())){
		layer.msg('栏目目录只能是拼音或英文字符！', {icon:2});
		return false;
	}
	if($("select[name='category_template']").val()==''){
		layer.msg('请选择单页模板！', {icon:2});
		$.Huitab("#tab_system .tabBar span","#tab_system .tabCon","current","click","1");
		return false;
	}
	var reg = /^http(.+)\/$/;
	var domain = $("input[name='domain']").val();
	if(domain!='' && !reg.test(domain)){
		layer.msg('绑定的栏目域名格式为http://www.yzmcms.com/，请以“/”结尾！', {icon:2});
		return false;
	}
	$.ajax({
		type: 'POST',
		url: '<?php echo U('edit');?>', 
		data: $(obj).serialize(),
		dataType: "json", 
		success: function (msg) {
			if(msg.status == 1){
				layer.msg(msg.message, {icon:1,time:1000}, function(){
					parent.location.reload();   
				});
			}else{
				layer.msg(msg.message, {icon:2});
			}
		}
	})
	return false;		
}

$(function(){
	$.Huitab("#tab_system .tabBar span","#tab_system .tabCon","current","click","<?php echo isset($_GET['tab']) ? intval($_GET['tab']) : '0'?>");
});
</script>

</body>
</html>