Ejemplo n.º 1
0
        public static void BuildTemplate(string directorypath)
        {
            int templateid = Convert.ToInt32(AdminTemplates.GetAllTemplateList(Utils.GetMapPath(@"..\..\templates\")).Select("tp_directory='" + directorypath + "'")[0]["tp_id"].ToString());

            Hashtable ht = new Hashtable();
            GetTemplates("default", ht);

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

            foreach (string key in ht.Keys)
            {
                string filename = key.Split('.')[0];
                string[] template = ht[key].ToString().Split('\\');
                forumpagetemplate.GetTemplate(BaseConfigs.GetSitePath, template[0], filename, template.Length >= 2 ? template[template.Length - 1] : "", 1, templateid);
            }
        }
        protected void CreateTemplate_Click(object sender, EventArgs e)
        {
            #region 建立文件
            if (CheckCookie())
            {
                string templatePathList = TreeView1.GetSelectString(",");   //取得勾选文件列表

                if (templatePathList == "")
                {
                    RegisterStartupScript("", "<script>alert('您未选中任何模板');</script>");
                    return;
                }
                if (SASRequest.GetString("chkall") == "" && templatePathList.Contains("_"))   //非全部生成
                {
                    templatePathList = RemadeTemplatePathList(templatePathList);
                }
                int templateId = SASRequest.GetInt("templateid", 1);
                int updateCount = 0;
                string forumPath = BaseConfigs.GetSitePath;
                LogicPageTemplate forumPageTemplate = new LogicPageTemplate();

                foreach (string templatePath in templatePathList.Split(','))
                {
                    string templateFileName = Path.GetFileName(templatePath).ToLower();//tempstr[tempstr.Length - 1];
                    string tempplaeExtName = Path.GetExtension(templateFileName); //tempstr = templateName.Split('.');
                    if ((tempplaeExtName.Equals(".htm") || (tempplaeExtName.Equals(".config"))) && !templateFileName.Contains("_"))
                    {
                        string subTemplateDirectory = "";
                        if (templatePath.Split('\\').Length >= 3)
                        {
                            subTemplateDirectory = Path.GetDirectoryName(templatePath).Substring(Path.GetDirectoryName(templatePath).LastIndexOf("\\") + 1);
                        }
                        forumPageTemplate.GetTemplate(forumPath, skinpath, Path.GetFileNameWithoutExtension(templateFileName),
                           subTemplateDirectory, 1, templateId);
                        updateCount++;
                    }
                }
                RegisterStartupScript("PAGETemplate", "共" + updateCount + " 个模板已更新");
            }
            #endregion
        }
Ejemplo n.º 3
0
 private void CreateTemplate(string forumpath, string templatepath, string pagename, int templateid)
 {
     if (!Directory.Exists(Utils.GetMapPath(forumpath + "aspx/" + templateid)))
     {
         Directory.CreateDirectory(Utils.GetMapPath(forumpath + "aspx/" + templateid));
     }
     if (!File.Exists(Utils.GetMapPath(forumpath + "aspx/" + templateid + "/" + pagename)))   //当前模板文件不存在
     {
         LogicPageTemplate forumpagetemplate = new LogicPageTemplate();
         forumpagetemplate.GetTemplate(forumpath, templatepath, pagename.Split('.')[0], 1, templateid);
     }
 }