예제 #1
0
        /// <summary>
        /// 编辑模板
        /// </summary>
        public void Edit_GET()
        {
            string tpl = Request["tpl"];

            if (String.IsNullOrEmpty(tpl))
            {
                tpl = base.CurrentSite.Tpl;
            }
            StringBuilder sb = new StringBuilder();

            DirectoryInfo dir = new DirectoryInfo(String.Format("{0}templates/{1}/", AppDomain.CurrentDomain.BaseDirectory, tpl));

            if (!dir.Exists)
            {
                Response.Redirect(Request.Path + "?module=template&action=templates", true);
                return;
            }

            EachClass.IterialTemplateFiles(dir, sb, tpl);

            base.RenderTemplate(ResourceMap.GetPageContent(ManagementPage.Template_Edit), new
            {
                tplfiles = sb.ToString(),
                tpl      = tpl
            });
        }
예제 #2
0
        /// <summary>
        /// 编辑模板
        /// </summary>
        public void Edit()
        {
            string tpl = Request.Query("tpl");

            if (string.IsNullOrEmpty(tpl))
            {
                tpl = CurrentSite.Tpl;
            }
            var sb = new StringBuilder();

            var dir = new DirectoryInfo($"{EnvUtil.GetBaseDirectory()}/templates/{tpl}/");

            if (!dir.Exists)
            {
                Response.Redirect(Request.GetPath() + "?module=template&action=templates", false);
                return;
            }

            EachClass.WalkTemplateFiles(dir, sb, tpl);

            RenderTemplate(ResourceMap.GetPageContent(ManagementPage.Template_Edit), new
            {
                tplfiles = sb.ToString(),
                tpl      = tpl
            });
        }
예제 #3
0
        public void Create_GET()
        {
            StringBuilder sb = new StringBuilder();
            string        archiveTplOpts,
                          categoryTplOpts;

            //模板目录
            DirectoryInfo dir = new DirectoryInfo(
                String.Format("{0}templates/{1}",
                              AppDomain.CurrentDomain.BaseDirectory,
                              Settings.TPL_MultMode ? "" :base.CurrentSite.Tpl + "/"
                              ));

            EachClass.EachTemplatePage(dir, sb, TemplatePageType.Archive);
            archiveTplOpts = sb.ToString();

            sb.Remove(0, sb.Length);

            EachClass.EachTemplatePage(dir, sb, TemplatePageType.Category);
            categoryTplOpts = sb.ToString();

            base.RenderTemplate(ResourceMap.EditModule, new
            {
                btnText         = "添加",
                tplName         = "",
                categoryTplPath = "",
                archiveTplPath  = "",
                category_tpls   = categoryTplOpts,
                archive_tpls    = archiveTplOpts
            });
        }
예제 #4
0
        /// <summary>
        /// 创建栏目
        /// </summary>
        public void Create()
        {
            string categoryOptions,     //栏目下拉列表
                   categoryTypeOptions, //栏目类型下拉列表
                   archiveTplOpts,
                   categoryTplOpts;

            var sb = new StringBuilder();

            //当前站点
            var site = CurrentSite;

            //加载模块

            /*
             * foreach (var m in CmsLogic.Module.GetSiteAvailableModules(siteID))
             * {
             *  if (!m.IsDelete)
             *  {
             *      sb.Append("<option value=\"").Append(m.ID.ToString()).Append("\">").Append(m.Name).Append("</option>");
             *  }
             * }
             * categoryTypeOptions = sb.ToString();
             * sb.Remove(0, sb.Length);
             */
            int.TryParse(Request.Query("parent_id"), out var parentId);

            categoryOptions = Helper.GetCategoryIdSelector(SiteId, parentId);


            //获取模板视图下拉项
            sb.Remove(0, sb.Length);

            //模板目录
            var dir   = new DirectoryInfo(string.Format("{0}templates/{1}/", Cms.PhysicPath, CurrentSite.Tpl));
            var names = Cms.TemplateManager.Get(CurrentSite.Tpl).GetNameDictionary();

            EachClass.EachTemplatePage(dir, dir, sb, names, new[] { TemplatePageType.Archive });
            archiveTplOpts = sb.ToString();

            sb.Remove(0, sb.Length);

            EachClass.EachTemplatePage(dir, dir, sb, names, new[] { TemplatePageType.Category });
            categoryTplOpts = sb.ToString();

            object data = new
            {
                url           = Request.GetPath() + Request.GetQueryString(),
                categories    = categoryOptions,
                category_tpls = categoryTplOpts,
                archive_tpls  = archiveTplOpts,
                parentId      = parentId
            };

            RenderTemplate(ResourceMap.GetPageContent(ManagementPage.Category_CreateCategory), data);
        }
예제 #5
0
        public string GetListJson_POST()
        {
            String        tpl = Request.Form.Get("tpl");
            DirectoryInfo dir = new DirectoryInfo(String.Format("{0}templates/{1}/", Cms.PyhicPath, tpl));

            if (dir.Exists)
            {
                IList <EachClass.TemplateNames> list     = new List <EachClass.TemplateNames>();
                IDictionary <String, String>    nameDict = Cms.TemplateManager.Get(tpl).GetNameDictionary();
                EachClass.IterTemplateFiles2(dir, dir.FullName.Length, list, nameDict);
                return(JsonConvert.SerializeObject(list));
            }
            return("[]");
        }
예제 #6
0
        public void Edit_GET()
        {
            string archiveTpl,
                   categoryTpl,
                   archiveTplOpts,
                   categoryTplOpts;


            var module = CmsLogic.Module.GetModule(int.Parse(HttpContext.Current.Request["id"]));

            StringBuilder sb = new StringBuilder();

            //模板目录
            DirectoryInfo dir = new DirectoryInfo(
                String.Format("{0}templates/{1}",
                              AppDomain.CurrentDomain.BaseDirectory,
                              Settings.TPL_MultMode ? "" :base.CurrentSite.Tpl + "/"
                              ));

            EachClass.EachTemplatePage(dir, sb, TemplatePageType.Archive);
            archiveTplOpts = sb.ToString();

            sb.Remove(0, sb.Length);

            EachClass.EachTemplatePage(dir, sb, TemplatePageType.Category);
            categoryTplOpts = sb.ToString();



            TemplateBind tb;

            //获取文档模板绑定
            tb          = CmsLogic.TemplateBind.GetBind(TemplateBindType.ModuleCategoryTemplate, module.ID.ToString());
            categoryTpl = tb == null?"": tb.TplPath;

            //获取文档模板绑定
            tb         = CmsLogic.TemplateBind.GetBind(TemplateBindType.ModuleArchiveTemplate, module.ID.ToString());
            archiveTpl = tb == null ? "" : tb.TplPath;


            base.RenderTemplate(ResourceMap.EditModule, new
            {
                btnText         = "修改",
                tplName         = module.Name,
                categoryTplPath = categoryTpl,
                archiveTplPath  = archiveTpl,
                category_tpls   = categoryTplOpts,
                archive_tpls    = archiveTplOpts
            });
        }
예제 #7
0
        /// <summary>
        /// 编辑模板
        /// </summary>
        public void Edit_GET()
        {
            StringBuilder sb = new StringBuilder();

            DirectoryInfo cssDir = new DirectoryInfo(String.Format("{0}style/", AppDomain.CurrentDomain.BaseDirectory));
            DirectoryInfo cfgDir = new DirectoryInfo(String.Format("{0}config/", AppDomain.CurrentDomain.BaseDirectory));

            //sb.Append("<optgroup label=\"样式表\">");
            //EachClass.EachFiles(cssDir, sb, "style",".css", true);
            sb.Append("</optgroup><optgroup label=\"设置文件\">");
            EachClass.EachFiles(cfgDir, sb, "config", ".xml ; .ini ; .conf", true);
            sb.Append("</optgroup>");

            base.RenderTemplate(ResourceMap.GetPageContent(ManagementPage.File_SelectEdit), new
            {
                files  = sb.ToString(),
                systpl = base.CurrentSite.Tpl
            });
        }
예제 #8
0
        /// <summary>
        /// 编辑模板
        /// </summary>
        public void Edit()
        {
            var sb = new StringBuilder();

            var cssDir = new DirectoryInfo($"{EnvUtil.GetBaseDirectory()}/style/");
            var cfgDir = new DirectoryInfo($"{EnvUtil.GetBaseDirectory()}/config/");

            //sb.Append("<optgroup label=\"样式表\">");
            //EachClass.EachFiles(cssDir, sb, "style",".css", true);
            sb.Append("</optgroup><optgroup label=\"设置文件\">");
            EachClass.EachFiles(cfgDir, sb, "config", ".xml ; .ini ; .conf", true);
            sb.Append("</optgroup>");

            RenderTemplate(ResourceMap.GetPageContent(ManagementPage.File_SelectEdit), new
            {
                files  = sb.ToString(),
                systpl = CurrentSite.Tpl
            });
        }
예제 #9
0
        // private static IDictionary<int, HttpTags> tags = new Dictionary<int, HttpTags>();

        /// <summary>
        /// 创建文档
        /// </summary>
        public void Create()
        {
            //栏目JSON
            string extendFieldsHtml = ""; //属性Html

            Module module;

            var categoryId = int.Parse(Request.Query("category.id").ToString() ?? "1"); //分类ID
            var category   = ServiceCall.Instance.SiteService.GetCategory(SiteId, categoryId);


            //获取模板视图下拉项
            var sb2 = new StringBuilder();

            //模板目录
            var dir = new DirectoryInfo(
                $"{EnvUtil.GetBaseDirectory()}/templates/{CurrentSite.Tpl + "/"}");

            var names = Cms.TemplateManager.Get(CurrentSite.Tpl).GetNameDictionary();

            EachClass.EachTemplatePage(
                dir,
                dir,
                sb2,
                names,
                new[] {
                TemplatePageType.Custom,
                TemplatePageType.Archive
            }
                );

            var tplList = sb2.ToString();

            sb2.Remove(0, sb2.Length);

            //获取该模块栏目JSON数据
            //categoryJSON = CmsLogic.Category.GetJson(m.ID);

            var nodesHtml = Helper.GetCategoryIdSelector(SiteId, categoryId);


            //=============  拼接模块的属性值 ==============//

            /*
             * //========= 统计tab =============//
             * sb.Append("<ul class=\"dataExtend_tabs\">");
             * foreach (DataExtend e in extends)
             * {
             *  sb.Append("<li><span>").Append(e.Name).Append("</span></li>");
             * }
             * sb.Append("</ul>");
             *
             * extendItemsHtml = sb.ToString();
             *
             * sb.Capacity = 1000;
             * sb.Remove(0, sb.Length);
             */


            //======== 生成值 =============//

            var sb = new StringBuilder(500);

            sb.Append("<div class=\"data-extend-item\">");
            PropertyUI uiType;

            foreach (var p in category.ExtendFields)
            {
                uiType = (PropertyUI)int.Parse(p.Type);
                AppendExtendFormHtml(sb, p, p.DefaultValue);
            }

            sb.Append("</div>");
            extendFieldsHtml = sb.ToString();

            // extendFieldsHtml = "<div style=\"color:red;padding:20px;\">所选栏目模块不包含任何自定义属性,如需添加请到模块管理-》属性设置</div>";
            object json = new
            {
                IsVisible = true,
                Thumbnail = CmsVariables.FRAMEWORK_ARCHIVE_NoPhoto,
                Location  = string.Empty
            };
            var    path  = Request.GetPath();
            var    query = Request.GetQueryString();
            object data  = new
            {
                extendFieldsHtml = extendFieldsHtml,
                extend_cls       = category.ExtendFields.Count == 0 ? "hidden" : "",
                thumbPrefix      = CmsVariables.Archive_ThumbPrefix,
                nodes            = nodesHtml,
                url  = path + query,
                tpls = tplList,
                json = JsonSerializer.Serialize(json)
            };

            RenderTemplate(ResourceMap.GetPageContent(ManagementPage.Archive_Create), data);
        }
예제 #10
0
        /// <summary>
        /// 更新文档
        /// </summary>
        public void Update()
        {
            object data;
            var    archiveId = int.Parse(Request.Query("archive.id"));
            string tpls,
                   nodesHtml,
            //栏目JSON
                   extendFieldsHtml = ""; //属性Html

            Module module;

            var siteId = CurrentSite.SiteId;

            var archive = ServiceCall.Instance.ArchiveService.GetArchiveById(siteId, archiveId);

            var categoryId = archive.Category.ID;

            //=============  拼接模块的属性值 ==============//

            var sb = new StringBuilder(50);

            string       attrValue;
            IExtendField field;

            sb.Append("<div class=\"data-extend-item\">");

            foreach (var extValue in archive.ExtendValues)
            {
                field     = extValue.Field;
                attrValue = (extValue.Value ?? field.DefaultValue).Replace("<br />", "\n");
                AppendExtendFormHtml(sb, field, attrValue);
            }


            sb.Append("</div>");

            extendFieldsHtml = sb.ToString();


            //获取模板视图下拉项
            var sb2 = new StringBuilder();

            //模板目录
            var dir = new DirectoryInfo(
                string.Format("{0}/templates/{1}",
                              EnvUtil.GetBaseDirectory(),
                              CurrentSite.Tpl + "/"
                              ));
            var names = Cms.TemplateManager.Get(CurrentSite.Tpl).GetNameDictionary();

            EachClass.EachTemplatePage(dir, dir,
                                       sb2,
                                       names,
                                       new[] {
                TemplatePageType.Custom,
                TemplatePageType.Archive
            }
                                       );

            tpls = sb2.ToString();

            nodesHtml = Helper.GetCategoryIdSelector(SiteId, categoryId);


            var thumbnail = !string.IsNullOrEmpty(archive.Thumbnail)
                ? archive.Thumbnail
                : "/" + CmsVariables.FRAMEWORK_ARCHIVE_NoPhoto;

            object json = new
            {
                //IsSpecial = flags.ContainsKey(ArchiveFlag.GetInternalFlagKey(BuiltInArchiveFlags.IsSpecial))
                //                            && flags[ArchiveFlag.GetInternalFlagKey(BuiltInArchiveFlags.IsSpecial)],

                //IsSystem = flags.ContainsKey(ArchiveFlag.GetInternalFlagKey(BuiltInArchiveFlags.IsSystem))
                //                            && flags[ArchiveFlag.GetInternalFlagKey(BuiltInArchiveFlags.IsSystem)],

                //IsNotVisible = !(flags.ContainsKey(ArchiveFlag.GetInternalFlagKey(BuiltInArchiveFlags.Visible))
                //                            && flags[ArchiveFlag.GetInternalFlagKey(BuiltInArchiveFlags.Visible)]),

                //AsPage = flags.ContainsKey(ArchiveFlag.GetInternalFlagKey(BuiltInArchiveFlags.AsPage))
                //                            && flags[ArchiveFlag.GetInternalFlagKey(BuiltInArchiveFlags.AsPage)],
                IsSpecial    = FlagAnd(archive.Flag, BuiltInArchiveFlags.IsSpecial),
                IsSystem     = FlagAnd(archive.Flag, BuiltInArchiveFlags.IsSystem),
                IsVisible    = FlagAnd(archive.Flag, BuiltInArchiveFlags.Visible),
                AsPage       = FlagAnd(archive.Flag, BuiltInArchiveFlags.AsPage),
                Id           = archive.Id,
                Title        = archive.Title,
                SmallTitle   = archive.SmallTitle,
                Alias        = archive.Alias ?? string.Empty,
                Tags         = archive.Tags,
                Source       = archive.Source,
                Outline      = archive.Outline,
                Content      = archive.Content,
                TemplatePath = archive.IsSelfTemplate &&
                               !string.IsNullOrEmpty(archive.TemplatePath)
                    ? archive.TemplatePath
                    : string.Empty,
                Thumbnail = thumbnail,
                Location  = archive.Location
            };

            var path  = Request.GetPath();
            var query = Request.GetQueryString();

            data = new
            {
                extendFieldsHtml = extendFieldsHtml,
                extend_cls       = archive.ExtendValues.Count == 0 ? "hidden" : "",
                nodes            = nodesHtml,
                url  = path + query,
                tpls = tpls,
                json = JsonSerializer.Serialize(json)
            };

            RenderTemplate(
                ResourceMap.GetPageContent(ManagementPage.Archive_Update),
                data);
        }
예제 #11
0
        /// <summary>
        /// 创建文档
        /// </summary>
        public void Create_GET()
        {
            object data;
            string tpls,
                   nodesHtml,
            //栏目JSON
                   extendFieldsHtml = "";                                                              //属性Html

            Module module;

            int         categoryId = int.Parse(base.Request["category.id"] ?? "1");                            //分类ID
            CategoryDto category   = ServiceCall.Instance.SiteService.GetCategory(base.SiteId, categoryId);


            //获取模板视图下拉项
            StringBuilder sb2 = new StringBuilder();

            //模板目录
            DirectoryInfo dir = new DirectoryInfo(
                String.Format("{0}templates/{1}",
                              AppDomain.CurrentDomain.BaseDirectory,
                              base.CurrentSite.Tpl + "/"
                              ));

            IDictionary <String, String> names = Cms.TemplateManager.Get(base.CurrentSite.Tpl).GetNameDictionary();

            EachClass.EachTemplatePage(
                dir,
                dir,
                sb2,
                names,
                TemplatePageType.Custom,
                TemplatePageType.Archive
                );

            tpls = sb2.ToString();
            sb2.Remove(0, sb2.Length);

            //获取该模块栏目JSON数据
            //categoryJSON = CmsLogic.Category.GetJson(m.ID);

            nodesHtml = Helper.GetCategoryIdSelector(this.SiteId, categoryId);


            //=============  拼接模块的属性值 ==============//

            /*
             * //========= 统计tab =============//
             * sb.Append("<ul class=\"dataExtend_tabs\">");
             * foreach (DataExtend e in extends)
             * {
             *  sb.Append("<li><span>").Append(e.Name).Append("</span></li>");
             * }
             * sb.Append("</ul>");
             *
             * extendItemsHtml = sb.ToString();
             *
             * sb.Capacity = 1000;
             * sb.Remove(0, sb.Length);
             */



            //======== 生成值 =============//

            StringBuilder sb = new StringBuilder(500);

            sb.Append("<div class=\"dataextend_item\">");
            PropertyUI uiType;

            foreach (IExtendField p in category.ExtendFields)
            {
                uiType = (PropertyUI)int.Parse(p.Type);
                this.AppendExtendFormHtml(sb, p, p.DefaultValue);
            }


            sb.Append("</div>");
            extendFieldsHtml = sb.ToString();


            // extendFieldsHtml = "<div style=\"color:red;padding:20px;\">所选栏目模块不包含任何自定义属性,如需添加请到模块管理-》属性设置</div>";


            object json = new
            {
                IsVisible = true,
                Thumbnail = CmsVariables.FRAMEWORK_ARCHIVE_NoPhoto,
                Location  = String.Empty
            };

            data = new
            {
                extendFieldsHtml = extendFieldsHtml,
                extend_cls       = category.ExtendFields.Count == 0 ? "hidden" : "",
                thumbPrefix      = CmsVariables.Archive_ThumbPrefix,
                nodes            = nodesHtml,
                url = Request.Url.PathAndQuery,
                tpls,
                json = JsonSerializer.Serialize(json)
            };

            base.RenderTemplate(ResourceMap.GetPageContent(ManagementPage.Archive_Create), data);
        }
예제 #12
0
        /// <summary>
        /// 创建栏目
        /// </summary>
        public void Update()
        {
            string categoryOptions,     //栏目下拉列表
                   categoryTypeOptions, //栏目类型下拉列表
                   archiveTpl,
                   archiveTplOpts,
                   categoryTplOpts;

            var sb = new StringBuilder();

            //获取栏目
            var categoryId = int.Parse(Request.Query("category_id"));
            var category   = ServiceCall.Instance.SiteService.GetCategory(SiteId, categoryId);


            //检验站点
            if (!(category.ID > 0))
            {
                return;
            }

            //获取父栏目pleft
            var pId = category.ParentId;

            /*
             * //加载模块
             * foreach (var m in CmsLogic.Module.GetSiteAvailableModules(this.SiteId))
             * {
             *  if (!m.IsDelete)
             *  {
             *      sb.Append("<option value=\"").Append(m.ID.ToString()).Append("\">").Append(m.Name).Append("</option>");
             *  }
             * }
             * categoryTypeOptions = sb.ToString();
             * sb.Remove(0, sb.Length);
             *
             */

            categoryOptions = Helper.GetCategoryIdSelector(SiteId, 0);


            //获取模板视图下拉项
            sb.Remove(0, sb.Length);

            //模板目录
            var dir = new DirectoryInfo($"{Cms.PhysicPath}templates/{CurrentSite.Tpl}/");

            var names = Cms.TemplateManager.Get(CurrentSite.Tpl).GetNameDictionary();

            EachClass.EachTemplatePage(dir, dir, sb, names, new[] { TemplatePageType.Archive });
            archiveTplOpts = sb.ToString();

            sb.Remove(0, sb.Length);

            EachClass.EachTemplatePage(dir, dir, sb, names, new[] { TemplatePageType.Category });
            categoryTplOpts = sb.ToString();


            //获取栏目及文档模板绑定
            var categoryTpl = string.IsNullOrEmpty(category.CategoryTemplate) ? "" : category.CategoryTemplate;

            archiveTpl = string.IsNullOrEmpty(category.CategoryArchiveTemplate) ? "" : category.CategoryArchiveTemplate;

            object data = new
            {
                entity     = JsonSerializer.Serialize(category),
                url        = Request.GetEncodedUrl(),
                categories = categoryOptions,
                //categoryTypes = categoryTypeOptions,
                parentId        = pId,
                categoryTplPath = categoryTpl,
                archiveTplPath  = archiveTpl,
                category_tpls   = categoryTplOpts,
                archive_tpls    = archiveTplOpts
            };

            RenderTemplate(ResourceMap.GetPageContent(ManagementPage.Category_EditCategory), data);
        }
예제 #13
0
        /// <summary>
        /// 创建栏目
        /// </summary>
        public void Create_GET()
        {
            string categoryOptions,             //栏目下拉列表
                   categoryTypeOptions,         //栏目类型下拉列表
                   archiveTplOpts,
                   categoryTplOpts;

            StringBuilder sb = new StringBuilder();

            //当前站点
            var site = base.CurrentSite;

            //加载模块

            /*
             * foreach (var m in CmsLogic.Module.GetSiteAvailableModules(siteID))
             * {
             *  if (!m.IsDelete)
             *  {
             *      sb.Append("<option value=\"").Append(m.ID.ToString()).Append("\">").Append(m.Name).Append("</option>");
             *  }
             * }
             * categoryTypeOptions = sb.ToString();
             * sb.Remove(0, sb.Length);
             */
            int parentId;

            int.TryParse(Request["parent_id"], out parentId);

            categoryOptions = Helper.GetCategoryIdSelector(this.SiteId, parentId);


            //获取模板视图下拉项
            sb.Remove(0, sb.Length);

            //模板目录
            DirectoryInfo dir = new DirectoryInfo(String.Format("{0}templates/{1}/", Cms.PyhicPath, base.CurrentSite.Tpl));
            IDictionary <String, String> names = Cms.TemplateManager.Get(base.CurrentSite.Tpl).GetNameDictionary();

            EachClass.EachTemplatePage(dir, dir, sb, names, TemplatePageType.Archive);
            archiveTplOpts = sb.ToString();

            sb.Remove(0, sb.Length);

            EachClass.EachTemplatePage(dir, dir, sb, names, TemplatePageType.Category);
            categoryTplOpts = sb.ToString();

            object entity = new
            {
                ParentId = Request["parent_id"]
            };

            object data = new
            {
                url           = base.Request.RawUrl,
                categories    = categoryOptions,
                tpls          = sb.ToString(),
                category_tpls = categoryTplOpts,
                archive_tpls  = archiveTplOpts,
                entity        = JsonSerializer.Serialize(entity)
            };

            base.RenderTemplate(ResourceMap.GetPageContent(ManagementPage.Category_CreateCategory), data);
        }
예제 #14
0
        /// <summary>
        /// 创建栏目
        /// </summary>
        public void Update_GET()
        {
            string categoryOptions,            //栏目下拉列表
                   categoryTypeOptions,        //栏目类型下拉列表
                   archiveTpl,
                   archiveTplOpts,
                   categoryTplOpts;

            StringBuilder sb = new StringBuilder();

            //获取栏目
            int         categoryId = int.Parse(base.Request["category_id"]);
            CategoryDto category   = ServiceCall.Instance.SiteService.GetCategory(this.SiteId, categoryId);


            //检验站点
            if (!(category.ID > 0))
            {
                return;
            }

            //获取父栏目pleft
            int         pId = 0;
            CategoryDto pc  = ServiceCall.Instance.SiteService.GetParentCategory(this.SiteId, category.Lft);

            if (pc.ID > 0)
            {
                pId = pc.ID;
            }

            /*
             * //加载模块
             * foreach (var m in CmsLogic.Module.GetSiteAvailableModules(this.SiteId))
             * {
             *  if (!m.IsDelete)
             *  {
             *      sb.Append("<option value=\"").Append(m.ID.ToString()).Append("\">").Append(m.Name).Append("</option>");
             *  }
             * }
             * categoryTypeOptions = sb.ToString();
             * sb.Remove(0, sb.Length);
             *
             */

            categoryOptions = Helper.GetCategoryIdSelector(this.SiteId, 0);



            //获取模板视图下拉项
            sb.Remove(0, sb.Length);

            //模板目录
            DirectoryInfo dir = new DirectoryInfo(String.Format("{0}templates/{1}/", Cms.PyhicPath, base.CurrentSite.Tpl));

            IDictionary <String, String> names = Cms.TemplateManager.Get(base.CurrentSite.Tpl).GetNameDictionary();

            EachClass.EachTemplatePage(dir, dir, sb, names, TemplatePageType.Archive);
            archiveTplOpts = sb.ToString();

            sb.Remove(0, sb.Length);

            EachClass.EachTemplatePage(dir, dir, sb, names, TemplatePageType.Category);
            categoryTplOpts = sb.ToString();


            //获取栏目及文档模板绑定
            var categoryTpl = String.IsNullOrEmpty(category.CategoryTemplate) ? "" : category.CategoryTemplate;

            archiveTpl = String.IsNullOrEmpty(category.CategoryArchiveTemplate) ? "" : category.CategoryArchiveTemplate;

            object data = new
            {
                entity     = JsonSerializer.Serialize(category),
                url        = base.Request.RawUrl,
                categories = categoryOptions,
                //categoryTypes = categoryTypeOptions,
                parentId        = pId,
                categoryTplPath = categoryTpl,
                archiveTplPath  = archiveTpl,
                category_tpls   = categoryTplOpts,
                archive_tpls    = archiveTplOpts
            };

            base.RenderTemplate(ResourceMap.GetPageContent(ManagementPage.Category_EditCategory), data);
        }
예제 #15
0
        /// <summary>
        /// 更新文档
        /// </summary>
        public void Update_GET()
        {
            object data;
            int    archiveId = int.Parse(base.Request["archive.id"]);
            string tpls, nodesHtml,
            //栏目JSON
                   extendFieldsHtml = "";                                     //属性Html

            Module module;

            int siteId = this.CurrentSite.SiteId;

            ArchiveDto archive = ServiceCall.Instance.ArchiveService.GetArchiveById(siteId, archiveId);

            int categoryId = archive.Category.ID;

            //=============  拼接模块的属性值 ==============//

            StringBuilder sb = new StringBuilder(50);

            string       attrValue;
            IExtendField field;

            sb.Append("<div class=\"dataextend_item\">");

            foreach (IExtendValue extValue in archive.ExtendValues)
            {
                field     = extValue.Field;
                attrValue = (extValue.Value ?? field.DefaultValue).Replace("<br />", "\n");
                this.AppendExtendFormHtml(sb, field, attrValue);
            }


            sb.Append("</div>");

            extendFieldsHtml = sb.ToString();



            //获取模板视图下拉项
            StringBuilder sb2 = new StringBuilder();

            //模板目录
            DirectoryInfo dir = new DirectoryInfo(
                String.Format("{0}templates/{1}",
                              AppDomain.CurrentDomain.BaseDirectory,
                              base.CurrentSite.Tpl + "/"
                              ));

            IDictionary <String, String> names = Cms.TemplateManager.Get(base.CurrentSite.Tpl).GetNameDictionary();

            EachClass.EachTemplatePage(dir, dir,
                                       sb2,
                                       names,
                                       TemplatePageType.Custom,
                                       TemplatePageType.Archive
                                       );

            tpls = sb2.ToString();

            nodesHtml = Helper.GetCategoryIdSelector(this.SiteId, categoryId);


            string thumbnail = !String.IsNullOrEmpty(archive.Thumbnail)
                    ? archive.Thumbnail
                    : "/" + CmsVariables.FRAMEWORK_ARCHIVE_NoPhoto;

            object json = new
            {
                //IsSpecial = flags.ContainsKey(ArchiveFlag.GetInternalFlagKey(BuiltInArchiveFlags.IsSpecial))
                //                            && flags[ArchiveFlag.GetInternalFlagKey(BuiltInArchiveFlags.IsSpecial)],

                //IsSystem = flags.ContainsKey(ArchiveFlag.GetInternalFlagKey(BuiltInArchiveFlags.IsSystem))
                //                            && flags[ArchiveFlag.GetInternalFlagKey(BuiltInArchiveFlags.IsSystem)],

                //IsNotVisible = !(flags.ContainsKey(ArchiveFlag.GetInternalFlagKey(BuiltInArchiveFlags.Visible))
                //                            && flags[ArchiveFlag.GetInternalFlagKey(BuiltInArchiveFlags.Visible)]),

                //AsPage = flags.ContainsKey(ArchiveFlag.GetInternalFlagKey(BuiltInArchiveFlags.AsPage))
                //                            && flags[ArchiveFlag.GetInternalFlagKey(BuiltInArchiveFlags.AsPage)],
                IsSpecial    = this.FlagAnd(archive.Flag, BuiltInArchiveFlags.IsSpecial),
                IsSystem     = this.FlagAnd(archive.Flag, BuiltInArchiveFlags.IsSystem),
                IsVisible    = this.FlagAnd(archive.Flag, BuiltInArchiveFlags.Visible),
                AsPage       = this.FlagAnd(archive.Flag, BuiltInArchiveFlags.AsPage),
                Id           = archive.Id,
                Title        = archive.Title,
                SmallTitle   = archive.SmallTitle,
                Alias        = archive.Alias ?? String.Empty,
                Tags         = archive.Tags,
                Source       = archive.Source,
                Outline      = archive.Outline,
                Content      = archive.Content,
                TemplatePath = archive.IsSelfTemplate &&
                               !String.IsNullOrEmpty(archive.TemplatePath) ?
                               archive.TemplatePath :
                               String.Empty,
                Thumbnail = thumbnail,
                Location  = archive.Location
            };


            data = new
            {
                extendFieldsHtml = extendFieldsHtml,
                extend_cls       = archive.ExtendValues.Count == 0 ? "hidden" : "",
                thumbPrefix      = CmsVariables.Archive_ThumbPrefix,
                nodes            = nodesHtml,
                url  = Request.Url.PathAndQuery,
                tpls = tpls,
                json = JsonSerializer.Serialize(json)
            };

            base.RenderTemplate(
                BasePage.CompressHtml(ResourceMap.GetPageContent(ManagementPage.Archive_Update)),
                data);
        }