示例#1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            KSSecurity.CheckPermissions();
            templateId = Utils.StrToInt(KSCMS.S("templateId"));
            if (templateId > 0)
            {
                Session["currTemplateId"] = templateId.ToString();
            }

            if (Session["currTemplateId"] != null)
            {
                int templateType = Utils.StrToInt(DataFactory.GetOnlyValue("select templateType From KS_Template Where TemplateID=" + Session["currTemplateId"].ToString()));
                switch (templateType)
                {
                case 1:
                    TemplateDir = MyCache.GetCacheConfig(85);     //手机模板总目录
                    break;

                case 2:
                    TemplateDir = MyCache.GetCacheConfig(86);     //机构模板总目录
                    break;

                case 3:
                    TemplateDir = MyCache.GetCacheConfig(87);     //个人空间模板
                    break;

                default:
                    TemplateDir = MyCache.GetCacheConfig(84);      //所有模板的总目录
                    break;
                }
                if (string.IsNullOrEmpty(TemplateDir))
                {
                    TemplateDir = "Template";
                }

                using (DataTable dt = DataFactory.GetDataTable("select top 1 * From KS_Template Where TemplateId=" + Utils.StrToInt(Session["currTemplateId"].ToString())))
                {
                    if (dt.Rows.Count > 0)
                    {
                        _MainTemplatePath = KSCMS.GetInstallDir() + TemplateDir + "/" + dt.Rows[0]["templateEname"].ToString() + "/";
                        templateName      = "当前风格:" + dt.Rows[0]["templateName"].ToString();
                    }
                }
            }
            else
            {
                JS.Alert("参数出错!");
            }


            xmldoc = new XmlDocument();
            xmldoc.Load(Server.MapPath(_MainTemplatePath + "config/pagestyle.config"));
            FieldsXML = XmlObject.XMLToString(ref xmldoc);

            if (KSCMS.S("action").Equals("Add"))
            {
                this.ListPannel.Visible = false;
                this.PanAdd.Visible     = true;
            }
            else
            {
                if (!IsPostBack)
                {
                    initialList(1);
                }
            }
        }
示例#2
0
        protected void Foot2_Submit(object sender, EventArgs e)
        {
            string title = this.TxtTitle.Text;

            if (string.IsNullOrEmpty(title))
            {
                JS.AlertDoFun("请输入分页名称!", "history.back()");
            }
            else
            {
                //创建一个新节点
                XmlElement newElement = xmldoc.CreateElement("item");

                XmlNode     root  = xmldoc.SelectSingleNode("pagetemplate");
                XmlNodeList xnl   = root.ChildNodes;
                int         maxid = 0;
                foreach (XmlNode xnf in xnl)
                {
                    XmlElement xe = (XmlElement)xnf;
                    int        id = Utils.StrToInt(xe.GetAttribute("name"));
                    if (id > maxid)
                    {
                        maxid = id;
                    }
                }

                newElement.SetAttribute("name", (maxid + 1).ToString());
                newElement.SetAttribute("issys", "0");
                newElement.SetAttribute("title", title);

                //创建newElement下的节点
                XmlElement etp = xmldoc.CreateElement("tp");

                etp.InnerText = this.TxtTp.Text;

                //将newElement下的节点加到newElement上

                newElement.AppendChild(etp);


                //将newElement加入到xml文件中(加在最后一条记录上)
                xmldoc.DocumentElement.AppendChild(newElement);
                xmldoc.Save(Server.MapPath(_MainTemplatePath + "config/pagestyle.config"));
            }
            JS.Confirm("恭喜,分页样式添加成功,继续添加吗?", "location.href='" + KSCMS.GetInstallDir() + MyCache.GetCacheConfig(4) + "/label/KS.Label.PageStyle.aspx?action=Add&templateId=" + templateId + "';", "location.href='" + KSCMS.GetInstallDir() + MyCache.GetCacheConfig(4) + "/label/KS.Label.PageStyle.Aspx?templateId=" + templateId + "';");
        }