{include file="head.html"}
<style>
.table_style td { border-bottom:1px #ddd solid;}
.libel_list {background-color:#f5f5f5; border:1px #ccc solid;  padding:5px;}
.libel_list a { padding-left:10px; float:left; padding-right:10px; line-height:22px; height:22px; background-color:#fefefe; border:1px #ddd solid; margin-top:3px;margin-right:10px;}
.title_width { width:120px; line-height:25px; float:left;}
.listcontent { width:300px; float:left;}
#echo { line-height:20px; font-size:12px;}
</style>
<script src="__PUBLIC__/js/insertContent.js"></script>
<div id="maincontent">
  <div class="wrap">
    <div class="tip">{lang='添加标签后会自动生成相应标签，把标签放入模板需要位置即可。'} </div>
    <form action="__URL__/edit" id="form" method="post">
      <div class="infobox">
        <h3>{lang='栏目标签编辑'}</h3>
        <table class="form-table table_style">
          <tr>
          <td><strong>{lang='标签信息'}：</strong></td>
        </tr>
        <tr>
          <td><div class="title_width">{lang='标签名称'}：</div>
          <input name="name" type="text" class="regular-text" id="name" value="{$info['name']}" /></td>
        </tr>
        <tr>
          <td><div class="title_width">{lang='标签标识'}：</div>
          <input name="label" type="text" class="regular-text" id="label" value="{$info['label']}" /></td>
        </tr>
        <tr>
          <td><strong>{lang='调用参数'}：</strong></td>
        </tr>
        <tr>
          <td>
            <select name="mid" id="mid"  >
              <option value="none">{lang='全部模型'}</option>
              <?php if(!empty($modlist)) foreach($modlist as $vo){ ?>
              <option value="{$vo['id']}" <?php if($config['mid']==$vo['id']) { ?> selected="selected" <?php } ?> >{$vo['name']}</option>
              <?php } ?>
            </select>
            <input name="pid" type="text" class="regular-text" id="pid" style="width:120px;" value="{$config['pid']}" />
            <select style="width:130px;" onChange="$('#pid').val(decodeURIComponent($(this).val()))"  >
              <option value="" selected="selected">{lang='全部栏目'}</option>
              <?php if(!empty($cat)) foreach($cat as $vo){ ?>
              <option value="{$vo['id']}" <?php if($config['pid']==$vo['id']) { ?> selected="selected" <?php } ?> >{$vo['cname']}</option>
              <?php } ?>            
          </select>
          <select name="classtype" id="classtype">
              <option value="none" <?php if($config['classtype']=='none') { ?> selected="selected" <?php } ?> >{lang='全部类型'}</option>
              <option value="top" <?php if($config['classtype']=='top') { ?> selected="selected" <?php } ?>>{lang='顶级栏目'}</option>
              <option value="sub" <?php if($config['classtype']=='sub') { ?> selected="selected" <?php } ?>>{lang='所有子栏目'}</option>
            </select>
         </td>
        </tr>
        <tr>
          <td>
            <input name="limit" type="text" class="regular-text" id="limit" style="width:50px;" value="{$config['limit']}" /> {lang='条'}
            <input name="order" type="text" class="regular-text" id="order" style="width:150px;" value="{$config['order']}" />
            <select onChange="$('#order').val($(this).val())">
              <option value="id desc" <?php if($config['order']=='id desc') { ?> selected="selected" <?php } ?> >{lang='按ID倒序排序'}</option>
              <option value="id asc" <?php if($config['order']=='id asc') { ?> selected="selected" <?php } ?> >{lang='按ID升序排序'}</option>
          </select>
            <select name="att" id="att"  >
              <option value="none" <?php if($config['att']=='none') { ?> selected="selected" <?php } ?> >{lang='(全部页面)'}</option>
              <option value="class" <?php if($config['att']=='class') { ?> selected="selected" <?php } ?> >{lang='栏目页'}</option>
              <option value="list" <?php if($config['att']=='list') { ?> selected="selected" <?php } ?> >{lang='列表页'}</option>
            </select>
           </td>
        </tr>
        <tr>
            <td>
              <strong>{lang='附加SQL条件'}：</strong>({lang='附件条件为标准的SQL和PHP语法。'})</td>
          </tr>
        <tr>
          <td>
            <input name="where" type="text" class="regular-text" id="where" value="{$config['where']}" />
            <select onChange="$('#where').val($(this).val())">
              <option value="">{lang='无'}</option>
              <option value="att=1">{lang='查询栏目属性为列表页(示例)'}</option>
            </select></td>
        </tr>
        
        <tr>
            <td><strong>{lang='循环标识'}：</strong>({lang='如果为多维循环循环标识不能相同，多维循环请点击"插入循环标签"插入在外部循环内。'})</td>
          </tr>
        <tr>
          <td>
            <input name="mark" type="text" class="regular-text" id="mark" style="width:100px;" value="{$config['mark']}" />
            </td>
        </tr>
        <tr>
          <td>
          <button type="button" onclick="out_label(1)">{lang='输出栏目标签'}</button>
          <button type="button" onclick="out_label(2)">{lang='插入栏目标签'}</button> 
          <button type="button" onclick="out_label(3)">{lang='清空标签'}</button>           
          </td>
        </tr>
        <tr>
          <td>
          {lang='复杂示例'}：<a href="javascript:void(0)" onclick="demo_label(1)">{lang='输出二级菜单循环'}</a>({lang='多维循环'}) </td>
        </tr>
        <tr>
          <td>
          <div class="libel_list">
          <div style="clear:both"></div>
          <a href="javascript:void(0)"  onclick="ins_html('id')">栏目编号</a>
          <a href="javascript:void(0)"  onclick="ins_html('pid')">上级栏目编号</a>
          <a href="javascript:void(0)"  onclick="ins_html('name')">栏目名称</a>
          <a href="javascript:void(0)"  onclick="ins_html('seoname')">栏目SEO名称</a>
          <a href="javascript:void(0)"  onclick="ins_html('pinyin')">栏目英文</a>
          <a href="javascript:void(0)"  onclick="ins_html('pic')">栏目形象图</a>
          <a href="javascript:void(0)"  onclick="ins_html('keywords')">栏目关键词</a>
          <a href="javascript:void(0)"  onclick="ins_html('description')">栏目描述</a>
          <a href="javascript:void(0)" onclick="ins_html('sorter')">栏目排序</a>
          <a href="javascript:void(0)" onclick="ins_html('i')">循环序号</a>
          <a href="javascript:void(0)" onclick="ins_html('curl')">栏目链接</a>
          <div style="clear:both"></div>
          </div>
          <textarea id="echo" name="content" style="width:98%; height:150px; border:1px solid #ccc; margin-top:10px;"><?php echo html_out($info['content']) ?></textarea>
          <div>{lang='点击上面各个标签按钮会插入相应的标签代码，请将代码插入循环内部。输出的标签也可直接用于模板内。'}</div>
          </td>
        </tr>
        </table>
      </div>
      <div class="submit_body">
        <input name="type" id="type" type="hidden" value="1" />
        <input name="id" id="id" type="hidden" value="{$info['id']}" />
        <button class="regular-button" type="button" onclick="post()">{lang='修改'}</button>
      </div>
    </form>
  </div>
</div>
<script>
function out_label(type) {
	
	if($('#pid').val()==""){
		var pid='';
	}else{
		var pid=' pid=('+$('#pid').val()+')'; //栏目ID
	}
	
	if($('#classtype').val()=="none"){
		var classtype='';
	}else{
		var classtype=' type=('+$('#classtype').val()+')'; //是否包含子栏目
	}
	
	var limit=' limit=('+$('#limit').val()+')'; //调用条数
	
	if($('#mid').val()=="none"){
		var mid='';
	}else{
		var mid=' mid=('+$('#mid').val()+')'; //模型ID
	}
	
	var order=' order=('+$('#order').val()+')'; //排序类型
	
	
	var mark=$('#mark').val(); //循环标识
	
	if($('#att').val()=="none"){
		var att='';
	}else{
		var att=' att=('+$('#att').val()+')'; //置顶内容
	}
	
	if($('#where').val()==""){
		var where='';
	}else{
		var where=' where=('+$('#where').val()+')'; //附加条件
	}
	
	var outhtml="<!--"+mark+":{table=(channel)";
	outhtml+=pid;
	outhtml+=classtype;
	outhtml+=limit;
	outhtml+=mid;
	outhtml+=order;
	outhtml+=att;
	outhtml+=where;
	outhtml+="}-->\n";
	outhtml+='<a href="['+mark+':curl]">['+mark+':name]</a>\n';
	outhtml+="<!--/"+mark+"-->";
	
	if(type==1){
	$('#echo').attr("value",outhtml);
	}
	if(type==2){
	$('#echo').insertContent(outhtml); 
	}
	if(type==3){
	$('#echo').attr("value",'');	
	}
	
	
	

};

function ins_html(content) {
	var mark=$('#mark').val(); //循环标识
	$('#echo').insertContent('['+mark+':'+content+']'); 
}



function demo_label(type) {
	if(type==1){
	var outhtml="<ul>\n<!--channel:{table=(channel) type=(top) limit=(10) order=(id desc)";
	outhtml+="}-->\n";
	outhtml+='<a href="[channel:'+'curl]">[channel'+':name]</a>\n';
	outhtml+="<!--list:{table=(channel) pid=(#[channel"+":"+"id]#) limit=(10) order=(id desc)";
	outhtml+="}-->\n";
	outhtml+='<li><a href="[list'+':'+'curl]">[list'+':'+'name]</a></li>\n';
	outhtml+="<!--/"+"list-->\n";
	outhtml+="<!--/"+"channel-->\n</ul>";
	}
	$('#echo').attr("value",outhtml);
}
 </script>
</body></html>