<!--{include file="<!--{$oetplpath}-->block_head.tpl"}-->
<!--{if $a == "run"}-->
<div class="oemarry_layout">
  <div class="oe_top_nav"><i></i>系统设置->自定义HTML标签</div>
  <div class="oe_content">
	
	<form id="serform" action="<!--{$oefile}-->&c=<!--{$c}-->" method="post">
	<div class="oe_txtwrap">
	  当前风格：<!--{$config.templet}-->&nbsp;&nbsp;
	  标签名：<input type="text" name="smark" id="smark" class="input-150" value="<!--{$smark}-->" />&nbsp;
	  标题：<input type="text" name="sname" id="sname" class="input-150" value="<!--{$sname}-->" />&nbsp;
	  &nbsp;&nbsp;&nbsp;<input type="submit" name="btn_search" id="btn_search" class="button_2" value="搜索" />
	</div>
	</form>

    <div class="oe_tools_bar clearfix">
      <a class="icon-checkbox-unchecked" href="javascript:;" id="selAll" onclick="oemarrySelectAll(this, 'selall');">选择</a>
      <a class="icon-remove-2" onclick="oemarryDialogFormDel('myform');">删除</a>
      <span class="fr"><a class="icon-plus" href="<!--{$oefile}-->&c=<!--{$c}-->&a=add">添加</a></span>
    </div>
    
	<form id="myform" action="<!--{$oefile}-->&c=<!--{$c}-->&a=del" method="post">
    <table class="oe_table_list table_cs">
	  <tr>
	    <th width="8%">ID</th>
		<th width="15%">标题</th>
		<th width="15%">标识</th>
		<th width="25%">调用标签</th>
		<th width="10%">所属风格</th>
		<th width="14%">添加时间</th>
		<th>操作</th>
	  </tr>
	  <!--{if empty($htmllabel)}-->
	  <tr>
	    <td class="text_center" colspan="7">没有符合条件的信息</td>
	  </tr>
	  <!--{else}-->
	  <!--{foreach $htmllabel as $volist}-->
	  <tr>
	    <td class="text_center"><input type="checkbox" name="id[]" id="id[]" class="selall" value="<!--{$volist.labelid}-->" /><!--{$volist.labelid}--></td>
		<td><!--{$volist.title}--></td>
		<td><!--{$volist.labelname}--></td>
		<td>&lt;!--{label name="<!--{$volist.labelname}-->"}--&gt;</td>
		<td class="text_center"><!--{$config.templet}--></td>
		<td><!--{$volist.addtime|date_format:"%Y-%m-%d %H:%M:%S"}--></td>
		<td class="text_center">
		 <a href="<!--{$oefile}-->&c=<!--{$c}-->&a=edit&id=<!--{$volist.labelid}-->&<!--{$comeurl}-->" class="oe_ico_blue">编辑</a>
		 <a href="javascript:;" onclick="oemarryDialogUrlDel('<!--{$oefile}-->&c=<!--{$c}-->&a=del&id[]=<!--{$volist.labelid}-->&<!--{$comeurl}-->');" class="oe_ico_red">删除</a>
		</td>
	  </tr>
	  <!--{/foreach}-->
	  <!--{/if}-->
	</table>
	</form>

	<div class="oe_page_box"><!--{$showpage}--></div>

  </div>
</div>
<!--{/if}-->

<!--{if $a == 'add'}-->
<div class="oemarry_layout">
  <div class="oe_top_nav">
	<i></i>系统设置->自定义HTML标签->添加
	<span><a href="<!--{$oefile}-->&c=<!--{$c}-->">&lt;&lt;返回列表</a></span>
  </div>
  <div class="oe_content">
    <h6>添加自定义HTML标签</h6>
	<form id="myform" action="<!--{$oefile}-->&c=<!--{$c}-->" method="post" />
	<input type="hidden" name="a" id="a" value="saveadd" />
    <table class="oe_table_wrap">
	  <tr>
	    <th width="15%">标签标识：<span class="f_red">*</span></th>
		<td width="85%">
		  <input type="text" name="labelname" id="labelname" class="input-b" />
		  <span class="oe_trap">（由字母、数字、下横线组成）</span>
		</td>
	  </tr>
	  <tr>
	    <th>标签标题：<span class="f_red">*</span></th>
		<td><input type="text" name="title" id="title" class="input-b" /></td>
	  </tr>
	  <tr>
	    <th>标签内容：</th>
		<td>
		  <textarea name="content" id="content" style="width:80%;height:250px;display:none;"></textarea>
		</td>
	  </tr>
	  <tr>
	    <td></td>
		<td><input type="button" id="btn_save" class="button_2" value="添加保存" /></td>
	  </tr>
	</table>
	</form>
  </div>
</div>
<script type="text/javascript">
$(function(){
	var myeditor;
	KindEditor.ready(function(K) {myeditor = K.create("#content");});

	$("#labelname").bind("blur", function(){ //检测标识
		if ($(this).val().length > 0) {
			$.ajax({
				type: "POST",
				url: "<!--{$oefile}-->&c=<!--{$c}-->",
				cache: false,
				data: {a:"check", name:$(this).val(), r:get_rndnum(8)},
				dataType: "json",
				success: function(data) {
					$json = eval(data);
					$response = $json.response;
					$result = $json.result;
					if ($response == '1') {
						oemarryCheckOk("labelname", "该标识可用");
					}
					else {
						if ($result.length == 0) {
							$result = "该标识已存在";
						}
						oemarryCheckError("labelname", $result);
					}
				},
				error: function() {
					ToastShow("检测失败，请检查网络...");
				}
			});
		}
	});

	$("#btn_save").bind("click", function(){
		if ($("#labelname").val().length == 0) {
			ToastShow("请填写标识", "labelname");
			return false;
		}
		if ($("#title").val().length == 0) {
			ToastShow("请填写标题", "title");
			return false;
		}
		$("#content").text(myeditor.html());
		$("#myform").submit();
	});

});
</script>

<!--{/if}-->


<!--{if $a == 'edit'}-->
<div class="oemarry_layout">
  <div class="oe_top_nav">
	<i></i>系统设置->自定义HTML标签->编辑
	<span><a href="<!--{$oefile}-->&c=<!--{$c}-->&<!--{$comeurl}-->">&lt;&lt;返回列表</a></span>
  </div>
  <div class="oe_content">
    <h6>编辑自定义HTML标签</h6>
	<form id="myform" action="<!--{$oefile}-->&c=<!--{$c}-->&<!--{$comeurl}-->" method="post" />
	<input type="hidden" name="a" id="a" value="saveedit" />
	<input type="hidden" name="id" id="id" value="<!--{$id}-->" />
    <table class="oe_table_wrap">
	  <tr>
	    <th width="15%">标签标识：<span class="f_red">*</span></th>
		<td width="85%">
		  <input type="text" name="labelname" id="labelname" class="input-b" value="<!--{$htmllabel.labelname}-->" />
		  <span class="oe_trap">（由字母、数字、下横线组成）</span>
		</td>
	  </tr>
	  <tr>
	    <th>标签标题：<span class="f_red">*</span></th>
		<td><input type="text" name="title" id="title" class="input-b" value="<!--{$htmllabel.title}-->" /></td>
	  </tr>
	  <tr>
	    <th>标签内容：</th>
		<td>
		  <textarea name="content" id="content" style="width:80%;height:250px;display:none;"><!--{$htmllabel.content}--></textarea>
		</td>
	  </tr>
	  <tr>
	    <td></td>
		<td><input type="button" id="btn_save" class="button_2" value="编辑保存" /></td>
	  </tr>
	</table>
	</form>
  </div>
</div>
<script type="text/javascript">
$(function(){

	var myeditor;
	KindEditor.ready(function(K) {myeditor = K.create("#content");});

	$("#labelname").bind("blur", function(){ //检测标识
		if ($(this).val().length > 0) {
			$.ajax({
				type: "POST",
				url: "<!--{$oefile}-->&c=<!--{$c}-->",
				cache: false,
				data: {a:"check", name:$(this).val(), labelid:"<!--{$id}-->", r:get_rndnum(8)},
				dataType: "json",
				success: function(data) {
					$json = eval(data);
					$response = $json.response;
					$result = $json.result;
					if ($response == '1') {
						oemarryCheckOk("labelname", "该标识可用");
					}
					else {
						if ($result.length == 0) {
							$result = "该标识已存在";
						}
						oemarryCheckError("labelname", $result);
					}
				},
				error: function() {
					ToastShow("检测失败，请检查网络...");
				}
			});
		}
	});

	$("#btn_save").bind("click", function(){
		if ($("#labelname").val().length == 0) {
			ToastShow("请填写标识", "labelname");
			return false;
		}
		if ($("#title").val().length == 0) {
			ToastShow("请填写标题", "title");
			return false;
		}
		$("#content").text(myeditor.html());
		$("#myform").submit();
	});

});
</script>
<!--{/if}-->
</body>
</html>