<%@ Page Language="C#" AutoEventWireup="true" Inherits="System_Label_PropertySyc, QianboCMS" EnableEventValidation="false" %>
<!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 type="text/javascript" src="../../Js/jquery.js"></script>
    <script type="text/javascript" src="../../Js/lhgdialog/lhgdialog.min.js?self=true"></script>
    <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" language="javascript">
        function SwitchList() {
            window.location.href = document.form1.selectList.value
        }
        function FunShoHIdComp() {
            if ($("selColumns").value != "1")
                trCom.style.display = "none";
            else
                trCom.style.display = "";
        }
        function SelectSorce(obj) {
            if ($("ddlProperty").value == "sel") {
                alert("请选择属性！");
                obj.checked = false;
                return;
            }
            var propertyId = $("ddlProperty").value;
            trSelSorce.style.display = "";
            switch (obj.value) {
                case "0":
                    document.getElementById("spanProSorceNmae").innerText = "模型";
                    dataSorceObj = System_Label_PropertySyc.GetDataSource("0" + "|" + propertyId);
                    $("tdDataSorce").innerHTML = GetSorceHtml(0, dataSorceObj);
                    break;
                case "1":
                    document.getElementById("spanProSorceNmae").innerText = "表单";
                    dataSorceObj = System_Label_PropertySyc.GetDataSource("1" + "|" + propertyId);
                    $("tdDataSorce").innerHTML = GetSorceHtml(1, dataSorceObj);
                    break;
                case "2":
                    document.getElementById("spanProSorceNmae").innerText = "用户";
                    dataSorceObj = System_Label_PropertySyc.GetDataSource("2" + "|" + propertyId);
                    $("tdDataSorce").innerHTML = GetSorceHtml(2, dataSorceObj);
                    break;
            }
        }
        function GetSorceHtml(type, obj) {
            switch (type) {
                case 0:
                    if (obj.value == null) {
                        return "该属性没有绑定模型";
                    }
                    break;
                case 1:
                    if (obj.value == null) {
                        return "该属性没有绑定表单";
                    }
                    break;
                case 2:
                    if (obj.value == null) {
                        return "该属性没有绑定用户";
                    }
                    break;
            }
            var count = obj.value.Rows.length;
            var htmlCode = "";
            for (var i = 0; i < count; i++) {
                switch (type) {
                    case 0:
                        htmlCode = htmlCode + "<input type=\"checkbox\" name=\"chkDataSorce\" value=\"" + obj.value.Rows[i]["ModelId"] + "\">" + obj.value.Rows[i]["ModelName"] + ""
                        break;
                    case 1:
                        htmlCode = htmlCode + "<input type=\"checkbox\" name=\"chkDataSorce\" value=\"" + obj.value.Rows[i]["CustomFormId"] + "\">" + obj.value.Rows[i]["FormName"] + ""
                        break;
                    case 2:
                        htmlCode = htmlCode + "<input type=\"checkbox\" name=\"chkDataSorce\" value=\"" + obj.value.Rows[i]["Id"] + "\">" + obj.value.Rows[i]["Name"] + ""
                        break;
                }
            }
            return htmlCode;
        }
        function CreateSysListLabel() {
            var propertyid = "0";
            var datasorcetype = "";
            var datasorceidstr = "";
            var listcolumns = "1";
            var propertystyle = "";
            var propertylistsytel = "";
            var layoutmethod = "out_table";
            var dateformat = "";
            var infocount = "10";
            var daterange = "10";
            var order = "";
            var titlelength = "30"
            var rowscount = "";
            var compart = "";
            var labelstr = "{$Qianbo id=\"propertysyslist\"";
            if ($("ddlProperty").value == "sel") {
                alert("请选择属性！");
                return;
            }
            else {
                labelstr += " propertyId=\"" + $("ddlProperty").value + "\""
            }
            var datasorcetypeobj = document.getElementsByName("rdoPropertySorce");
            var datasorcetypeflag = false;
            for (var i = 0; i < datasorcetypeobj.length; i++) {
                if (datasorcetypeobj[i].checked == true) {
                    datasorcetype = datasorcetypeobj[i].value;
                    datasorcetypeflag = true;
                }
            }
            if (!datasorcetypeflag) {
                alert("请选择数据来源！");
                return;
            }
            else {
                labelstr += " datasorcetype=\"" + datasorcetype + "\"";
            }
            var datasorceobj = document.getElementsByName("chkDataSorce");
            for (var i = 0; i < datasorceobj.length; i++) {
                if (datasorceobj[i].checked == true) {
                    datasorceidstr += datasorceobj[i].value + ",";
                }
            }
            if (datasorceidstr.length > 0) {
                datasorceidstr = datasorceidstr.substring(0, datasorceidstr.length - 1);
                labelstr += " datasorceidstr=\"" + datasorceidstr + "\"";
            }
            else {
                alert("请选择具体数据源！");
                return;
            }
            labelstr += " listcolumns=\"" + $("selColumns").value + "\"";
            labelstr += " propertystyle=\"" + $("ddlPropertyStyle").value + "\"";
            labelstr += " propertyliststyle=\"" + $("ddlPropertyListStyle").value + "\"";
            labelstr += " layoutmethod=\"" + $("selLayoutMethod").value + "\"";
            labelstr += " dateformat=\"" + $("txtDateFormat").value + "\"";
            labelstr += " infocount=\"" + $("txtArticleCount").value + "\"";
            labelstr += " daterange=\"" + $("txtDateRange").value + "\"";
            labelstr += " order=\"" + $("selectOrder").value + "\"";
            labelstr += " titlelength=\"" + $("txtTitleCount").value + "\"";
            labelstr += " rowscount=\"" + $("txtNewsRows").value + "\"";
            labelstr += " compart=\"" + $("txtCompart").value + "\"";
            labelstr += " /}";
            D.all.lblContent.focus();
            if (D.selection) {
                var reange = D.selection.createRange();
                reange.text = labelstr;
            }
            api.close();
        }
    </script>
</head>

<body>
    <form id="form1" runat="server">
        <div>
            <table 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></span>
					</td>
                </tr>
            </table>
            <table 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="PropertyList.aspx">属性列表</option>
                            <option value="PropertySyc.aspx" selected="selected">属性循环</option>
                        </select>
					</td>
                </tr>
                <tr>
                    <td class="bqleft">择择属性：</td>
                    <td class="bqright">
                        <asp:DropDownList ID="ddlProperty" runat="server"></asp:DropDownList>
					</td>
                </tr>
                <tr>
                    <td class="bqleft">数据来源：</td>
                    <td class="bqright">
                        <input id="Radio1" onclick="SelectSorce(this)" name="rdoPropertySorce" value="0" type="radio" />模型
                        <input id="Radio2" onclick="SelectSorce(this)" name="rdoPropertySorce" value="1" type="radio" />表单
                        <input id="Radio3" onclick="SelectSorce(this)" name="rdoPropertySorce" value="2" type="radio" />用户
					</td>
                </tr>
                <tr id="trSelSorce" style="display: none;">
                    <td class="bqleft">请选择<span id="spanProSorceNmae"></span>：</td>
                    <td class="bqright" id="tdDataSorce"></td>
                </tr>
                <tr>
                    <td class="bqleft">属性列表显示的列数：</td>
                    <td class="bqright">
                        <select id="selColumns" onchange="FunShoHIdComp()">
                            <script language="javascript" type="text/javascript">
                                for (i = 1; i <= 5; i++) {
                                    document.write("<option value=" + i + ">" + i + "</option>");
                                }
                            </script>
                        </select>
					</td>
                </tr>
                <tr>
                    <td class="bqleft">引用属性样式：</td>
                    <td class="bqright">
                        <asp:DropDownList ID="ddlPropertyStyle" runat="server"></asp:DropDownList>
					</td>
                </tr>
                <tr>
                    <td class="bqleft">引用属性列表样式：</td>
                    <td class="bqright">
                        <asp:DropDownList ID="ddlPropertyListStyle" runat="server"></asp:DropDownList>
					</td>
                </tr>
                <tr>
                    <td class="bqleft">布局方式：</td>
                    <td class="bqright">
                        <select id="selLayoutMethod">
                            <option value="out_table" selected="selected">表格</option>
                            <option value="out_div">Div+Css</option>
                        </select>
					</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 id="txtDateRange" 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>
					</td>
                </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="CreateSysListLabel()" />
                        <input class="btn" type="button" value="取消" onclick="javascript: api.close();" />
					</td>
                </tr>
            </table>
        </div>
    </form>
    <br />
</body>
</html>