protected void saveinfo_Click(object sender, EventArgs e)
        {
			string configPath = Page.Server.MapPath("../xml/user_" + this.userid + ".config");
            XmlDocumentExtender doc = new XmlDocumentExtender();
            if (System.IO.File.Exists(configPath))
            {
                if (doc.SelectSingleNode("/UserConfig/ShowInfo") == null)
                {
                    XmlNode userconfig = doc.CreateElement("UserConfig");
                    doc.AppendChild(userconfig);
                    XmlNode showinfo = doc.CreateElement("ShowInfo");
                    showinfo.InnerText = showhelp.SelectedValue.ToString();
                    userconfig.AppendChild(showinfo);
                }
                else
                {
                    XmlNode showinfo = doc.SelectSingleNode("/UserConfig/ShowInfo");
                    showinfo.InnerText = showhelp.SelectedValue.ToString();
                }
            }
            else
            {
                XmlElement userconfig = doc.CreateElement("UserConfig");
                XmlElement showinfo = doc.CreateElement("ShowInfo");
                showinfo.InnerText = showhelp.SelectedValue.ToString();
                userconfig.AppendChild(showinfo);
                doc.AppendChild(userconfig);
            }
            doc.Save(configPath);
            this.RegisterStartupScript("PAGE", "window.location='likesetting.aspx'");
        }
		public void BindData()
        {
            #region 绑定数据
            DataGrid1.AllowCustomPaging = false;
            DataGrid1.DataKeyField = "menuid";
			DataGrid1.TableHeaderName = "我的菜单列表";

            
		    DataSet dsSrc = new DataSet();
			XmlDocumentExtender xmldocument = new XmlDocumentExtender();
			xmldocument.Load(configPath);
			XmlNode node = xmldocument.SelectSingleNode("/menuset");
            if (node == null ||node.ChildNodes.Count == 0)
                return;
			XmlNodeReader rdr = new XmlNodeReader(node);
			dsSrc.ReadXml(rdr);
            dsSrc.Tables[0].Columns.Add("menuid");
            int i = 0;
            foreach (DataRow dr in dsSrc.Tables[0].Rows)
            {
                dr["menuid"] = i.ToString();
                i++;
            }
			DataGrid1.DataSource = dsSrc.Tables[0];
			DataGrid1.DataBind();
            #endregion
        }
		public void BindData()
        {
            #region 绑定轮换图片列表
            DataGrid1.AllowCustomPaging = false;
			DataGrid1.DataKeyField = "rotatepicid";
            DataGrid1.TableHeaderName = "聚合轮换图片列表";

			XmlDocumentExtender xmldocument = new XmlDocumentExtender();
			xmldocument.Load(configPath);
			XmlNode node = xmldocument.SelectSingleNode(targetNode);
            if (node == null || node.ChildNodes.Count == 0)
            {
                DataGrid1.Visible = SaveRotatepic.Visible = false;
                return;
            }
			XmlNodeReader rdr = new XmlNodeReader(node);
			dsSrc.ReadXml(rdr);
            dsSrc.Tables[0].Columns.Add("rowid");
            int i = 0;
            foreach (DataRow dr in dsSrc.Tables[0].Rows)
            {
                dr["rowid"] = i.ToString();
                i++;
            }
			DataGrid1.DataSource = dsSrc.Tables[0];
			DataGrid1.DataBind();
            #endregion
        }
Exemple #4
0
        /// <summary>
        /// 增加主菜单
        /// </summary>
        /// <param name="title">主菜单标题</param>
        /// <param name="defaulturl">主菜单默认展开的页面</param>
        /// <returns>新主菜单项ID</returns>
        public static int NewMainMenu(string title, string defaulturl)
        {
            XmlDocumentExtender doc = new XmlDocumentExtender();
            doc.Load(configPath);
            XmlNodeList mainmenus = doc.SelectNodes("/dataset/toptabmenu");
            int newMenuId = mainmenus.Count + 1;
            XmlElement newMainMenuItem = doc.CreateElement("toptabmenu");
            XmlElement node = doc.CreateElement("id");
            node.InnerText = newMenuId.ToString();
            newMainMenuItem.AppendChild(node);

            node = doc.CreateElement("title");
            node.InnerText = title;
            newMainMenuItem.AppendChild(node);

            node = doc.CreateElement("mainmenulist");
            node.InnerText = "";
            newMainMenuItem.AppendChild(node);

            node = doc.CreateElement("mainmenuidlist");
            node.InnerText = "";
            newMainMenuItem.AppendChild(node);

            node = doc.CreateElement("defaulturl");
            node.InnerText = defaulturl;
            newMainMenuItem.AppendChild(node);

            node = doc.CreateElement("system");
            node.InnerText = "0";
            newMainMenuItem.AppendChild(node);

            doc.SelectSingleNode("/dataset").AppendChild(newMainMenuItem);
            doc.Save(configPath);
            return newMenuId;
        }
        private void LoadInfo()
        {
            string fids = "";
            XmlDocumentExtender doc = new XmlDocumentExtender();
            doc.Load(configPath);
            XmlNode fidlist = doc.SelectSingleNode("/Aggregationinfo/Aggregationpage/Website/Website_forumrecomend/fidlist");
            if (fidlist == null)
            {
                return;
            }
            fids = fidlist.InnerText;
            string strJson = "";
            Discuz.Common.Generic.List<ForumInfo> lists = Discuz.Forum.Forums.GetForumList();
            foreach (string fid in fids.Split(','))
            {
                foreach (ForumInfo foruminfo in lists)
                {
                    if (foruminfo.Fid.ToString() == fid)
                    {
                        strJson += "{'fid':'" + foruminfo.Fid + "','forumtitle':'" + foruminfo.Name + "'},";
                        break;
                    }
                }
            }
            if (strJson != "")
            {
                strJson = strJson.TrimEnd(',');
            }

            strJson = "<script type='text/javascript'>\r\nvar fidlist = [" + strJson + "];\r\nfor(var i = 0 ; i < fidlist.length ; i++)\r\n{\r\nvar no = new Option();\r\nno.value = fidlist[i]['fid'];\r\nno.text = fidlist[i]['forumtitle'];\r\nForm1.list2.options[Form1.list2.options.length] = no;\r\n}\r\n</script>";
            base.RegisterStartupScript("", strJson);
        }
        protected void Page_Load(object sender, EventArgs e)
		{
			// 在此处放置用户代码以初始化页面
            allowUserGroup.Attributes.Add("onclick", "ChanageUserGroupStatus(this.checked)");
			if (!IsPostBack)
			{
                EnableSpace.SelectedValue = config.Enablespace.ToString();
                EnableSpace.Items[0].Attributes.Add("onclick", "ShowHiddenOption(true);");
                EnableSpace.Items[1].Attributes.Add("onclick", "ShowHiddenOption(false);");
                ShowSpaceOption.Attributes.Add("style", config.Enablespace == 1 ? "display:block" : "display:none");
                ShowUserGroup.Attributes.Add("style", config.Enablespace == 1 ? "display:block" : "display:none");
				LoadUserGroup();
                XmlDocumentExtender xmlDoc = new XmlDocumentExtender();
				xmlDoc.Load(Server.MapPath("../../config/space.config"));
                XmlNode root = xmlDoc.SelectSingleNode("SpaceActiveConfigInfo");
                XmlNodeInnerTextVisitor rootvisitor = new XmlNodeInnerTextVisitor();
                rootvisitor.SetNode(root);
                allowPostcount.Checked = rootvisitor["AllowPostcount"] == "1" ? true : false;
                Postcount.Text = rootvisitor["Postcount"];
                allowDigestcount.Checked = rootvisitor["AllowDigestcount"] == "1" ? true : false;
                Digestcount.Text = rootvisitor["Digestcount"];
                allowScore.Checked = rootvisitor["AllowScore"] == "1" ? true : false;
                Score.Text = rootvisitor["Score"];
                allowUserGroup.Checked = rootvisitor["AllowUsergroups"] == "1" ? true : false;
                string groupList = rootvisitor["Usergroups"];
				if (!allowUserGroup.Checked || groupList == "")
					return;
				else
					BindUserGroup(groupList);
                ActiveType.SelectedValue = rootvisitor["ActiveType"];
                BindUserGorupMaxspaceattachsize();
			}
		}
        private void addmenu_Click(Object sender, EventArgs e)
        {
            #region 插入菜单

            if ((atext.Text.Trim() != "") && (ahref.Text.Trim() != ""))
            {
                XmlDocumentExtender doc = new XmlDocumentExtender();
                doc.Load(configPath);
                int lastmenuorder = 0;
                if (doc.SelectSingleNode("/menuset").ChildNodes.Count != 0)
                {
                   lastmenuorder = int.Parse(doc.SelectSingleNode("/menuset").LastChild["menuorder"].InnerText);
                }
                lastmenuorder++;
                XmlElement menunode = doc.CreateElement("menuitem");
                doc.AppendChildElementByNameValue(ref menunode, "menuorder", lastmenuorder.ToString());
                doc.AppendChildElementByNameValue(ref menunode, "text", atext.Text.Trim());
                doc.AppendChildElementByNameValue(ref menunode, "href", ahref.Text.Trim());
                doc.AppendChildElementByNameValue(ref menunode, "onclick", aonclick.Text.Trim(),true);
                doc.AppendChildElementByNameValue(ref menunode, "target", atarget.Text.Trim());

                doc.CreateNode("/menuset").AppendChild(menunode);
                doc.Save(configPath);
                CreateJsFile();
                try
                {
                    BindData();
                    ResetForm();
                    base.RegisterStartupScript("PAGE", "window.location.href='forum_mymenumanage.aspx';");
                    return;
                }
                catch
                {
                    base.RegisterStartupScript("", "<script>alert('无法更新XML文件');window.location.href='forum_mymenumanage.aspx';</script>");
                    return;
                }

            }
            else
            {
                base.RegisterStartupScript("", "<script>alert('链接文字和链接地址是必须输入的,如果无链接地址请输入\"#\".');window.location.href='forum_mymenumanage.aspx';</script>");
                return;
            }

            #endregion
        }
 protected void Page_Load(object sender, EventArgs e)
 {
     string configPath = Page.Server.MapPath("../xml/user_" + this.userid + ".config");
     if (!IsPostBack)
     {
         if (File.Exists(configPath))
         {
             XmlDocumentExtender doc = new XmlDocumentExtender();
             doc.Load(configPath);
             showhelp.SelectedValue = doc.SelectSingleNode("/UserConfig/ShowInfo") != null ? doc.SelectSingleNode("/UserConfig/ShowInfo").InnerText : "1";
             showupgrade.SelectedValue = doc.SelectSingleNode("/UserConfig/ShowUpgrade") != null ? doc.SelectSingleNode("/UserConfig/ShowUpgrade").InnerText : "1";
         }
         else
         {
             showhelp.SelectedValue = "1";
             showupgrade.SelectedValue = "1";
         }
     }
 }
Exemple #9
0
        protected void Page_Load(object sender, EventArgs e)
        {
            bool isShowUpgradeInfo = false;
            string configPath = Page.Server.MapPath("../xml/user_" + this.userid + ".config");
            if (File.Exists(configPath))
            {
                XmlDocumentExtender doc = new XmlDocumentExtender();
                doc.Load(configPath);
                isShowUpgradeInfo = doc.SelectSingleNode("/UserConfig/ShowUpgrade") != null ? doc.SelectSingleNode("/UserConfig/ShowUpgrade").InnerText == "1": false;
            }
            else
                isShowUpgradeInfo = true;
            if(isShowUpgradeInfo)
                LoadUpgradeInfo();

            LoadTemplateInfo();
            GetStatInfo();
            //加载论坛版块信息
            forumid.BuildTree(Forums.GetForumListForDataTable(), "name", "fid");
            LinkDiscuzVersionPage();
        }
        private void LoadInfo()
        {
            string fids = "";
            XmlDocumentExtender doc = new XmlDocumentExtender();
            doc.Load(configPath);
            fids = doc.SelectSingleNode("/Aggregationinfo/Aggregationpage/Website/Website_forumrecomend/fidlist").InnerText;
            XmlNodeList forumrecomendtopic = doc.SelectNodes("/Aggregationinfo/Aggregationpage/Website/Website_forumrecomendtopiclist/Website_forumrecomendtopic");
            List<ForumInfo> lists = Discuz.Forum.Forums.GetForumList();
            DataTable forumdata = new DataTable();
            forumdata.Columns.Add("fid");
            forumdata.Columns.Add("name");
            forumdata.Columns.Add("tid");
            forumdata.Columns.Add("title");
            forumdata.Columns.Add("img");

            foreach (string fid in fids.Split(','))
            {
                foreach (ForumInfo foruminfo in lists)
                {
                    if (foruminfo.Fid.ToString() == fid)    //在板块信息中找到当前选择的板块
                    {
                        DataRow dr = forumdata.NewRow();
                        dr["fid"] = fid;
                        dr["name"] = foruminfo.Name;
                        dr["tid"] = "";
                        dr["title"] = "";
                        dr["img"] = "";
                        forumdata.Rows.Add(dr);
                        break;
                    }
                }
            }

            foreach (XmlNode topic in forumrecomendtopic)
            {
                foreach (DataRow dr in forumdata.Rows)
                {
                    if (topic["fid"].InnerText == dr["fid"].ToString())
                    {
                        dr["tid"] = topic["tid"].InnerText;
                        dr["title"] = topic["title"].InnerText;
                        dr["img"] = topic["img"].InnerText;
                        break;
                    }
                }
            }

            DataGrid1.TableHeaderName = "推荐版块图片选择";
            DataGrid1.DataKeyField = "fid";
            DataGrid1.DataSource = forumdata;
            DataGrid1.DataBind();
        }
Exemple #11
0
 private void LoadWebSiteConfig()
 {
     #region 绑定自动推荐相册
     //装载配置文件
     XmlDocumentExtender doc = new XmlDocumentExtender();
     doc.Load(configPath);
     XmlNode albumconfig = doc.SelectSingleNode("/Aggregationinfo/Aggregationpage/Albumindex/Albumconfig");
     focusphotoshowtype.SelectedIndex =  Convert.ToInt32(doc.GetSingleNodeValue(albumconfig, "Focusphotoshowtype"));
     focusphotodays.Text = doc.GetSingleNodeValue(albumconfig, "Focusphotodays");
     focusphotocount.Text = doc.GetSingleNodeValue(albumconfig, "Focusphotocount");
     recommendalbumtype.SelectedIndex = Convert.ToInt32(doc.GetSingleNodeValue(albumconfig, "Focusalbumshowtype"));
     focusalbumdays.Text = doc.GetSingleNodeValue(albumconfig, "Focusalbumdays");
     focusalbumcount.Text = doc.GetSingleNodeValue(albumconfig, "Focusalbumcount");
     weekhot.Text = doc.GetSingleNodeValue(albumconfig, "Weekhot");
     #endregion
 }
 protected void Page_Load(object sender, EventArgs e)
 {
     //加入快捷操作菜单
     resultmessage = "<img src='../images/existmenu.gif' style='vertical-align:middle'/> 已经收藏";
     string configPath = Page.Server.MapPath("xml/navmenu.config");
     string title = "";
     string menuparentid = "";
     string url = DNTRequest.GetString("url").ToLower();
     XmlDocumentExtender doc = new XmlDocumentExtender();
     doc.Load(configPath);
     //读到快捷操作菜单
     XmlNodeList shortcuts = doc.SelectNodes("/dataset/shortcut");
     foreach (XmlNode singleshortcut in shortcuts)
     {
         //如果当前链接在快捷菜单内,则返回
         if (singleshortcut.SelectSingleNode("link").InnerText == url.ToLower().Trim()) return;
     }
     XmlNodeList submains = doc.SelectNodes("/dataset/submain");
     XmlNodeInnerTextVisitor submainsvisitor = new XmlNodeInnerTextVisitor();
     
     foreach (XmlNode submain in submains)
     {
         submainsvisitor.SetNode(submain);
         if (submainsvisitor["link"].ToLower() == url)
         {
             title = submainsvisitor["menutitle"];
             menuparentid = submainsvisitor["menuparentid"];
         }
     }
     string[] parm = GetParm(doc,menuparentid);
     XmlElement shortcut = doc.CreateElement("shortcut");
     //将当前页面存入快捷操作菜单内
     doc.AppendChildElementByNameValue(ref shortcut, "link", url);
     doc.AppendChildElementByNameValue(ref shortcut, "menutitle", title);
     doc.AppendChildElementByNameValue(ref shortcut, "frameid", "main");
     doc.AppendChildElementByNameValue(ref shortcut, "custommenu", "true");
     doc.AppendChildElementByNameValue(ref shortcut, "showmenuid", parm[0]);
     doc.AppendChildElementByNameValue(ref shortcut, "toptabmenuid", parm[1]);
     doc.AppendChildElementByNameValue(ref shortcut, "mainmenulist", parm[2]);
     doc.SelectSingleNode("/dataset").AppendChild(shortcut);
     doc.Save(configPath);
     //managemainmenu.CreateMenu(Utils.GetMapPath("xml/navmenu.config"), Utils.GetMapPath("framepage") + "/navmenu.js");
     MenuManage.CreateMenuJson();
 }
Exemple #13
0
        /// <summary>
        /// 增加子菜单
        /// </summary>
        /// <param name="mainmenuid">主菜单ID</param>
        /// <param name="menutitle">子菜单标题</param>
        /// <returns>新建子菜单ID</returns>
        public static int NewSubMenu(int mainmenuid, string menutitle)
        {
            int newid = 1;
            int newmenuid = 100;
            XmlDocumentExtender doc = new XmlDocumentExtender();
            doc.Load(configPath);
            XmlNodeList submains = doc.SelectNodes("/dataset/mainmenu");
            newid += int.Parse(submains.Item(submains.Count - 1)["id"].InnerText);
            newmenuid += int.Parse(submains.Item(submains.Count - 1)["menuid"].InnerText);
            XmlElement mainmenu = doc.CreateElement("mainmenu");
            XmlElement node = doc.CreateElement("id");
            node.InnerText = newid.ToString();
            mainmenu.AppendChild(node);

            node = doc.CreateElement("menuid");
            node.InnerText = newmenuid.ToString();
            mainmenu.AppendChild(node);

            node = doc.CreateElement("menutitle");
            node.InnerText = menutitle;
            mainmenu.AppendChild(node);

            doc.SelectSingleNode("/dataset").AppendChild(mainmenu);

            XmlNodeList mainMenus = doc.SelectNodes("/dataset/toptabmenu");
            foreach (XmlNode menuItem in mainMenus) //查找主菜单信息
            {
                if (menuItem["id"].InnerText == mainmenuid.ToString())
                {
                    menuItem["mainmenulist"].InnerText += "," + newid;
                    menuItem["mainmenuidlist"].InnerText += "," + newmenuid;
                    menuItem["mainmenulist"].InnerText = menuItem["mainmenulist"].InnerText.TrimStart(',');
                    menuItem["mainmenuidlist"].InnerText = menuItem["mainmenuidlist"].InnerText.TrimStart(',');
                    break;
                }
            }
            doc.Save(configPath);
            return newmenuid;
        }
        /// <summary>
        /// 保存主题显示
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void SaveTopicDisplay_Click(object sender, EventArgs e)
        {
            #region 保存主题显示
            //if (!Utils.IsNumeric(topnumber.Text))
            //{
            //    base.RegisterStartupScript("", "<script>alert('显示主题条数必须为数字!');</script>");
            //    return;
            //}
            //if (Convert.ToInt32(topnumber.Text) <= 0)
            //{
            //    base.RegisterStartupScript("", "<script>alert('显示主题条数至少是1条!');</script>");
            //    return;
            //}
            XmlDocumentExtender doc = new XmlDocumentExtender();
            doc.Load(configPath);
            doc.RemoveNodeAndChildNode("/Aggregationinfo/Aggregationpage/Website/Forum/Bbs");
            //doc.InitializeNode("/Aggregationinfo/Aggregationpage/Website/Forum");

            if (doc.SelectSingleNode("/Aggregationinfo/Aggregationpage/Website/Forum") == null)
                doc.InitializeNode("/Aggregationinfo/Aggregationpage/Website/Forum");

            XmlElement BBS = doc.CreateElement("Bbs");
            doc.AppendChildElementByNameValue(ref BBS, "Topnumber", topnumber.Text, false);
            doc.AppendChildElementByNameValue(ref BBS, "Showtype", showtype.SelectedValue, false);
            doc.SelectSingleNode("/Aggregationinfo/Aggregationpage/Website/Forum").AppendChild(BBS);
            doc.Save(configPath);
            AggregationConfig.ResetConfig();
            AggregationFacade.ForumAggregation.ClearAllDataBind();
            #endregion
        }
        private void SaveRotatepic_Click(object sender, EventArgs e)
        {
            #region 保存轮换图片修改
            int rowid = 0;
            bool error = false;

            XmlDocumentExtender doc = new XmlDocumentExtender();
            doc.Load(configPath);
            XmlNodeList __xmlnodelist = doc.SelectSingleNode(targetNode).ChildNodes;

            if ((__xmlnodelist != null) && (__xmlnodelist.Count > 0))
            {
                doc.InitializeNode(targetNode);
            }

            foreach (object o in DataGrid1.GetKeyIDArray())
            {
                #region 轮换图片
                string rotatepicid = DataGrid1.GetControlValue(rowid, "rotatepicid");
                //string name = ((TextBox)E.Item.FindControl("rotatepicid")).Text;
                string img = DataGrid1.GetControlValue(rowid, "img");
                string url = DataGrid1.GetControlValue(rowid, "url");
                string titlecontent = DataGrid1.GetControlValue(rowid, "titlecontent").Trim();
                if (!Utils.IsNumeric(rotatepicid) || !Utils.IsURL(img) || !Utils.IsURL(url) || titlecontent == "")
                {
                    //base.RegisterStartupScript("", "<script>alert('序号、图片路径或点击链接可能是非法URL或说明文字为空');window.location.href='aggregation_rotatepic.aspx?pagename=" + DNTRequest.GetString("pagename") + "';</script>");
                    //return;
                    error = true;
                    //continue;
                    break;//如果用continue,则导致正确的设置可以被保存,有错误的设置却被删除,即使被修改之前是正确的。会丢失数据
                }
                bool insert = false;
                XmlElement rotatepicNode = doc.CreateElement(nodeName);
                doc.AppendChildElementByNameValue(ref rotatepicNode, "rotatepicid", rotatepicid);
                doc.AppendChildElementByNameValue(ref rotatepicNode, "pagetype", "1");
                doc.AppendChildElementByNameValue(ref rotatepicNode, "img", img);
                doc.AppendChildElementByNameValue(ref rotatepicNode, "url", url);
                doc.AppendChildElementByNameValue(ref rotatepicNode, "titlecontent", titlecontent);

                foreach (XmlNode __node in __xmlnodelist)
                {
                    if (int.Parse(__node["rotatepicid"].InnerText) > int.Parse(rotatepicid))
                    {
                        doc.SelectSingleNode(targetNode).InsertBefore(rotatepicNode, __node);
                        insert = true;
                        break;
                    }
                }
                if (!insert)
                {
                    doc.SelectSingleNode(targetNode).AppendChild(rotatepicNode);
                }
                rowid++;
                #endregion
            }
            AggregationFacade.BaseAggregation.ClearAllDataBind();
            if(!error)
            {
                SiteUrls.SetInstance();
                AdminVistLogs.InsertLog(this.userid, this.username, this.usergroupid, this.grouptitle, this.ip, "聚合页面论坛广告编辑", "");
                doc.Save(configPath);

                base.RegisterStartupScript("PAGE", "window.location.href='aggregation_rotatepic.aspx?pagename=" + DNTRequest.GetString("pagename") + "';");
                return;
            }
            else
            {
                base.RegisterStartupScript("", "<script>alert('某行序号、图片路径或点击链接可能是非法URL或说明文字为空,不能进行更新.');window.location.href='aggregation_rotatepic.aspx?pagename=" + DNTRequest.GetString("pagename") + "';</script>");
                return;
            }
            #endregion
        }
        /// <summary>
        /// 保存主题显示
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void SaveTopicDisplay_Click(object sender, EventArgs e)
        {
            #region 保存主题显示
            XmlDocumentExtender doc = new XmlDocumentExtender();
            doc.Load(configPath);
            //doc.RemoveNodeAndChildNode("/Aggregationinfo/Aggregationpage/Website/Forum/Bbs");
            doc.InitializeNode("/Aggregationinfo/Aggregationpage/Website/Forum");

            XmlElement BBS = doc.CreateElement("Bbs");
            doc.AppendChildElementByNameValue(ref BBS, "Topnumber", topnumber.Text, false);
            doc.AppendChildElementByNameValue(ref BBS, "Showtype", showtype.SelectedValue, false);
            doc.SelectSingleNode("/Aggregationinfo/Aggregationpage/Website/Forum").AppendChild(BBS);
            doc.Save(configPath);
            #endregion
        }
		private void DelRec_Click(object sender, EventArgs e)
		{
			#region 删除选定的图版轮换页
			if (this.CheckCookie())
			{
				string rowidlist = DNTRequest.GetString("rowid");
				if (rowidlist != "")
				{
                    int delcount = 0;
                    XmlDocumentExtender doc = new XmlDocumentExtender();
                    doc.Load(configPath);
                    XmlNodeList __xmlnodelist = doc.SelectSingleNode(targetNode).ChildNodes;
                    foreach (string menuid in rowidlist.Split(','))
                    {
                        doc.SelectSingleNode(targetNode).RemoveChild(__xmlnodelist.Item(int.Parse(menuid) - delcount));
                        delcount++;
                    }
                    doc.Save(configPath);

					AdminVistLogs.InsertLog(this.userid, this.username, this.usergroupid, this.grouptitle, this.ip, "删除选定的图版轮换页", "删除选定的图版轮换页,ID为: " + DNTRequest.GetString("id").Replace("0 ", ""));
					Response.Redirect("aggregation_rotatepic.aspx?pagename=" + DNTRequest.GetString("pagename"));
				}
				else
				{
					base.RegisterStartupScript( "","<script>alert('您未选中任何选项');window.location.href='aggregation_rotatepic.aspx?pagename=" + DNTRequest.GetString("pagename") + "';</script>");
				}
			}

			#endregion
		}
        private void AddNewRec_Click(object sender, EventArgs e)
        {
            #region 添加附件分类
            if (typename.Text == "")
            {
                base.RegisterStartupScript("", "<script>alert('附件分类名称不能为空!');window.location.href='forum_attchemnttypes.aspx';</script>");
                return;
            }

            XmlDocumentExtender doc = new XmlDocumentExtender();
            doc.Load(AppDomain.CurrentDomain.BaseDirectory + "config/myattachment.config");
            if (DNTRequest.GetString("atttypeid") == "")   //增加附件分类
            {
                XmlNode attachtypes = doc.SelectSingleNode("/MyAttachmentsTypeConfigInfo/attachtypes");
                XmlElement attachtype = doc.CreateElement("AttachmentType");
                XmlElement node = doc.CreateElement("TypeId");
                int maxTypeid = GetMaxTypeid();
                node.InnerText = (++maxTypeid).ToString();
                attachtype.AppendChild(node);
                node = doc.CreateElement("TypeName");
                node.InnerText = typename.Text;
                attachtype.AppendChild(node);
                node = doc.CreateElement("ExtName");
                node.InnerText = GetAttTypeList();
                attachtype.AppendChild(node);
                attachtypes.AppendChild(attachtype);
            }
            else
            {
                XmlNodeList xnl = doc.SelectNodes("/MyAttachmentsTypeConfigInfo/attachtypes/AttachmentType");
                foreach (XmlNode xn in xnl)
                {
                    if (xn["TypeId"].InnerText == DNTRequest.GetString("atttypeid"))
                    {
                        xn["TypeName"].InnerText = typename.Text;
                        xn["ExtName"].InnerText = GetAttTypeList();
                    }
                }
            }
            doc.Save(AppDomain.CurrentDomain.BaseDirectory + "config/myattachment.config");
            UpdateAttchmentTypes();
            base.RegisterStartupScript("", "<script>window.location.href='forum_attchemnttypes.aspx';</script>");
            #endregion
        }
        /// <summary>
        /// 建立前台所使用的JS文件
        /// </summary>
        private void CreateJsFile()
        {
            #region 建立JS文件
            string jspath = Server.MapPath(BaseConfigs.GetForumPath + "javascript/mymenu.js");
            XmlDocumentExtender doc = new XmlDocumentExtender();
            doc.Load(configPath);
            XmlNodeList __xmlnodelist = doc.SelectSingleNode("/menuset").ChildNodes;
            if (__xmlnodelist.Count == 0)
                return;
            StringBuilder jscontent = new StringBuilder();
            foreach (XmlNode __xmlnode in __xmlnodelist)
            {
                jscontent.Append(string.Format("document.write('<li><a href=\"{0}\" {1} {2}>{3}</a></li>');\r\n",
                    __xmlnode["href"].InnerText,
                    (__xmlnode["onclick"].InnerText == "" ? "" : "onclick=\"" + __xmlnode["onclick"].InnerText.Replace("'","\\'") + "\""),
                    (__xmlnode["target"].InnerText == "" ? "" : "target=\"" + __xmlnode["target"].InnerText + "\""),
                    __xmlnode["text"].InnerText));
            }
            jscontent = jscontent.Replace(" onclick=\"\"", "").Replace(" target=\"\"","");
            using (FileStream fs = new FileStream(jspath, FileMode.Create, FileAccess.ReadWrite, FileShare.ReadWrite))
            {
                Byte[] info = System.Text.Encoding.UTF8.GetBytes(jscontent.ToString());
                fs.Write(info, 0, info.Length);
                fs.Close();
            }
            #endregion

        }
		private void DelRec_Click(object sender, EventArgs e)
		{
			#region 删除菜单项
			if (this.CheckCookie())
			{
                string menuidlist = DNTRequest.GetString("menuid");
                if (menuidlist != "")
                {
                    int delcount = 0;
                    XmlDocumentExtender doc = new XmlDocumentExtender();
                    doc.Load(configPath);
                    XmlNodeList __xmlnodelist = doc.SelectSingleNode("/menuset").ChildNodes;
                    foreach (string menuid in menuidlist.Split(','))
                    {
                        doc.SelectSingleNode("/menuset").RemoveChild(__xmlnodelist.Item(int.Parse(menuid) - delcount));
                        delcount++;
                    }
                    doc.Save(configPath);
                    CreateJsFile();
                    Response.Redirect("forum_mymenumanage.aspx");
                }
                else
                {
                    base.RegisterStartupScript("", "<script>alert('您未选中任何选项');window.location.href='forum_mymenumanage.aspx';</script>");
                }
                CreateJsFile();
			}

			#endregion
		}
Exemple #21
0
        /// <summary>
        /// 新建菜单项
        /// </summary>
        /// <param name="menuparentid">父菜单ID</param>
        /// <param name="title">菜单标题</param>
        /// <param name="link">菜单链接</param>
        /// <returns>操作成功否</returns>
        public static bool NewMenuItem(int menuparentid, string title, string link)
        {
            XmlDocumentExtender doc = new XmlDocumentExtender();
            doc.Load(configPath);
            XmlNodeList submains = doc.SelectNodes("/dataset/submain");
            foreach (XmlNode sub in submains)
            {
                if (sub["link"].InnerText == link)
                {
                    return false;
                }
            }
            XmlElement submain = doc.CreateElement("submain");
            XmlElement node = doc.CreateElement("menuparentid");
            node.InnerText = menuparentid.ToString();
            submain.AppendChild(node);

            node = doc.CreateElement("menutitle");
            node.InnerText = title;
            submain.AppendChild(node);

            node = doc.CreateElement("link");
            node.InnerText = link;
            submain.AppendChild(node);

            node = doc.CreateElement("frameid");
            node.InnerText = "main";
            submain.AppendChild(node);

            doc.SelectSingleNode("/dataset").AppendChild(submain);
            doc.Save(configPath);
            return true;
        }
        private void addrota_Click(Object sender, EventArgs e)
        {
            #region 插入聚合页图版轮换广告

            if ((rotaimg.Text.Trim() != "") && (url.Text.Trim() != "") && (titlecontent.Text.Trim() != ""))
            {
                if((!Utils.IsURL(rotaimg.Text.Trim()) || (!Utils.IsURL(url.Text.Trim()))))
                {
                    base.RegisterStartupScript("", "<script>alert('图片路径或点击链接可能是非法URL');</script>");
                    BindData();
                    ResetForm();
                    return;
                }
               
                XmlDocumentExtender doc = new XmlDocumentExtender();
                doc.Load(configPath);
                int lastRotatepicid = 0;
				if (doc.SelectSingleNode(targetNode) != null)
				{
					if (doc.SelectSingleNode(targetNode).InnerText != "")
					{
						lastRotatepicid = int.Parse(doc.SelectSingleNode(targetNode).LastChild["rotatepicid"].InnerText);
					}
				}
                lastRotatepicid++;

                XmlElement rotatepicNode = doc.CreateElement(nodeName);
                doc.AppendChildElementByNameValue(ref rotatepicNode, "rotatepicid", lastRotatepicid.ToString());
                doc.AppendChildElementByNameValue(ref rotatepicNode, "pagetype", "1");
                doc.AppendChildElementByNameValue(ref rotatepicNode, "img", rotaimg.Text.Trim());
                doc.AppendChildElementByNameValue(ref rotatepicNode, "url", url.Text.Trim());
                doc.AppendChildElementByNameValue(ref rotatepicNode, "titlecontent", titlecontent.Text.Trim());

                doc.CreateNode(targetNode).AppendChild(rotatepicNode);
                doc.Save(configPath);
                AggregationFacade.BaseAggregation.ClearAllDataBind();
                AdminVistLogs.InsertLog(this.userid, this.username, this.usergroupid, this.grouptitle, this.ip, "添加聚合页图版轮换广告", "添加聚合页图版轮换广告,名称为: " + titlecontent.Text.Trim());

                try
                {
                    BindData();
                    Discuz.Cache.DNTCache.GetCacheService().RemoveObject("/Forum/ForumLinkList");
                    ResetForm();
					base.RegisterStartupScript("PAGE", "window.location.href='aggregation_rotatepic.aspx?pagename=" + DNTRequest.GetString("pagename") + "';");
                    return;
                }
                catch
                {
                    base.RegisterStartupScript("", "<script>alert('无法更新XML文件');window.location.href='aggregation_rotatepic.aspx?pagename=" + DNTRequest.GetString("pagename") + "';</script>");
                    return;
                }

            }
            else
            {
                base.RegisterStartupScript("", "<script>alert('图片或链接地址以及标题不能为空.');window.location.href='aggregation_rotatepic.aspx?pagename=" + DNTRequest.GetString("pagename") + "';</script>");
                return;
            }

            #endregion
        }
		protected void SaveMyMenu_Click(object sender, EventArgs e)
        {
            #region 保存“我的”菜单
            int menuid = 0;
            bool error = false;
            XmlDocumentExtender doc = new XmlDocumentExtender();
            doc.Load(configPath);
            XmlNodeList __xmlnodelist = doc.SelectSingleNode("/menuset").ChildNodes;
            if ((__xmlnodelist != null) && (__xmlnodelist.Count > 0))
            {
                doc.InitializeNode("/menuset");
            }
            foreach (object o in DataGrid1.GetKeyIDArray())
            {
                string menuorder = DataGrid1.GetControlValue(menuid, "menuorder");
                string text = DataGrid1.GetControlValue(menuid, "text");
                string href = DataGrid1.GetControlValue(menuid, "href");
                string onclick = DataGrid1.GetControlValue(menuid, "onclick");
                string target = DataGrid1.GetControlValue(menuid, "target");
                if ((text.Trim() == "") && (href.Trim() == ""))
                {
                    error = true;
                    continue;
                }
                                
                bool insert = false;
                XmlElement __newxmlnode = doc.CreateElement("menuitem");
                doc.AppendChildElementByNameValue(ref __newxmlnode, "menuorder", menuorder);
                doc.AppendChildElementByNameValue(ref __newxmlnode, "text", text);
                doc.AppendChildElementByNameValue(ref __newxmlnode, "href", href);
                doc.AppendChildElementByNameValue(ref __newxmlnode, "onclick", onclick, true);
                doc.AppendChildElementByNameValue(ref __newxmlnode, "target", target);
                foreach (XmlNode __node in __xmlnodelist)
                {
                    if (int.Parse(__node["menuorder"].InnerText) > int.Parse(menuorder))
                    {
                        doc.SelectSingleNode("/menuset").InsertBefore(__newxmlnode, __node);
                        insert = true;
                        break;
                    }
                }
                if (!insert)
                {
                    doc.SelectSingleNode("/menuset").AppendChild(__newxmlnode);
                }
                menuid++;
            }
            doc.Save(configPath);
            CreateJsFile();
            if (error)
            {
                base.RegisterStartupScript("", "<script>alert('链接文字和链接地址是必须输入的,如果无链接地址请输入\"#\".');window.location.href='forum_mymenumanage.aspx';</script>");
            }
            else
            {
                base.RegisterStartupScript("", "<script>window.location.href='forum_mymenumanage.aspx';</script>");
            }
            #endregion
        }