<?php 
	$this->display(tpl('head',true)); 
	$setting=unserialize($data[setting]);
	$is_comment[$data[is_comment]]="checked";
?>

<style>
	.layui-tab{
		padding-left: 20px;
	}
	.layui-field-box{
		color: red;
	}
	.layui-input,.layui-textarea{
		width: 30%;
		float: left;
	}
	.layui-form .layui-form-select .layui-input{
		width: 100%;
	}
	.layui-form .layui-form-select{
		width: 30%;
		float: left;
	}
	.layui-table p{
		width: 100%;
		float: left;
	}
	#select_pic{
		margin-left: 20px;
	}
	td span{
		line-height: 35px;
		margin-left: 10px;
	}
</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">
		
		<div class="layui-tab-content">
			<div class="layui-tab-item layui-show">
				<table class="layui-table my-tabel">
					<tr>
						<td>专题名称</td>
						<td><input name="post[name]" id="name" placeholder="请输入专题名称" value="<?php echo $data[name] ?>" class="layui-input" ></td>
					</tr>
			
					<tr>
						<td>所属专题</td>
						<td>
							<select name="post[sid]" >
			    				<option value="">顶级分类</option>
								<?php echo $special_category ?>
			    			</select>
						</td>
					</tr>
					<tr>
						<td>缩略图</td>
						<td>
							<input name="post[thumb]" id="thumb" class="layui-input  my-input" type="text" value="<?php echo $data[thumb] ?>">
			    			<button type="button" class="layui-btn layui-btn-normal" id="select_pic">选择图片上传</button>
						</td>
					</tr>
					<tr>
						<td>列表行数</td>
						<td><input name="setting[rows]" id="rows" placeholder="前台页面列表的行数" value="<?php echo $setting[rows] ?>" class="layui-input" > <span>条</span></td>
					</tr>
					<tr>
						<td>评论显示行数</td>
						<td><input name="setting[comment_rows]" id="rows" placeholder="前台页面评论显示行数" value="<?php echo $setting[comment_rows] ?>" class="layui-input" > <span>条</span></td>
					</tr>
					<tr>
						<td>评论状态</td>
						<td>
							<input type="radio" name="post[is_comment]" value="1" title="开启评论" <?php echo $is_comment[1] ?>>
							<input type="radio" name="post[is_comment]" value="0" title="关闭评论" <?php echo $is_comment[0] ?>>
						</td>
					</tr>
					<tr>
						<td>通配关键词</td>
						<td>
							<input name="post[keyword]" id="keyword"  value="<?php echo $data[keyword] ?>" class="layui-input" >
							<p>如果开启了发布时直接按照关键词入库专题，才需填写。多个关键词用空格隔开</p>
						</td>
					
					</tr>
					
					
					<tr>
						<td>SEO标题</td>
						<td><input name="post[seo_name]" placeholder="请输入SEO标题" value="<?php echo $data[seo_name] ?>" class="layui-input" ></td>
					</tr>
					
					<tr>
						<td>SEO关键字</td>
						<td><input name="post[seo_keywords]" placeholder="请输入SEO关键字" value="<?php echo $data[seo_keywords] ?>" class="layui-input" ></td>
					</tr>
					
					<tr>
						<td>SEO简介</td>
						<td>
							<textarea class="layui-textarea" name="post[seo_description]" placeholder="请输入SEO简介"><?php echo $data[seo_description] ?></textarea>
						</td>
					</tr>
					<tr>
						<td>专题介绍</td>
						<td>
							<textarea class="layui-textarea" name="post[content]" placeholder="请输入专题介绍"><?php echo $data[seo_description] ?></textarea>
						</td>
					</tr>
					<tr>
						<td>伪静态目录</td>
						<td>
							<input name="post[dir_name]" id="dir_name" value="<?php echo $data[dir_name] ?>" class="layui-input" >
							<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[tpl][list]" value="<?php echo $setting[tpl]['list'] ?>" id="tpllist" class="layui-input layui-input-my left" type="text">
				    		<select lay-filter="tpllist" class="left" id="setting_list">
				    			<option value="">请选择一个模板</option>
				           		<option value="special/content">默认模板</option>
				           		<?php foreach($content_template AS $row){ ?>
									<option value="<?php echo $row[file] ?>"><?php echo $row[name] ?></option>
								<?php } ?>
				    		</select>
				    		<p>如果专题页没有设置模板会以此模板为默认模板。如果都没设置，则以默认模板为准</p>
		    			</td>
		    		</tr>
					<tr>
						<td colspan="2" class="my_button">
							<input type="hidden" name="id" value="<?php echo $_GET[id] ?>" />
							<input type="hidden" name="step" value="post" />
							<button class="layui-btn">立即提交</button>
						</td>
					</tr>
				</table>
			</div>
			
		</div>
	</div>
	
</form>
<script>
	layui.config({
		version: '<?php echo NOWTIME ?>' //为了更新 js 缓存，可忽略
	});
	layui.use(['form','layer','element','upload'], function(){
		var form = layui.form,upload=layui.upload;
		form.on('select(tpllist)', function(data){
		  $('#tpllist').val(data.value);
		});
		//选完文件后不自动上传
		upload.render({
		    elem: '#select_pic',
		    url: '<?php echo admin_module_url?>/upfile/up/thumb_1/json_true/',
		    auto: true,
		    bindAction: '#star_upload',
		    before: function(obj){
		    	files = obj.pushFile(); //将每次选择的文件追加到文件队列
		    	loading = layer.load();
		    },
		    done: function(res, index, upload){
		    	layer.close(loading);
			    if(res.Result==0){
			    	layer.msg(res.content);
			    }else{
			      	$('#thumb').val(res.url); 
			    }
			    delete files[index]; //删除对应的文件
		    }
		});
	});
	function shengcheng(){
		var name=$("#name").val();
		$.ajax({
			url:"/admin/pinyin/pinyin/name_"+name,
		    type: 'get',
		    dataType: 'json',
		    success: function(data){
		       $("#dir_name").val(data.pinyin);
		    }
		})
	}	  
</script>

<?php $this->display(tpl('foot',true)); ?>   
