コード例 #1
0
        /// <summary>
        /// Load assigne preset for associate page.
        /// </summary>
        /// <param name="TemplateName">Template name.</param>
        /// <param name="PageName">Page name.</param>
        /// <returns>Preset path.</returns>
        public static string LoadActivePresetForPage(string TemplateName, string PageName)
        {
            string            presetPath       = TemplateName.ToLower().Equals("default")?Utils.GetPresetPath_DefaultTemplate(TemplateName):Utils.GetPresetPath(TemplateName);
            List <PresetInfo> lstActivePresets = new List <PresetInfo>();
            string            pagepreset       = presetPath + "/" + TemplateConstants.PagePresetFile;
            List <string>     lstAllPages      = new List <string>();

            if (File.Exists(pagepreset))
            {
                if (!CacheHelper.Get("PresetList", out lstActivePresets))
                {
                    lstActivePresets = PresetHelper.ParsePreset(pagepreset, "pagepreset/layout/preset", out lstAllPages);
                    CacheHelper.Add(lstActivePresets, "PresetList");
                }
            }
            else
            {
                lstActivePresets.Add(PresetInfo.GetPresetPages("default", "*"));
            }
            string pagepresetactive = string.Empty;
            string defaultpreset    = "layout.ascx";

            foreach (PresetInfo preset in lstActivePresets)
            {
                if (preset.IsDefault)
                {
                    defaultpreset = string.Format("{0}.ascx", preset.PresetName);;
                }
                else
                {
                    string presetPathFull = string.Empty;
                    foreach (string page in preset.LSTPages)
                    {
                        if (page.ToLower().Equals(PageName.ToLower()))
                        {
                            pagepresetactive = string.Format("{0}.ascx", preset.PresetName);;
                            break;
                        }
                    }
                }
            }
            if (pagepresetactive == string.Empty)
            {
                pagepresetactive = defaultpreset;
            }
            pagepresetactive = Decide.IsTemplateDefault(TemplateName)?string.Format("~/Core/Template/{1}", TemplateName, pagepresetactive):string.Format("~/Templates/{0}/{1}", TemplateName, pagepresetactive);
            return(pagepresetactive);
        }
コード例 #2
0
        public static string LoadActivePresetForPage(string TemplateName, string PageName)
        {
            string            presetPath       = Utils.GetPresetPath(TemplateName);
            List <PresetInfo> lstActivePresets = new List <PresetInfo>();
            string            pagepreset       = presetPath + "/" + TemplateConstants.PagePresetFile;
            List <string>     lstAllPages      = new List <string>();

            if (File.Exists(pagepreset))
            {
                lstActivePresets = PresetHelper.ParsePreset(pagepreset, "pagepresets/page", out lstAllPages);
            }
            else
            {
                lstActivePresets.Add(PresetInfo.GetPresetPages("default", "*"));
            }

            string pagepresetactive = "layout.ascx";

            foreach (PresetInfo preset in lstActivePresets)
            {
                if (preset.IsDefault)
                {
                    string     presetPathFull = presetPath + "/" + preset.PresetName + ".xml";
                    PresetInfo presetdetail   = LoadPresetDetails(presetPathFull);
                    pagepresetactive = presetdetail.ActiveLayout.ToLower() + ".ascx";
                }
                else
                {
                    string     presetPathFull = presetPath + "/" + preset.PresetName + ".xml";
                    PresetInfo presetdetail   = LoadPresetDetails(presetPathFull);
                    foreach (string page in preset.LSTPages)
                    {
                        if (page.ToLower().Equals(PageName.ToLower()))
                        {
                            pagepresetactive = presetdetail.ActiveLayout.ToLower() + ".ascx";
                            break;
                        }
                    }
                }
            }

            pagepresetactive = "~/Templates/" + TemplateName + "/" + pagepresetactive;

            return(pagepresetactive);
        }