Beispiel #1
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);
        }
Beispiel #2
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);
        }