public void Page_Load(object sender, EventArgs e) { if (IsForbidden) { return; } PageUtils.CheckRequestParameter("siteId", "channelId"); var channelId = AuthRequest.GetQueryInt("channelId"); var contentId = AuthRequest.GetQueryInt("id"); ReturnUrl = StringUtils.ValueFromUrl(AuthRequest.GetQueryString("returnUrl")); if (string.IsNullOrEmpty(ReturnUrl)) { ReturnUrl = CmsPages.GetContentsUrl(SiteId, channelId); } _channelInfo = ChannelManager.GetChannelInfo(SiteId, channelId); _tableName = ChannelManager.GetTableName(SiteInfo, _channelInfo); ContentInfo contentInfo = null; _styleInfoList = TableStyleManager.GetContentStyleInfoList(SiteInfo, _channelInfo); if (!IsPermissions(contentId)) { return; } if (contentId > 0) { contentInfo = ContentManager.GetContentInfo(SiteInfo, _channelInfo, contentId); } var titleFormat = IsPostBack ? Request.Form[ContentAttribute.GetFormatStringAttributeName(ContentAttribute.Title)] : contentInfo?.GetString(ContentAttribute.GetFormatStringAttributeName(ContentAttribute.Title)); LtlTitleHtml.Text = ContentUtility.GetTitleHtml(titleFormat, AjaxCmsService.GetTitlesUrl(SiteId, _channelInfo.Id)); AcAttributes.SiteInfo = SiteInfo; AcAttributes.ChannelId = _channelInfo.Id; AcAttributes.ContentId = contentId; AcAttributes.StyleInfoList = _styleInfoList; if (!IsPostBack) { var pageTitle = contentId == 0 ? "添加内容" : "编辑内容"; LtlPageTitle.Text = pageTitle; if (HasChannelPermissions(_channelInfo.Id, ConfigManager.ChannelPermissions.ContentTranslate)) { PhTranslate.Visible = true; BtnTranslate.Attributes.Add("onclick", ModalChannelMultipleSelect.GetOpenWindowString(SiteId, true)); ETranslateContentTypeUtils.AddListItems(DdlTranslateType, true); ControlUtils.SelectSingleItem(DdlTranslateType, ETranslateContentTypeUtils.GetValue(ETranslateContentType.Copy)); } else { PhTranslate.Visible = false; } CblContentAttributes.Items.Add(new ListItem("置顶", ContentAttribute.IsTop)); CblContentAttributes.Items.Add(new ListItem("推荐", ContentAttribute.IsRecommend)); CblContentAttributes.Items.Add(new ListItem("热点", ContentAttribute.IsHot)); CblContentAttributes.Items.Add(new ListItem("醒目", ContentAttribute.IsColor)); TbAddDate.DateTime = DateTime.Now; TbAddDate.Now = true; var contentGroupNameList = ContentGroupManager.GetGroupNameList(SiteId); foreach (var groupName in contentGroupNameList) { var item = new ListItem(groupName, groupName); CblContentGroups.Items.Add(item); } BtnContentGroupAdd.Attributes.Add("onclick", ModalContentGroupAdd.GetOpenWindowString(SiteId)); LtlTags.Text = ContentUtility.GetTagsHtml(AjaxCmsService.GetTagsUrl(SiteId)); if (HasChannelPermissions(_channelInfo.Id, ConfigManager.ChannelPermissions.ContentCheck)) { PhStatus.Visible = true; int checkedLevel; var isChecked = CheckManager.GetUserCheckLevel(AuthRequest.AdminPermissionsImpl, SiteInfo, _channelInfo.Id, out checkedLevel); if (AuthRequest.IsQueryExists("contentLevel")) { checkedLevel = TranslateUtils.ToIntWithNagetive(AuthRequest.GetQueryString("contentLevel")); if (checkedLevel != CheckManager.LevelInt.NotChange) { isChecked = checkedLevel >= SiteInfo.Additional.CheckContentLevel; } } CheckManager.LoadContentLevelToEdit(DdlContentLevel, SiteInfo, contentInfo, isChecked, checkedLevel); } else { PhStatus.Visible = false; } BtnSubmit.Attributes.Add("onclick", InputParserUtils.GetValidateSubmitOnClickScript("myForm", true, "autoCheckKeywords()")); //自动检测敏感词 ClientScriptRegisterStartupScript("autoCheckKeywords", WebUtils.GetAutoCheckKeywordsScript(SiteInfo)); if (contentId == 0) { var attributes = TableStyleManager.GetDefaultAttributes(_styleInfoList); if (AuthRequest.IsQueryExists("isUploadWord")) { var isFirstLineTitle = AuthRequest.GetQueryBool("isFirstLineTitle"); var isFirstLineRemove = AuthRequest.GetQueryBool("isFirstLineRemove"); var isClearFormat = AuthRequest.GetQueryBool("isClearFormat"); var isFirstLineIndent = AuthRequest.GetQueryBool("isFirstLineIndent"); var isClearFontSize = AuthRequest.GetQueryBool("isClearFontSize"); var isClearFontFamily = AuthRequest.GetQueryBool("isClearFontFamily"); var isClearImages = AuthRequest.GetQueryBool("isClearImages"); var contentLevel = AuthRequest.GetQueryInt("contentLevel"); var fileName = AuthRequest.GetQueryString("fileName"); var formCollection = WordUtils.GetWordNameValueCollection(SiteId, isFirstLineTitle, isFirstLineRemove, isClearFormat, isFirstLineIndent, isClearFontSize, isClearFontFamily, isClearImages, fileName); attributes.Load(formCollection); TbTitle.Text = formCollection[ContentAttribute.Title]; } AcAttributes.Attributes = attributes; } else if (contentInfo != null) { TbTitle.Text = contentInfo.Title; TbTags.Text = contentInfo.Tags; var list = new List <string>(); if (contentInfo.IsTop) { list.Add(ContentAttribute.IsTop); } if (contentInfo.IsRecommend) { list.Add(ContentAttribute.IsRecommend); } if (contentInfo.IsHot) { list.Add(ContentAttribute.IsHot); } if (contentInfo.IsColor) { list.Add(ContentAttribute.IsColor); } ControlUtils.SelectMultiItems(CblContentAttributes, list); TbLinkUrl.Text = contentInfo.LinkUrl; TbAddDate.DateTime = contentInfo.AddDate; ControlUtils.SelectMultiItems(CblContentGroups, TranslateUtils.StringCollectionToStringList(contentInfo.GroupNameCollection)); AcAttributes.Attributes = contentInfo; } } else { AcAttributes.Attributes = new AttributesImpl(Request.Form); } //DataBind(); }