Beispiel #1
0
        public static TemplateState GetTemplateState(HttpContextBase context, int? id, ITemplatesService service)
        {
            TemplateState template = null;
            Template t = null;
            if (id != null)
            {
                t = service.Get(id.Value);
            }
            else
            {
                //Gets the current template code from db
                t = service.GetCurrent();
            }

            if (t != null)
            {
                //Get all the files in the directory
                template = new TemplateState(t.Key);
                template.Id = t.Id;
                string[] fileNameList = SafeIO.Directory_GetFiles(Config.General.TemplateFolderPathFull(template.Name), "*.part.*.html");
                foreach (string fileName in fileNameList)
                {
                    template.Items.Add(new TemplateState.TemplateItem(SafeIO.File_ReadAllText(fileName)));
                }
            }
            return template;
        }