Exemple #1
0
        /// <summary>
        /// 创建栏目
        /// </summary>
        public void Update_GET()
        {
            string categoryOptions,             //栏目下拉列表
                      categoryTypeOptions,     //栏目类型下拉列表
                      categoryTpl,
                      archiveTpl,
                      archiveTplOpts,
                      categoryTplOpts;

            StringBuilder sb = new StringBuilder();

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


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

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

            if (pc.ID > 0) pleft = pc.Lft;

            /*
            //加载模块
            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);

            */

            //加载栏目(排除当前栏目)
            ServiceCall.Instance.SiteService.HandleCategoryTree(this.SiteId, 1, (c, level) =>
            {
                if (c.Lft != leftID)
                {
                    sb.Append("<option value=\"").Append(c.Lft.ToString()).Append("\">");
                    for (var i = 0; i < level; i++)
                    {
                        sb.Append(CmsCharMap.Dot);
                    }
                    sb.Append(c.Name).Append("</option>");
                }
            });

            categoryOptions = sb.ToString();



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

            //模板目录
            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();


            //获取栏目及文档模板绑定
            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,
                parentLft = pleft,
                categoryTplPath = categoryTpl,
                archiveTplPath = archiveTpl,
                category_tpls = categoryTplOpts,
                archive_tpls = archiveTplOpts
            };

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

            StringBuilder sb = new StringBuilder();
            int siteID = base.CurrentSite.SiteId;

            //当前站点
            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);
            */

            //加载栏目
            ServiceCall.Instance.SiteService.HandleCategoryTree(this.SiteId, 1, (category, level) =>
            {
                sb.Append("<option value=\"").Append(category.Lft.ToString()).Append("\">");
                for (var i = 0; i < level; i++)
                {
                    sb.Append(CmsCharMap.Dot);
                }
                sb.Append(category.Name).Append("</option>");

            });

            categoryOptions = sb.ToString();



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

            //模板目录
            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();

            object entity = new
            {
                ParentLft = Request["lft"]
            };

            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);
        }