public void Page_Load(object sender, EventArgs e) { if (IsForbidden) { return; } PageUtils.CheckRequestParameter("siteId"); if (AuthRequest.IsQueryExists("isContent")) { _isContent = AuthRequest.GetQueryBool("isContent"); } if (_isContent) { BtnAddGroup.Text = " 新建内容组"; _idsDictionary = ContentUtility.GetIDsDictionary(Request.QueryString); } else { BtnAddGroup.Text = " 新建栏目组"; _channelIdArrayList = TranslateUtils.StringCollectionToIntList(AuthRequest.GetQueryString("ChannelIDCollection")); } if (!IsPostBack) { if (_isContent) { var contentGroupNameList = ContentGroupManager.GetGroupNameList(SiteId); foreach (var groupName in contentGroupNameList) { var item = new ListItem(groupName, groupName); CblGroupNameCollection.Items.Add(item); } var showPopWinString = ModalContentGroupAdd.GetOpenWindowString(SiteId); BtnAddGroup.Attributes.Add("onclick", showPopWinString); } else { var nodeGroupNameList = ChannelGroupManager.GetGroupNameList(SiteId); foreach (var groupName in nodeGroupNameList) { var item = new ListItem(groupName, groupName); CblGroupNameCollection.Items.Add(item); } var showPopWinString = ModalNodeGroupAdd.GetOpenWindowString(SiteId); BtnAddGroup.Attributes.Add("onclick", showPopWinString); } } }
public IHttpActionResult GetConfig() { try { var request = new RequestImpl(); var siteId = request.GetQueryInt("siteId"); var channelId = request.GetQueryInt("channelId"); if (!request.IsUserLoggin || !request.UserPermissionsImpl.HasChannelPermissions(siteId, channelId, ConfigManager.ChannelPermissions.ContentDelete)) { return(Unauthorized()); } var siteInfo = SiteManager.GetSiteInfo(siteId); if (siteInfo == null) { return(BadRequest("无法确定内容对应的站点")); } var channelInfo = ChannelManager.GetChannelInfo(siteId, channelId); if (channelInfo == null) { return(BadRequest("无法确定内容对应的栏目")); } var contentGroupNameList = ContentGroupManager.GetGroupNameList(siteId); return(Ok(new { Value = contentGroupNameList })); } catch (Exception ex) { LogUtils.AddErrorLog(ex); return(InternalServerError(ex)); } }
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(); }
public object GetContentAdd(RequestImpl request) { var requestSiteId = request.SiteId; var requestChannelId = request.ChannelId; var requestContentId = request.ContentId; var sites = new List <object>(); var channels = new List <object>(); object site = null; object channel = null; List <string> groupNames = null; List <string> tagNames = null; ContentInfo contentInfo = null; List <TableStyleInfo> styles = null; List <KeyValuePair <int, string> > checkedLevels = null; var checkedLevel = 0; if (request.IsUserLoggin) { SiteInfo siteInfo = null; ChannelInfo channelInfo = null; var siteIdList = request.UserPermissionsImpl.GetSiteIdList(); foreach (var siteId in siteIdList) { var permissionSiteInfo = SiteManager.GetSiteInfo(siteId); if (requestSiteId == siteId) { siteInfo = permissionSiteInfo; } sites.Add(new { permissionSiteInfo.Id, permissionSiteInfo.SiteName }); } if (siteInfo == null && siteIdList.Count > 0) { siteInfo = SiteManager.GetSiteInfo(siteIdList[0]); } if (siteInfo != null) { var channelIdList = request.UserPermissionsImpl.GetChannelIdList(siteInfo.Id, ConfigManager.ChannelPermissions.ContentAdd); foreach (var permissionChannelId in channelIdList) { var permissionChannelInfo = ChannelManager.GetChannelInfo(siteInfo.Id, permissionChannelId); if (channelInfo == null || permissionChannelInfo.Id == requestChannelId) { channelInfo = permissionChannelInfo; } channels.Add(new { permissionChannelInfo.Id, ChannelName = ChannelManager.GetChannelNameNavigation(siteInfo.Id, permissionChannelId) }); } site = new { siteInfo.Id, siteInfo.SiteName, SiteUrl = PageUtility.GetSiteUrl(siteInfo, false) }; groupNames = ContentGroupManager.GetGroupNameList(siteInfo.Id); tagNames = ContentTagManager.GetTagNameList(siteInfo.Id); } if (channelInfo != null) { channel = new { channelInfo.Id, ChannelName = ChannelManager.GetChannelNameNavigation(siteInfo.Id, channelInfo.Id) }; styles = TableStyleManager.GetContentStyleInfoList(siteInfo, channelInfo); var checkKeyValuePair = CheckManager.GetUserCheckLevel(request.AdminPermissionsImpl, siteInfo, siteInfo.Id); checkedLevels = CheckManager.GetCheckedLevels(siteInfo, checkKeyValuePair.Key, checkedLevel, true); if (requestContentId != 0) { checkedLevels.Insert(0, new KeyValuePair <int, string>(CheckManager.LevelInt.NotChange, CheckManager.Level.NotChange)); checkedLevel = CheckManager.LevelInt.NotChange; contentInfo = ContentManager.GetContentInfo(siteInfo, channelInfo, requestContentId); if (contentInfo != null && (contentInfo.SiteId != siteInfo.Id || contentInfo.ChannelId != channelInfo.Id)) { contentInfo = null; } } else { contentInfo = new ContentInfo(new { Id = 0, SiteId = siteInfo.Id, ChannelId = channelInfo.Id, AddDate = DateTime.Now }); } } } return(new { Value = request.UserInfo, Config = ConfigManager.Instance.SystemConfigInfo, Sites = sites, Channels = channels, Site = site, Channel = channel, AllGroupNames = groupNames, AllTagNames = tagNames, Styles = styles, CheckedLevels = checkedLevels, CheckedLevel = checkedLevel, Content = contentInfo, }); }