private void CreateSingleTemplate(string filename, string path)
        {
            int result     = -1;
            int templateid = Convert.ToInt32(AdminTemplates.GetAllTemplateList(Utils.GetMapPath(@"..\..\templates\")).Select("directory='" + path + "'")[0]["templateid"].ToString());

            if (filename != "")
            {
                ForumPageTemplate forumpagetemplate = new ForumPageTemplate();
                forumpagetemplate.GetTemplate(BaseConfigs.GetForumPath, path, filename, 1, templateid);
                result = 1;
            }
            Response.Write(result);
            Response.ExpiresAbsolute = DateTime.Now.AddSeconds(-1);
            Response.Expires         = -1;
            Response.End();
        }
示例#2
0
 private void InitializeComponent()
 {
     this.EditUser.Click              += new EventHandler(this.EditUser_Click);
     this.EditForum.Click             += new EventHandler(this.EditForum_Click);
     this.EditUserGroup.Click         += new EventHandler(this.EditUserGroup_Click);
     this.UpdateCache.Click           += new EventHandler(this.UpdateCache_Click);
     this.CreateTemplate.Click        += new EventHandler(this.CreateTemplate_Click);
     this.UpdateForumStatistics.Click += new EventHandler(this.UpdateForumStatistics_Click);
     foreach (DataRow dataRow in AdminTemplates.GetAllTemplateList(Utils.GetMapPath("..\\..\\templates\\")).Rows)
     {
         if (dataRow["valid"].ToString() == "1")
         {
             this.Templatepath.Items.Add(new ListItem(dataRow["name"].ToString(), dataRow["directory"].ToString()));
         }
     }
     this.Username.AddAttributes("onkeydown", "if(event.keyCode==13) return(document.forms(0).EditUser.focus());");
     this.Usergroupid.AddTableData(UserGroups.GetUserGroupForDataTable(), "grouptitle", "groupid");
 }
        private void RemoveTemplateInDB(string templateidlist, string tempstr)
        {
            #region 移除模板
            GeneralConfigInfo __configinfo = GeneralConfigs.GetConfig();
            if (tempstr.IndexOf("," + __configinfo.Templateid + ",") >= 0) //当要删除的模板是系统的默认模板时
            {
                __configinfo.Templateid = 1;
            }

            GeneralConfigs.Serialiaze(__configinfo, AppDomain.CurrentDomain.BaseDirectory + "config/general.config");

            DatabaseProvider.GetInstance().UpdateForumAndUserTemplateId(templateidlist);
            AdminTemplates.DeleteTemplateItem(templateidlist);

            Discuz.Cache.DNTCache.GetCacheService().RemoveObject("/Forum/TemplateList");
            Discuz.Cache.DNTCache.GetCacheService().RemoveObject("/Forum/TemplateIDList");
            Discuz.Cache.DNTCache.GetCacheService().RemoveObject("/Forum/UI/TemplateListBoxOptions");
            AdminVistLogs.InsertLog(this.userid, this.username, this.usergroupid, this.grouptitle, this.ip, "从数据库中删除模板文件", "ID为:" + DNTRequest.GetString("templateid").Replace("0 ", "").Trim());
            #endregion
        }
示例#4
0
        public static void BuildTemplate(string directorypath)
        {
            int templateid = Convert.ToInt32(AdminTemplates.GetAllTemplateList(AppDomain.CurrentDomain.BaseDirectory + "templates/").Select("directory='" + directorypath + "'")[0]["templateid"].ToString());

            Hashtable ht = new Hashtable();

            GetTemplates("default", ht);

            if (directorypath != "default")
            {
                GetTemplates(directorypath, ht);
            }

            ForumPageTemplate forumpagetemplate = new ForumPageTemplate();

            foreach (string key in ht.Keys)
            {
                string filename = key.Split('.')[0];
                forumpagetemplate.GetTemplate("/", directorypath, filename, 1, templateid);
            }
        }
示例#5
0
        public static void BuildTemplate(string directorypath)
        {
            int templateid = Convert.ToInt32(AdminTemplates.GetAllTemplateList(Utils.GetMapPath(@"..\..\templates\")).Select("directory='" + directorypath + "'")[0]["templateid"].ToString());

            Hashtable ht = new Hashtable();

            GetTemplates("default", ht);

            if (directorypath != "default")
            {
                GetTemplates(directorypath, ht);
            }
            ForumPageTemplate forumpagetemplate = new ForumPageTemplate();

            foreach (string key in ht.Keys)
            {
                string   filename = key.Split('.')[0];
                string[] template = ht[key].ToString().Split('\\');
                forumpagetemplate.GetTemplate(BaseConfigs.GetForumPath, template[0], filename, template.Length >= 2 ? template[template.Length - 1] : "", 1, templateid);
            }
        }
示例#6
0
        private void InitializeComponent()
        {
            this.EditUser.Click              += new EventHandler(this.EditUser_Click);
            this.EditForum.Click             += new EventHandler(this.EditForum_Click);
            this.EditUserGroup.Click         += new EventHandler(this.EditUserGroup_Click);
            this.UpdateCache.Click           += new EventHandler(this.UpdateCache_Click);
            this.CreateTemplate.Click        += new EventHandler(this.CreateTemplate_Click);
            this.UpdateForumStatistics.Click += new EventHandler(this.UpdateForumStatistics_Click);
            this.Load += new EventHandler(this.Page_Load);

            //装入有效的模板信息项
            foreach (DataRow dr in AdminTemplates.GetAllTemplateList(AppDomain.CurrentDomain.BaseDirectory + "templates/").Rows)
            {
                if (dr["valid"].ToString() == "1")
                {
                    Templatepath.Items.Add(new ListItem(dr["name"].ToString(), dr["directory"].ToString()));
                }
            }
            Username.AddAttributes("onkeydown", "if(event.keyCode==13) return(document.forms(0).EditUser.focus());");
            Usergroupid.AddTableData(DatabaseProvider.GetInstance().GetUserGroupsStr());
        }
 protected void DelTemplates_Click(object sender, EventArgs e)
 {
     #region  除模板
     if (CheckCookie())
     {
         string templateidlist = DNTRequest.GetString("templateid");
         if (templateidlist != "")
         {
             if (("," + templateidlist + ",").IndexOf(",1,") >= 0)
             {
                 RegisterStartupScript("", "<script>alert('您选中的数据项中含有系统初始化模板,此次提交无法执行');window.location.href='global_templatesgrid.aspx'</script>");
                 return;
             }
             AdminTemplates.DeleteTemplate(templateidlist, userid, username, usergroupid, grouptitle, ip);
             Response.Redirect("global_templatesgrid.aspx");
         }
         else
         {
             RegisterStartupScript("", "<script>alert('您未选中任何选项'); window.location.href='global_templatesgrid.aspx';</script>");
         }
     }
     #endregion
 }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                int    result   = -1;
                string filename = DNTRequest.GetString("filename");
                string path     = DNTRequest.GetString("path");

                int templateid = Convert.ToInt32(AdminTemplates.GetAllTemplateList(AppDomain.CurrentDomain.BaseDirectory + "templates/").Select("directory='" + path + "'")[0]["templateid"].ToString());

                if (filename != "")
                {
                    ForumPageTemplate forumpagetemplate = new ForumPageTemplate();
                    forumpagetemplate.GetTemplate("/", path, filename, 1, templateid);
                    result = 1;
                }

                Response.Write(result);
                Response.ExpiresAbsolute = DateTime.Now.AddSeconds(-1);
                Response.Expires         = -1;
                Response.End();
            }
        }
        public void LoadTemplateData()
        {
            #region 加载模板数据

            path = AppDomain.CurrentDomain.BaseDirectory + "templates/";

            string templatepath   = "由于目录 : ";
            string templateidlist = "0";
            foreach (DataRow dr in buildGridData().Select("valid =1"))
            {
                DirectoryInfo dirinfo = new DirectoryInfo(path + dr["directory"].ToString() + "/");
                if (dr["directory"].ToString().ToLower() == "default")
                {
                    continue;
                }
                if (!dirinfo.Exists)
                {
                    templatepath   += dr["directory"].ToString() + " ,";
                    templateidlist += "," + dr["templateid"].ToString();
                }
            }

            if ((templateidlist != "") && (templateidlist != "0"))
            {
                base.RegisterStartupScript("", "<script>alert('" + templatepath.Substring(0, templatepath.Length - 1) + "已被删除, 因此系统将自动更新模板列表!')</script>");
                AdminTemplates.DeleteTemplateItem(templateidlist);
                AdminVistLogs.InsertLog(this.userid, this.username, this.usergroupid, this.grouptitle, this.ip, "从数据库中删除模板文件", "ID为:" + templateidlist);
                Discuz.Cache.DNTCache.GetCacheService().RemoveObject("/Forum/TemplateIDList");
                Templates.GetValidTemplateIDList();
            }

            DataGrid1.AllowCustomPaging = false;
            DataGrid1.DataSource        = buildGridData();
            DataGrid1.DataBind();

            #endregion
        }
        private void DelRec_Click(object sender, EventArgs e)
        {
            #region 将指定的模板从数据库中删除

            if (this.CheckCookie())
            {
                string templateidlist = DNTRequest.GetString("templateid");
                if (templateidlist != "")
                {
                    if (("," + templateidlist + ",").IndexOf(",1,") >= 0)
                    {
                        base.RegisterStartupScript("", "<script>alert('选中的模板中含有系统初始化模板,此次提交无法执行');window.location.href='global_templatesgrid.aspx'</script>");
                        return;
                    }

                    int maxdbtemplateid = TypeConverter.ObjectToInt(Templates.GetValidTemplateList().Rows[Templates.GetValidTemplateList().Rows.Count - 1]["templateid"]);
                    foreach (string templateid in templateidlist.Split(','))
                    {
                        if (Utils.StrToInt(templateid, 0) > maxdbtemplateid)
                        {
                            base.RegisterStartupScript("", "<script>alert('选中出库的模板中含有已出库模板,此次提交无法执行');window.location.href='global_templatesgrid.aspx'</script>");
                            return;
                        }
                    }

                    AdminTemplates.RemoveTemplateInDB(templateidlist, userid, username, usergroupid, grouptitle, ip);
                    Response.Redirect("global_templatesgrid.aspx");
                }
                else
                {
                    base.RegisterStartupScript("", "<script>alert('您未选中任何选项'); window.location.href='global_templatesgrid.aspx';</script>");
                }
            }

            #endregion
        }
 private DataTable buildGridData()
 {
     return(AdminTemplates.GetAllTemplateList(path));
 }