/// <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 Comment_GET() { string commentListHtml; int id = int.Parse(base.Request["archive.id"]); ArchiveDto archive = ServiceCall.Instance.ArchiveService.GetArchiveById(this.SiteId, id); bool desc = base.Request["desc"] == "true"; CategoryDto category = archive.Category; StringBuilder sb = new StringBuilder(); DataTable table = CmsLogic.Comment.GetArchiveComments(archive.StrId, desc); int i = 1; bool isGuest = false; string nickName, content, avatar; Match match; foreach (DataRow dr in table.Rows) { //筛选出游客的昵称和内容 if (dr["memberid"].ToString() != "0") { nickName = dr["nickname"].ToString(); content = dr["content"].ToString(); avatar = dr["avatar"].ToString(); isGuest = false; } else { content = dr["content"].ToString(); match = Regex.Match(content, "\\(u:'(?<user>.+?)'\\)"); if (match != null) { nickName = match.Groups["user"].Value; content = Regex.Replace(content, "\\(u:'(.+?)'\\)", String.Empty); } else { nickName = "游客"; } avatar = "?module=file&action=guestavatar"; isGuest = true; } sb.Append("<p class=\"comment\"><img src=\"").Append(avatar).Append("\" /><span class=\"time\">") .Append(String.Format("{0:yyyy-MM-dd HH:mm:ss}", dr["createdate"])).Append("</span><span class=\"details\"><a href=\"#\">") .Append(nickName).Append("</a><br />").Append(content).Append("</span><span class=\"floor\">") .Append(i.ToString()).Append("楼</span><span class=\"control\"><a href=\"javascript:;\" onclick=\"remove(this,'").Append(dr["id"].ToString()).Append("')\">删除</a></span></p>"); ++i; } commentListHtml = sb.Length == 0 ? "暂无评论!" : sb.ToString(); object data = new { archiveID = archive.StrId, archiveTitle = archive.Title, author = archive.Author, publishDate = String.Format("{0:yyyy-MM-dd HH:mm:ss}", archive.CreateDate), commentListHtml = commentListHtml }; base.RenderTemplate(ResourceMap.CommentList, 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 AppConfig_GET() { object data = new { license_name = Settings.License_NAME, license_key = Settings.License_KEY, site_domain = Request.Url.Host, sys_autowww = Settings.SYS_AUTOWWW, sys_admin_tag = Settings.SYS_ADMIN_TAG, db_prefix = Settings.DB_PREFIX, opti_IndexCacheSeconds = (Settings.Opti_IndexCacheSeconds / 60).ToString(), opti_ClientCacheSeconds = (Settings.Opti_ClientCacheSeconds / 60).ToString(), Opti_GC_Collect_Interval = (Settings.Opti_GC_Collect_Interval / 3600000), opti_debug = Settings.Opti_Debug, server_static = Settings.SERVER_STATIC, server_static_enabled = Settings.SERVER_STATIC_ENABLED, tpl_usefullpath = Settings.TPL_UseFullPath, tpl_usecompress = Settings.TPL_UseCompress }; base.RenderTemplate(ResourceMap.GetPageContent(ManagementPage.App_Config), new { json = JsonSerializer.Serialize(data) }); }