<%@ Page Language="C#" AutoEventWireup="true" Inherits="System_Label_SubList, QianboCMS" EnableEventValidation="false" %>
<%@ Import Namespace="Qianbo.BLL.CommonModel" %>
<%@ Import Namespace="Qianbo.BLL" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="Qianbo.Common" %>
<!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 id="Head1" runat="server">
<title>子类列表标签参数设置</title>
<script language="javascript" type="text/javascript" src="../../Js/Common.js"></script>
<link rel="stylesheet" type="text/css" href="../Css/layout.css" />
<script type="text/javascript">
var api = frameElement.api, W = api.opener, D = W.document;
</script>
<script language="javascript" type="text/javascript">
function SwitchList()
{
    window.location.href=document.form1.selectList.value;
}
function ControlStyle()
{
    if($("selShowStyle").value=="out_table")
    {
        trStyle1.style.display="none";
    }
    else
    {
        trStyle1.style.display="";
    }
}
function hidenSelect()
{
    $("ddlColumnStyle").style.display="";
    $("ddlStyle").style.display="";
    $("selShowStyle").style.display="";
    $("selectOrder").style.display="";
    $("selColumn").style.display="";
    $("ddlStyle").options[0].selected=true;
}
function CustomStyle()
{
    if($("ddlStyle").value=="0")
    {
        myfun();
/*
        $("ddlColumnStyle").style.display="none";
        $("ddlStyle").style.display="none";
        $("selShowStyle").style.display="none";
        $("selectOrder").style.display="none";
        $("selColumn").style.display="none";
*/
    }
    else
    {
        $("ddlColumnStyle").style.display="";
        $("ddlStyle").style.display="";
        $("selShowStyle").style.display="";
        $("selectOrder").style.display="";
        $("selColumn").style.display="";
    }
}
function setx(obj)
{
    $("test").focus();
    if (document.selection)
    {
        var range= document.selection.createRange();
        if(obj.value=="$search$")
        range.text="<a href=javascript:showlist(\"<%=Param.ApplicationRootPath %>\",\"{Qianbo_chid}\",\"字段名称\",\"{Qianbo_字段名称}\",\"blank\")>字段值</a>";
        else
        range.text= obj.value;
    }
    obj.options[0].selected=true;
}
function myfun()
{
    DivSetStyle.style.display="";
    DivSetStyle.style.width="600";
    DivSetStyle.style.marginLeft=50;
    DivSetStyle.style.marginTop=82;
}
function CheckValidate()
{
    if($("txtTypeName").value.trim().length==0)
    {
        alert("样式名称不能为空！");
        $("txtTypeName").focus();
        return false;
    }
    if($("test").value.trim().length==0)
    {
        alert("样式内容不能为空！");
        return false;
    }
    return true;
}
function UpdateChild(result)
{
    var childDropDown = document.forms[0].elements['ddlChild'];
    if (!childDropDown)
    return;
    childDropDown.length = 0;
    if (!result)
    return;
    var ddlChild = document.getElementById("ddlChild");
    ddlChild.options.add(new Option("当前栏目","0"));
    var items=result.split('|');
    for (var i = 0;i < items.length;i++)
    {
        var item=items[i].split(',');
        if(item[0]!="")
        {
            var option = document.createElement("option");
            option.value = item[1];
            option.innerHTML = item[0];
            ddlChild.appendChild(option);
        }
    }
}
function ShowError(result, context)
{
    alert(result);
}
function SubList()
{
    values="{$Qianbo id=\"col_childcol_infolist\""+" chid=\""+$("ddlChild").value+"\" ";
    values=values+"colcount=\""+$("txtcolumntop").value+"\" ";
    if($("chkIncludeSub").checked==true)
    values=values+"includesub=\"true\"";
    else
    values=values+"includesub=\"false\" ";
    values=values+"colstyle=\""+$("ddlColumnStyle").value+"\" ";
    values=values+"liststyle=\""+$("ddlStyle").value+"\" ";
    values=values+"modelid=\""+$("hidModelId").value+"\" ";
    values=values+"colcellcount=\""+document.form1.selColumn.value+"\" ";
    values=values+"showstyle=\""+$("selShowStyle").value+"\" ";
    values=values+"divid=\""+$("DivID").value+"\" ";
    values=values+"divclass=\""+$("Divclass").value+"\" ";
    values=values+"ulid=\""+$("ulid").value+"\" ";
    values=values+"ulclass=\""+$("ulclass").value+"\" ";
    values=values+"dateformat=\""+$("txtDateFormat").value+"\" "
    values=values+"infocount=\""+$("txtArticleCount").value+"\" ";
    values=values+"daterange=\""+$("txtDateRange").value+"\" ";
    values=values+"order=\""+$("selectOrder").value+"\" ";
    values=values+"titlelength=\""+$("txtTitleCount").value+"\" ";
    if($("txtNewsRows").value=="0")
    {
        values=values+"rowcount=\"\" ";
        values=values+"compart=\"\" /}";
    }
    else
    {
        values=values+"rowcount=\""+$("txtNewsRows").value+"\" ";
        values=values+"compart=\""+$("txtCompart").value+"\" /}";
    }
    D.all.lblContent.focus();
    if(D.selection)
    {
        var reange=D.selection.createRange();
        reange.text=values;
    }
    api.close();
}
function FunShoHIdComp()
{
    if($("selColumn").value!="1")
    trCom.style.display="none";
    else
    trCom.style.display="";
}
function shwhidtop()
{
    if(document.form1.ddlChild.value=="0")
    {
        columnTop.style.display="";
    }
    else
    {
        columnTop.style.display="none";
    }
}
</script>
</head>

<body>
<form id="form1" runat="server">
  <div>
    <table width="99%" cellspacing="1" cellpadding="0" class="wzdh" align="center">
      <tr>
        <td><span style="float: left;"><strong>子类列表标签参数设置</strong></span>
          <span style="float: right;"><a href="#" onclick="javascript:api.close();">关闭</a>&nbsp;</span></td>
      </tr>
    </table>
    <table width="99%" border="0" cellpadding="0" cellspacing="1" class="border" align="center">
      <tr>
        <td class="bqleft">标签所属类别：</td>
        <td class="bqright"><select id="selectList" onchange="SwitchList()">
            <option value="CommonlyList.aspx?modelId=<%=modelId %>">普通列表</option>
            <option value="CycChColList.aspx?modelId=<%=modelId %>">栏目循环</option>
            <option value="UltimateList.aspx?modelId=<%=modelId %>">终极列表</option>
            <option value="SubList.aspx?modelId=<%=modelId %>" selected="selected">子类列表</option>
          </select>
          <input id="hidModelId" type="hidden" value="<%=modelId %>" /></td>
      </tr>
      <tr id="row1">
        <td class="bqleft">所属频道：</td>
        <td class="bqright"><asp:DropDownList ID="ddlParent" runat="server" onchange="ListData(this.options[this.selectedIndex].value);"></asp:DropDownList>
          <span id="showhidencol">栏目：
          <asp:DropDownList ID="ddlChild" runat="server" onchange="shwhidtop()"></asp:DropDownList>
          <span id="columnTop">Top：<input id="txtcolumntop" type="text" size="2" /></span>
          <input type="checkbox" id="chkIncludeSub" />
          包含子栏目 <span class="tips">不勾选则只调用选中文章</span></span></td>
      </tr>
      <tr style="" id="trShowColumns">
        <td class="bqleft">栏目显示列数：</td>
        <td class="bqright"><select id="selColumn" onchange="FunShoHIdComp()">
<script language="javascript" type="text/javascript">
for(i=1;i<=8;i++)
{
    document.write("<option value="+i+">"+i+"</option>")
}
</script>
          </select>
           </td>
      </tr>
      <tr id="columnstyle">
        <td class="bqleft">引用栏目样式：</td>
        <td class="bqright"><asp:DropDownList ID="ddlColumnStyle" runat="server"></asp:DropDownList></td>
      </tr>
      <tr>
        <td class="bqleft">引用内容样式：</td>
        <td class="bqright"><asp:DropDownList ID="ddlStyle" runat="server" onchange="CustomStyle();"></asp:DropDownList></td>
      </tr>
      <tr>
        <td class="bqleft">布局方式：</td>
        <td class="bqright"><select id="selShowStyle" onchange="ControlStyle()">
            <option value="out_table" selected="selected">表格</option>
            <option value="out_div">Div+Css</option>
          </select></td>
      </tr>
      <tr style="display: none;" id="trStyle1">
        <td class="bqleft">Div控制：</td>
        <td class="bqright">&lt;div id=&quot;
          <input name="DivID" type="text" id="DivID" size="10" title="前台生成Div调用ID号，不能为空。" />
          &quot; class=&quot;
          <input name="Divclass" type="text" id="Divclass" size="10" title="前台生成Div调用Class名称，可以为空。" />
          &quot;&gt; &lt;ul id=&quot;
          <input name="ulid" type="text" id="ulid" size="10" title="前台生成ul调用ID，可以为空！" />
          &quot; class=&quot;
          <input name="ulclass" type="text" id="ulclass" size="10" title="前台生成ul调用Class名称，可以为空！" />
          &quot;&gt;</td>
      </tr>
      <tr>
        <td class="bqleft">日期样式：</td>
        <td class="bqright"><input id="txtDateFormat" type="text" value="YY年MM月DD日" size="12" />
          格式：YYYY(4位数年份 如：2012)、MM(月)、DD(日)、HH(小时)、MI(分)、SS(秒)</td>
      </tr>
      <tr id="ultimateList">
        <td class="bqleft">文章数目：</td>
        <td class="bqright"><input name="txtArticleCount" id="txtArticleCount" type="text" value="10" size="3" maxlength="200" />
          <span class="tips">为0则显示所有文章</span></td>
      </tr>
      <tr>
        <td class="bqleft">日期范围：</td>
        <td class="bqright">默认最近显示
          <input type="text" value="0" size="4" maxlength="200" id="txtDateRange" />
          天内的文章 <span class="tips">为0则显示所有文章</span></td>
      </tr>
      <tr>
        <td class="bqleft">排序方式：</td>
        <td class="bqright"><select name="selectOrder" id="selectOrder">
            <option value="datedesc">添加日期降序</option>
            <option value="dateasc">添加日期升序</option>
            <option value="hitasc">文章点击升序</option>
            <option value="hitdesc">文章点击降序</option>
          </select>
      </tr>
      <tr>
        <td class="bqleft">标题字数：</td>
        <td class="bqright"><input name="txtTitleCount" type="text" value="30" size="3" maxlength="200" />
          <span class="tips">为0则显示完整标题</span></td>
      </tr>
      <tr id="trCom">
        <td class="bqleft">循环行样式：</td>
        <td class="bqright">每显示
          <input type="text" value="0" size="1" maxlength="200" id="txtNewsRows" />
          行后，向循环列表中插入代码：
          <input type="text" value="&lt;hr&gt;" size="50" maxlength="200" id="txtCompart" />
          <span class="tips">支持Html代码</span></td>
      </tr>
      <tr>
        <td class="bqleft"></td>
        <td class="bqright"><input id="btnSubmit" class="btn" type="button" value="确定创建此标签" onclick="SubList()" />
          <input class="btn" type="button" value="取消" onclick="javascript:api.close();" /></td>
      </tr>
    </table>
  </div>
  <div id="DivSetStyle" style="display: none; position: absolute; top: 0px;">
    <table width="99%" border="0" cellpadding="2" cellspacing="1" class="border" align="center">
      <tbody>
        <tr class="title">
          <td colspan="2">创建样式</td>
        </tr>
        <tr>
          <td class="bqleft">样式名称：</td>
          <td class="bqright"><asp:TextBox ID="txtTypeName" runat="server" Width="40%" MaxLength="200"></asp:TextBox>
            <asp:DropDownList ID="ddlStyleType" runat="server"></asp:DropDownList></td>
        </tr>
        <tr>
          <td class="bqleft">系统字段：</td>
          <td class="bqright"><asp:DropDownList ID="selectcolumn" runat="server" onchange="setx(this)"></asp:DropDownList>
<%if (modelId != 1 && modelId != 2 && modelId != 3)
    {%>
            用户自定义：
            <select id="selectChangeYou" onchange="setx(this)">
              <option value="">请选择样式字段</option>
<%
        B_ModelField ModelFieldBll = new B_ModelField();
        DataTable dt = ModelFieldBll.GetList(modelId);
        for (int i = 0; i < dt.Rows.Count; i++)
        {
            Response.Write("<option value=\"{Qianbo_" + dt.Rows[i]["Name"] + "}\">" + dt.Rows[i]["Alias"] + "</option>");
        }
%>
            </select>
<%}
        else if (modelId == 1 && modelId != 2 && modelId != 3)
{ %>
            字段：
            <select id="select1" onchange="setx(this)">
              <option value="">请选择样式字段</option>
<%
        B_SysModelField sysModelFieldBll = new B_SysModelField();
        DataTable dt = sysModelFieldBll.GetArticleListDt();
        for (int i = 0; i < dt.Rows.Count; i++)
        {
            Response.Write("<option value=\"" + dt.Rows[i]["FieldValue"] + "\">" + dt.Rows[i]["FieldName"] + "</option>");
        }
%>
            </select>
<%}
        else if (modelId != 1 && modelId == 2 && modelId != 3)
{ %>
            字段：
            <select id="select2" onchange="setx(this)">
              <option value="">请选择样式字段</option>
<%
        B_SysModelField sysModelFieldBll = new B_SysModelField();
        DataTable dt = sysModelFieldBll.GetImageListDt();
        for (int i = 0; i < dt.Rows.Count; i++)
        {
            Response.Write("<option value=\"" + dt.Rows[i]["FieldValue"] + "\">" + dt.Rows[i]["FieldName"] + "</option>");
        }
%>
            </select>
<%}
        else if (modelId != 1 && modelId != 2 && modelId == 3)
{ %>
            字段：
            <select id="select3" onchange="setx(this)">
              <option value="">请选择样式字段</option>
<%
        B_SysModelField sysModelFieldBll = new B_SysModelField();
        DataTable dt = sysModelFieldBll.GetDownLoadListDt();
        for (int i = 0; i < dt.Rows.Count; i++)
        {
            Response.Write("<option value=\"" + dt.Rows[i]["FieldValue"] + "\">" + dt.Rows[i]["FieldName"] + "</option>");
        }
%>
            </select>
<%} %></td>
        </tr>
        <tr>
          <td class="bqleft">样式内容：</td>
          <td class="bqright"><textarea id="test" rows="10" cols="50" runat="server"></textarea></td>
        </tr>
        <tr>
          <td class="bqleft"></td>
          <td class="bqright"><asp:Button ID="btnSave" CssClass="btn" runat="server" Text="添加样式" OnClick="btnSave_Click" OnClientClick="return CheckValidate()" />
            <input id="Button1" type="button" class="btn" value="关闭" onclick="javascript:DivSetStyle.style.display='none';hidenSelect()" /></td>
        </tr>
      </tbody>
    </table>
  </div>
</form>
<br />
</body>
</html>