<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>标签生成器</title>
<style type="text/css">
<!--
input{font-size: 12px;}
a{color:#4A621A;text-decoration:none;background-color: #ECF4D9;}
a:hover{text-decoration:none;color:#FF0000;background-color:#FFEEEE;}
form {margin: 0px;padding: 0px;}
fieldset{padding: 0px;}
legend {font-size: 14px;}
.intro{font-size: 12px;color: #666666;}
#tagsBhelp a,#tagsAhelp a{color: #0000FF;text-decoration: none;cursor: hand;}
#tagsBhelp a:hover,#tagsAhelp a:hover{color: #FF0000;text-decoration: none;}
#tagsout{font-size: 13px;line-height: 180%;color: #316912;}
#tagsout a{color: #0000FF;text-decoration: none;cursor: hand;padding-right: 2px;padding-left: 2px;background-color: #F2F9E8;}
-->
</style>
<script language="javascript">
function S(objname){var obj = document.getElementById(objname);obj.style.display = "block";}
function H(objname){var obj = document.getElementById(objname);obj.style.display = "none";}
function F(objname){var obj = document.getElementById(objname);}
</script>
<link href="Images/Style.Css" rel="stylesheet" type="text/css" />
</head>
<body>
<%
If Request("Act") = "Int" Then Response.End
If Request("Act") = "Create" Then

	TagsName = Request("name") : TagsCache = Request("cache") : TagsRow = Request("row") : TagsCol = Request("col") : TagsWidth = Request("width"): TagsClass = Request("class")
	TagsName = UCase(Left(TagsName,1)) & Right(TagsName,Len(TagsName)-1)
	Response.Write "<div id='tagsout'>"
	Response.Write "<font color=red>" & Server.HtmlEncode("<!--") & "</font><a>" & TagsName & "</a><font color=red>:{</font>"
	If Len(TagsCache)>0 And IsNumeric(TagsCache) Then Response.Write " <a>$Cache</a><font color=black>=</font>" & TagsCache & " "
	If Len(TagsRow)>0 And IsNumeric(TagsRow) Then Response.Write " <a>$Row</a><font color=black>=</font>" & TagsRow & " "
	If Len(TagsCol)>0 And IsNumeric(TagsCol) And TagsCol>1 Then
		Response.Write " <a>$Col</a><font color=black>=</font>" & TagsCol & " "
		If Len(TagsWidth)>0 Then Response.Write " <a>$Width</a><font color=black>=</font>" & TagsWidth & " "
		If Len(TagsClass)>0 Then Response.Write " <a>$Class</a><font color=black>=</font>" & TagsClass & " "
	End If
	Select Case Request("tags")
	Case "a"
		If Len(Request("aid"))>0 Then Response.Write " <a>$Aid</a><font color=black>=</font>" & Request("aid") & " "
		If Len(Request("cid"))>0 Then Response.Write " <a>$Cid</a><font color=black>=</font>" & Request("cid") & " "
		If Len(Request("type"))>0 Then Response.Write " <a>$Type</a><font color=black>=</font>" & Request("type") & " "
		If Len(Request("mode"))>0 Then 
			Response.Write " <a>$Mode</a><font color=black>=</font>" & Request("mode") & " "
			If Len(Request("keys"))>0 Then Response.Write " <a>$Keys</a><font color=black>=</font>" & Request("keys") & " "
		End If
		If Len(Request("orders"))>0 Then Response.Write " <a>$Order</a><font color=black>=</font>" & Request("orders") & " "
		If Len(Request("field1"))> 0 Then Response.Write " <a>$Field</a><font color=black>=</font>" & Request("field1") & " "
		Response.Write "<font color=red>" & Server.HtmlEncode("}-->") & "</font>"
		Response.Write "<BR><a><font color=red>[</font>" & TagsName & ":i<font color=red>]</a></font> <span class=intro>表示输出的记录编号</span>"
		Response.Write "<BR><a><font color=red>[</font>" & TagsName & ":curl<font color=red>]</a></font> <span class=intro>文章所属栏目链接地址</span>"
		Response.Write "<BR><a><font color=red>[</font>" & TagsName & ":cname<font color=red>]</a></font> <span class=intro>文章所属栏目名称</span>"
		Response.Write "<BR><a><font color=red>[</font>" & TagsName & ":aurl<font color=red>]</a></font> <span class=intro>文章链接地址</span>"
		Response.Write "<BR><a><font color=red>[</font>" & TagsName & ":titlex<font color=red>]</a></font> <span class=intro>文章标题带属性(颜色+样式)</span>"
	Case "b"
		If Len(Request("table"))>0 Then Response.Write " <a>$Table</a><font color=black>=</font>" & Request("table") & " "
		If Len(Request("where"))>0 Then Response.Write " <a>$Where</a><font color=black>=</font>" & Request("where") & " " 
		If Len(Request("order"))>0 Then Response.Write " <a>$Order</a><font color=black>=</font>" & Request("order") & " " 
		If Len(Request("field2"))> 0 Then Response.Write " <a>$Field</a><font color=black>=</font>" & Request("field2") & " "
		Response.Write "<font color=red>" & Server.HtmlEncode("}-->") & "</font>"
		Response.Write "<BR><a><font color=red>[</font>" & TagsName & ":i<font color=red>]</a></font> <span class=intro>表示输出的记录编号</span>"
		If Request("table") = "Content" Then
			Response.Write "<BR><a><font color=red>[</font>" & TagsName & ":curl<font color=red>]</a></font> <span class=intro>文章所属栏目链接地址</span>"
			Response.Write "<BR><a><font color=red>[</font>" & TagsName & ":cname<font color=red>]</a></font> <span class=intro>文章所属栏目名称</span>"
			Response.Write "<BR><a><font color=red>[</font>" & TagsName & ":aurl<font color=red>]</a></font> <span class=intro>文章链接地址</span>"
			Response.Write "<BR><a><font color=red>[</font>" & TagsName & ":titlex<font color=red>]</a></font> <span class=intro>文章标题带属性(颜色+样式)</span>"
		End If
		If Request("table") = "Channel" Then
			Response.Write "<BR><a><font color=red>[</font>" & TagsName & ":curl<font color=red>]</a></font> <span class=intro>栏目链接地址</span>"
			Response.Write "<BR><a><font color=red>[</font>" & TagsName & ":cname<font color=red>]</a></font> <span class=intro>文栏目名称</span>"
		End If
	Case "c"
		Response.Write " <a>$Sql</a><font color=black>=</font>" & Request("sql") & " "
		Response.Write "<font color=red>" & Server.HtmlEncode("}-->") & "</font>"
		Response.Write "<BR><a><font color=red>[</font>" & TagsName & ":i<font color=red>]</a></font> <span class=intro>表示输出的记录编号</span>"
	Case Else
		Response.Write " <a>$Table</a><font color=black>=</font>Content "
		Response.Write "<font color=red>" & Server.HtmlEncode("}-->") & "</font>"
		Response.Write "<BR><a><font color=red>[</font>" & TagsName & ":i<font color=red>]</a></font> <span class=intro>表示输出的记录编号</span>"
	End Select
	Response.Write "<BR><a><font color=red>[</font>" & TagsName & ":字段<font color=red>]</a></font> <span class=intro>输出对应字段的值</span>"
	Response.Write "<BR>"
	Response.Write "<font color=red>" & Server.HtmlEncode("<!--") & "</font><a>" & TagsName & "</a><font color=red>--></font>"
	Response.Write "</div>"
	Response.End
End If
%>
<center><br />
  <form action="Tags.Asp?Act=Create" method="post" name="frm" target="stafrm" id="frm">
    <fieldset>
    <legend>标签生成器</legend>
    <table width="100%" cellpadding="0" cellspacing="0">
      <tr>
        <td><table width="100%" border="0" cellpadding="5" cellspacing="0">
            <tr>
              <td width="14%" align="right">标签名称：</td>
              <td width="36%" align="left"><input name="name" type="text" id="name" onkeyup="do_submit();" value="List" size="16" /></td>
              <td width="14%" align="right">缓存时间：</td>
              <td width="36%" align="left"><input name="cache" type="text" id="cache" onkeyup="do_submit();" size="16" />
                <span class="intro">秒</span></td>
            </tr>
            <tr>
              <td align="right">返回行数：</td>
              <td align="left"><input name="row" type="text" id="row" onkeyup="do_submit();backn.innerHTML=frm.row.value*frm.col.value;" value="10" size="16" />
                <span class="intro">返回记录 <span id="backn" style="color:red;">10</span> 条 </span></td>
              <td align="right">返回列数：</td>
              <td align="left"><input name="col" type="text" id="col" onblur="var intstr=/^\d+$/;if(!intstr.test(this.value)){this.value=1;} if(this.value&gt;1){S('echotable');}else{H('echotable')}" onkeyup="var intstr=/^\d+$/;if(!intstr.test(this.value)){this.value=1;} if(this.value&gt;1){S('echotable');}else{H('echotable')}do_submit();backn.innerHTML=frm.row.value*frm.col.value;" value="1" size="16" /></td>
            </tr>
            <tr id="echotable" style="display:none;">
              <td align="right">表格宽度：</td>
              <td align="left"><input name="width" type="text" id="width" onkeyup="do_submit();" value="100%" size="16" /></td>
              <td align="right">表格样式：</td>
              <td align="left"><input name="class" type="text" id="class" onkeyup="do_submit();" size="16" /></td>
            </tr>
            <tr>
              <td align="right"><strong>标签类型</strong>：</td>
              <td colspan="3" align="left"><input name="tags" type="radio" onclick="S('tagsA');H('tagsB');H('tagsC');frm.Submit.disabled=false;do_submit();" value="a" />
                文章列表
                <input name="tags" type="radio" onclick="H('tagsA');S('tagsB');H('tagsC');do_table('Content');frm.Submit.disabled=false;do_submit();" value="b" />
                组合SQL
                <input name="tags" type="radio" onclick="H('tagsA');H('tagsB');S('tagsC');frm.Submit.disabled=false;do_submit();" value="c" />
              独立SQL</td>
            </tr>
          </table></td>
      </tr>
    </table>
    </fieldset>
    <div id="tagsA"><br />
      <fieldset>
      <legend>文章列表</legend>
      <table width="100%" cellpadding="0" cellspacing="0">
        <tr>
          <td><table width="100%" border="0" cellpadding="5" cellspacing="0">
              <tr>
                <td width="14%" align="right">所属栏目：</td>
                <td width="36%" align="left"><input name="cid" type="text" id="cid" onclick="tagsAhelp.innerHTML='为空则显示所有文章,指定单个栏目则填写该栏目的ID即可,如 &lt;a&gt;1&lt;/a&gt; ,如需指定多个栏目下的文章则用英文状态下的逗号(,)分隔多个栏目ID,如 &lt;a&gt;1,2,3,4&lt;/a&gt;';" onkeyup="do_submit();" size="16" />
                <span class="intro">数字,多以用,分隔</span></td>
                <td width="14%" align="right">排除文章：</td>
                <td width="36%" align="left"><input name="aid" type="text" id="aid" onclick="tagsAhelp.innerHTML='输入不相输出的文章ID编号,可以是多个文章ID编号,如 &lt;a&gt;1,2,3,4&lt;/a&gt;';" onkeyup="do_submit();" size="16" />                  
                <span class="intro">数字,多以用,分隔</span></td>
              </tr>
              <tr>
                <td align="right">输出类型：</td>
                <td align="left"><select name="type" id="type" onfocus="tagsAhelp.innerHTML='';" onblur="tagsAhelp.innerHTML='';" onchange="tagsAhelp.innerHTML='';do_submit();">
                    <option value="" selected="selected">所有文章</option>
                    <option value="Images">有形象图</option>
                </select>                </td>
                <td align="right">文章类型：</td>
                <td align="left"><select name="mode" id="mode" onfocus="tagsAhelp.innerHTML='';" onblur="tagsAhelp.innerHTML='';" onchange="tagsAhelp.innerHTML='';if(this.value=='about'){S('about_1');S('about_2');}else{H('about_1');H('about_2');}do_submit();">
                    <option value="" selected="selected">所有文章</option>
					<option value="Commend">推荐文章</option>
                    <option value="Hot">热文文章</option>
                    <option value="About">相关文章</option>
                </select></td>
              </tr>
              <tr>
			                  <td align="right">排序方式：</td>
                <td align="left"><select name="orders" id="orders" onfocus="tagsAhelp.innerHTML='';" onblur="tagsAhelp.innerHTML='';" onchange="tagsAhelp.innerHTML='';do_submit();">
                    <option value="[ID] Desc" selected="selected">编号 大→小</option>
                    <option value="[ID] Asc">编号 小→大</option>
                    <option value="[Order] Desc">权重 大→小</option>
                    <option value="[Modifytime] Desc">更新时间 近→远</option>
                </select></td>
                <td align="right"><span id="about_1" style="display:none;">标题匹配：</span></td>
                <td align="left"><span id="about_2" style="display:none;">
                  <input name="keys" onkeyup="do_submit();" size="30" type="text" id="keys" onclick="tagsAhelp.innerHTML='文章类型为相关文章时,这里一定需要输入关键字,如 &lt;a&gt;关键字1,关键字2,关键字3&lt;/a&gt;';" /></span></td>
              </tr>
              <!--<tr>
                <td align="right">指定字段：</td>
                <td colspan="2" align="left"><input name="field1" type="text" id="field1" style="width:98%" onclick="tagsAhelp.innerHTML='指定了字段可以提升SQL查询效率,数据库数据量大时可以通过这个进行优化!如果你不了解SQL查询语句请不要使用,留空就行了!';" onkeyup="do_submit();" /></td>
                <td align="left" class="intro">指定字段可提高效率,新手勿用,请留空</td>
              </tr>-->
              <tr>
			    <td align="right">&nbsp;</td>
                <td colspan="3" align="left" class="intro" id="tagsAhelp">&nbsp;</td>
              </tr>
          </table></td>
        </tr>
      </table>
      </fieldset>
    </div>
    <div id="tagsB"><br />
      <fieldset>
      <legend>组合SQL</legend>
      <table width="100%" cellpadding="0" cellspacing="0">
        <tr>
          <td><table width="100%" border="0" cellpadding="5" cellspacing="0">
              <tr>
                <td align="right">指定数据库：</td>
                <td width="36%" align="left"><select name="table" id="table" onblur="do_table(this.value);" onchange="do_table(this.value);do_submit();">
                    <option value="Content" selected="selected">文章信息 (Content)</option>
                    <option value="Channel">栏目信息 (Channel)</option>
                    <option value="Comment">文章评论 (Comment)</option>
                    <option value="Sitelink">站内链接 (Sitelink)</option>
                    <option value="Upload">上传文件 (Upload)</option>
                    <option value="Diypage">自定义页面 (Diypage)</option>
                    <option value="Tags">关键字/标签 (Tags)</option>
                  </select>
                <a href="http://www.xxzwz.com/Svc/Database.Asp" target="_blank"><span class="intro">表结构说明</span></a></td>
                <td width="14%" align="right">排序方式：</td>
                <td width="36%" align="left"><select name="order" id="order" onchange="do_submit();">
                </select>                </td>
              </tr>
              <tr>
                <td align="right">查询条件：</td>
                <td colspan="2" align="left"><input name="where" type="text" id="where" style="width:98%" onkeyup="do_submit();" /></td>
                <td align="left" class="intro">可以使用 And 和 Or 连结不同的条件 </td>
              </tr>
              <!--<tr>
                <td align="right">指定字段：</td>
                <td colspan="2" align="left"><input name="field2" type="text" id="field2" style="width:98%" onclick="tagsBhelp.innerHTML='指定了字段可以提升SQL查询效率,数据库数据量大时可以通过这个进行优化!如果你不了解SQL查询语句请不要使用,留空就行了!';" onkeyup="do_submit();" /></td>
                <td align="left" class="intro">指定字段可提高效率,新手勿用请留空!</td>
              </tr>-->
              <tr>
                <td width="14%" align="right">参考信息：</td>
                <td colspan="3" align="left" class="intro" id="tagsBhelp">&nbsp;</td>
              </tr>
            </table></td>
        </tr>
      </table>
      </fieldset>
    </div>
    <div id="tagsC"><br />
      <fieldset>
      <legend>独立SQL</legend>
      <table width="100%" cellpadding="0" cellspacing="0">
        <tr>
          <td><table width="100%" border="0" cellpadding="5" cellspacing="0">
              <tr>
                <td width="14%" align="right">SQL语句：</td>
                <td><input name="sql" type="text" id="sql" style="width:98%" onkeyup="do_submit();" value="Select * From [{pre}表名] Where 条件 Order By 排序方式" /></td>
                <td width="36%" align="left" class="intro">如果你不熟悉SQL查询语句请尽量不要使用</td>
              </tr>
            </table></td>
        </tr>
      </table>
      </fieldset>
    </div>
    <div align="center" style="display:none;"> <br />
      <input name="Submit" type="button" disabled="disabled" id="Submit" onclick="do_submit();" value="创建标签" /><br />
    </div>
    <div><br />
      <fieldset>
      <legend>标签参考代码</legend>
      <table width="100%" cellpadding="0" cellspacing="5">
        <tr>
          <td><table width="100%" border="0" cellpadding="0" cellspacing="0">
              <tr>
                <td align="left"><iframe src="Tags.Asp?Act=Int" name="stafrm" width="100%" marginwidth="0" height="240" marginheight="0" scrolling="Auto" frameborder="0" id="stafrm"></iframe></td>
              </tr>
            </table></td>
        </tr>
      </table>
      </fieldset>
    </div>
  </form>
</center>
<script>
// 初始化
H("tagsA");H("tagsB");H("tagsC");

// 数据验证
function do_submit(){
	var chk=true;
	var intstr=/^\d+$/;
	if(chk&&frm.name.value.length<1){chk=false;alert('请输入标签名称!');}
	if(chk&&frm.name.value=='page'){chk=false;alert('标签名称 page 为系统预留标签,不可以使用!');}
	if(chk&&frm.name.value=='field'){chk=false;alert('标签名称 field 为系统预留标签,不可以使用!');}
	if(chk&&(!intstr.test(frm.cache.value)||frm.cache.value<1)){frm.cache.value='';} //缓存
	if(chk&&(!intstr.test(frm.row.value)||frm.row.value<1)){frm.row.value=10;} //行
	if(chk&&(!intstr.test(frm.col.value)||frm.col.value<1)){frm.col.value=1;}
	if(chk)frm.submit();
}

// 内容表数据验证
function do_table(s){
	frm.order.length=0;
	switch(s){
	case "Content":
		frm.order.options[0]=new Option('编号 大→小','[ID] Desc');
		frm.order.options[1]=new Option('编号 小→大','');
		frm.order.options[2]=new Option('权重 大→小','[Order] Desc');
		frm.order.options[3]=new Option('浏览次数 多→少','[Views] Desc');
		frm.order.options[4]=new Option('更新时间 近→远','[Createtime] Desc');
		frm.order.options[5]=new Option('评论次数 多→少','[Createtime] Desc');
		tagsBhelp.innerHTML='有形象图 <a>[Indexpic]<>\'\'</a> 没有形象图 <a>[Indexpic]=\'\'</a> 推荐文章 <a>[Commend]=1</a> 普通文章 <a>[Commend]=0</a> 文章为显示 <a>[Display]=1</a> 文章为隐藏 <a>[Display]=0</a> 有评论 <a>[Comments]>0</a> 允许评论 <a>[Iscomment]=1</a> 禁止评论 <a>[Iscommment]=0</a>';
		break;
	case "Channel":
		frm.order.options[0]=new Option('编号 大→小','[ID] Desc');
		frm.order.options[1]=new Option('编号 小→大','');
		frm.order.options[2]=new Option('顺序 大→小','[Order] Desc');
		tagsBhelp.innerHTML='一级栏目 <a>[ParentID]=0</a> 有栏目形象图 <a>[Picture]<>\'\'</a> 无栏目形象图 <a>[Picture]=\'\'</a> 绑定域名 <a>[Domain]<>\'\'</a> 未绑定域名 <a>[Domain]=\'\'</a> 有子栏目 <a>[ChildID]<>\'\'</a> 无子栏目 <a>[ChildID]=\'\'</a> ';
		break;
	case "Comment":
		frm.order.options[0]=new Option('编号 大→小','[ID] Desc');
		frm.order.options[1]=new Option('编号 小→大','');
		tagsBhelp.innerHTML='已审核 <a>[State]=1</a> 未审核 <a>[State]=0</a>';
		break;
	case "Tags":
		frm.order.options[0]=new Option('更新时间 近→远','[Modifytime] Desc');
		tagsBhelp.innerHTML='';
		break;
	case "Sitelink":
		frm.order.options[0]=new Option('编号 大→小','[ID] Desc');
		frm.order.options[1]=new Option('编号 小→大','');
		frm.order.options[2]=new Option('顺序 大→小','[Order] Desc');
		tagsBhelp.innerHTML='已启用站内链接 <a>[State]=1</a> 已禁用的站内链接 <a>[State]=0</a>';
		break;
	case "Upload":
		frm.order.options[0]=new Option('编号 大→小','[ID] Desc');
		frm.order.options[1]=new Option('编号 小→大','');
		tagsBhelp.innerHTML='所有图片类型 <a>[Ext]=\'jpg\' Or [Ext]=\'gif\' Or [Ext]=\'bmp\' Or [Ext]=\'png\' Or [Ext]=\'jpeg\'</a> GIF文件 <a>[Ext]=\'gif\'</a> JPG文件 <a>[Ext]=\'jpg\'</a> RAR文件 <a>[Ext]=\'rar\'</a>';
		break;
	case "Diypage":
		frm.order.options[0]=new Option('编号 大→小','[ID] Desc');
		frm.order.options[1]=new Option('编号 小→大','');
		tagsBhelp.innerHTML='';
		break;
	}
}
</script>
</body>
</html>
