/// <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 }); }
/// <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 }); }
/// <summary> /// 创建文档 /// </summary> public void Create_GET() { object data; string tpls, nodesHtml, //栏目JSON extendFieldsHtml = "", //属性Html extendItemsHtml = ""; 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, Settings.TPL_MultMode ? "" : base.CurrentSite.Tpl + "/" )); EachClass.EachTemplatePage( dir, sb2, TemplatePageType.Custom, TemplatePageType.Archive ); tpls = sb2.ToString(); sb2.Remove(0, sb2.Length); //获取该模块栏目JSON数据 //categoryJSON = CmsLogic.Category.GetJson(m.ID); ServiceCall.Instance.SiteService.HandleCategoryTree(this.SiteId, 1, (_category, level) => { sb2.Append("<option value=\"").Append(_category.ID.ToString()).Append("\""); if (_category.ID == category.ID) { sb2.Append(" selected=\"selected\""); } sb2.Append(">"); for (int i = 0; i < level; i++) { sb2.Append(CmsCharMap.Dot); } sb2.Append(_category.Name).Append("</option>"); }); nodesHtml = sb2.ToString(); //============= 拼接模块的属性值 ==============// /* * //========= 统计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\">"); foreach (IExtendField p in category.ExtendFields) { sb.Append("<dl><dt>").Append(p.Name).Append(":</dt><dd>"); if (p.Type == ((int)PropertyUI.Text).ToString()) { sb.Append("<input type=\"text\" class=\"tb_normal\" field=\"extend_").Append(p.ID.ToString()) .Append("\" value=\"").Append(p.DefaultValue).Append("\"/>"); } else if (p.Type == ((int)PropertyUI.Upload).ToString()) { sb.Append("<input type=\"text\" disabled=\"disabled\" class=\"tb_normal\" id=\"extend_").Append(p.ID.ToString()) .Append("\" field=\"extend_").Append(p.ID.ToString()) .Append("\" value=\"").Append(p.DefaultValue).Append("\"/><span id=\"upload_") .Append(p.ID.ToString()).Append("\">选择文件</span>") .Append("<script type=\"text/javascript\">cms.propertyUpload(") .Append("'upload_").Append(p.ID.ToString()).Append("','extend_").Append(p.ID.ToString()).Append("');</script>"); } sb.Append("</dd></dl>"); /*<p><span class="txt">标签:</span> * <span class="input"><input type="text" name="tags" size="30"/></span> * <span class="msg"></span></p> */ } sb.Append("</div>"); extendFieldsHtml = sb.ToString(); // extendFieldsHtml = "<div style=\"color:red;padding:20px;\">所选栏目模块不包含任何自定义属性,如需添加请到模块管理-》属性设置</div>"; object json = new { Thumbnail = CmsVariables.FRAMEWORK_ARCHIVE_NoPhoto }; data = new { extendFieldsHtml = extendFieldsHtml, extendItemsHtml = extendItemsHtml, thumbPrefix = CmsVariables.Archive_ThumbPrefix, nodes = nodesHtml, url = Request.Url.PathAndQuery, tpls = tpls, json = JsonSerializer.Serialize(json) }; base.RenderTemplate(ResourceMap.GetPageContent(ManagementPage.Archive_Create), data); }
/// <summary> /// 更新文档 /// </summary> public void Update_GET() { object data; int archiveId = int.Parse(base.Request["archive.id"]); string tpls, nodesHtml, //栏目JSON extendFieldsHtml = "", //属性Html extendItemsHtml = ""; Module module; int siteId = this.CurrentSite.SiteId; ArchiveDto archive = ServiceCall.Instance.ArchiveService.GetArchiveById(siteId, archiveId); int categoryId = archive.Category.ID; #region 旧的 //获取上次发布的栏目 //Category category = CmsLogic.Category.Get(a => a.ID == archive.Category.ID); //if (base.CompareSite(category.SiteId)) return; //bool categoryIsNull = category == null; /* * if (!categoryIsNull) * { * * module = CmsLogic.Module.GetModule(category.ModuleID); * * //============= 拼接模块的属性值 ==============// * * StringBuilder sb = new StringBuilder(50); * IList<DataExtend> extends = null;// new List<DataExtend>(CmsLogic.DataExtend.GetExtendsByModule(module)); * * if (extends.Count > 0) * { * * //========= 统计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); * * * //======== 生成值 =============// * * IEnumerable<DataExtendAttr> attrs; * IDictionary<string, string> extendFields = null;// CmsLogic.DataExtend.GetExtendFiledDictionary(archive.ID); * string attrValue; * * foreach (DataExtend e in extends) * { * sb.Append("<div class=\"dataextend_item\">"); * * attrs = CmsLogic.DataExtend.GetExtendAttrs(e.ID); * * foreach (DataExtendAttr p in attrs) * { * * * attrValue = extendFields.ContainsKey(p.AttrName) ? extendFields[p.AttrName] : p.AttrVal; * * sb.Append("<dl><dt>").Append(p.AttrName).Append(":</dt><dd>"); * * if (p.AttrType == ((int)PropertyUI.Text).ToString()) * { * sb.Append("<input type=\"text\" class=\"tb_normal\" name=\"extend_").Append(p.ID.ToString()) * .Append("\" value=\"").Append(attrValue).Append("\"/>"); * } * else if (p.AttrType == ((int)PropertyUI.Upload).ToString()) * { * sb.Append("<input type=\"text\" disabled=\"disabled\" class=\"tb_normal\" id=\"extend_").Append(p.ID.ToString()).Append("\" name=\"extend_").Append(p.ID.ToString()) * .Append("\" value=\"").Append(attrValue).Append("\"/><span id=\"upload_") * .Append(p.ID.ToString()).Append("\">选择文件</span>") * .Append("<script type=\"text/javascript\">cms.propertyUpload(") * .Append("'upload_").Append(p.ID.ToString()).Append("','extend_").Append(p.ID.ToString()).Append("');</script>"); * } * * * sb.Append("</dd></dl>"); * * //<p><span class="txt">标签:</span> * // <span class="input"><input type="text" name="tags" size="30"/></span> * // <span class="msg"></span></p> * * } * * * sb.Append("</div>"); * } * * extendFieldsHtml = sb.ToString(); * } * * // extendFieldsHtml = "<div style=\"color:red;padding:20px;\">所选栏目模块不包含任何自定义属性,如需添加请到模块管理-》属性设置</div>"; * * } */ #endregion //============= 拼接模块的属性值 ==============// 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; sb.Append("<dl><dt>").Append(field.Name).Append(":</dt><dd>"); if (field.Type == ((int)PropertyUI.Text).ToString()) { sb.Append("<input type=\"text\" class=\"tb_normal\" field=\"extend_").Append(field.ID.ToString()) .Append("\" value=\"").Append(attrValue).Append("\"/>"); } else if (field.Type == ((int)PropertyUI.Upload).ToString()) { sb.Append("<input type=\"text\" disabled=\"disabled\" class=\"tb_normal\" id=\"extend_").Append(field.ID.ToString()) .Append("\" field=\"extend_").Append(field.ID.ToString()) .Append("\" value=\"").Append(attrValue).Append("\"/><span id=\"upload_") .Append(field.ID.ToString()).Append("\">选择文件</span>") .Append("<script type=\"text/javascript\">cms.propertyUpload(") .Append("'upload_").Append(field.ID.ToString()).Append("','extend_").Append(field.ID.ToString()) .Append("');</script>"); } sb.Append("</dd></dl>"); } sb.Append("</div>"); extendFieldsHtml = sb.ToString(); //获取模板视图下拉项 StringBuilder sb2 = new StringBuilder(); //模板目录 DirectoryInfo dir = new DirectoryInfo( String.Format("{0}templates/{1}", AppDomain.CurrentDomain.BaseDirectory, Settings.TPL_MultMode ? "" : base.CurrentSite.Tpl + "/" )); EachClass.EachTemplatePage(dir, sb2, TemplatePageType.Custom, TemplatePageType.Archive ); tpls = sb2.ToString(); sb2.Remove(0, sb2.Length); ServiceCall.Instance.SiteService.HandleCategoryTree(this.SiteId, 1, (_category, level) => { sb2.Append("<option value=\"").Append(_category.ID.ToString()).Append("\""); //if (_category.ModuleID != category.ModuleID) //{ // sb2.Append(" disabled=\"disabled\" class=\"disabled\""); //} sb2.Append(_category.ID == categoryId ? " selected=\"selected\"" : "").Append(">"); for (int i = 0; i < level; i++) { sb2.Append(CmsCharMap.Dot); } sb2.Append(_category.Name).Append("</option>"); }); nodesHtml = sb2.ToString(); //标签 Dictionary <string, bool> flags = ArchiveFlag.GetFlagsDict(archive.Flags); 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)], Id = archive.Id, Title = archive.Title, 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 }; data = new { extendFieldsHtml = extendFieldsHtml, extendItemsHtml = extendItemsHtml, 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); }
/// <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); }
/// <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); }