<?php
	$this->display(tpl('head',true));
	$type[$data[type]]="checked";
	$dis="";
	if($data[type] != 2){
		$dis=' style="display: none;"';
	}
	$dis1="";
	$dis2="";
	if($data[type]==1){
		$dis1=' style="display: none;"';
	}
	if($data[type]==2){
		$dis1=' style="display: none;"';
	}
	$setting=unserialize($data['setting']);
?>

<style>
	.layui-tab{
		padding-left: 20px;
	}
	.layui-form-select {
	    position: relative;
	    width: 30%;
	}
	.layui-input-my {
	    display: block;
	    width: 30%;
	    padding-left: 10px;
	}
	.layui-form-checkbox{
		margin: 5px 10px 5px 0;
	}
</style>
<fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
  <legend>分类/栏目修改</legend>
</fieldset>
<form class="layui-form"  method="post" >
<div class="layui-tab">
	<ul class="layui-tab-title">
	    <li class="layui-this">基本设置</li>
	    <li>SEO设置</li>
	    <li>模板设置</li>
	    <li>权限设置</li>
	</ul>
	<div class="layui-tab-content">
	    <div class="layui-tab-item layui-show">
	    	<table class="layui-table  my-tabel">
	    		<tbody>
	    			<tr>
	    				<td>栏目名称</td>
	    				<td>
	    					<input name="name" id="name" value="<?php echo $data[name] ?>" placeholder="请输入栏目名称" class="layui-input layui-input-my" type="text">
	    				</td>
	    			</tr>
	    			<tr>
	    				<td>栏目类型</td>
	    				<td>
	    					<input name="type" value="0" lay-filter="type" title="栏目" type="radio" <?php echo $type['0'] ?>>
			    			<input name="type" value="1" lay-filter="type" title="分类" type="radio" <?php echo $type['1'] ?>>
			    			<input name="type" value="2" lay-filter="type" title="单页" type="radio" <?php echo $type['2'] ?>>
	    				</td>
	    			</tr>
	    			<tr>
	    				<td>所属分类</td>
	    				<td>
	    					<select name="upcid">
	    						<option value="">顶级分类</option>
								<?php
								foreach($allcidDB AS $row){
									$selected="";
									if($data[upcid]==$row[cid]){
										$selected=" selected";
									}
								?>
								<option value="<?php echo $row[cid] ?>"<?php echo $selected ?>><?php echo $row[levels]; echo $row[name] ?></option>
								<?php } ?>
	    					</select>
	    				</td>
	    			</tr>
	    			<tr>
	    				<td>所属内容模型</td>
	    				<td>
	    					<select name="mid">
	    						<option value="">不使用模型</option>
								<?php
								foreach($moduleDB AS $row){
									$selected="";
									if($data[cmid]==$row[id]){
										$selected="selected";
									}
								?>
	               				<option value="<?php echo $row[id] ?>" <?php echo $selected ?>><?php echo $row[name] ?></option>
								<?php } ?>
	    					</select>
	    				</td>
	    			</tr>
	    			<tr>
	    				<td>栏目目录</td>
	    				<td>
	    					<input name="dir_name" id="dir_name" value="<?php echo $data[dir_name] ?>" lay-verify="dir_name" placeholder="请输入栏目目录,英文或者数字" class="layui-input layui-input-my left" type="text">
	    					<a href="javascript:void();" onclick="shengcheng()" style="float: left;height: 45px;line-height: 35px;padding-left: 10px;color: red;">一键生成</a>
	    				</td>
	    			</tr>
	    			<tr>
	    				<td>列表页显示条数</td>
	    				<td>
	    					<input name="setting[rows]" value="<?php echo $setting[rows] ?>"  class="layui-input layui-input-my left" type="number">
	    					<span style="height: 45px;line-height: 35px;padding-left: 10px">如果不填或者为0默认为20</span>
	    				</td>
	    			</tr>
	    			<tr>
	    				<td>列表页每条显示字数</td>
	    				<td>
	    					<input name="setting[number]" value="<?php echo $setting[number] ?>"  class="layui-input layui-input-my left" type="number">
	    					<span style="height: 45px;line-height: 35px;padding-left: 10px">如果不填或者为0默认为30个字符</span>
	    				</td>
	    			</tr>
	    			<tr id="danyecontent" <?php echo $dis ?>>
	    				<td>单页内容</td>
	    				<td>
	    					<textarea name="content" style="height:500px; width: 100%;" id="content" placeholder="单页内容" ><?php echo $data[content] ?></textarea>
							<script type="text/javascript">
								var ue = UE.getEditor('content',{
									zIndex : 900,
									autoHeightEnabled:false,
								    // 服务器统一请求接口路径
								    serverUrl: "/admin/index/plugin/ueditor/setting/ueditor_config/",
								    toolbars: [[
								        'source', '|', 'undo', 'redo', '|',
								        'bold', 'italic', 'underline', 'fontborder', 'strikethrough', 'superscript', 'subscript', 'removeformat', 'formatmatch', 'autotypeset', 'blockquote', 'pasteplain', '|', 'forecolor', 'backcolor', 'insertorderedlist', 'insertunorderedlist', 'selectall', 'cleardoc', '|',
								        'rowspacingtop', 'rowspacingbottom', 'lineheight', '|',
								        'customstyle', 'paragraph', 'fontfamily', 'fontsize', '|',
								        'directionalityltr', 'directionalityrtl', 'indent', '|',
								        'justifyleft', 'justifycenter', 'justifyright', 'justifyjustify', '|', 'touppercase', 'tolowercase', '|',
								        'link', 'unlink', 'anchor', '|', 'imagenone', 'imageleft', 'imageright', 'imagecenter', '|',
								        'simpleupload', 'insertimage', 'emotion', 'scrawl', 'insertvideo', 'music', 'attachment', 'map', 'gmap', 'insertframe', 'insertcode', 'webapp', 'pagebreak', 'template', 'background', '|',
								        'horizontal', 'date', 'time', 'spechars', 'snapscreen', 'wordimage', '|',
								        'inserttable', 'deletetable', 'insertparagraphbeforetable', 'insertrow', 'deleterow', 'insertcol', 'deletecol', 'mergecells', 'mergeright', 'mergedown', 'splittocells', 'splittorows', 'splittocols', 'charts', '|',
								        'print', 'preview', 'searchreplace', 'drafts', 'help'
								    ]]});
							</script>
	    				</td>
	    			</tr>
	    		</tbody>
	    	</table>
	    </div>
	    <div class="layui-tab-item">
	    	<table class="layui-table  my-tabel">
	    		<tbody>
	    			<tr>
	    				<td>SEO标题</td>
	    				<td>
	    					<input name="seo_name" value="<?php echo $data[seo_name] ?>" placeholder="请输入本栏目优化标题" class="layui-input layui-input-my" type="text">
	    				</td>
	    			</tr>
	    			<tr>
	    				<td>SEO关键字</td>
	    				<td>
	    					<input name="seo_keywords" value="<?php echo $data[seo_keywords] ?>" placeholder="请输入本栏目优化关键字" class="layui-input layui-input-my" type="text">
	    				</td>
	    			</tr>
	    			<tr>
	    				<td>SEO描述</td>
	    				<td>
	    					<input name="seo_description" value="<?php echo $data[seo_description] ?>" placeholder="请输入本栏目优化描述" class="layui-input layui-input-my" type="text">
	    				</td>
	    			</tr>
		    	</tbody>
		    </table>
	    </div>
	    <div class="layui-tab-item mytemp">
	    	<table class="layui-table  my-tabel">
	    		<tbody>
	    			<tr <?php echo $dis1 ?>>
	    				<td>内容模板</td>
	    				<td>
	    					<input name="setting[tpl][article]" value="<?php echo $setting[tpl][article] ?>" id="tplcontent" class="layui-input layui-input-my left" type="text">
			    			<select class="left" id="setting_content">
			    				<option value="0">请选择一个模板</option>
			               		<option value="articles">默认模板</option>
								<?php foreach($article_template AS $row){ ?>
			               		<option value="<?php echo $row[file] ?>"><?php echo $row[name] ?></option>
								<?php } ?>
			    			</select>
	    				</td>
	    			</tr>
	    			<tr>
	    				<td>列表模板</td>
	    				<td>
	    					<input name="setting[tpl][category]" value="<?php echo $setting[tpl]['category'] ?>" id="tplcategory" class="layui-input layui-input-my left" type="text">
			    			<select class="left" id="setting_list">
			    				<option value="0">请选择一个模板</option>
			               		<option value="category">默认模板</option>
								<?php foreach($list_template AS $row){ ?>
			              		<option value="<?php echo $row[file] ?>"><?php echo $row[name] ?></option>
								<?php } ?>
			    			</select>
	    				</td>
	    			</tr>
	    			
		    	</tbody>
		    </table>
	    	<blockquote class="layui-elem-quote layui-text">
			  	<p>1.内容模板,列表模板,你都可以自己做一个,然后在上面输入他们所在的目录即可调用显示.留空的话.将以默认为标准.</p>
			  	<p>2.模板里可以加载{include="head.htm"}{include="foot.htm"}碎片。程序会自动编译。</p>
			</blockquote>
	    </div>
	    <div class="layui-tab-item">
	    	<table class="layui-table  my-tabel">
	    		<tbody>
	    			<tr>
	    				<td>内容查看权限</td>
	    				<td>
	    					<?php foreach(C('USER_GROUP') AS $key =>$row ) {
	    						$checked='';
	    						if(in_array($key,$setting['look'])){
	    							$checked='checked';
	    						}
	    						
	    					 ?>
	    						<input <?php echo $checked ?> type="checkbox" name="setting[look][]"  value="<?php echo $key; ?>" title="<?php echo $row[name]; ?>"/>
	    					<?php } ?>
	    				</td>
	    			</tr>
	    			<tr>
	    				<td>会员中心信息发布&修改权限</td>
	    				<td>
	    					<table class="layui-table  my-tabel">
					    		<tbody>
					    			<?php foreach(C('USER_GROUP') AS $key =>$row ) { 
					    				$add=$is_state=$is_edit=$is_edit_state=$is_sell=$is_pass=$is_comment=$is_state_no_del=$is_state_yes_del='';
					    				foreach($setting['power'][$key] as $_key=>$v){
					    					$$_key='checked';
					    				}
					    			?>
					    			<tr>
					    				<td width="150">【<?php echo $row[name]; ?>】权限设置</td>
					    				<td>
					    					<input <?php echo $add ?> type="checkbox" name="setting[power][<?php echo $key ?>][add]" value="1" title="允许发布内容"/>
					    					<input <?php echo $is_state ?> type="checkbox" name="setting[power][<?php echo $key ?>][is_state]" value="1" title="发布内容时直接审核"/>
					    					<input <?php echo $is_edit ?> type="checkbox" name="setting[power][<?php echo $key ?>][is_edit]" value="1" title="审核后的内容可以修改"/>
					    					<input <?php echo $is_edit_state ?> type="checkbox" name="setting[power][<?php echo $key ?>][is_edit_state]" value="1" title="修改后的内容直接审核"/>
					    					<input <?php echo $is_sell ?> type="checkbox" name="setting[power][<?php echo $key ?>][is_sell]" value="1" title="允许发布出售文章"/>
					    					<input <?php echo $is_pass ?> type="checkbox" name="setting[power][<?php echo $key ?>][is_pass]" value="1" title="允许发布加密文章"/>
					    					<input <?php echo $is_comment ?> type="checkbox" name="setting[power][<?php echo $key ?>][is_comment]" value="1" title="允许开启或关闭评论"/>
					    					<input <?php echo $is_state_no_del ?> type="checkbox" name="setting[power][<?php echo $key ?>][is_state_no_del]" value="1" title="允许删除自己未审核的文章"/>
					    					<input <?php echo $is_state_yes_del ?> type="checkbox" name="setting[power][<?php echo $key ?>][is_state_yes_del]" value="1" title="允许删除自己已审核的文章"/>
					    				</td>
					    			</tr>
					    			<?php } ?>
					    			<tr>
					    				<td colspan="2">
					    					<p>以上设置勾选为有权限，否则则没有权限</p>
					    				</td>
					    			</tr>
						    	</tbody>
						    </table>
	    				</td>
	    			</tr>
	    			
		    	</tbody>
		    </table>
	    </div>
  	</div>
 
  	<table class="layui-table  my-tabel">
	   	<tbody>
	    	<tr>
	    		<td class="my-button">
	    			<input type="hidden" name="step" value="post" />
					<input type="hidden" name="cid" value="<?php echo $data[cid] ?>" />
					<button class="layui-btn">立即设置</button>
	    		</td>
	    	</tr>
		</tbody>	
	</table>
</div>
</form>
<script type="text/javascript">
	function shengcheng(){
		var name=document.getElementById("name").value;
		$.ajax({
			url:"{{admin_module_url}}/pinyin/pinyin/json_true/name_"+name,
		    type: 'get',
		    dataType: 'json',
		    success: function(data){
		    	if(data.code==0){
		    		document.getElementById("dir_name").value=data.pinyin;
		    		return false;
		    	}
		       alert(data.text);
		    }
		})
	}
	layui.use(['form', 'layedit', 'laydate','element'], function(){
	  	var $ = layui.jquery
	  	,element = layui.element; //Tab的切换功能，切换事件监听等，需要依赖element模块
	  	$('.site-demo-active').on('click', function(){
	    	var othis = $(this), type = othis.data('type');
	    	active[type] ? active[type].call(this, othis) : '';
	  	});
	  	var form = layui.form;
	  	//监听指定开关
  		form.on('radio(type)', function(data){
    		if(data.value==2){
    			$('#layui_list').hide("slow");
    			$('#layui_content').hide("slow");
    			$('#danyecontent').show("slow");
    		}else{
    			$('#layui_list').show("slow");
    			$('#layui_content').hide("slow");
    			$('#danyecontent').hide("slow");
    		}
  		});
	});
$(document).ready(function(){
   	$("#setting_head").change(function(){
       	var selected=$(this).children('option:selected').val();
       	if(selected==0){
           	$("#tplhead").val("");
       	}else{
           	$("#tplhead").val(selected);
       	}
   	});
   	$("#setting_foot").change(function(){
   	    var selected=$(this).children('option:selected').val();
       if(selected==0){
        	$("#tplfoot").val("");
      	}else{
      	    $("#tplfoot").val(selected);
     	}
   	});
   	$("#setting_content").change(function(){
   	    var selected=$(this).children('option:selected').val();
       if(selected==0){
        	$("#tplcontent").val("");
      	}else{
      	    $("#tplcontent").val(selected);
     	}
   	});
   	$("#setting_list").change(function(){
   	    var selected=$(this).children('option:selected').val();
       if(selected==0){
        	$("#tplcategory").val("");
      	}else{
      	    $("#tplcategory").val(selected);
     	}
   	});
   	$("#setting_onepage").change(function(){
   	    var selected=$(this).children('option:selected').val();
       if(selected==0){
        	$("#tplonepage").val("");
      	}else{
      	    $("#tplonepage").val(selected);
     	}
   	});
});
</script>
<?php $this->display(tpl('foot',true)); ?>   
