public void Page_Load(object sender, EventArgs e) { if (IsForbidden) { return; } if (Body.IsQueryExists("Delete")) { var userIdList = TranslateUtils.StringCollectionToIntList(Body.GetQueryString("UserIDCollection")); try { foreach (var userId in userIdList) { BaiRongDataProvider.UserDao.Delete(userId); } Body.AddAdminLog("删除用户", string.Empty); SuccessDeleteMessage(); } catch (Exception ex) { FailDeleteMessage(ex); } } else if (Body.IsQueryExists("Lock")) { var userIdList = TranslateUtils.StringCollectionToIntList(Body.GetQueryString("UserIDCollection")); try { BaiRongDataProvider.UserDao.Lock(userIdList); Body.AddAdminLog("锁定用户", string.Empty); SuccessMessage("成功锁定所选会员!"); } catch (Exception ex) { FailMessage(ex, "锁定所选会员失败!"); } } else if (Body.IsQueryExists("UnLock")) { var userIdList = TranslateUtils.StringCollectionToIntList(Body.GetQueryString("UserIDCollection")); try { BaiRongDataProvider.UserDao.UnLock(userIdList); Body.AddAdminLog("解除锁定用户", string.Empty); SuccessMessage("成功解除锁定所选会员!"); } catch (Exception ex) { FailMessage(ex, "解除锁定所选会员失败!"); } } SpContents.ControlToPaginate = RptContents; if (string.IsNullOrEmpty(Body.GetQueryString("GroupID"))) { SpContents.ItemsPerPage = TranslateUtils.ToInt(DdlPageNum.SelectedValue) == 0 ? 25 : TranslateUtils.ToInt(DdlPageNum.SelectedValue); SpContents.SelectCommand = BaiRongDataProvider.UserDao.GetSelectCommandAll(true, Body.GetQueryInt("UserTypeId")); } else { SpContents.ItemsPerPage = Body.GetQueryInt("PageNum") == 0 ? StringUtils.Constants.PageSize : Body.GetQueryInt("PageNum"); SpContents.SelectCommand = BaiRongDataProvider.UserDao.GetSelectCommandAll(Body.GetQueryString("Keyword"), Body.GetQueryInt("CreationDate"), Body.GetQueryInt("LastActivityDate"), true, Body.GetQueryInt("GroupID"), Body.GetQueryInt("LoginCount"), Body.GetQueryString("SearchType"), Body.GetQueryInt("TypeId")); } RptContents.ItemDataBound += rptContents_ItemDataBound; SpContents.SortField = BaiRongDataProvider.UserDao.GetSortFieldName(); SpContents.SortMode = SortMode.DESC; _lockType = EUserLockTypeUtils.GetEnumType(ConfigManager.UserConfigInfo.LoginLockingType); if (IsPostBack) { return; } BreadCrumbUser(AppManager.User.LeftMenu.UserManagement, "用户管理", AppManager.User.Permission.UserManagement); var theListItem = new ListItem("全部", "0") { Selected = true }; DdlGroup.Items.Add(theListItem); var groupInfoList = UserGroupManager.GetGroupInfoList(); foreach (var userGroupInfo in groupInfoList) { var listitem = new ListItem(userGroupInfo.GroupName, userGroupInfo.GroupId.ToString()); DdlGroup.Items.Add(listitem); } //添加隐藏属性 DdlSearchType.Items.Add(new ListItem("用户ID", "userID")); DdlSearchType.Items.Add(new ListItem("用户名", "userName")); DdlSearchType.Items.Add(new ListItem("邮箱", "email")); DdlSearchType.Items.Add(new ListItem("手机", "mobile")); //默认选择用户名 DdlSearchType.SelectedValue = "userName"; if (!string.IsNullOrEmpty(Body.GetQueryString("SearchType"))) { ControlUtils.SelectListItems(DdlSearchType, Body.GetQueryString("SearchType")); } if (!string.IsNullOrEmpty(Body.GetQueryString("GroupID"))) { ControlUtils.SelectListItems(DdlGroup, Body.GetQueryString("GroupID")); } if (!string.IsNullOrEmpty(Body.GetQueryString("PageNum"))) { ControlUtils.SelectListItems(DdlPageNum, Body.GetQueryString("PageNum")); } if (!string.IsNullOrEmpty(Body.GetQueryString("LoginCount"))) { ControlUtils.SelectListItems(DdlLoginCount, Body.GetQueryString("LoginCount")); } if (!string.IsNullOrEmpty(Body.GetQueryString("Keyword"))) { TbKeyword.Text = Body.GetQueryString("Keyword"); } if (!string.IsNullOrEmpty(Body.GetQueryString("CreationDate"))) { ControlUtils.SelectListItems(DdlCreationDate, Body.GetQueryString("CreationDate")); } if (!string.IsNullOrEmpty(Body.GetQueryString("LastActivityDate"))) { ControlUtils.SelectListItems(DdlLastActivityDate, Body.GetQueryString("LastActivityDate")); } var showPopWinString = ModalAddToUserGroup.GetOpenWindowString(); // BtnAddToGroup.Attributes.Add("onclick", showPopWinString); var backgroundUrl = GetRedirectUrl(); BtnAdd.Attributes.Add("onclick", $"location.href='{PageUserAdd.GetRedirectUrlToAdd(PageUrl)}';return false;"); BtnLock.Attributes.Add("onclick", PageUtils.GetRedirectStringWithCheckBoxValueAndAlert( $"{backgroundUrl}?Lock=True", "UserIDCollection", "UserIDCollection", "请选择需要锁定的会员!", "此操作将锁定所选会员,确认吗?")); BtnUnLock.Attributes.Add("onclick", PageUtils.GetRedirectStringWithCheckBoxValueAndAlert( $"{backgroundUrl}?UnLock=True", "UserIDCollection", "UserIDCollection", "请选择需要解除锁定的会员!", "此操作将解除锁定所选会员,确认吗?")); BtnDelete.Attributes.Add("onclick", PageUtils.GetRedirectStringWithCheckBoxValueAndAlert( $"{backgroundUrl}?Delete=True", "UserIDCollection", "UserIDCollection", "请选择需要删除的会员!", "此操作将删除所选会员,确认吗?")); //BtnImport.Attributes.Add("onclick", ModalUserImport.GetOpenWindowString()); //BtnExport.Attributes.Add("onclick", ModalUserExport.GetOpenWindowString()); SpContents.DataBind(); }
public void Page_Load(object sender, EventArgs e) { if (IsForbidden) { return; } PageUtils.CheckRequestParameter("siteId", "channelId", "ReturnUrl"); _channelId = AuthRequest.GetQueryInt("channelId"); _returnUrl = StringUtils.ValueFromUrl(AuthRequest.GetQueryString("ReturnUrl")); CacAttributes.SiteInfo = SiteInfo; CacAttributes.ChannelId = _channelId; if (!IsPostBack) { if (!HasChannelPermissions(_channelId, ConfigManager.ChannelPermissions.ChannelEdit)) { PageUtils.RedirectToErrorPage("您没有修改栏目的权限!"); return; } var nodeInfo = ChannelManager.GetChannelInfo(SiteId, _channelId); if (nodeInfo == null) { return; } if (nodeInfo.ParentId == 0) { PhLinkUrl.Visible = false; PhLinkType.Visible = false; PhChannelTemplateId.Visible = false; PhFilePath.Visible = false; } BtnSubmit.Attributes.Add("onclick", $"if (UE && UE.getEditor('Content', {ETextEditorTypeUtils.ConfigValues})){{ UE.getEditor('Content', {ETextEditorTypeUtils.ConfigValues}).sync(); }}"); CacAttributes.Attributes = nodeInfo.Additional; if (PhLinkType.Visible) { ELinkTypeUtils.AddListItems(DdlLinkType); } ETaxisTypeUtils.AddListItemsForChannelEdit(DdlTaxisType); CblNodeGroupNameCollection.DataSource = DataProvider.ChannelGroupDao.GetDataSource(SiteId); if (PhChannelTemplateId.Visible) { DdlChannelTemplateId.DataSource = DataProvider.TemplateDao.GetDataSourceByType(SiteId, TemplateType.ChannelTemplate); } DdlContentTemplateId.DataSource = DataProvider.TemplateDao.GetDataSourceByType(SiteId, TemplateType.ContentTemplate); DataBind(); if (PhChannelTemplateId.Visible) { DdlChannelTemplateId.Items.Insert(0, new ListItem("<未设置>", "0")); ControlUtils.SelectSingleItem(DdlChannelTemplateId, nodeInfo.ChannelTemplateId.ToString()); } DdlContentTemplateId.Items.Insert(0, new ListItem("<未设置>", "0")); ControlUtils.SelectSingleItem(DdlContentTemplateId, nodeInfo.ContentTemplateId.ToString()); TbNodeName.Text = nodeInfo.ChannelName; TbNodeIndexName.Text = nodeInfo.IndexName; if (PhLinkUrl.Visible) { TbLinkUrl.Text = nodeInfo.LinkUrl; } foreach (ListItem item in CblNodeGroupNameCollection.Items) { item.Selected = StringUtils.In(nodeInfo.GroupNameCollection, item.Value); } if (PhFilePath.Visible) { TbFilePath.Text = nodeInfo.FilePath; } if (PhLinkType.Visible) { ControlUtils.SelectSingleItem(DdlLinkType, nodeInfo.LinkType); } ControlUtils.SelectSingleItem(DdlTaxisType, nodeInfo.Additional.DefaultTaxisType); TbImageUrl.Text = nodeInfo.ImageUrl; LtlImageUrlButtonGroup.Text = WebUtils.GetImageUrlButtonGroupHtml(SiteInfo, TbImageUrl.ClientID); TbContent.SetParameters(SiteInfo, ChannelAttribute.Content, nodeInfo.Content); if (TbKeywords.Visible) { TbKeywords.Text = nodeInfo.Keywords; } if (TbDescription.Visible) { TbDescription.Text = nodeInfo.Description; } } else { CacAttributes.Attributes = new ExtendedAttributes(Request.Form); } }
public static string Parse(string stlElement, XmlNode node, PageInfo pageInfo, ContextInfo contextInfoRef) { string parsedContent; var contextInfo = contextInfoRef.Clone(); try { var stlAnchor = new HtmlAnchor(); var type = TypeNextContent; var emptyText = string.Empty; var tipText = string.Empty; var wordNum = 0; var isDynamic = false; var isKeyboard = false; var ie = node.Attributes?.GetEnumerator(); if (ie != null) { while (ie.MoveNext()) { var attr = (XmlAttribute)ie.Current; if (StringUtils.EqualsIgnoreCase(attr.Name, AttributeType)) { type = attr.Value; } else if (StringUtils.EqualsIgnoreCase(attr.Name, AttributeEmptyText)) { emptyText = attr.Value; } else if (StringUtils.EqualsIgnoreCase(attr.Name, AttributeTipText)) { tipText = attr.Value; } else if (StringUtils.EqualsIgnoreCase(attr.Name, AttributeWordNum)) { wordNum = TranslateUtils.ToInt(attr.Value); } else if (StringUtils.EqualsIgnoreCase(attr.Name, AttributeIsDynamic)) { isDynamic = TranslateUtils.ToBool(attr.Value); } else if (StringUtils.EqualsIgnoreCase(attr.Name, AttributeIsKeyboard)) { isKeyboard = TranslateUtils.ToBool(attr.Value); } else { ControlUtils.AddAttributeIfNotExists(stlAnchor, attr.Name, attr.Value); } } } parsedContent = isDynamic ? StlDynamic.ParseDynamicElement(stlElement, pageInfo, contextInfo) : ParseImpl(node, pageInfo, contextInfo, stlAnchor, type, emptyText, tipText, wordNum, isKeyboard); } catch (Exception ex) { parsedContent = StlParserUtility.GetStlErrorMessage(ElementName, ex); } return(parsedContent); }
private void tmiCentreImage_Click(object sender, EventArgs e) { var panPctBox = ControlUtils.GetToolStripSourceControl(sender) as PannablePictureBox; panPctBox?.CenterImage(); }
public void Page_Load(object sender, EventArgs e) { if (IsForbidden) { return; } PageUtils.CheckRequestParameter("siteId"); _templateType = AuthRequest.GetQueryString("templateType"); _keywords = AuthRequest.GetQueryString("keywords"); if (IsPostBack) { return; } VerifySitePermissions(ConfigManager.SitePermissions.Templates); DdlTemplateType.Items.Add(new ListItem("<所有类型>", string.Empty)); TemplateTypeUtils.AddListItems(DdlTemplateType); ControlUtils.SelectSingleItem(DdlTemplateType, _templateType); TbKeywords.Text = _keywords; if (AuthRequest.IsQueryExists("Delete")) { var templateId = AuthRequest.GetQueryInt("TemplateID"); try { var templateInfo = TemplateManager.GetTemplateInfo(SiteId, templateId); if (templateInfo != null) { DataProvider.TemplateDao.Delete(SiteId, templateId); AuthRequest.AddSiteLog(SiteId, $"删除{TemplateTypeUtils.GetText(templateInfo.TemplateType)}", $"模板名称:{templateInfo.TemplateName}"); } SuccessDeleteMessage(); } catch (Exception ex) { FailDeleteMessage(ex); } } else if (AuthRequest.IsQueryExists("SetDefault")) { var templateId = AuthRequest.GetQueryInt("TemplateID"); try { var templateInfo = TemplateManager.GetTemplateInfo(SiteId, templateId); if (templateInfo != null) { DataProvider.TemplateDao.SetDefault(SiteId, templateId); AuthRequest.AddSiteLog(SiteId, $"设置默认{TemplateTypeUtils.GetText(templateInfo.TemplateType)}", $"模板名称:{templateInfo.TemplateName}"); } SuccessMessage(); } catch (Exception ex) { FailMessage(ex, "操作失败"); } } if (string.IsNullOrEmpty(_templateType)) { LtlCommands.Text = $@" <input type=""button"" class=""btn"" onclick=""location.href='{PageTemplateAdd.GetRedirectUrl(SiteId, 0, TemplateType.IndexPageTemplate)}';"" value=""添加首页模板"" /> <input type=""button"" class=""btn"" onclick=""location.href='{PageTemplateAdd.GetRedirectUrl(SiteId, 0, TemplateType.ChannelTemplate)}';"" value=""添加栏目模板"" /> <input type=""button"" class=""btn"" onclick=""location.href='{PageTemplateAdd.GetRedirectUrl(SiteId, 0, TemplateType.ContentTemplate)}';"" value=""添加内容模板"" /> <input type=""button"" class=""btn"" onclick=""location.href='{PageTemplateAdd.GetRedirectUrl(SiteId, 0, TemplateType.FileTemplate)}';"" value=""添加单页模板"" /> "; } else { var templateType = TemplateTypeUtils.GetEnumType(_templateType); LtlCommands.Text = $@" <input type=""button"" class=""btn btn-success"" onclick=""location.href='{PageTemplateAdd.GetRedirectUrl(SiteId, 0, templateType)}';"" value=""添加{TemplateTypeUtils.GetText(templateType)}"" /> "; } RptContents.DataSource = DataProvider.TemplateDao.GetDataSource(SiteId, _keywords, _templateType); RptContents.ItemDataBound += RptContents_ItemDataBound; RptContents.DataBind(); }
private string ParseTopics(string Template, DataTable Topics, string Section) { string sOutput = Template; sOutput = TemplateUtils.GetTemplateSection(Template, "[" + Section + "]", "[/" + Section + "]"); string sTopics = string.Empty; string MemberListMode = MainSettings.MemberListMode; var ProfileVisibility = MainSettings.ProfileVisibility; string UserNameDisplay = MainSettings.UserNameDisplay; bool DisableUserProfiles = false; string sLastReply = TemplateUtils.GetTemplateSection(sOutput, "[LASTPOST]", "[/LASTPOST]"); int iLength = 0; if (sLastReply.Contains("[LASTPOSTSUBJECT:")) { int inStart = (sLastReply.IndexOf("[LASTPOSTSUBJECT:", 0) + 1) + 17; int inEnd = (sLastReply.IndexOf("]", inStart - 1) + 1); string sLength = sLastReply.Substring(inStart - 1, inEnd - inStart); iLength = Convert.ToInt32(sLength); } int rowcount = 0; LastReplySubjectReplaceTag = "[LASTPOSTSUBJECT:" + iLength.ToString() + "]"; if (Topics == null) { sOutput = TemplateUtils.ReplaceSubSection(Template, string.Empty, "[" + Section + "]", "[/" + Section + "]"); return sOutput; } if (Topics.Rows.Count > 0) { foreach (DataRow drTopic in Topics.Rows) { string sTopicsTemplate = sOutput; int TopicId = Convert.ToInt32(drTopic["TopicId"]); string Subject = Convert.ToString(drTopic["Subject"]); string Summary = Convert.ToString(drTopic["Summary"]); string Body = Convert.ToString(drTopic["Body"]); //Strip comments int AuthorId = Convert.ToInt32(drTopic["AuthorId"]); string AuthorName = Convert.ToString(drTopic["AuthorName"]).ToString().Replace("&#", "&#"); string AuthorFirstName = Convert.ToString(drTopic["AuthorFirstName"]).ToString().Replace("&#", "&#"); string AuthorLastName = Convert.ToString(drTopic["AuthorLastName"]).ToString().Replace("&#", "&#"); string AuthorUserName = Convert.ToString(drTopic["AuthorUserName"]); if (AuthorUserName == string.Empty) { AuthorUserName = AuthorName; } string AuthorDisplayName = Convert.ToString(drTopic["AuthorDisplayName"]).ToString().Replace("&#", "&#"); int ReplyCount = Convert.ToInt32(drTopic["ReplyCount"]); int ViewCount = Convert.ToInt32(drTopic["ViewCount"]); DateTime DateCreated = Convert.ToDateTime(drTopic["DateCreated"]); int StatusId = Convert.ToInt32(drTopic["StatusId"]); //LastReply info int LastReplyId = Convert.ToInt32(drTopic["LastReplyId"]); string LastReplySubject = Convert.ToString(drTopic["LastReplySubject"]); if (LastReplySubject == "") { LastReplySubject = "RE: " + Subject; } string LastReplySummary = Convert.ToString(drTopic["LastReplySummary"]); if (LastReplySummary == "") { LastReplySummary = Summary; } int LastReplyAuthorId = Convert.ToInt32(drTopic["LastReplyAuthorId"]); string LastReplyAuthorName = Convert.ToString(drTopic["LastReplyAuthorName"]).ToString().Replace("&#", "&#"); string LastReplyFirstName = Convert.ToString(drTopic["LastReplyFirstName"]).ToString().Replace("&#", "&#"); string LastReplyLastName = Convert.ToString(drTopic["LastReplyLastName"]).ToString().Replace("&#", "&#"); string LastReplyUserName = Convert.ToString(drTopic["LastReplyUserName"]); string LastReplyDisplayName = Convert.ToString(drTopic["LastReplyDisplayName"]).ToString().Replace("&#", "&#"); DateTime LastReplyDate = Convert.ToDateTime(drTopic["LastReplyDate"]); int UserLastTopicRead = Convert.ToInt32(drTopic["UserLastTopicRead"]); int UserLastReplyRead = Convert.ToInt32(drTopic["UserLastReplyRead"]); bool isLocked = Convert.ToBoolean(drTopic["IsLocked"]); bool isPinned = Convert.ToBoolean(drTopic["IsPinned"]); string TopicURL = drTopic["TopicURL"].ToString(); string topicData = drTopic["TopicData"].ToString(); if (isLocked) { sTopicsTemplate = sTopicsTemplate.Replace("[RESX:LockTopic]", "[RESX:UnLockTopic]"); sTopicsTemplate = sTopicsTemplate.Replace("[RESX:Confirm:Lock]", "[RESX:Confirm:UnLock]"); } if (isPinned) { sTopicsTemplate = sTopicsTemplate.Replace("[RESX:PinTopic]", "[RESX:UnPinTopic]"); sTopicsTemplate = sTopicsTemplate.Replace("[RESX:Confirm:Pin]", "[RESX:Confirm:UnPin]"); } if (string.IsNullOrEmpty(topicData)) { sTopicsTemplate = TemplateUtils.ReplaceSubSection(sTopicsTemplate, string.Empty, "[AF:PROPERTIES]", "[/AF:PROPERTIES]"); } else { string sPropTemplate = TemplateUtils.GetTemplateSection(sTopicsTemplate, "[AF:PROPERTIES]", "[/AF:PROPERTIES]"); string sProps = string.Empty; XmlDocument xDoc = new XmlDocument(); xDoc.LoadXml(topicData); if (xDoc != null) { System.Xml.XmlNode xRoot = xDoc.DocumentElement; System.Xml.XmlNodeList xNodeList = xRoot.SelectNodes("//properties/property"); if (xNodeList.Count > 0) { int i = 0; for (i = 0; i < xNodeList.Count; i++) { string tmp = sPropTemplate; string pName = Utilities.HTMLDecode(xNodeList[i].ChildNodes[0].InnerText); string pValue = Utilities.HTMLDecode(xNodeList[i].ChildNodes[1].InnerText); tmp = tmp.Replace("[AF:PROPERTY:LABEL]", Utilities.GetSharedResource("[RESX:" + pName + "]")); tmp = tmp.Replace("[AF:PROPERTY:VALUE]", pValue); sTopicsTemplate = sTopicsTemplate.Replace("[AF:PROPERTY:" + pName + ":LABEL]", Utilities.GetSharedResource("[RESX:" + pName + "]")); sTopicsTemplate = sTopicsTemplate.Replace("[AF:PROPERTY:" + pName + ":VALUE]", pValue); string pValueKey = string.Empty; if (!(string.IsNullOrEmpty(pValue))) { pValueKey = Utilities.CleanName(pValue).ToLowerInvariant(); } sTopicsTemplate = sTopicsTemplate.Replace("[AF:PROPERTY:" + pName + ":VALUEKEY]", pValueKey); sProps += tmp; } } if (sTopicsTemplate.Contains("[AF:PROPERTY:")) { } } sTopicsTemplate = TemplateUtils.ReplaceSubSection(sTopicsTemplate, sProps, "[AF:PROPERTIES]", "[/AF:PROPERTIES]"); } sTopicsTemplate = sTopicsTemplate.Replace("[TOPICID]", TopicId.ToString()); sTopicsTemplate = sTopicsTemplate.Replace("[AUTHORID]", AuthorId.ToString()); sTopicsTemplate = sTopicsTemplate.Replace("[FORUMID]", ForumId.ToString()); sTopicsTemplate = sTopicsTemplate.Replace("[USERID]", UserId.ToString()); sTopicsTemplate = sTopicsTemplate.Replace("[POSTICON]", GetIcon(UserLastTopicRead, UserLastReplyRead, TopicId, LastReplyId, drTopic["TopicIcon"].ToString(), isPinned, isLocked)); if (!(string.IsNullOrEmpty(Summary))) { if (!(Utilities.HasHTML(Summary))) { Summary = Summary.Replace(System.Environment.NewLine, "<br />"); } } string sBodyTitle = string.Empty; if (bRead) { sBodyTitle = GetTitle(Body, AuthorId); } sTopicsTemplate = sTopicsTemplate.Replace("[BODYTITLE]", sBodyTitle); sTopicsTemplate = sTopicsTemplate.Replace("[BODY]", GetBody(Body, AuthorId)); int BodyLength = -1; string BodyTrim = string.Empty; if (Template.Contains("[BODY:")) { int inStart = (Template.IndexOf("[BODY:", 0) + 1) + 5; int inEnd = (Template.IndexOf("]", inStart - 1) + 1) - 1; string sLength = Template.Substring(inStart, inEnd - inStart); BodyLength = Convert.ToInt32(sLength); BodyTrim = "[BODY:" + BodyLength.ToString() + "]"; } string BodyPlain = string.Empty; if (string.IsNullOrEmpty(Summary) && sTopicsTemplate.Contains("[SUMMARY]") && string.IsNullOrEmpty(BodyTrim)) { BodyTrim = "[BODY:250]"; BodyLength = 250; } if (!(BodyTrim == string.Empty)) { BodyPlain = Body.Replace("<br>", System.Environment.NewLine); BodyPlain = BodyPlain.Replace("<br />", System.Environment.NewLine); BodyPlain = Utilities.StripHTMLTag(BodyPlain); if (BodyLength > 0 & BodyPlain.Length > BodyLength) { BodyPlain = BodyPlain.Substring(0, BodyLength); } BodyPlain = BodyPlain.Replace(System.Environment.NewLine, "<br />"); sTopicsTemplate = sTopicsTemplate.Replace(BodyTrim, BodyPlain); } if (string.IsNullOrEmpty(Summary)) { Summary = BodyPlain; Summary = Summary.Replace("<br />", " "); } sTopicsTemplate = sTopicsTemplate.Replace("[SUMMARY]", Summary); string sPollImage = ""; if (Convert.ToInt32(drTopic["TopicType"]) == 1) { sPollImage = "<img src=\"" + MyThemePath + "/images/poll.png\" style=\"vertical-align:middle;\" alt=\"[RESX:Poll]\" />"; } string sTopicURL = string.Empty; ControlUtils ctlUtils = new ControlUtils(); sTopicURL = ctlUtils.BuildUrl(ForumTabId, ForumModuleId, ForumInfo.ForumGroup.PrefixURL, ForumInfo.PrefixURL, ForumGroupId, ForumId, TopicId, TopicURL, -1, -1, string.Empty, 1, -1, SocialGroupId); var @params = new List<string> { ParamKeys.TopicId + "=" + TopicId, ParamKeys.ContentJumpId + "=" + LastReplyId }; if (SocialGroupId > 0) @params.Add("GroupId=" + SocialGroupId.ToString()); string sLastReplyURL = NavigateUrl(TabId, "", @params.ToArray()); if (!(string.IsNullOrEmpty(sTopicURL))) { if (sTopicURL.EndsWith("/")) { sLastReplyURL = sTopicURL + "?" + ParamKeys.ContentJumpId + "=" + LastReplyId; } } string sLastReadURL = string.Empty; string sUserJumpUrl = string.Empty; if (UserLastReplyRead > 0) { @params = new List<string> { ParamKeys.ForumId + "=" + ForumId, ParamKeys.TopicId + "=" + TopicId, ParamKeys.ViewType + "=topic", ParamKeys.FirstNewPost + "=" + UserLastReplyRead }; if (SocialGroupId > 0) @params.Add("GroupId=" + SocialGroupId.ToString()); sLastReadURL = NavigateUrl(TabId, "", @params.ToArray()); if (MainSettings.UseShortUrls) { @params = new List<string> { ParamKeys.TopicId + "=" + TopicId, ParamKeys.FirstNewPost + "=" + UserLastReplyRead }; if (SocialGroupId > 0) @params.Add("GroupId=" + SocialGroupId.ToString()); sLastReadURL = NavigateUrl(TabId, "", @params.ToArray()); } if (sTopicURL.EndsWith("/")) { sLastReadURL = sTopicURL + "?" + ParamKeys.FirstNewPost + "=" + UserLastReplyRead; } } if (UserPrefJumpLastPost && sLastReadURL != string.Empty) { sTopicURL = sLastReadURL; sUserJumpUrl = sLastReadURL; } if (UserId == -1 || LastReplyId == 0) { sTopicsTemplate = sTopicsTemplate.Replace("[AF:ICONLINK:LASTREAD]", string.Empty); sTopicsTemplate = sTopicsTemplate.Replace("[AF:URL:LASTREAD]", string.Empty); } else { if ((UserLastTopicRead >= TopicId || UserLastTopicRead == 0) & (UserLastReplyRead >= LastReplyId || UserLastReplyRead == 0)) { sTopicsTemplate = sTopicsTemplate.Replace("[AF:ICONLINK:LASTREAD]", string.Empty); sTopicsTemplate = sTopicsTemplate.Replace("[AF:URL:LASTREAD]", string.Empty); } else { sTopicsTemplate = sTopicsTemplate.Replace("[AF:ICONLINK:LASTREAD]", "<a href=\"" + sLastReadURL + "\" rel=\"nofollow\"><img src=\"" + MyThemePath + "/images/miniarrow_down.png\" style=\"vertical-align:middle;\" alt=\"[RESX:JumpToLastRead]\" border=\"0\" class=\"afminiarrow\" /></a>"); sTopicsTemplate = sTopicsTemplate.Replace("[AF:URL:LASTREAD]", sLastReadURL); } } if (LastReplyId > 0 && bRead) { sTopicsTemplate = sTopicsTemplate.Replace("[AF:ICONLINK:LASTREPLY]", "<a href=\"" + sLastReplyURL + "\" rel=\"nofollow\"><img src=\"" + MyThemePath + "/images/miniarrow_right.png\" style=\"vertical-align:middle;\" alt=\"[RESX:JumpToLastReply]\" border=\"0\" class=\"afminiarrow\" /></a>"); sTopicsTemplate = sTopicsTemplate.Replace("[AF:URL:LASTREPLY]", sLastReplyURL); sTopicsTemplate = sTopicsTemplate.Replace("[AF:UI:MINIPAGER]", GetSubPages(TabId, ModuleId, ReplyCount, ForumId, TopicId)); } else { sTopicsTemplate = sTopicsTemplate.Replace("[AF:ICONLINK:LASTREPLY]", string.Empty); sTopicsTemplate = sTopicsTemplate.Replace("[AF:URL:LASTREPLY]", string.Empty); sTopicsTemplate = sTopicsTemplate.Replace("[AF:UI:MINIPAGER]", string.Empty); } sTopicsTemplate = sTopicsTemplate.Replace("[TOPICURL]", sTopicURL); Subject = Utilities.StripHTMLTag(Subject); Subject = Subject.Replace("[", "["); Subject = Subject.Replace("]", "]"); sTopicsTemplate = sTopicsTemplate.Replace("[SUBJECT]", sPollImage + Subject); //sTopicsTemplate = sTopicsTemplate.Replace("[SUBJECTLINK]", sPollImage & GetTopic(ModuleId, TabId, ForumId, TopicId, Subject, sBodyTitle, UserId, AuthorId, ReplyCount, -1, sUserJumpUrl)) sTopicsTemplate = sTopicsTemplate.Replace("[SUBJECTLINK]", sPollImage + GetTopic(ModuleId, TabId, ForumId, TopicId, Subject, sBodyTitle, UserId, AuthorId, ReplyCount, -1, sTopicURL)); sTopicsTemplate = sTopicsTemplate.Replace("[STARTEDBY]", UserProfiles.GetDisplayName(ModuleId, true, bModApprove, ForumUser.IsAdmin || ForumUser.IsSuperUser, AuthorId, AuthorUserName, AuthorFirstName, AuthorLastName, AuthorDisplayName).ToString().Replace("&#", "&#")); sTopicsTemplate = sTopicsTemplate.Replace("[DATECREATED]", GetDate(DateCreated)); sTopicsTemplate = sTopicsTemplate.Replace("[REPLIES]", ReplyCount.ToString()); sTopicsTemplate = sTopicsTemplate.Replace("[VIEWS]", ViewCount.ToString()); sTopicsTemplate = sTopicsTemplate.Replace("[ROWCSS]", GetRowCSS(UserLastTopicRead, UserLastReplyRead, TopicId, LastReplyId, rowcount)); if (Convert.ToInt32(drTopic["TopicRating"]) == 0) { sTopicsTemplate = sTopicsTemplate.Replace("[POSTRATINGDISPLAY]", string.Empty); } else { string sRatingImage = null; //sRatingImage = "<img src=""" & MyThemePath & "/yellow_star_0" & drTopic("TopicRating").ToString & ".gif"" alt=""" & drTopic("TopicRating").ToString & """ />" sRatingImage = "<span class=\"af-rater rate" + drTopic["TopicRating"].ToString() + "\"> </span>"; sTopicsTemplate = sTopicsTemplate.Replace("[POSTRATINGDISPLAY]", sRatingImage); } if (sTopicsTemplate.Contains("[STATUS]")) { string sImg = string.Empty; if (StatusId == -1) { sTopicsTemplate = sTopicsTemplate.Replace("[STATUS]", string.Empty); } else { sImg = "<img alt=\"[RESX:PostStatus" + StatusId.ToString() + "]\" src=\"" + MyThemePath + "/images/status" + StatusId.ToString() + ".png\" />"; } sTopicsTemplate = sTopicsTemplate.Replace("[STATUS]", sImg); } if (sTopicsTemplate.Contains("[LASTPOST]")) { if (LastReplyId == 0) { sTopicsTemplate = TemplateUtils.ReplaceSubSection(sTopicsTemplate, GetDate(LastReplyDate), "[LASTPOST]", "[/LASTPOST]"); } else { string sLastReplyTemp = sLastReply; if (bRead) { sLastReplyTemp = sLastReplyTemp.Replace("[AF:ICONLINK:LASTREPLY]", "<a href=\"" + sLastReplyURL + "\" rel=\"nofollow\"><img src=\"" + MyThemePath + "/images/miniarrow_right.png\" style=\"vertical-align:middle;\" alt=\"[RESX:JumpToLastReply]\" border=\"0\" class=\"afminiarrow\" /></a>"); sLastReplyTemp = sLastReplyTemp.Replace("[AF:URL:LASTREPLY]", sLastReplyURL); } else { sLastReplyTemp = sLastReplyTemp.Replace("[AF:ICONLINK:LASTREPLY]", string.Empty); sLastReplyTemp = sLastReplyTemp.Replace("[AF:URL:LASTREPLY]", string.Empty); } sLastReplyTemp = sLastReplyTemp.Replace(LastReplySubjectReplaceTag, Utilities.GetLastPostSubject(LastReplyId, TopicId, ForumId, TabId, LastReplySubject, iLength, PageSize, ReplyCount, bRead)); //sLastReplyTemp = sLastReplyTemp.Replace("[RESX:BY]", Utilities.GetSharedResource("By.Text")) if (LastReplyAuthorId > 0) { sLastReplyTemp = sLastReplyTemp.Replace("[LASTPOSTDISPLAYNAME]", UserProfiles.GetDisplayName(ModuleId, true, bModApprove, ForumUser.IsAdmin || ForumUser.IsSuperUser, LastReplyAuthorId, LastReplyUserName, LastReplyFirstName, LastReplyLastName, LastReplyDisplayName).ToString().Replace("&#", "&#")); } else { sLastReplyTemp = sLastReplyTemp.Replace("[LASTPOSTDISPLAYNAME]", LastReplyAuthorName); } sLastReplyTemp = sLastReplyTemp.Replace("[LASTPOSTDATE]", GetDate(LastReplyDate)); sTopicsTemplate = TemplateUtils.ReplaceSubSection(sTopicsTemplate, sLastReplyTemp, "[LASTPOST]", "[/LASTPOST]"); } } sTopics += sTopicsTemplate; rowcount += 1; } sOutput = TemplateUtils.ReplaceSubSection(Template, sTopics, "[" + Section + "]", "[/" + Section + "]"); } else { sOutput = TemplateUtils.ReplaceSubSection(Template, string.Empty, "[" + Section + "]", "[/" + Section + "]"); } return sOutput; }
public string RenderView() { StringBuilder sb = new StringBuilder(); Forum forumInfo = null; string groupPrefix = string.Empty; string forumPrefix = string.Empty; if (ForumId > 0) { ForumController fc = new ForumController(); forumInfo = fc.GetForum(PortalId, ModuleId, ForumId); if (forumInfo != null) { groupPrefix = forumInfo.ForumGroup.PrefixURL; forumPrefix = forumInfo.PrefixURL; } } ControlUtils cUtils = new ControlUtils(); using (IDataReader dr = DataProvider.Instance().Tags_List(PortalId, ModuleId, true, 0, 200, "ASC", "TagName", ForumId, ForumGroupId)) { dr.NextResult(); while (dr.Read()) { string tmp = Template; string categoryName = dr["TagName"].ToString(); tmp = tmp.Replace("[CATEGORYURL]", cUtils.BuildUrl(TabId, ModuleId, groupPrefix, forumPrefix, ForumGroupId, ForumId, -1, int.Parse(dr["TagId"].ToString()), Utilities.CleanName(categoryName), 1, -1)); tmp = tmp.Replace("[CATEGORYNAME]", categoryName); if (int.Parse(dr["TagId"].ToString()) == SelectedCategory) { tmp = tmp.Replace("[CSSCLASS]", CSSClass + "-selected"); } else { tmp = tmp.Replace("[CSSCLASS]", CSSClass); } sb.Append(tmp); } dr.Close(); } if (sb.Length > 0) { sb.Insert(0, HeaderTemplate); sb.Append(FooterTemplate); } return sb.ToString(); }
public void Page_Load(object sender, EventArgs e) { if (IsForbidden) { return; } var permissions = PermissionsManager.GetPermissions(Body.AdministratorName); PageUtils.CheckRequestParameter("PublishmentSystemID", "NodeID"); var nodeID = Body.GetQueryInt("NodeID"); relatedIdentities = RelatedIdentities.GetChannelRelatedIdentities(PublishmentSystemId, nodeID); nodeInfo = NodeManager.GetNodeInfo(PublishmentSystemId, nodeID); tableName = NodeManager.GetTableName(PublishmentSystemInfo, nodeInfo); tableStyle = NodeManager.GetTableStyle(PublishmentSystemInfo, nodeInfo); styleInfoList = TableStyleManager.GetTableStyleInfoList(tableStyle, tableName, relatedIdentities); if (nodeInfo.Additional.IsPreviewContents) { new Action(() => { DataProvider.ContentDao.DeletePreviewContents(PublishmentSystemId, tableName, nodeInfo); }).BeginInvoke(null, null); } if (!HasChannelPermissions(nodeID, AppManager.Cms.Permission.Channel.ContentView, AppManager.Cms.Permission.Channel.ContentAdd, AppManager.Cms.Permission.Channel.ContentEdit, AppManager.Cms.Permission.Channel.ContentDelete, AppManager.Cms.Permission.Channel.ContentTranslate)) { if (!Body.IsAdministratorLoggin) { PageUtils.RedirectToLoginPage(); return; } PageUtils.RedirectToErrorPage("您无此栏目的操作权限!"); return; } attributesOfDisplay = TranslateUtils.StringCollectionToStringCollection(NodeManager.GetContentAttributesOfDisplay(PublishmentSystemId, nodeID)); //this.attributesOfDisplay = TranslateUtils.StringCollectionToStringCollection(this.nodeInfo.Additional.ContentAttributesOfDisplay); spContents.ControlToPaginate = rptContents; rptContents.ItemDataBound += rptContents_ItemDataBound; spContents.ItemsPerPage = PublishmentSystemInfo.Additional.PageSize; var administratorName = AdminUtility.IsViewContentOnlySelf(Body.AdministratorName, PublishmentSystemId, nodeID) ? Body.AdministratorName : string.Empty; if (Body.IsQueryExists("SearchType")) { var owningNodeIdList = new List <int> { nodeID }; spContents.SelectCommand = DataProvider.ContentDao.GetSelectCommend(tableStyle, tableName, PublishmentSystemId, nodeID, permissions.IsSystemAdministrator, owningNodeIdList, Body.GetQueryString("SearchType"), Body.GetQueryString("Keyword"), Body.GetQueryString("DateFrom"), string.Empty, false, ETriState.All, false, false, false, administratorName); } else { spContents.SelectCommand = BaiRongDataProvider.ContentDao.GetSelectCommend(tableName, nodeID, ETriState.All, administratorName); } spContents.SortField = BaiRongDataProvider.ContentDao.GetSortFieldName(); spContents.SortMode = SortMode.DESC; spContents.OrderByString = ETaxisTypeUtils.GetOrderByString(tableStyle, ETaxisType.OrderByTaxisDesc); //分页的时候,不去查询总条数,直接使用栏目的属性:ContentNum spContents.IsQueryTotalCount = false; spContents.TotalCount = nodeInfo.ContentNum; if (!IsPostBack) { var nodeName = NodeManager.GetNodeNameNavigation(PublishmentSystemId, nodeID); BreadCrumbWithItemTitle(AppManager.Cms.LeftMenu.IdContent, "内容管理", nodeName, string.Empty); ltlContentButtons.Text = WebUtils.GetContentCommands(Body.AdministratorName, PublishmentSystemInfo, nodeInfo, PageUrl, GetRedirectUrl(PublishmentSystemId, nodeInfo.NodeId), false); spContents.DataBind(); if (styleInfoList != null) { foreach (var styleInfo in styleInfoList) { if (styleInfo.IsVisible) { var listitem = new ListItem(styleInfo.DisplayName, styleInfo.AttributeName); SearchType.Items.Add(listitem); } } } //添加隐藏属性 SearchType.Items.Add(new ListItem("内容ID", ContentAttribute.Id)); SearchType.Items.Add(new ListItem("添加者", ContentAttribute.AddUserName)); SearchType.Items.Add(new ListItem("最后修改者", ContentAttribute.LastEditUserName)); SearchType.Items.Add(new ListItem("内容组", ContentAttribute.ContentGroupNameCollection)); if (Body.IsQueryExists("SearchType")) { DateFrom.Text = Body.GetQueryString("DateFrom"); ControlUtils.SelectListItems(SearchType, Body.GetQueryString("SearchType")); Keyword.Text = Body.GetQueryString("Keyword"); ltlContentButtons.Text += @" <script> $(document).ready(function() { $('#contentSearch').show(); }); </script> "; } ltlColumnHeadRows.Text = ContentUtility.GetColumnHeadRowsHtml(styleInfoList, attributesOfDisplay, tableStyle, PublishmentSystemInfo); ltlCommandHeadRows.Text = ContentUtility.GetCommandHeadRowsHtml(Body.AdministratorName, tableStyle, PublishmentSystemInfo, nodeInfo); } }
protected override void OnLoad(EventArgs e) { base.OnLoad(e); var timeOffset = PortalSettings.TimeZoneOffset; if (UserId > 0) { var uc = new Entities.Users.UserController(); var dnnUser = uc.GetUser(PortalId, UserId); timeOffset = dnnUser.Profile.TimeZone; if (timeOffset == 0) timeOffset = PortalSettings.TimeZoneOffset; } var sHeaderTemplate = "<div style=\"padding:10px;padding-top:5px;\">"; var sFooterTemplate = "</div>"; if (HeaderTemplate != null) sHeaderTemplate = HeaderTemplate.Text; if (FooterTemplate != null) sFooterTemplate = FooterTemplate.Text; var sTemplate = "<div style=\"padding-bottom:2px;\" class=\"normal\">[SUBJECTLINK]</div><div style=\"padding-bottom:2px;border-bottom:solid 1px #AAA;\">by [AUTHORDISPLAYNAME]</div>"; if (Template != null) sTemplate = Template.Text; if (ForumIds == string.Empty && FilterByUserId <= 0) return; if (ForumIds.Contains(";")) ForumIds = ForumIds.Replace(";", ":"); var sb = new StringBuilder(1024); sb.Append(sHeaderTemplate); var bodyLength = -1; var bodyTrim = string.Empty; if (sTemplate.Contains("[BODY:")) { var inStart = (sTemplate.IndexOf("[BODY:", StringComparison.Ordinal) + 1) + 5; var inEnd = (sTemplate.IndexOf("]", inStart - 1, StringComparison.Ordinal) + 1) - 1; var sLength = sTemplate.Substring(inStart, inEnd - inStart); bodyLength = Convert.ToInt32(sLength); bodyTrim = "[BODY:" + bodyLength + "]"; } IDataReader dr; if (ForumIds == string.Empty && FilterByUserId > 0) { var fc = new ForumController(); var uc = new UserController(); var u = uc.DNNGetCurrentUser(PortalId, -1); ForumIds = fc.GetForumsForUser(u.UserRoles, PortalId, -1); ForumIds = ForumIds.Replace(";", ":"); dr = DataProvider.Instance().GetPostsByUser(PortalId, Rows, UserInfo.IsSuperUser, UserInfo.UserID, FilterByUserId, TopicsOnly, ForumIds); } else { dr = DataProvider.Instance().GetPosts(PortalId, ForumIds, TopicsOnly, RandomOrder, Rows, Tags, FilterByUserId); } var useFriendly = Utilities.IsRewriteLoaded(); var sHost = Utilities.GetHost(); try { var sTempTemplate = sTemplate; string lastPostDate; while (dr.Read()) { var groupName = Convert.ToString(dr["GroupName"]); var groupId = Convert.ToString(dr["ForumGroupId"]); var topicTabId = Convert.ToString(dr["TabId"]); var topicModuleId = Convert.ToString(dr["ModuleId"]); var forumName = Convert.ToString(dr["ForumName"]); var forumId = Convert.ToString(dr["ForumId"]); var subject = Convert.ToString(dr["Subject"]); var userName = Convert.ToString(dr["AuthorUserName"]); var firstName = Convert.ToString(dr["AuthorFirstName"]); var lastName = Convert.ToString(dr["AuthorLastName"]); var authorId = Convert.ToString(dr["AuthorId"]); var displayName = Convert.ToString(dr["AuthorDisplayName"]); var postDate = Convert.ToString(dr["DateCreated"]); var body = Utilities.StripHTMLTag(Convert.ToString(dr["Body"])); var topicId = Convert.ToString(dr["TopicId"]); var replyId = Convert.ToString(dr["ReplyId"]); var bodyHTML = Convert.ToString(dr["Body"]); var replyCount = Convert.ToString(dr["ReplyCount"]); var sForumUrl = dr["PrefixURL"].ToString(); var sTopicURL = dr["TopicURL"].ToString(); var sGroupPrefixURL = dr["GroupPrefixURL"].ToString(); sTempTemplate = sTempTemplate.Replace("[FORUMGROUPNAME]", groupName); sTempTemplate = sTempTemplate.Replace("[FORUMGROUPID]", groupId); sTempTemplate = sTempTemplate.Replace("[TOPICTABID]", topicTabId); sTempTemplate = sTempTemplate.Replace("[TOPICMODULEID]", topicModuleId); sTempTemplate = sTempTemplate.Replace("[FORUMNAME]", forumName); sTempTemplate = sTempTemplate.Replace("[FORUMID]", forumId); sTempTemplate = sTempTemplate.Replace("[SUBJECT]", subject); sTempTemplate = sTempTemplate.Replace("[AUTHORUSERNAME]", userName); sTempTemplate = sTempTemplate.Replace("[AUTHORFIRSTNAME]", firstName); sTempTemplate = sTempTemplate.Replace("[AUTHORLASTNAME]", lastName); sTempTemplate = sTempTemplate.Replace("[AUTHORID]", authorId); sTempTemplate = sTempTemplate.Replace("[AUTHORDISPLAYNAME]", displayName); sTempTemplate = sTempTemplate.Replace("[DATE]", Utilities.GetDate(Convert.ToDateTime(postDate), Convert.ToInt32(topicModuleId), timeOffset)); sTempTemplate = sTempTemplate.Replace("[BODY]", body); sTempTemplate = sTempTemplate.Replace("[BODYHTML]", bodyHTML); sTempTemplate = sTempTemplate.Replace("[BODYTEXT]", Utilities.StripHTMLTag(bodyHTML)); if (bodyTrim != string.Empty) { if (bodyLength > 0 & body.Length > bodyLength) sTempTemplate = sTempTemplate.Replace(bodyTrim, body.Substring(0, bodyLength) + "..."); else sTempTemplate = sTempTemplate.Replace(bodyTrim, body); } sTempTemplate = sTempTemplate.Replace("[TOPICID]", topicId); sTempTemplate = sTempTemplate.Replace("[REPLYID]", replyId); sTempTemplate = sTempTemplate.Replace("[REPLYCOUNT]", replyCount); if (TabId == -1) TabId = Convert.ToInt32(topicTabId); if (useFriendly && !(string.IsNullOrEmpty(sForumUrl)) && !(string.IsNullOrEmpty(sTopicURL))) { var ctlUtils = new ControlUtils(); sTopicURL = ctlUtils.BuildUrl(Convert.ToInt32(topicTabId), Convert.ToInt32(topicModuleId), sGroupPrefixURL, sForumUrl, Convert.ToInt32(groupId), Convert.ToInt32(forumId), Convert.ToInt32(topicId), sTopicURL, -1, -1, string.Empty, 1, Convert.ToInt32(replyId), -1); if (Convert.ToInt32(replyId) == 0) { sTempTemplate = sTempTemplate.Replace("[POSTURL]", sTopicURL); sTempTemplate = sTempTemplate.Replace("[SUBJECTLINK]", "<a href=\"" + sTopicURL + "\">" + subject + "</a>"); } else { if (!(sTopicURL.EndsWith("/"))) sTopicURL += "/"; sTopicURL += "?afc=" + replyId; sTempTemplate = sTempTemplate.Replace("[POSTURL]", sTopicURL); if (Request.IsAuthenticated) sTempTemplate = sTempTemplate.Replace("[SUBJECTLINK]", "<a href=\"" + sTopicURL + "\">" + subject + "</a>"); else sTempTemplate = sTempTemplate.Replace("[SUBJECTLINK]", "<a href=\"" + sTopicURL + "\" rel=\"nofollow\">" + subject + "</a>"); } sTempTemplate = sTempTemplate.Replace("[TOPICSURL]", sForumUrl); } else { List<string> @params; if (Convert.ToInt32(replyId) == 0) { @params = new List<string>{ ParamKeys.ViewType + "=" + Views.Topic, ParamKeys.ForumId + "=" + forumId, ParamKeys.TopicId + "=" + topicId }; if (AdditionalParams != string.Empty) @params.Add(AdditionalParams); sTempTemplate = sTempTemplate.Replace("[POSTURL]", Utilities.NavigateUrl(TabId, string.Empty, @params.ToArray())); @params = new List<string> { ParamKeys.ViewType + "=" + Views.Topic, ParamKeys.ForumId + "=" + forumId, ParamKeys.TopicId + "=" + topicId }; if (AdditionalParams != string.Empty) @params.Add(AdditionalParams); sTempTemplate = sTempTemplate.Replace("[SUBJECTLINK]", "<a href=\"" + Utilities.NavigateUrl(TabId, "", @params.ToArray()) + "\">" + subject + "</a>"); } else { @params = new List<string> { ParamKeys.ViewType + "=" + Views.Topic, ParamKeys.ForumId + "=" + forumId, ParamKeys.TopicId + "=" + topicId, ParamKeys.ContentJumpId + "=" + replyId }; if (AdditionalParams != string.Empty) @params.Add(AdditionalParams); sTempTemplate = sTempTemplate.Replace("[POSTURL]", Utilities.NavigateUrl(TabId, "", @params.ToArray())); @params = new List<string> { ParamKeys.ViewType + "=" + Views.Topic, ParamKeys.ForumId + "=" + forumId, ParamKeys.TopicId + "=" + topicId, ParamKeys.ContentJumpId + "=" + replyId }; if (AdditionalParams != string.Empty) @params.Add(AdditionalParams); sTempTemplate = sTempTemplate.Replace("[SUBJECTLINK]", "<a href=\"" + Utilities.NavigateUrl(TabId, string.Empty, @params.ToArray()) + "\">" + subject + "</a>"); } @params = new List<string> { ParamKeys.ViewType + "=" + Views.Topics, ParamKeys.ForumId + "=" + forumId }; if (AdditionalParams != string.Empty) @params.Add(AdditionalParams); sTempTemplate = sTempTemplate.Replace("[TOPICSURL]", Utilities.NavigateUrl(TabId, string.Empty, @params.ToArray())); } sTempTemplate = sTempTemplate.Replace("[FORUMURL]", Utilities.NavigateUrl(TabId)); sb.Append(sTempTemplate); } dr.Close(); var sRSSImage = "<img src=\"" + Page.ResolveUrl("~/DesktopModules/ActiveForums/images/feedicon.gif") + "\" border=\"0\" />"; var sRSSURL = Page.ResolveUrl("~/desktopmodules/activeforumswhatsnew/feeds.aspx") + "?portalId=" + PortalId + "&tabid=" + TabId.ToString() + "&moduleid=" + ModuleId.ToString(); var sRSSIconLink = "<a href=\"" + sRSSURL + "\">" + sRSSImage + "</a>"; sFooterTemplate = sFooterTemplate.Replace("[RSSICON]", sRSSImage); sFooterTemplate = sFooterTemplate.Replace("[RSSURL]", sRSSURL); sFooterTemplate = sFooterTemplate.Replace("[RSSICONLINK]", sRSSIconLink); sb.Append(sFooterTemplate); var lit = new Literal {Text = sb.ToString()}; Controls.Add(lit); } catch (Exception ex) { if (!dr.IsClosed) { dr.Close(); } sb.Append(ex.StackTrace); var lit = new Literal {Text = ex.Message}; Controls.Add(lit); } }
private string BuildRSS() { const int indent = 2; var counter = 0; var sb = new StringBuilder(1024); // build header sb.Append(XmlHeader + System.Environment.NewLine); sb.Append(RSSHeader + System.Environment.NewLine); // build channel var pc = new PortalController(); var ps = PortalController.GetCurrentPortalSettings(); var offSet = ps.TimeZoneOffset; sb.Append(WriteElement("channel", indent)); sb.Append(WriteElement("title", ps.PortalName, indent)); sb.Append(WriteElement("link", "http://" + HttpContext.Current.Request.Url.Host, indent)); sb.Append(WriteElement("description", ps.PortalName, indent)); sb.Append(WriteElement("generator", "ActiveForums 5.0", indent)); sb.Append(WriteElement("language", ps.DefaultLanguage, indent)); if (ps.LogoFile != string.Empty) { var sLogo = "<image><url>http://" + HttpContext.Current.Request.Url.Host + ps.HomeDirectory + ps.LogoFile + "</url>"; sLogo += "<title>" + ps.PortalName + "</title>"; sLogo += "<link>http://" + HttpContext.Current.Request.Url.Host + "</link></image>"; sb.Append(sLogo); } sb.Append(WriteElement("copyright", ps.FooterText.Replace("[year]",DateTime.Now.Year.ToString()), 2)); sb.Append(WriteElement("lastBuildDate", "[LASTBUILDDATE]", 2)); var lastBuildDate = DateTime.MinValue; // build items var forumids = Settings.RSSIgnoreSecurity ? Settings.Forums : AuthorizedForums; var useFriendly = Utilities.IsRewriteLoaded(); var dr = DataProvider.Instance().GetPosts(RequestPortalID, forumids, true, false, Settings.Rows, Settings.Tags); var sHost = Utilities.GetHost(); try { while (dr.Read()) { var groupName = Convert.ToString(dr["GroupName"]); var groupId = Convert.ToInt32(dr["ForumGroupId"]); var topicTabId = Convert.ToInt32(dr["TabId"]); var topicModuleId = Convert.ToInt32(dr["ModuleId"]); var forumName = Convert.ToString(dr["ForumName"]); var forumId = Convert.ToInt32(dr["ForumId"]); var subject = Convert.ToString(dr["Subject"]); var userName = Convert.ToString(dr["AuthorUserName"]); var postDate = Convert.ToString(dr["DateCreated"]); var body = Utilities.StripHTMLTag(Convert.ToString(dr["Body"])); var bodyHtml = Convert.ToString(dr["Body"]); var displayName = Convert.ToString(dr["AuthorDisplayName"]); var replyCount = Convert.ToString(dr["ReplyCount"]); var lastPostDate = string.Empty; var topicId = Convert.ToInt32(dr["TopicId"]); var replyId = Convert.ToInt32(dr["ReplyId"]); var firstName = Convert.ToString(dr["AuthorFirstName"]); var lastName = Convert.ToString(dr["AuthorLastName"]); var authorId = Convert.ToInt32(dr["AuthorId"]); var sForumUrl = Convert.ToString(dr["PrefixURL"]); var sTopicUrl = Convert.ToString(dr["TopicURL"]); var sGroupPrefixUrl = Convert.ToString(dr["GroupPrefixURL"]); var dateCreated = Convert.ToDateTime(dr["DateCreated"]).AddMinutes(offSet); if (lastBuildDate == DateTime.MinValue || dateCreated > lastBuildDate) { lastBuildDate = dateCreated; } var ts = DataCache.MainSettings(topicModuleId); string url; if (string.IsNullOrEmpty(sTopicUrl) || !useFriendly) { string[] Params = { ParamKeys.ViewType + "=" + Views.Topic, ParamKeys.ForumId + "=" + forumId, ParamKeys.TopicId + "=" + topicId }; url = Common.Globals.NavigateURL(topicTabId, "", Params); if (url.IndexOf(HttpContext.Current.Request.Url.Host, StringComparison.CurrentCulture) == -1) { url = Common.Globals.AddHTTP(HttpContext.Current.Request.Url.Host) + url; } } else { var ctlUtils = new ControlUtils(); sTopicUrl = ctlUtils.BuildUrl(topicTabId, topicModuleId, sGroupPrefixUrl, sForumUrl, groupId, forumId, topicId, sTopicUrl, -1, -1, string.Empty, 1, -1); if (sHost.EndsWith("/") && sTopicUrl.StartsWith("/")) { sHost = sHost.Substring(0, sHost.Length - 1); } url = sHost + sTopicUrl; } sb.Append(WriteElement("item", indent)); sb.Append(WriteElement("title", subject, indent + 1)); if (Settings.RSSIncludeBody) { if (bodyHtml.IndexOf("<body>", StringComparison.CurrentCulture) > 0) { bodyHtml = TemplateUtils.GetTemplateSection(bodyHtml, "<body>", "</body>"); } if (bodyHtml.Contains("[IMAGE:")) { var strHost = Common.Globals.AddHTTP(Common.Globals.GetDomainName(HttpContext.Current.Request)) + "/"; const string pattern = "([IMAGE:(.+?)])"; var regExp = new Regex(pattern); var matches = regExp.Matches(bodyHtml); foreach (Match match in matches) { var sImage = "<img src=\"" + strHost + "DesktopModules/ActiveForums/viewer.aspx?portalid=" + RequestPortalID + "&moduleid=" + RequestModuleID + "&attachid=" + match.Groups[2].Value + "\" border=\"0\" />"; bodyHtml = bodyHtml.Replace(match.Value, sImage); } } if (bodyHtml.Contains("[THUMBNAIL:")) { var strHost = Common.Globals.AddHTTP(Common.Globals.GetDomainName(HttpContext.Current.Request)) + "/"; const string pattern = "([THUMBNAIL:(.+?)])"; var regExp = new Regex(pattern); var matches = regExp.Matches(bodyHtml); foreach (Match match in matches) { var thumbId = match.Groups[2].Value.Split(':')[0]; var parentId = match.Groups[2].Value.Split(':')[1]; var sImage = "<a href=\"" + strHost + "DesktopModules/ActiveForums/viewer.aspx?portalid=" + RequestPortalID + "&moduleid=" + RequestModuleID + "&attachid=" + parentId + "\" target=\"_blank\"><img src=\"" + strHost + "DesktopModules/ActiveForums/viewer.aspx?portalid=" + RequestPortalID + "&moduleid=" + RequestModuleID + "&attachid=" + thumbId + "\" border=\"0\" /></a>"; bodyHtml = bodyHtml.Replace(match.Value, sImage); } } bodyHtml = bodyHtml.Replace("src=\"/Portals", "src=\"" + Common.Globals.AddHTTP(HttpContext.Current.Request.Url.Host) + "/Portals"); bodyHtml = Utilities.ManageImagePath(bodyHtml, Common.Globals.AddHTTP(HttpContext.Current.Request.Url.Host)); sb.Append(WriteElement("description", bodyHtml, indent + 1)); } else { sb.Append(WriteElement("description", string.Empty, indent + 1)); } sb.Append(WriteElement("link", url, indent + 1)); sb.Append(WriteElement("comments", url, indent + 1)); sb.Append(WriteElement("pubDate", Convert.ToDateTime(postDate).AddMinutes(offSet).ToString("r"), indent + 1)); sb.Append(WriteElement("dc:creator", displayName, indent + 1)); sb.Append(WriteElement("guid", url, indent + 1)); sb.Append(WriteElement("slash:comments", replyCount, indent + 1)); sb.Append(WriteElement("/item", indent)); } dr.Close(); sb.Append("<atom:link href=\"http://" + HttpContext.Current.Request.Url.Host + HttpUtility.HtmlEncode(HttpContext.Current.Request.RawUrl) + "\" rel=\"self\" type=\"application/rss+xml\" />"); sb.Append(WriteElement("/channel", 1)); sb.Append("</rss>"); sb.Replace("[LASTBUILDDATE]", lastBuildDate.ToString("r")); return sb.ToString(); } catch (Exception ex) { return ex.ToString(); } }
/* private void LinkControls(ControlCollection ctrls) { foreach (Control ctrl in ctrls) { if ((ctrl) is ForumBase) { ((ForumBase)ctrl).ModuleConfiguration = this.ModuleConfiguration; ((ForumBase)ctrl).TopicId = TopicId; } if (ctrl.Controls.Count > 0) { LinkControls(ctrl.Controls); } } }*/ private string ParseControls(string sOutput) { // Do a few things before we switch to a string builder // Add This if (sOutput.Contains("[AF:CONTROL:ADDTHIS")) { var strHost = Common.Globals.AddHTTP(Common.Globals.GetDomainName(Request)); sOutput = TemplateUtils.ParseSpecial(sOutput, SpecialTokenTypes.AddThis, strHost + Request.RawUrl, _topicSubject, _bRead, MainSettings.AddThisAccount); } // Banners if (sOutput.Contains("[BANNER")) { sOutput = sOutput.Replace("[BANNER]", "<dnn:BANNER runat=\"server\" GroupName=\"FORUMS\" BannerCount=\"1\" EnableViewState=\"False\" />"); const string pattern = @"(\[BANNER:(.+?)\])"; const string sBanner = "<dnn:BANNER runat=\"server\" BannerCount=\"1\" GroupName=\"$1\" EnableViewState=\"False\" />"; sOutput = Regex.Replace(sOutput, pattern, sBanner); } // Hide Toolbar if (sOutput.Contains("[NOTOOLBAR]")) { if (HttpContext.Current.Items.Contains("ShowToolbar")) { HttpContext.Current.Items["ShowToolbar"] = false; } else { HttpContext.Current.Items.Add("ShowToolbar", false); } } // Now use the string builder to do all replacements var sbOutput = new StringBuilder(sOutput); if (Request.QueryString["dnnprintmode"] != null) { sbOutput.Replace("[ADDREPLY]", string.Empty); sbOutput.Replace("[QUICKREPLY]", string.Empty); sbOutput.Replace("[TOPICSUBSCRIBE]", string.Empty); sbOutput.Replace("[AF:CONTROL:PRINTER]", string.Empty); sbOutput.Replace("[AF:CONTROL:EMAIL]", string.Empty); sbOutput.Replace("[PAGER1]", string.Empty); sbOutput.Replace("[PAGER2]", string.Empty); sbOutput.Replace("[SORTDROPDOWN]", string.Empty); sbOutput.Replace("[POSTRATINGBUTTON]", string.Empty); sbOutput.Replace("[JUMPTO]", string.Empty); sbOutput.Replace("[NEXTTOPIC]", string.Empty); sbOutput.Replace("[PREVTOPIC]", string.Empty); sbOutput.Replace("[AF:CONTROL:STATUS]", string.Empty); sbOutput.Replace("[ACTIONS:DELETE]", string.Empty); sbOutput.Replace("[ACTIONS:EDIT]", string.Empty); sbOutput.Replace("[ACTIONS:QUOTE]", string.Empty); sbOutput.Replace("[ACTIONS:REPLY]", string.Empty); sbOutput.Replace("[ACTIONS:ANSWER]", string.Empty); sbOutput.Replace("[ACTIONS:ALERT]", string.Empty); sbOutput.Replace("[ACTIONS:MOVE]", string.Empty); sbOutput.Replace("[RESX:SortPosts]:", string.Empty); sbOutput.Append("<img src=\"~/desktopmodules/activeforums/images/spacer.gif\" width=\"800\" height=\"1\" runat=\"server\" alt=\"---\" />"); } sbOutput.Replace("[NOPAGING]", "<script type=\"text/javascript\">afpagesize=" + int.MaxValue + ";</script>"); sbOutput.Replace("[NOTOOLBAR]", string.Empty); // Subscribe Option if (_bSubscribe) { var subControl = new ToggleSubscribe(1, ForumId, TopicId); subControl.Checked = _isSubscribedTopic; subControl.Text = "[RESX:TopicSubscribe:" + _isSubscribedTopic.ToString().ToUpper() + "]"; sbOutput.Replace("[TOPICSUBSCRIBE]", subControl.Render()); } else { sbOutput.Replace("[TOPICSUBSCRIBE]", string.Empty); } // Topic and post actions var tc = new TokensController(); var topicActions = tc.TokenGet("topic", "[AF:CONTROL:TOPICACTIONS]"); var postActions = tc.TokenGet("topic", "[AF:CONTROL:POSTACTIONS]"); if (sOutput.Contains("[AF:CONTROL:TOPICACTIONS]")) { _useListActions = true; sbOutput.Replace("[AF:CONTROL:TOPICACTIONS]", topicActions); sbOutput.Replace("[AF:CONTROL:POSTACTIONS]", postActions); } // Quick Reply if (_bLocked) { sbOutput.Replace("[ADDREPLY]", "<span class=\"afnormal\">[RESX:TopicLocked]</span>"); sbOutput.Replace("[QUICKREPLY]", string.Empty); } else { //TODO: Check for owner if (CanReply) { var @params = new List<string> { ParamKeys.ViewType + "=post", ParamKeys.TopicId + "=" + TopicId, ParamKeys.ForumId + "=" + ForumId }; if (SocialGroupId > 0) @params.Add("GroupId=" + SocialGroupId); sbOutput.Replace("[ADDREPLY]", "<a href=\"" + Utilities.NavigateUrl(TabId, "", @params.ToArray()) + "\" class=\"dnnPrimaryAction\">[RESX:AddReply]</a>"); sbOutput.Replace("[QUICKREPLY]", "<asp:placeholder id=\"plhQuickReply\" runat=\"server\" />"); } else { sbOutput.Replace("[ADDREPLY]", "<span class=\"afnormal\">[RESX:NotAuthorizedReply]</span>"); sbOutput.Replace("[QUICKREPLY]", string.Empty); } //TODO: Check for owner } if (_bModSplit && (_replyCount > 0)) { /*var @params = new List<string> { ParamKeys.ViewType + "=post", ParamKeys.TopicId + "=" + TopicId, ParamKeys.ForumId + "=" + ForumId };*/ sbOutput.Replace("[SPLITBUTTONS]", "<div id=\"splitbuttons\"><div><a href=\"javascript:void(0);\" onclick=\"amaf_splitCreate(this," + TopicId + ");\" title=\"[RESX:SplitCreate]\" class=\"dnnPrimaryAction\">[RESX:SplitCreate]</a></div><div><span class=\"NormalBold\">[RESX:SplitHeader]</span> <a href=\"javascript:void(0);\" title=\"[RESX:SplitSave]\" class=\"dnnPrimaryAction af-button-split\" data-id='" + TopicId + "'>[RESX:SplitSave]</a> <a href=\"javascript:void(0);\" onclick=\"amaf_splitCancel();\" title=\"[RESX:SplitCancel]\" class=\"dnnPrimaryAction\">[RESX:SplitCancel]</a></div></div><script type=\"text/javascript\">var splitposts=new Array();var current_topicid = " + TopicId + ";</script>"); //sbOutput.Replace("[QUICKREPLY]", "<asp:placeholder id=\"plhQuickReply\" runat=\"server\" />"); } else { //sbOutput.Replace("[SPLIT]", "<span class=\"afnormal\">[RESX:NotAuthorizedSplit]</span>"); sbOutput.Replace("[SPLITBUTTONS]", string.Empty); } // Parent Forum Link if (sOutput.Contains("[PARENTFORUMLINK]")) { if (ForumInfo.ParentForumId > 0) { if (MainSettings.UseShortUrls) sbOutput.Replace("[PARENTFORUMLINK]", "<a href=\"" + Utilities.NavigateUrl(TabId, "", new[] { ParamKeys.ForumId + "=" + ForumInfo.ParentForumId }) + "\">" + ForumInfo.ParentForumName + "</a>"); else sbOutput.Replace("[PARENTFORUMLINK]", "<a href=\"" + Utilities.NavigateUrl(TabId, "", new[] { ParamKeys.ViewType + "=" + Views.Topics, ParamKeys.ForumId + "=" + ForumInfo.ParentForumId }) + "\">" + ForumInfo.ParentForumName + "</a>"); } else if (ForumInfo.ForumGroupId > 0) sbOutput.Replace("[PARENTFORUMLINK]", "<a href=\"" + Utilities.NavigateUrl(TabId) + "\">" + ForumInfo.GroupName + "</a>"); } // Parent Forum Name if (string.IsNullOrEmpty(ForumInfo.ParentForumName)) sbOutput.Replace("[PARENTFORUMNAME]", ForumInfo.ParentForumName); // ForumLinks var ctlUtils = new ControlUtils(); var groupUrl = ctlUtils.BuildUrl(ForumTabId, ForumModuleId, ForumInfo.ForumGroup.PrefixURL, string.Empty, ForumInfo.ForumGroupId, -1, -1, -1, string.Empty, 1, -1, SocialGroupId); var forumUrl = ctlUtils.BuildUrl(ForumTabId, ForumModuleId, ForumInfo.ForumGroup.PrefixURL, ForumInfo.PrefixURL, ForumInfo.ForumGroupId, ForumInfo.ForumID, -1, -1, string.Empty, 1, -1, SocialGroupId); var topicUrl = ctlUtils.BuildUrl(ForumTabId, ForumModuleId, ForumInfo.ForumGroup.PrefixURL, ForumInfo.PrefixURL, ForumInfo.ForumGroupId, ForumInfo.ForumID, TopicId, _topicURL, -1, -1, string.Empty, 1, -1, SocialGroupId); sbOutput.Replace("[FORUMMAINLINK]", "<a href=\"" + NavigateUrl(TabId) + "\">[RESX:ForumMain]</a>"); sbOutput.Replace("[FORUMGROUPLINK]", "<a href=\"" + groupUrl + "\">" + _groupName + "</a>"); if (MainSettings.UseShortUrls) sbOutput.Replace("[FORUMLINK]", "<a href=\"" + forumUrl + "\">" + _forumName + "</a>"); else sbOutput.Replace("[FORUMLINK]", "<a href=\"" + forumUrl + "\">" + _forumName + "</a>"); // Names and Ids sbOutput.Replace("[FORUMID]", ForumId.ToString()); sbOutput.Replace("[FORUMNAME]", _forumName); sbOutput.Replace("[GROUPNAME]", _groupName); // Printer Friendly Link var sURL = "<a rel=\"nofollow\" href=\"" + Utilities.NavigateUrl(TabId, "", ParamKeys.ForumId + "=" + ForumId, ParamKeys.ViewType + "=" + Views.Topic, ParamKeys.TopicId + "=" + TopicId, "mid=" + ModuleId, "dnnprintmode=true") + "?skinsrc=" + HttpUtility.UrlEncode("[G]" + UI.Skins.SkinInfo.RootSkin + "/" + Common.Globals.glbHostSkinFolder + "/" + "No Skin") + "&containersrc=" + HttpUtility.UrlEncode("[G]" + UI.Skins.SkinInfo.RootContainer + "/" + Common.Globals.glbHostSkinFolder + "/" + "No Container") + "\" target=\"_blank\">"; //sURL += "<img src=\"" + _myThemePath + "/images/print16.png\" border=\"0\" alt=\"[RESX:PrinterFriendly]\" /></a>"; sURL += "<i class=\"fa fa-print fa-fw fa-blue\"></i></a>"; sbOutput.Replace("[AF:CONTROL:PRINTER]", sURL); // Email Link if (Request.IsAuthenticated) { sURL = Utilities.NavigateUrl(TabId, "", new[] { ParamKeys.ViewType + "=sendto", ParamKeys.ForumId + "=" + ForumId, ParamKeys.TopicId + "=" + TopicId }); //sbOutput.Replace("[AF:CONTROL:EMAIL]", "<a href=\"" + sURL + "\" rel=\"nofollow\"><img src=\"" + _myThemePath + "/images/email16.png\" border=\"0\" alt=\"[RESX:EmailThis]\" /></a>"); sbOutput.Replace("[AF:CONTROL:EMAIL]", "<a href=\"" + sURL + "\" rel=\"nofollow\"><i class=\"fa fa-envelope-o fa-fw fa-blue\"></i></a>"); } else sbOutput.Replace("[AF:CONTROL:EMAIL]", string.Empty); // RSS Link if (_bAllowRSS) { var url = Common.Globals.AddHTTP(Common.Globals.GetDomainName(Request)) + "/DesktopModules/ActiveForums/feeds.aspx?portalid=" + PortalId + "&forumid=" + ForumId + "&tabid=" + TabId + "&moduleid=" + ModuleId; sbOutput.Replace("[RSSLINK]", "<a href=\"" + url + "\"><img src=\"~/DesktopModules/ActiveForums/themes/" + _myTheme + "/images/rss.png\" runat=server border=\"0\" alt=\"[RESX:RSS]\" /></a>"); } else sbOutput.Replace("[RSSLINK]", string.Empty); // Subject _topicSubject = _topicSubject.Replace("[", "["); _topicSubject = _topicSubject.Replace("]", "]"); sbOutput.Replace("[SUBJECT]", Utilities.StripHTMLTag(_topicSubject)); // Reply Count sbOutput.Replace("[REPLYCOUNT]", _replyCount.ToString()); sbOutput.Replace("[AF:LABEL:ReplyCount]", _replyCount.ToString()); // View Count sbOutput.Replace("[VIEWCOUNT]", _viewCount.ToString()); // Last Post sbOutput.Replace("[AF:LABEL:LastPostDate]", _lastPostDate); sbOutput.Replace("[AF:LABEL:LastPostAuthor]", UserProfiles.GetDisplayName(ModuleId, true, _bModApprove, ForumUser.IsAdmin || ForumUser.IsSuperUser, _lastPostAuthor.AuthorId, _lastPostAuthor.Username, _lastPostAuthor.FirstName, _lastPostAuthor.LastName, _lastPostAuthor.DisplayName)); // Topic Info sbOutput.Replace("[AF:LABEL:TopicAuthor]", UserProfiles.GetDisplayName(ModuleId, _topicAuthorId, _topicAuthorDisplayName, string.Empty, string.Empty, _topicAuthorDisplayName)); sbOutput.Replace("[AF:LABEL:TopicDateCreated]", _topicDateCreated); if (_bModSplit && (_replyCount > 0)) { /*var @params = new List<string> { ParamKeys.ViewType + "=post", ParamKeys.TopicId + "=" + TopicId, ParamKeys.ForumId + "=" + ForumId };*/ sbOutput.Replace("[SPLITBUTTONS2]", "<script type=\"text/javascript\">amaf_splitRestore();</script>"); } else { sbOutput.Replace("[SPLITBUTTONS2]", string.Empty); } // Pagers if (_pageSize == int.MaxValue) { sbOutput.Replace("[PAGER1]", string.Empty); sbOutput.Replace("[PAGER2]", string.Empty); } else { sbOutput.Replace("[PAGER1]", "<am:pagernav id=\"Pager1\" runat=\"server\" EnableViewState=\"False\" />"); sbOutput.Replace("[PAGER2]", "<am:pagernav id=\"Pager2\" runat=\"server\" EnableViewState=\"False\" />"); } // Sort sbOutput.Replace("[SORTDROPDOWN]", "<asp:placeholder id=\"plhTopicSort\" runat=\"server\" />"); var rateControl = new Ratings(TopicId, true, _topicRating); sbOutput.Replace("[POSTRATINGBUTTON]", rateControl.Render()); // Jump To sbOutput.Replace("[JUMPTO]", "<asp:placeholder id=\"plhQuickJump\" runat=\"server\" />"); // Next Topic if (_nextTopic == 0) sbOutput.Replace("[NEXTTOPIC]", string.Empty); else { string nextTopic; if (MainSettings.UseShortUrls) { if (SocialGroupId > 0) nextTopic = Utilities.NavigateUrl(TabId, "", ParamKeys.TopicId + "=" + _nextTopic + "&" + ParamKeys.GroupIdName + "=" + SocialGroupId); else nextTopic = Utilities.NavigateUrl(TabId, "", ParamKeys.TopicId + "=" + _nextTopic); } else { if (SocialGroupId > 0) nextTopic = Utilities.NavigateUrl(TabId, "", ParamKeys.ForumId + "=" + ForumId + "&" + ParamKeys.TopicId + "=" + _nextTopic + "&" + ParamKeys.ViewType + "=" + Views.Topic + "&" + ParamKeys.GroupId + SocialGroupId); else nextTopic = Utilities.NavigateUrl(TabId, "", ParamKeys.ForumId + "=" + ForumId + "&" + ParamKeys.TopicId + "=" + _nextTopic + "&" + ParamKeys.ViewType + "=" + Views.Topic); } sbOutput.Replace("[NEXTTOPIC]", "<a href=\"" + nextTopic + "\" rel=\"nofollow\"><span>[RESX:NextTopic]</span><img src=\"~/DesktopModules/ActiveForums/themes/" + _myTheme + "/images/arrow_right_blue.gif\" runat=server style=\"vertical-align:middle;\" border=\"0\" alt=\"[RESX:NextTopic]\" /></a>"); } // Previous Topic if (_prevTopic == 0) sbOutput.Replace("[PREVTOPIC]", string.Empty); else { string prevTopic; if (MainSettings.UseShortUrls) { if (SocialGroupId > 0) prevTopic = Utilities.NavigateUrl(TabId, "", ParamKeys.TopicId + "=" + _prevTopic + "&" + ParamKeys.GroupIdName + "=" + SocialGroupId); else prevTopic = Utilities.NavigateUrl(TabId, "", ParamKeys.TopicId + "=" + _prevTopic); } else { if (SocialGroupId > 0) prevTopic = Utilities.NavigateUrl(TabId, "", ParamKeys.ForumId + "=" + ForumId + "&" + ParamKeys.TopicId + "=" + _prevTopic + "&" + ParamKeys.ViewType + "=" + Views.Topic + "&" + ParamKeys.GroupIdName + "=" + SocialGroupId); else prevTopic = Utilities.NavigateUrl(TabId, "", ParamKeys.ForumId + "=" + ForumId + "&" + ParamKeys.TopicId + "=" + _prevTopic + "&" + ParamKeys.ViewType + "=" + Views.Topic); } sbOutput.Replace("[PREVTOPIC]", "<a href=\"" + prevTopic + "\" rel=\"nofollow\"><img src=\"~/DesktopModules/ActiveForums/themes/" + _myTheme + "/images/arrow_left_blue.gif\" runat=server style=\"vertical-align:middle;\" border=\"0\" alt=\"[RESX:PrevTopic]\" /><span>[RESX:PrevTopic]</span></a>"); } // Topic Status if (((_bRead && _topicAuthorId == UserId) || _bModEdit) & _statusId >= 0) { sbOutput.Replace("[AF:CONTROL:STATUS]", "<asp:placeholder id=\"plhStatus\" runat=\"server\" />"); //sbOutput.Replace("[AF:CONTROL:STATUSICON]", "<img alt=\"[RESX:PostStatus" + _statusId.ToString() + "]\" src=\"" + _myThemePath + "/images/status" + _statusId.ToString() + ".png\" />"); sbOutput.Replace("[AF:CONTROL:STATUSICON]", "<div><i class=\"fa fa-status" + _statusId.ToString() + " fa-red fa-2x\"></i></div>"); } else if (_statusId >= 0) { sbOutput.Replace("[AF:CONTROL:STATUS]", string.Empty); //sbOutput.Replace("[AF:CONTROL:STATUSICON]", "<img alt=\"[RESX:PostStatus" + _statusId.ToString() + "]\" src=\"" + _myThemePath + "/images/status" + _statusId.ToString() + ".png\" />"); sbOutput.Replace("[AF:CONTROL:STATUSICON]", "<div><i class=\"fa fa-status" + _statusId.ToString() + " fa-red fa-2x\"></i></div>"); } else { sbOutput.Replace("[AF:CONTROL:STATUS]", string.Empty); sbOutput.Replace("[AF:CONTROL:STATUSICON]", string.Empty); } // Poll if (_topicType == (int)TopicTypes.Poll) sbOutput.Replace("[AF:CONTROL:POLL]", "<asp:placeholder id=\"plhPoll\" runat=\"server\" />"); else sbOutput.Replace("[AF:CONTROL:POLL]", string.Empty); return sbOutput.ToString(); }
protected override void Render(HtmlTextWriter writer) { User forumUser = null; if (string.IsNullOrEmpty(ForumIds)) { UserController uc = new UserController(); forumUser = uc.GetUser(PortalId, ModuleId); if (string.IsNullOrEmpty(forumUser.UserForums)) { ForumController fc = new ForumController(); ForumIds = fc.GetForumsForUser(forumUser.UserRoles, PortalId, ModuleId); } else { ForumIds = forumUser.UserForums; } } SettingsInfo _mainSettings = DataCache.MainSettings(ModuleId); Data.Common db = new Data.Common(); IDataReader dr = db.TagCloud_Get(PortalId, ModuleId, ForumIds, TagCount); ControlUtils ctlUtils = new ControlUtils(); string sURL = string.Empty; while (dr.Read()) { int priority = 1; string tagName = string.Empty; string css = string.Empty; priority = int.Parse(dr["Priority"].ToString()); tagName = dr["TagName"].ToString(); switch (priority) { case 1: css = CSSOne; break; case 2: css = CSSTwo; break; case 3: css = CSSThree; break; } writer.Write("<span class=\"" + css + "\">"); writer.Write("<a href=\""); sURL = ctlUtils.BuildUrl(TabId, ModuleId, string.Empty, string.Empty, -1, -1, int.Parse(dr["TagID"].ToString()), -1, Utilities.CleanName(tagName), 1, -1, -1); writer.Write(sURL); writer.Write("\" title=\"" + HttpUtility.HtmlAttributeEncode(tagName) + "\">" + tagName + "</a></span> "); } dr.Close(); dr.Dispose(); }
private string ParseDataRow(IDataRecord row, string tmp) { try { tmp = tmp.Replace("[AVATAR]", "[AF:AVATAR]"); for (int i = 0; i < row.FieldCount; i++) { string name = row.GetName(i); string k = "[" + name.ToUpperInvariant() + "]"; string value = row[i].ToString(); switch (row[i].GetType().ToString()) { case "System.DateTime": value = Utilities.GetDate(Convert.ToDateTime(row[i].ToString()), ModuleId, TimeZoneOffset); break; } tmp = tmp.Replace(k, value); } ControlUtils cUtils = new ControlUtils(); Author auth = new Author(); string columnPrefix = "Topic"; if (Convert.ToInt32(row["ReplyId"].ToString()) > 0) { columnPrefix = "Reply"; auth.DisplayName = row[columnPrefix + "AuthorDisplayName"].ToString(); } else { auth.DisplayName = row["TopicAuthorName"].ToString(); } auth.AuthorId = int.Parse(row[columnPrefix + "AuthorId"].ToString()); auth.LastName = row[columnPrefix + "AuthorLastName"].ToString(); auth.FirstName = row[columnPrefix + "AuthorFirstName"].ToString(); auth.Username = row[columnPrefix + "AuthorUsername"].ToString(); tmp = tmp.Replace("[TOPICURL]", cUtils.TopicURL(row, TabId, ModuleId)); tmp = tmp.Replace("[FORUMURL]", cUtils.ForumURL(row, TabId, ModuleId)); if (int.Parse(row["LastAuthorId"].ToString()) == -1) { try { tmp = tmp.Replace("[LASTAUTHOR]", UserProfiles.GetDisplayName(ModuleId, true, ForumUser.Profile.IsMod, ForumUser.IsAdmin || ForumUser.IsSuperUser, -1, auth.Username, auth.FirstName, auth.LastName, auth.DisplayName)); } catch (Exception ex) { tmp = tmp.Replace("[LASTAUTHOR]", "anon"); } } else { tmp = tmp.Replace("[LASTAUTHOR]", UserProfiles.GetDisplayName(ModuleId, true, ForumUser.Profile.IsMod, ForumUser.IsAdmin || ForumUser.IsSuperUser, int.Parse(row["LastAuthorId"].ToString()), auth.Username, auth.FirstName, auth.LastName, auth.DisplayName)); } if (_canEdit) { tmp = tmp.Replace("[AF:QUICKEDITLINK]", "<span class=\"af-icon16 af-icon16-gear\" onclick=\"amaf_quickEdit(" + row["TopicId"].ToString() + ");\"></span>"); } else { tmp = tmp.Replace("[AF:QUICKEDITLINK]", string.Empty); } // tmp = tmp.Replace("[TOPICSTATE]", cUtils.TopicState(row)); var sAvatar = UserProfiles.GetAvatar(auth.AuthorId, _mainSettings.AvatarWidth, _mainSettings.AvatarHeight); tmp = tmp.Replace("[AF:AVATAR]", sAvatar); return tmp; } catch (Exception ex) { return ex.Message; } }
public static T Get <T>(string id) where T : Control { return(ControlUtils.FindControl <T>(ResponseManager.ResourceManager, id) as T); }
public string Render() { StringBuilder sb = new StringBuilder(); Data.CommonDB db = new Data.CommonDB(); string sHost = Utilities.GetHost(); if (sHost.EndsWith("/")) { sHost = sHost.Substring(0, sHost.Length - 1); } ControlUtils ctlUtils = new ControlUtils(); string forumPrefix = string.Empty; string groupPrefix = string.Empty; //Dim _forumGroupId As Integer = -1 if (ParentForumId == -1) { ParentForumId = ForumId; } string groupTemplate = TemplateUtils.GetTemplateSection(ItemTemplate, "[AF:DIR:FORUMGROUP]", "[/AF:DIR:FORUMGROUP]"); string forumTemplate = TemplateUtils.GetTemplateSection(ItemTemplate, "[AF:DIR:FORUM]", "[/AF:DIR:FORUM]"); string subForumTemplate = TemplateUtils.GetTemplateSection(ItemTemplate, "[AF:DIR:SUBFORUM]", "[/AF:DIR:SUBFORUM]"); bool useFriendlyUrl = Utilities.IsRewriteLoaded(); int currGroup = -1; string gtmp = string.Empty; string ftmp = string.Empty; string subtmp = string.Empty; using (IDataReader dr = db.ForumContent_List(PortalId, ModuleId, ForumGroupId, ForumId, ParentForumId)) { //ParentForum Section while (dr.Read()) { string sURL = ctlUtils.BuildUrl(TabId, ModuleId, dr["GroupPrefixURL"].ToString(), dr["PrefixURL"].ToString(), int.Parse(dr["ForumGroupId"].ToString()), int.Parse(dr["ForumId"].ToString()), -1, -1, string.Empty, 1, -1); if (IncludeClasses) { sb.Append("<div class=\"fcv-header\"><a href=\"" + sURL + "\"><span>" + dr["ForumName"].ToString() + "</span></a></div>"); } else { sb.Append("<div><a href=\"" + sURL + "\"><span>" + dr["ForumName"].ToString() + "</span></a></div>"); } forumPrefix = dr["PrefixURL"].ToString(); groupPrefix = dr["GroupPrefixURL"].ToString(); // _forumGroupId = Integer.Parse(dr("ForumGroupId").ToString) } //SubForums dr.NextResult(); int subForumCount = 0; string sSubforums = string.Empty; while (dr.Read()) { if (Permissions.HasPerm(dr["CanRead"].ToString(), ForumUser.UserRoles)) { string sURL = ctlUtils.BuildUrl(TabId, ModuleId, dr["GroupPrefixURL"].ToString(), dr["PrefixURL"].ToString(), int.Parse(dr["ForumGroupId"].ToString()), int.Parse(dr["ForumId"].ToString()), -1, -1, string.Empty, 1, -1); if (ForumId == int.Parse(dr["ForumId"].ToString())) { sSubforums += "<li class=\"fcv-selected\">"; } else { sSubforums += "<li>"; } sSubforums += "<a href=\"" + sURL + "\"><em></em><span>" + dr["ForumName"].ToString() + "</span></a></li>"; if (IncludeClasses) { sSubforums += "<li class=\"fcv-desc\">" + dr["ForumDesc"].ToString() + "</li>"; } else { sSubforums += "<li>" + dr["ForumDesc"].ToString() + "</li>"; } } } if (! (string.IsNullOrEmpty(sSubforums))) { if (IncludeClasses) { sb.Append("<ul class=\"fcv-subforums\">"); } else { sb.Append("<ul>"); } sb.Append(sSubforums); sb.Append("</ul>"); } //Topics in ParentForum dr.NextResult(); string catKey = string.Empty; int count = 0; int catCount = 0; while (dr.Read()) { if (catKey != dr["CategoryName"].ToString() + dr["CategoryId"].ToString()) { if (count > 0) { sb.Replace("[CATCOUNT]", catCount.ToString()); sb.Append("</ul></div>"); count = 0; catCount = 0; } if (IncludeClasses) { sb.Append("<div class=\"fcv-categorysection\"><div class=\"fcv-categoryname\"><span class=\"fcv-catcount\">[CATCOUNT]</span>" + dr["CategoryName"].ToString() + " </div>"); sb.Append("<ul class=\"fcv-topicslist\">"); } else { sb.Append("<div><div><span>[CATCOUNT]</span>" + dr["CategoryName"].ToString() + " </div>"); sb.Append("<ul>"); } catKey = dr["CategoryName"].ToString() + dr["CategoryId"].ToString(); } //Dim Params As String() = {"aff=" & ForumId, "fcc=" & dr("TopicId").ToString} if (TopicId == Convert.ToInt32(dr["TopicId"].ToString())) { sb.Append("<li class=\"fcv-selected\">"); } else { sb.Append("<li>"); } catCount += 1; //Dim Params As String() = {ParamKeys.ForumId & "=" & ForumId, ParamKeys.TopicId & "=" & TopicId, ParamKeys.ViewType & "=topic"} string[] Params = {ParamKeys.TopicId + "=" + dr["TopicId"].ToString()}; string sTopicURL = ctlUtils.BuildUrl(TabId, ModuleId, groupPrefix, forumPrefix, ForumGroupId, ForumId, int.Parse(dr["TopicId"].ToString()), dr["URL"].ToString(), -1, -1, string.Empty, 1, -1); sb.Append("<a href=\"" + sTopicURL + "\"><span>" + dr["Subject"].ToString() + "</span></a></li>"); if (TopicId > 0) { if (Convert.ToInt32(dr["TopicId"].ToString()) == TopicId) { // RenderTopic(dr) } } count += 1; } sb.Replace("[CATCOUNT]", catCount.ToString()); if (count > 0) { sb.Append("</ul></div>"); } dr.Close(); } return sb.ToString(); }
public override void DataBind() { if (_bound) { return; } _bound = true; if (String.IsNullOrWhiteSpace(Category)) { if (Randomise) { this.SelectCommand = string.Format("Select top {0} *, newid() as ___Ran from AlbumsView", Top); this.OrderBy = "___Ran"; } else { this.SelectCommand = string.Format("Select top {0} * from AlbumsView", Top); } } else { if (Randomise) { this.SelectCommand = string.Format("Select top {0} *, newid() as ___Ran from AlbumsFullView", Top); this.OrderBy = "___Ran"; } else { this.SelectCommand = string.Format("Select top {0} * from AlbumsFullView", Top); } } if (!CMSMode.Value && !MyPage.Editable) { this.SelectCommand += string.Format(" Where Status={0}", Status == true ? "1" : "0"); } else { this.SelectCommand += " Where 1=1"; } //TODO: Display Disabled Albums in case an administrator is logged in if (!String.IsNullOrWhiteSpace(Category)) { this.SelectCommand += string.Format(" And (UniqueName='{0}' or CategoryName='{0}')", StringUtils.SQLEncode(Category)); } else if (CategoryId > 0) { this.SelectCommand += string.Format(" And CategoryId&power(2, {0}) = power(2, {0})", CategoryId); } if (_language != Languages.Default) { this.SelectCommand += string.Format(" And (Language={0} or Language={1})", (int)_language, (int)Languages.Default); } if (!string.IsNullOrWhiteSpace(Condition)) { this.SelectCommand += string.Format(" And " + Condition); } if (PagesCategoryId.HasValue && PagesCategoryId.Value > 0) { } this.SelectCommand += string.Format(" And CategoryId <> {0}", PagesCategoryId); if (NetworkBound) { NetworkRelations networkRelations = new NetworkRelations(); SelectCommand += " and " + networkRelations.GetRelationQueryByNetwork(cte.NetworkRelationTable, cte.NetworkRelateToField, Int32.Parse(networkName)); } if (RelateToSection != null) { int relationValue = -1; switch (RelateToSection) { case SiteSections.Page: relationValue = (int)ControlUtils.GetBoundedDataField(this.NamingContainer, "PageId"); break; default: break; } this.SelectCommand += String.Format(" and Id in (select AlbumId from PhotoAlbumRelations where RelateToId={0} and Section={1})", relationValue, (int)RelateToSection); } if (CMSMode != null && CMSMode.Value) { string q = WebContext.Request["q"]; string cat = WebContext.Request["CategoryId"]; string net = WebContext.Request["NetworkId"]; if (!string.IsNullOrWhiteSpace(q)) { this.SelectCommand += string.Format(" and (Name like '%{0}%' or DisplayName like '%{0}%')", StringUtils.SQLEncode(q)); } if (!string.IsNullOrWhiteSpace(cat)) { this.SelectCommand += string.Format(" and (categoryid & POWER(2, {0}) = POWER(2, {0}))", StringUtils.SQLEncode(cat)); } if (!string.IsNullOrWhiteSpace(net)) { if (net != "-1") { this.SelectCommand += string.Format(" and Id in (select Id from PhotoAlbumsNetwork where NetworkId={0})", Int32.Parse(net)); } else { this.SelectCommand += string.Format(" and Id in (select Id from PhotoAlbumsNetwork)"); } } } if (!String.IsNullOrWhiteSpace(Filter)) { this.SelectCommand += " and " + Filter; } if (!EnablePaging) { this.SelectCommand += " Order By " + this.OrderBy; } base.DataBind(); }
private string GetLastPostSubject(int LastPostID, int ParentPostID, int ForumID, int TabID, string Subject, int Length, int PageSize, Forum fi) { //TODO: Verify that this will still jump to topics on page 2 var sb = new StringBuilder(); int PostId = LastPostID; Subject = Utilities.StripHTMLTag(Subject); Subject = Subject.Replace("[", "["); Subject = Subject.Replace("]", "]"); if (Subject.Length > Length & Length > 0) { Subject = Subject.Substring(0, Length) + "..."; } if (LastPostID != 0) { string sTopicURL; var ctlUtils = new ControlUtils(); sTopicURL = ctlUtils.BuildUrl(ForumTabId, ForumModuleId, fi.ForumGroup.PrefixURL, fi.PrefixURL, fi.ForumGroupId, ForumID, ParentPostID, fi.TopicUrl, -1, -1, string.Empty, 1, -1, SocialGroupId); string sURL; if (ParentPostID == 0 || LastPostID == ParentPostID) { sURL = sTopicURL; //If UseShortUrls Then // sURL = Utilities.NavigateUrl(TabID, "", New String() {ParamKeys.TopicId & "=" & PostId}) //Else // sURL = Utilities.NavigateUrl(TabID, "", New String() {ParamKeys.ForumId & "=" & ForumID, ParamKeys.ViewType & "=" & Views.Topic, ParamKeys.TopicId & "=" & PostId}) //End If } else { if (sTopicURL.EndsWith("/")) { sURL = sTopicURL + "?" + ParamKeys.ContentJumpId + "=" + PostId; } else { var @params = new List<string> { ParamKeys.TopicId + "=" + ParentPostID, ParamKeys.ContentJumpId + "=" + PostId }; if (SocialGroupId > 0) @params.Add("GroupId=" + SocialGroupId.ToString()); sURL = Utilities.NavigateUrl(TabID, "", @params.ToArray()); } } sb.Append("<a href=\"" + sURL + "\">" + Utilities.HTMLEncode(Subject) + "</a>"); } return sb.ToString(); }
private static string ParseImpl(PageInfo pageInfo, ContextInfo contextInfo, string separator, string target, string linkClass, int wordNum, bool isContainSelf) { if (!string.IsNullOrEmpty(contextInfo.InnerHtml)) { separator = contextInfo.InnerHtml; } var nodeInfo = ChannelManager.GetChannelInfo(pageInfo.SiteId, contextInfo.ChannelId); var builder = new StringBuilder(); var parentsPath = nodeInfo.ParentsPath; var parentsCount = nodeInfo.ParentsCount; if (parentsPath.Length != 0) { var nodePath = parentsPath; if (isContainSelf) { nodePath = nodePath + "," + contextInfo.ChannelId; } var channelIdArrayList = TranslateUtils.StringCollectionToStringList(nodePath); foreach (var channelIdStr in channelIdArrayList) { var currentId = int.Parse(channelIdStr); var currentNodeInfo = ChannelManager.GetChannelInfo(pageInfo.SiteId, currentId); if (currentId == pageInfo.SiteId) { var stlAnchor = new HtmlAnchor(); if (!string.IsNullOrEmpty(target)) { stlAnchor.Target = target; } if (!string.IsNullOrEmpty(linkClass)) { stlAnchor.Attributes.Add("class", linkClass); } var url = PageUtility.GetIndexPageUrl(pageInfo.SiteInfo, pageInfo.IsLocal); if (url.Equals(PageUtils.UnclickedUrl)) { stlAnchor.Target = string.Empty; } stlAnchor.HRef = url; stlAnchor.InnerHtml = StringUtils.MaxLengthText(currentNodeInfo.ChannelName, wordNum); ControlUtils.AddAttributesIfNotExists(stlAnchor, contextInfo.Attributes); builder.Append(ControlUtils.GetControlRenderHtml(stlAnchor)); if (parentsCount > 0) { builder.Append(separator); } } else if (currentId == contextInfo.ChannelId) { var stlAnchor = new HtmlAnchor(); if (!string.IsNullOrEmpty(target)) { stlAnchor.Target = target; } if (!string.IsNullOrEmpty(linkClass)) { stlAnchor.Attributes.Add("class", linkClass); } var url = PageUtility.GetChannelUrl(pageInfo.SiteInfo, currentNodeInfo, pageInfo.IsLocal); if (url.Equals(PageUtils.UnclickedUrl)) { stlAnchor.Target = string.Empty; } stlAnchor.HRef = url; stlAnchor.InnerHtml = StringUtils.MaxLengthText(currentNodeInfo.ChannelName, wordNum); ControlUtils.AddAttributesIfNotExists(stlAnchor, contextInfo.Attributes); builder.Append(ControlUtils.GetControlRenderHtml(stlAnchor)); } else { var stlAnchor = new HtmlAnchor(); if (!string.IsNullOrEmpty(target)) { stlAnchor.Target = target; } if (!string.IsNullOrEmpty(linkClass)) { stlAnchor.Attributes.Add("class", linkClass); } var url = PageUtility.GetChannelUrl(pageInfo.SiteInfo, currentNodeInfo, pageInfo.IsLocal); if (url.Equals(PageUtils.UnclickedUrl)) { stlAnchor.Target = string.Empty; } stlAnchor.HRef = url; stlAnchor.InnerHtml = StringUtils.MaxLengthText(currentNodeInfo.ChannelName, wordNum); ControlUtils.AddAttributesIfNotExists(stlAnchor, contextInfo.Attributes); builder.Append(ControlUtils.GetControlRenderHtml(stlAnchor)); if (parentsCount > 0) { builder.Append(separator); } } } } return(builder.ToString()); }
private string ParseForumRow(string Template, Forum fi, int currForumIndex, string ThemePath, int totalForums) { if (Template.Contains("[SUBFORUMS]") && Template.Contains("[/SUBFORUMS]")) { Template = GetSubForums(Template, fi.ForumID, ModuleId, TabId, ThemePath); } else { Template = Template.Replace("[SUBFORUMS]", GetSubForums(fi.ForumID, ModuleId, TabId)); } string[] css = null; string cssmatch = string.Empty; if (Template.Contains("[CSS:")) { string pattern = "(\\[CSS:.+?\\])"; if (Regex.IsMatch(Template, pattern)) { cssmatch = Regex.Match(Template, pattern).Value; css = cssmatch.Split(':'); //0=CSS,1=TopRow, 2=mid rows, 3=lastRow } } if (cssmatch != string.Empty) { if (currForumIndex == 1) { Template = Template.Replace(cssmatch, css[1]); } else if (currForumIndex > 1 & currForumIndex < totalForums) { Template = Template.Replace(cssmatch, css[2]); } else { Template = Template.Replace(cssmatch, css[3].Replace("]", string.Empty)); } } bool canView = Permissions.HasPerm(fi.Security.View, ForumUser.UserRoles); bool canSubscribe = Permissions.HasPerm(fi.Security.Subscribe, ForumUser.UserRoles); bool canRead = Permissions.HasPerm(fi.Security.Read, ForumUser.UserRoles); string sIcon = TemplateUtils.ShowIcon(canView, fi.ForumID, CurrentUserId, fi.LastPostDateTime, fi.LastRead, fi.LastPostID); string sIconImage = "<img alt=\"" + fi.ForumName + "\" src=\"" + ThemePath + "images/" + sIcon + "\" />"; if (Template.Contains("[FORUMICON]")) { Template = Template.Replace("[FORUMICON]", sIconImage); } else if (Template.Contains("[FORUMICONCSS]")) { string sFolderCSS = "fa-folder fa-blue"; switch (sIcon.ToLower()) { case "folder.png": sFolderCSS = "fa-folder fa-blue"; break; case "folder_new.png": sFolderCSS = "fa-folder fa-red"; break; case "folder_forbidden.png": sFolderCSS = "fa-folder fa-grey"; break; case "folder_closed.png": sFolderCSS = "fa-folder-o fa-grey"; break; } Template = Template.Replace("[FORUMICONCSS]", "<div style=\"height:30px;margin-right:10px;\"><i class=\"fa " + sFolderCSS + " fa-2x\"></i></div>"); } var ctlUtils = new ControlUtils(); ForumURL = ctlUtils.BuildUrl(ForumTabId, ForumModuleId, fi.ForumGroup.PrefixURL, fi.PrefixURL, fi.ForumGroupId, fi.ForumID, -1, string.Empty, -1, -1, string.Empty, 1, -1, SocialGroupId); //ForumURL = GetForumLink(.ForumID, TabId, canView, MainSettings.UseShortUrls, .PrefixURL) Template = Template.Replace("[FORUMNAME]", GetForumLink(fi.ForumName, fi.ForumID, TabId, canView, ForumURL)); Template = Template.Replace("[FORUMNAMENOLINK]", fi.ForumName); Template = Template.Replace("[FORUMID]", fi.ForumID.ToString()); if (Template.Contains("[RSSLINK]")) { if (fi.AllowRSS && canRead) { string Url; Url = Common.Globals.AddHTTP(Common.Globals.GetDomainName(Request)) + "/DesktopModules/ActiveForums/feeds.aspx?portalid=" + PortalId + "&forumid=" + fi.ForumID + "&tabid=" + TabId + "&moduleid=" + ModuleId; Template = Template.Replace("[RSSLINK]", "<a href=\"" + Url + "\" target=\"_blank\"><img src=\"" + ThemePath + "images/rss.png\" border=\"0\" alt=\"[RESX:RSS]\" /></a>"); } else { Template = Template.Replace("[RSSLINK]", "<img src=\"" + ThemePath + "images/rss_disabled.png\" border=\"0\" alt=\"[RESX:RSSDisabled]\" />"); } } if (Template.Contains("[AF:CONTROL:TOGGLESUBSCRIBE]")) { if (canSubscribe) { bool IsSubscribed = Subscriptions.IsSubscribed(PortalId, ModuleId, fi.ForumID, 0, SubscriptionTypes.Instant, CurrentUserId); string sAlt = "[RESX:ForumSubscribe:" + IsSubscribed.ToString().ToUpper() + "]"; string sImg = ThemePath + "images/email_unchecked.png"; if (IsSubscribed) { sImg = ThemePath + "images/email_checked.png"; } var subControl = new ToggleSubscribe(0, fi.ForumID, -1); subControl.Checked = IsSubscribed; subControl.DisplayMode = 1; subControl.UserId = CurrentUserId; subControl.ImageURL = sImg; subControl.Text = "[RESX:ForumSubscribe:" + IsSubscribed.ToString().ToUpper() + "]"; string subOption = subControl.Render(); //Template = Template.Replace("[AF:CONTROL:TOGGLESUBSCRIBE]", "<a href=""javascript:af_toggleSubscribe(" & .ForumID & ",'" & PortalId & "|" & ModuleId & "|" & .ForumID & "|" & CurrentUserId & "');""><img id=""toggleSub" & .ForumID & """ src=""" & sImg & """ border=""0"" alt=""" & sAlt & """ /></a>") Template = Template.Replace("[AF:CONTROL:TOGGLESUBSCRIBE]", subOption); } else { Template = Template.Replace("[AF:CONTROL:TOGGLESUBSCRIBE]", "<img src=\"" + ThemePath + "email_disabled.png\" border=\"0\" alt=\"[RESX:ForumSubscribe:Disabled]\" />"); } } Template = canRead ? Template.Replace("[AF:CONTROL:ADDFAVORITE]", "<a href=\"javascript:afAddBookmark('" + fi.ForumName + "','" + ForumURL + "');\"><img src=\"" + ThemePath + "images/favorites16_add.png\" border=\"0\" alt=\"[RESX:AddToFavorites]\" /></a>") : Template.Replace("[AF:CONTROL:ADDFAVORITE]", string.Empty); if (Template.Contains("[AF:CONTROL:ADDTHIS")) { Template = TemplateUtils.ParseSpecial(Template, SpecialTokenTypes.AddThis, ForumURL, fi.ForumName, canRead, MainSettings.AddThisAccount); } if (fi.ForumDesc != "") { Template = Template.Replace("[FORUMDESCRIPTION]", "<i class=\"fa fa-file-o fa-grey\"></i> " + fi.ForumDesc); } else { Template = Template.Replace("[FORUMDESCRIPTION]", ""); } Template = Template.Replace("[TOTALTOPICS]", fi.TotalTopics.ToString()); Template = Template.Replace("[TOTALREPLIES]", fi.TotalReplies.ToString()); //Last Post Section int intLength = 0; if ((Template.IndexOf("[LASTPOSTSUBJECT:", 0) + 1) > 0) { int inStart = (Template.IndexOf("[LASTPOSTSUBJECT:", 0) + 1) + 17; int inEnd = (Template.IndexOf("]", inStart - 1) + 1); string sLength = Template.Substring(inStart - 1, inEnd - inStart); intLength = Convert.ToInt32(sLength); } string ReplaceTag = "[LASTPOSTSUBJECT:" + intLength.ToString() + "]"; if (fi.LastPostID == 0) { Template = Template.Replace("[RESX:BY]", string.Empty); Template = Template.Replace("[DISPLAYNAME]", string.Empty); Template = Template.Replace("[LASTPOSTDATE]", string.Empty); Template = Template.Replace(ReplaceTag, string.Empty); //Template = TemplateUtils.ParseUserDetails(PortalId, -1, Template, String.Empty) } else { if (canView) { if (fi.LastPostUserID <= 0) { //Template = Template.Replace("[RESX:BY]", String.Empty) Template = Template.Replace("[DISPLAYNAME]", "<i class=\"fa fa-user fa-fw fa-blue\"></i> " + fi.LastPostDisplayName); //Template = TemplateUtils.ParseUserDetails(PortalId, -1, Template, "FG") } else { bool isMod = CurrentUserType == CurrentUserTypes.Admin || CurrentUserType == CurrentUserTypes.ForumMod || CurrentUserType == CurrentUserTypes.SuperUser; bool isAdmin = CurrentUserType == CurrentUserTypes.Admin || CurrentUserType == CurrentUserTypes.SuperUser; Template = Template.Replace("[DISPLAYNAME]", "<i class=\"fa fa-user fa-fw fa-blue\"></i> " + UserProfiles.GetDisplayName(ModuleId, true, isMod, isAdmin, fi.LastPostUserID, fi.LastPostUserName, fi.LastPostFirstName, fi.LastPostLastName, fi.LastPostDisplayName)); //Template = TemplateUtils.ParseUserDetails(PortalId, .LastPostUserID, Template, "FG") } DateTime dtLastPostDate = fi.LastPostDateTime; Template = Template.Replace("[LASTPOSTDATE]", Utilities.GetDate(dtLastPostDate, ModuleId, TimeZoneOffset)); string Subject = fi.LastPostSubject; if (Subject == "") { Subject = GetSharedResource("[RESX:SubjectPrefix]") + " " + fi.TopicSubject; } if (Subject != string.Empty) { string sDots = ""; if (Subject.Length > intLength) { sDots = "..."; } Template = Template.Replace(ReplaceTag, GetLastPostSubject(fi.LastPostID, fi.TopicId, fi.ForumID, TabId, Subject, intLength, MainSettings.PageSize, fi)); } else { Template = Template.Replace("[RESX:BY]", string.Empty); Template = Template.Replace(ReplaceTag, string.Empty); } } else { Template = Template.Replace("[DISPLAYNAME]", string.Empty); Template = Template.Replace("[LASTPOSTDATE]", string.Empty); Template = Template.Replace("[RESX:BY]", string.Empty); Template = Template.Replace(ReplaceTag, string.Empty); } } return Template; }
private static string ParseImpl(PageInfo pageInfo, ContextInfo contextInfo, XmlNode node, NameValueCollection attributes, string type, string returnUrl) { var stlAnchor = new HtmlAnchor(); foreach (string attributeName in attributes.Keys) { stlAnchor.Attributes.Add(attributeName, attributes[attributeName]); } var url = PageUtils.UnclickedUrl; var onclick = string.Empty; var innerBuilder = new StringBuilder(node.InnerXml); StlParserManager.ParseInnerContent(innerBuilder, pageInfo, contextInfo); stlAnchor.InnerHtml = innerBuilder.ToString(); //计算动作开始 if (!string.IsNullOrEmpty(type)) { if (StringUtils.EqualsIgnoreCase(type, TypeLogin)) { if (string.IsNullOrEmpty(returnUrl)) { returnUrl = StlUtility.GetStlCurrentUrl(pageInfo, contextInfo.ChannelId, contextInfo.ContentId, contextInfo.ContentInfo); } url = HomeUtils.GetLoginUrl(pageInfo.HomeUrl, returnUrl); } else if (StringUtils.EqualsIgnoreCase(type, TypeRegister)) { if (string.IsNullOrEmpty(returnUrl)) { returnUrl = StlUtility.GetStlCurrentUrl(pageInfo, contextInfo.ChannelId, contextInfo.ContentId, contextInfo.ContentInfo); } url = HomeUtils.GetRegisterUrl(pageInfo.HomeUrl, returnUrl); } else if (StringUtils.EqualsIgnoreCase(type, TypeLogout)) { if (string.IsNullOrEmpty(returnUrl)) { returnUrl = StlUtility.GetStlCurrentUrl(pageInfo, contextInfo.ChannelId, contextInfo.ContentId, contextInfo.ContentInfo); } url = HomeUtils.GetLogoutUrl(pageInfo.HomeUrl, returnUrl); } else if (StringUtils.EqualsIgnoreCase(type, TypeAddFavorite)) { pageInfo.SetPageScripts(TypeAddFavorite, @" <script type=""text/javascript""> function AddFavorite(){ if (document.all) { window.external.addFavorite(window.location.href, document.title); } else if (window.sidebar) { window.sidebar.addPanel(document.title, window.location.href, """"); } } </script> ", true); stlAnchor.Attributes["onclick"] = "AddFavorite();"; } else if (StringUtils.EqualsIgnoreCase(type, TypeSetHomePage)) { url = pageInfo.PublishmentSystemInfo.PublishmentSystemUrl; pageInfo.AddPageEndScriptsIfNotExists(TypeAddFavorite, $@" <script type=""text/javascript""> function SetHomepage(){{ if (document.all) {{ document.body.style.behavior = 'url(#default#homepage)'; document.body.setHomePage(""{url}""); }} else if (window.sidebar) {{ if (window.netscape) {{ try {{ netscape.security.PrivilegeManager.enablePrivilege(""UniversalXPConnect""); }} catch(e) {{ alert(""该操作被浏览器拒绝,如果想启用该功能,请在地址栏内输入 about:config,然后将项 signed.applets.codebase_principal_support 值该为true""); }} }} var prefs = Components.classes['@mozilla.org/preferences-service;1'].getService(Components.interfaces.nsIPrefBranch); prefs.setCharPref('browser.startup.homepage', ""{url}""); }} }} </script> "); stlAnchor.Attributes["onclick"] = "SetHomepage();"; } else if (StringUtils.EqualsIgnoreCase(type, TypeTranslate)) { pageInfo.AddPageScriptsIfNotExists(PageInfo.JsAhTranslate); var msgToTraditionalChinese = "繁體"; var msgToSimplifiedChinese = "简体"; if (!string.IsNullOrEmpty(stlAnchor.InnerHtml)) { if (stlAnchor.InnerHtml.IndexOf(",", StringComparison.Ordinal) != -1) { msgToTraditionalChinese = stlAnchor.InnerHtml.Substring(0, stlAnchor.InnerHtml.IndexOf(",", StringComparison.Ordinal)); msgToSimplifiedChinese = stlAnchor.InnerHtml.Substring(stlAnchor.InnerHtml.IndexOf(",", StringComparison.Ordinal) + 1); } else { msgToTraditionalChinese = stlAnchor.InnerHtml; } } stlAnchor.InnerHtml = msgToTraditionalChinese; if (string.IsNullOrEmpty(stlAnchor.ID)) { stlAnchor.ID = "translateLink"; } pageInfo.SetPageEndScripts(TypeTranslate, $@" <script type=""text/javascript""> var defaultEncoding = 0; var translateDelay = 0; var cookieDomain = ""/""; var msgToTraditionalChinese = ""{msgToTraditionalChinese}""; var msgToSimplifiedChinese = ""{msgToSimplifiedChinese}""; var translateButtonId = ""{stlAnchor.ClientID}""; translateInitilization(); </script> "); } else if (StringUtils.EqualsIgnoreCase(type, TypeClose)) { url = "javascript:window.close()"; } } //计算动作结束 stlAnchor.HRef = url; if (!string.IsNullOrEmpty(onclick)) { stlAnchor.Attributes.Add("onclick", onclick); } return(ControlUtils.GetControlRenderHtml(stlAnchor)); }
private void BindTopic() { string sOutput; var bFullTopic = true; // Load the proper template into out output variable if (!string.IsNullOrWhiteSpace(TopicTemplate)) { // Note: The template may be set in the topic review section of the Post form. bFullTopic = false; sOutput = TopicTemplate; sOutput = Utilities.ParseSpacer(sOutput); } else if (UseTemplatePath && TemplatePath != string.Empty) { sOutput = Utilities.GetFileContent(TemplatePath + "TopicView.htm"); sOutput = Utilities.ParseSpacer(sOutput); } else { sOutput = DataCache.GetCachedTemplate(MainSettings.TemplateCache, ModuleId, "TopicView", _topicTemplateId); } // Handle the postinfo token if present if (sOutput.Contains("[POSTINFO]") && ForumInfo.ProfileTemplateId > 0) sOutput = sOutput.Replace("[POSTINFO]", DataCache.GetCachedTemplate(MainSettings.TemplateCache, ModuleId, "ProfileInfo", ForumInfo.ProfileTemplateId)); // Run some basic rpleacements sOutput = sOutput.Replace("[PORTALID]", PortalId.ToString()); sOutput = sOutput.Replace("[MODULEID]", ForumModuleId.ToString()); sOutput = sOutput.Replace("[TABID]", ForumTabId.ToString()); sOutput = sOutput.Replace("[TOPICID]", TopicId.ToString()); sOutput = sOutput.Replace("[AF:CONTROL:FORUMID]", ForumId.ToString()); sOutput = sOutput.Replace("[AF:CONTROL:FORUMGROUPID]", ForumGroupId.ToString()); sOutput = sOutput.Replace("[AF:CONTROL:PARENTFORUMID]", ParentForumId.ToString()); // Add Topic Scripts var ctlTopicScripts = (af_topicscripts)(LoadControl("~/DesktopModules/ActiveForums/controls/af_topicscripts.ascx")); ctlTopicScripts.ModuleConfiguration = ModuleConfiguration; Controls.Add(ctlTopicScripts); // Pretty sure this is no longer used /* if (sOutput.Contains("<am:TopicsNavigator")) { var ctl = ParseControl(sOutput); if(ctl != null) Controls.Add(ctl); LinkControls(Controls); return; } */ #region Build Topic Properties if (sOutput.Contains("[AF:PROPERTIES")) { var sProps = string.Empty; if(!string.IsNullOrWhiteSpace(_topicData)) { var sPropTemplate = TemplateUtils.GetTemplateSection(sOutput, "[AF:PROPERTIES]", "[/AF:PROPERTIES]"); try { var xDoc = new XmlDocument(); xDoc.LoadXml(_topicData); var xRoot = xDoc.DocumentElement; var xNodeList = (xRoot != null) ? xRoot.SelectNodes("//properties/property") : null; if (xNodeList != null && xNodeList.Count > 0) { for (var i = 0; i < xNodeList.Count; i++) { var pName = Utilities.HTMLDecode(xNodeList[i].ChildNodes[0].InnerText); var pValue = Utilities.HTMLDecode(xNodeList[i].ChildNodes[1].InnerText); // This builds the replacement text for the properties template var tmp = sPropTemplate.Replace("[AF:PROPERTY:LABEL]", "[RESX:" + pName + "]"); tmp = tmp.Replace("[AF:PROPERTY:VALUE]", pValue); sProps += tmp; // This deals with any specific property tokens that may be present outside of the normal properties template sOutput = sOutput.Replace("[AF:PROPERTY:" + pName + ":LABEL]", Utilities.GetSharedResource("[RESX:" + pName + "]")); sOutput = sOutput.Replace("[AF:PROPERTY:" + pName + ":VALUE]", pValue); var pValueKey = string.IsNullOrWhiteSpace(pValue) ? string.Empty : Utilities.CleanName(pValue).ToLowerInvariant(); sOutput = sOutput.Replace("[AF:PROPERTY:" + pName + ":VALUEKEY]", pValueKey); } } } catch (XmlException) { // Property XML is invalid // Nothing to do in this case but ignore the issue. } } sOutput = TemplateUtils.ReplaceSubSection(sOutput, sProps, "[AF:PROPERTIES]", "[/AF:PROPERTIES]"); } #endregion #region Populate Metadata // If the template contains a meta template, grab it then remove the token if (sOutput.Contains("[META]")) { MetaTemplate = TemplateUtils.GetTemplateSection(sOutput, "[META]", "[/META]"); sOutput = TemplateUtils.ReplaceSubSection(sOutput, string.Empty, "[META]", "[/META]"); } //Parse Meta Template if (!string.IsNullOrEmpty(MetaTemplate)) { MetaTemplate = MetaTemplate.Replace("[FORUMNAME]", _forumName); MetaTemplate = MetaTemplate.Replace("[GROUPNAME]", _groupName); var settings = Entities.Portals.PortalController.GetCurrentPortalSettings(); var pageName = (settings.ActiveTab.Title.Length == 0) ? Server.HtmlEncode(settings.ActiveTab.TabName) : Server.HtmlEncode(settings.ActiveTab.Title); MetaTemplate = MetaTemplate.Replace("[PAGENAME]", pageName); MetaTemplate = MetaTemplate.Replace("[PORTALNAME]", settings.PortalName); MetaTemplate = MetaTemplate.Replace("[TAGS]", _tags); // Subject if (MetaTemplate.Contains("[TOPICSUBJECT:")) { const string pattern = "(\\[TOPICSUBJECT:(.+?)\\])"; foreach (Match m in Regex.Matches(MetaTemplate, pattern)) { var maxLength = Utilities.SafeConvertInt(m.Groups[2].Value, 255); if (_topicSubject.Length > maxLength) MetaTemplate = MetaTemplate.Replace(m.Value, _topicSubject.Substring(0, maxLength) + "..."); else MetaTemplate = MetaTemplate.Replace(m.Value, Utilities.StripHTMLTag(_topicSubject)); } } MetaTemplate = MetaTemplate.Replace("[TOPICSUBJECT]", Utilities.StripHTMLTag(_topicSubject)); // Body if (MetaTemplate.Contains("[BODY:")) { const string pattern = "(\\[BODY:(.+?)\\])"; foreach (Match m in Regex.Matches(MetaTemplate, pattern)) { var maxLength = Utilities.SafeConvertInt(m.Groups[2].Value, 512); if (_topicDescription.Length > maxLength) MetaTemplate = MetaTemplate.Replace(m.Value, _topicDescription.Substring(0, maxLength) + "..."); else MetaTemplate = MetaTemplate.Replace(m.Value, _topicDescription); } } MetaTemplate = MetaTemplate.Replace("[BODY]", _topicDescription); MetaTitle = TemplateUtils.GetTemplateSection(MetaTemplate, "[TITLE]", "[/TITLE]").Replace("[TITLE]", string.Empty).Replace("[/TITLE]", string.Empty); MetaTitle = MetaTitle.TruncateAtWord(SEOConstants.MaxMetaTitleLength); MetaDescription = TemplateUtils.GetTemplateSection(MetaTemplate, "[DESCRIPTION]", "[/DESCRIPTION]").Replace("[DESCRIPTION]", string.Empty).Replace("[/DESCRIPTION]", string.Empty); MetaDescription = MetaDescription.TruncateAtWord(SEOConstants.MaxMetaDescriptionLength); MetaKeywords = TemplateUtils.GetTemplateSection(MetaTemplate, "[KEYWORDS]", "[/KEYWORDS]").Replace("[KEYWORDS]", string.Empty).Replace("[/KEYWORDS]", string.Empty); } #endregion #region Setup Breadcrumbs var breadCrumb = TemplateUtils.GetTemplateSection(sOutput, "[BREADCRUMB]", "[/BREADCRUMB]").Replace("[BREADCRUMB]", string.Empty).Replace("[/BREADCRUMB]", string.Empty); if (MainSettings.UseSkinBreadCrumb) { var ctlUtils = new ControlUtils(); var groupUrl = ctlUtils.BuildUrl(ForumTabId, ForumModuleId, ForumInfo.ForumGroup.PrefixURL, string.Empty, ForumInfo.ForumGroupId, -1, -1, -1, string.Empty, 1, SocialGroupId); var forumUrl = ctlUtils.BuildUrl(ForumTabId, ForumModuleId, ForumInfo.ForumGroup.PrefixURL, ForumInfo.PrefixURL, ForumInfo.ForumGroupId, ForumInfo.ForumID, -1, -1, string.Empty, 1, SocialGroupId); var topicUrl = ctlUtils.BuildUrl(ForumTabId, ForumModuleId, ForumInfo.ForumGroup.PrefixURL, ForumInfo.PrefixURL, ForumInfo.ForumGroupId, ForumInfo.ForumID, TopicId, _topicURL, -1, -1, string.Empty, 1, SocialGroupId); var sCrumb = "<a href=\"" + groupUrl + "\">" + _groupName + "</a>|"; sCrumb += "<a href=\"" + forumUrl + "\">" + _forumName + "</a>"; sCrumb += "|<a href=\"" + topicUrl + "\">" + _topicSubject + "</a>"; if (Environment.UpdateBreadCrumb(Page.Controls, sCrumb)) breadCrumb = string.Empty; } sOutput = TemplateUtils.ReplaceSubSection(sOutput, breadCrumb, "[BREADCRUMB]", "[/BREADCRUMB]"); #endregion // Parse Common Controls First sOutput = ParseControls(sOutput); // Note: If the containing element is not found, GetTemplateSection returns the entire template // This is desired behavior in this case as it's possible that the entire template is our topics container. var topic = TemplateUtils.GetTemplateSection(sOutput, "[AF:CONTROL:CALLBACK]", "[/AF:CONTROL:CALLBACK]"); topic = ParseTopic(topic); if (!topic.Contains(Globals.ControlRegisterTag)) topic = Globals.ControlRegisterTag + topic; topic = Utilities.LocalizeControl(topic); // If a template was passed in, we don't need to do this. if (bFullTopic) { sOutput = TemplateUtils.ReplaceSubSection(sOutput, "<asp:placeholder id=\"plhTopic\" runat=\"server\" />", "[AF:CONTROL:CALLBACK]", "[/AF:CONTROL:CALLBACK]"); sOutput = Utilities.LocalizeControl(sOutput); sOutput = Utilities.StripTokens(sOutput); // If we added a banner, make sure we register than banner tag if (sOutput.Contains("<dnn:BANNER") && !sOutput.Contains(Globals.BannerRegisterTag)) sOutput = Globals.BannerRegisterTag + sOutput; var ctl = ParseControl(sOutput); if(ctl != null) Controls.Add(ctl); } // Create a topic placeholder if we don't have one. var plhTopic = FindControl("plhTopic") as PlaceHolder; if (plhTopic == null) { plhTopic = new PlaceHolder { ID = "plhTopic" }; Controls.Add(plhTopic); } // Parse and add out topic control // If we added a banner, make sure we register than banner tag // This has to be done separately from sOutput because they are usually different. if (topic.Contains("<dnn:BANNER") && !topic.Contains(Globals.BannerRegisterTag)) topic = Globals.BannerRegisterTag + topic; var ctlTopic = ParseControl(topic); if(ctlTopic != null) plhTopic.Controls.Add(ctlTopic); //Add helper controls //Quick Jump DropDownList var plh = FindControl("plhQuickJump") as PlaceHolder; if (plh != null) { plh.Controls.Clear(); var ctlForumJump = new af_quickjump { ModuleConfiguration = ModuleConfiguration, MOID = ModuleId, dtForums = null, ForumId = ForumId, EnableViewState = false, ForumInfo = ForumId > 0 ? ForumInfo : null }; if (!(plh.Controls.Contains(ctlForumJump))) { plh.Controls.Add(ctlForumJump); } } //Poll Container plh = FindControl("plhPoll") as PlaceHolder; if (plh != null) { plh.Controls.Clear(); plh.Controls.Add(new af_polls { ModuleConfiguration = ModuleConfiguration, TopicId = TopicId, ForumId = ForumId }); } //Quick Reply if (CanRead && _bLocked == false) { plh = FindControl("plhQuickReply") as PlaceHolder; if (plh != null) { plh.Controls.Clear(); var ctlQuickReply = (af_quickreplyform)(LoadControl("~/DesktopModules/ActiveForums/controls/af_quickreply.ascx")); ctlQuickReply.ModuleConfiguration = ModuleConfiguration; ctlQuickReply.CanTrust = _bTrust; ctlQuickReply.ModApprove = _bModApprove; ctlQuickReply.IsTrusted = _isTrusted; ctlQuickReply.Subject = _topicSubject; ctlQuickReply.AllowSubscribe = _allowSubscribe; ctlQuickReply.AllowHTML = _allowHTML; ctlQuickReply.AllowScripts = _allowScript; ctlQuickReply.ForumId = ForumId; ctlQuickReply.SocialGroupId = SocialGroupId; ctlQuickReply.ForumModuleId = ForumModuleId; ctlQuickReply.ForumTabId = TabId; if (ForumId > 0) ctlQuickReply.ForumInfo = ForumInfo; plh.Controls.Add(ctlQuickReply); } } // Topic Sort plh = FindControl("plhTopicSort") as PlaceHolder; if (plh != null) { plh.Controls.Clear(); var ctlTopicSort = (af_topicsorter)(LoadControl("~/DesktopModules/ActiveForums/controls/af_topicsort.ascx")); ctlTopicSort.ModuleConfiguration = ModuleConfiguration; ctlTopicSort.ForumId = ForumId; ctlTopicSort.DefaultSort = _defaultSort; if (ForumId > 0) ctlTopicSort.ForumInfo = ForumInfo; plh.Controls.Add(ctlTopicSort); } // Topic Status plh = FindControl("plhStatus") as PlaceHolder; if (plh != null) { plh.Controls.Clear(); var ctlTopicStatus = (af_topicstatus)(LoadControl("~/DesktopModules/ActiveForums/controls/af_topicstatus.ascx")); ctlTopicStatus.ModuleConfiguration = ModuleConfiguration; ctlTopicStatus.Status = _statusId; ctlTopicStatus.ForumId = ForumId; if (ForumId > 0) ctlTopicStatus.ForumInfo = ForumInfo; plh.Controls.Add(ctlTopicStatus); } BuildPager(); }
public string Render() { ForumController fc = new ForumController(); string fs = fc.GetForumsForUser(ForumUser.UserRoles, PortalId, ModuleId, "CanEdit"); if (! (string.IsNullOrEmpty(fs))) { _canEdit = true; } System.Text.StringBuilder sb = new System.Text.StringBuilder(); string forumPrefix = string.Empty; string groupPrefix = string.Empty; _mainSettings = DataCache.MainSettings(ModuleId); if (_mainSettings.URLRewriteEnabled) { if (ForumId > 0) { Forum f = fc.GetForum(PortalId, ModuleId, ForumId); if (f != null) { forumPrefix = f.PrefixURL; groupPrefix = f.ForumGroup.PrefixURL; } } else if (ForumGroupId > 0) { ForumGroupController grp = new ForumGroupController(); ForumGroupInfo g = grp.Groups_Get(ModuleId, ForumGroupId); if (g != null) { groupPrefix = g.PrefixURL; } } } string tmp = string.Empty; Data.Topics db = new Data.Topics(); int recordCount = 0; int i = 0; sb.Append(HeaderTemplate); using (IDataReader dr = db.TopicsList(PortalId, PageIndex, PageSize, ForumIds, CategoryId, TagId)) { while (dr.Read()) { if (recordCount == 0) { recordCount = int.Parse(dr["RecordCount"].ToString()); } tmp = ParseDataRow(dr, Template); if (i % 2 == 0) { tmp = tmp.Replace("[ROWCSS]", ItemCss); } else { tmp = tmp.Replace("[ROWCSS]", AltItemCSS); } i += 1; sb.Append(tmp); } dr.Close(); } sb.Append(FooterTemplate); int pageCount = 1; pageCount = Convert.ToInt32(System.Math.Ceiling((double)recordCount / PageSize)); ControlUtils cUtils = new ControlUtils(); string otherPrefix = string.Empty; if (TagId > 0 | CategoryId > 0) { int id = -1; if (TagId > 0) { id = TagId; } else { id = CategoryId; } using (IDataReader dr = DataProvider.Instance().Tags_Get(PortalId, ModuleId, id)) { while (dr.Read()) { otherPrefix = Utilities.CleanName(dr["TagName"].ToString()); } dr.Close(); } } sb.Append(cUtils.BuildPager(TabId, ModuleId, groupPrefix, forumPrefix, ForumGroupId, ForumId, TagId, CategoryId, otherPrefix, PageIndex, pageCount)); return sb.ToString(); }
private string ParseTopic(IDataRecord row, string tmp) { tmp = ParseDataRow(row, tmp); ControlUtils cUtils = new ControlUtils(); tmp = tmp.Replace("[TOPICURL]", cUtils.TopicURL(row, TabId, ModuleId)); tmp = tmp.Replace("[FORUMURL]", cUtils.ForumURL(row, TabId, ModuleId)); tmp = tmp.Replace("[TOPICSTATE]", cUtils.TopicState(row)); return tmp; }
private bool ValidateForm() { var result = true; if (cmbOperator.SelectedItem != null && cmbOperator.SelectedItem is OperatorItem) { var oper = (OperatorItem)cmbOperator.SelectedItem; AttributeItem attribute = null; if (cmbAttribute.SelectedItem != null && cmbAttribute.SelectedItem is AttributeItem) { // Get type from condition attribute attribute = (AttributeItem)cmbAttribute.SelectedItem; } var valueType = oper.ValueType; var attributeType = oper.AttributeType; var value = ControlUtils.GetValueFromControl(cmbValue).Trim(); if (valueType == AttributeTypeCode.ManagedProperty) { // Type not defined by operator if (attribute != null) { // Get type from condition attribute valueType = attribute.Metadata.AttributeType; } else { // Default, cannot determine type valueType = AttributeTypeCode.String; } } var error = ""; if (attributeType != null && attribute != null) { if (attributeType != attribute.Metadata.AttributeType) { if (attributeType != AttributeTypeCode.Lookup || (attribute.Metadata.AttributeType != AttributeTypeCode.Owner && attribute.Metadata.AttributeType != AttributeTypeCode.Customer)) { error = "Operator " + oper.ToString() + " is not valid for attribute of type " + attribute.Metadata.AttributeType.ToString(); } } } switch (valueType) { case null: if (!string.IsNullOrWhiteSpace(value)) { error = "Operator " + oper.ToString() + " does not allow value"; } break; case AttributeTypeCode.Boolean: if (value != "0" && value != "1") { error = "Value must be 0 or 1"; } break; case AttributeTypeCode.DateTime: DateTime date; if (!DateTime.TryParse(value, out date)) { error = "Operator " + oper.ToString() + " requires date value"; } break; case AttributeTypeCode.Integer: case AttributeTypeCode.State: case AttributeTypeCode.Status: case AttributeTypeCode.Picklist: case AttributeTypeCode.BigInt: int intvalue; if (!int.TryParse(value, out intvalue)) { error = "Operator " + oper.ToString() + " requires whole number value"; } break; case AttributeTypeCode.Decimal: case AttributeTypeCode.Double: case AttributeTypeCode.Money: decimal decvalue; if (!decimal.TryParse(value, out decvalue)) { error = "Operator " + oper.ToString() + " requires decimal value"; } break; case AttributeTypeCode.Lookup: case AttributeTypeCode.Customer: case AttributeTypeCode.Owner: case AttributeTypeCode.Uniqueidentifier: Guid guidvalue; if (!Guid.TryParse(value, out guidvalue)) { error = "Operator " + oper.ToString() + " requires a proper guid with format: " + Guid.Empty.ToString(); } break; case AttributeTypeCode.String: case AttributeTypeCode.Memo: case AttributeTypeCode.EntityName: case AttributeTypeCode.Virtual: break; case AttributeTypeCode.PartyList: case AttributeTypeCode.CalendarRules: case AttributeTypeCode.ManagedProperty: error = "Unsupported condition attribute type: " + valueType; break; } if (!string.IsNullOrWhiteSpace(error)) { MessageBox.Show(error, "Condition error", MessageBoxButtons.OK, MessageBoxIcon.Warning); result = false; } } return(result); }
private static string ParseElement(PageInfo pageInfo, ContextInfo contextInfo, ListInfo listInfo, DataSet dataSource) { var parsedContent = string.Empty; if (listInfo.Layout == ELayout.None) { var rptContents = new Repeater { ItemTemplate = new RepeaterTemplate(listInfo.ItemTemplate, listInfo.SelectedItems, listInfo.SelectedValues, listInfo.SeparatorRepeatTemplate, listInfo.SeparatorRepeat, pageInfo, EContextType.Content, contextInfo) }; if (!string.IsNullOrEmpty(listInfo.HeaderTemplate)) { rptContents.HeaderTemplate = new SeparatorTemplate(listInfo.HeaderTemplate); } if (!string.IsNullOrEmpty(listInfo.FooterTemplate)) { rptContents.FooterTemplate = new SeparatorTemplate(listInfo.FooterTemplate); } if (!string.IsNullOrEmpty(listInfo.SeparatorTemplate)) { rptContents.SeparatorTemplate = new SeparatorTemplate(listInfo.SeparatorTemplate); } if (!string.IsNullOrEmpty(listInfo.AlternatingItemTemplate)) { rptContents.AlternatingItemTemplate = new RepeaterTemplate(listInfo.AlternatingItemTemplate, listInfo.SelectedItems, listInfo.SelectedValues, listInfo.SeparatorRepeatTemplate, listInfo.SeparatorRepeat, pageInfo, EContextType.Content, contextInfo); } rptContents.DataSource = dataSource; rptContents.DataBind(); if (rptContents.Items.Count > 0) { parsedContent = ControlUtils.GetControlRenderHtml(rptContents); } } else { var pdlContents = new ParsedDataList(); TemplateUtility.PutListInfoToMyDataList(pdlContents, listInfo); pdlContents.ItemTemplate = new DataListTemplate(listInfo.ItemTemplate, listInfo.SelectedItems, listInfo.SelectedValues, listInfo.SeparatorRepeatTemplate, listInfo.SeparatorRepeat, pageInfo, EContextType.Content, contextInfo); if (!string.IsNullOrEmpty(listInfo.HeaderTemplate)) { pdlContents.HeaderTemplate = new SeparatorTemplate(listInfo.HeaderTemplate); } if (!string.IsNullOrEmpty(listInfo.FooterTemplate)) { pdlContents.FooterTemplate = new SeparatorTemplate(listInfo.FooterTemplate); } if (!string.IsNullOrEmpty(listInfo.SeparatorTemplate)) { pdlContents.SeparatorTemplate = new SeparatorTemplate(listInfo.SeparatorTemplate); } if (!string.IsNullOrEmpty(listInfo.AlternatingItemTemplate)) { pdlContents.AlternatingItemTemplate = new DataListTemplate(listInfo.AlternatingItemTemplate, listInfo.SelectedItems, listInfo.SelectedValues, listInfo.SeparatorRepeatTemplate, listInfo.SeparatorRepeat, pageInfo, EContextType.Content, contextInfo); } pdlContents.DataSource = dataSource; pdlContents.DataKeyField = ContentAttribute.Id; pdlContents.DataBind(); if (pdlContents.Items.Count > 0) { parsedContent = ControlUtils.GetControlRenderHtml(pdlContents); } } return(parsedContent); }
public void Page_Load(object sender, EventArgs e) { if (IsForbidden) { return; } SpContents.ControlToPaginate = RptContents; SpContents.ItemsPerPage = Constants.PageSize; SpContents.SelectCommand = !AuthRequest.IsQueryExists("LogType") ? DataProvider.SiteLogDao.GetSelectCommend() : DataProvider.SiteLogDao.GetSelectCommend(SiteId, AuthRequest.GetQueryString("LogType"), AuthRequest.GetQueryString("UserName"), AuthRequest.GetQueryString("Keyword"), AuthRequest.GetQueryString("DateFrom"), AuthRequest.GetQueryString("DateTo")); SpContents.SortField = nameof(SiteLogInfo.Id); SpContents.SortMode = SortMode.DESC; RptContents.ItemDataBound += RptContents_ItemDataBound; if (AuthRequest.IsQueryExists("Delete")) { var arraylist = TranslateUtils.StringCollectionToIntList(AuthRequest.GetQueryString("IDCollection")); DataProvider.SiteLogDao.Delete(arraylist); SuccessDeleteMessage(); } else if (AuthRequest.IsQueryExists("DeleteAll")) { DataProvider.SiteLogDao.DeleteAll(); SuccessDeleteMessage(); } else if (AuthRequest.IsQueryExists("Setting")) { ConfigManager.SystemConfigInfo.IsLogSite = !ConfigManager.SystemConfigInfo.IsLogSite; DataProvider.ConfigDao.Update(ConfigManager.Instance); SuccessMessage($"成功{(ConfigManager.SystemConfigInfo.IsLogSite ? "启用" : "禁用")}日志记录"); } if (IsPostBack) { return; } VerifySystemPermissions(ConfigManager.SettingsPermissions.Log); if (SiteId == 0) { LtlSite.Text = @"<th align=""text-center text-nowrap"">站点名称</th>"; } DdlSiteId.Items.Add(new ListItem("<<全部站点>>", "0")); var siteIdList = SiteManager.GetSiteIdListOrderByLevel(); foreach (var psId in siteIdList) { DdlSiteId.Items.Add(new ListItem(SiteManager.GetSiteInfo(psId).SiteName, psId.ToString())); } DdlLogType.Items.Add(new ListItem("全部记录", "All")); DdlLogType.Items.Add(new ListItem("栏目相关记录", "Channel")); DdlLogType.Items.Add(new ListItem("内容相关记录", "Content")); if (AuthRequest.IsQueryExists("LogType")) { ControlUtils.SelectSingleItem(DdlSiteId, SiteId.ToString()); ControlUtils.SelectSingleItem(DdlLogType, AuthRequest.GetQueryString("LogType")); TbUserName.Text = AuthRequest.GetQueryString("UserName"); TbKeyword.Text = AuthRequest.GetQueryString("Keyword"); TbDateFrom.Text = AuthRequest.GetQueryString("DateFrom"); TbDateTo.Text = AuthRequest.GetQueryString("DateTo"); } BtnDelete.Attributes.Add("onclick", PageUtils.GetRedirectStringWithCheckBoxValueAndAlert( PageUtils.GetSettingsUrl(nameof(PageLogSite), new NameValueCollection { { "Delete", "True" } }), "IDCollection", "IDCollection", "请选择需要删除的日志!", "此操作将删除所选日志,确认吗?")); BtnDeleteAll.Attributes.Add("onclick", AlertUtils.ConfirmRedirect("删除所有日志", "此操作将删除所有日志信息,确定吗?", "删除全部", PageUtils.GetSettingsUrl(nameof(PageLogSite), new NameValueCollection { { "DeleteAll", "True" } }))); if (ConfigManager.SystemConfigInfo.IsLogSite) { BtnSetting.Text = "禁用站点日志"; BtnSetting.Attributes.Add("onclick", AlertUtils.ConfirmRedirect("禁用站点日志", "此操作将禁用站点日志记录功能,确定吗?", "禁 用", PageUtils.GetSettingsUrl(nameof(PageLogSite), new NameValueCollection { { "Setting", "True" } }))); } else { LtlState.Text = @"<div class=""alert alert-danger m-t-10"">站点日志当前处于禁用状态,系统将不会记录站点操作日志!</div>"; BtnSetting.Text = "启用站点日志"; BtnSetting.Attributes.Add("onclick", AlertUtils.ConfirmRedirect("启用站点日志", "此操作将启用站点日志记录功能,确定吗?", "启 用", PageUtils.GetSettingsUrl(nameof(PageLogSite), new NameValueCollection { { "Setting", "True" } }))); } SpContents.DataBind(); }
private void button1_Click(object sender, EventArgs e) { DataTable results = db.execute(request).Tables[request.tableName];//TODO Should get from database ControlUtils.FillComboBoxWithDataSet <SectorComboBoxItem>(comboBox1, results); }
public static string ReplaceIDTokens(string script, Control seed) { script = TokenUtils.ReplaceDirectMethods(script, seed); Control control = null; string[] parts = null; foreach (Match match in ID_Pattern_RE.Matches(script)) { parts = match.Value.Between("{", "}").Split('.'); control = ControlUtils.FindControl(seed, parts[0]); if (control != null) { if (parts.Length == 2) { PropertyInfo prop = control.GetType().GetProperty(parts[1]); if (prop != null) { object value = prop.GetValue(control, null); if (value == null) { value = ReflectionUtils.GetDefaultValue(prop); } if (value is string) { string val = TokenUtils.ParseTokens(value.ToString(), control); if (TokenUtils.IsRawToken(val)) { val = JSON.Serialize(TokenUtils.ReplaceRawToken(val)).Chop(); } else { val = JSON.Serialize(val); } script = script.Replace(match.Value, val); } else { script = script.Replace(match.Value, JSON.Serialize(value)); } } } else { if (control is Observable || control is UserControl) { script = script.Replace(match.Value, control.ClientID); } else { script = script.Replace(match.Value, "Ext.get(\"" + control.ClientID + "\")"); } } } else { script = script.Replace(match.Value, "Ext.get(\"" + parts[0] + "\")"); } } return(script); }
public static BaseControl Get(string id) { return(ControlUtils.FindControl <BaseControl>(ResourceManager.GetInstance(HttpContext.Current), id)); }
public static Control Get(string id) { return(ControlUtils.FindControl <Control>(ResponseManager.ResourceManager, id)); }
public static T Get <T>(string id) where T : BaseControl { return(ControlUtils.FindControl <T>(ResourceManager.GetInstance(HttpContext.Current), id)); }
public string Parse(int currentPageIndex, int pageCount) { var parsedContent = string.Empty; _contextInfo.PageItemIndex = currentPageIndex * DisplayInfo.PageNum; try { if (_node != null) { if (_dataSet != null) { var objPage = new PagedDataSource { DataSource = _dataSet.Tables[0].DefaultView }; //分页类 if (pageCount > 1) { objPage.AllowPaging = true; objPage.PageSize = DisplayInfo.PageNum;//每页显示的项数 } else { objPage.AllowPaging = false; } objPage.CurrentPageIndex = currentPageIndex;//当前页的索引 if (DisplayInfo.Layout == ELayout.None) { var rptContents = new Repeater { ItemTemplate = new RepeaterTemplate(DisplayInfo.ItemTemplate, DisplayInfo.SelectedItems, DisplayInfo.SelectedValues, DisplayInfo.SeparatorRepeatTemplate, DisplayInfo.SeparatorRepeat, _pageInfo, EContextType.Channel, _contextInfo) }; if (!string.IsNullOrEmpty(DisplayInfo.HeaderTemplate)) { rptContents.HeaderTemplate = new SeparatorTemplate(DisplayInfo.HeaderTemplate); } if (!string.IsNullOrEmpty(DisplayInfo.FooterTemplate)) { rptContents.FooterTemplate = new SeparatorTemplate(DisplayInfo.FooterTemplate); } if (!string.IsNullOrEmpty(DisplayInfo.SeparatorTemplate)) { rptContents.SeparatorTemplate = new SeparatorTemplate(DisplayInfo.SeparatorTemplate); } if (!string.IsNullOrEmpty(DisplayInfo.AlternatingItemTemplate)) { rptContents.AlternatingItemTemplate = new RepeaterTemplate(DisplayInfo.AlternatingItemTemplate, DisplayInfo.SelectedItems, DisplayInfo.SelectedValues, DisplayInfo.SeparatorRepeatTemplate, DisplayInfo.SeparatorRepeat, _pageInfo, EContextType.Channel, _contextInfo); } rptContents.DataSource = objPage; rptContents.DataBind(); if (rptContents.Items.Count > 0) { parsedContent = ControlUtils.GetControlRenderHtml(rptContents); } } else { var pdlContents = new ParsedDataList(); //设置显示属性 TemplateUtility.PutListInfoToMyDataList(pdlContents, DisplayInfo); //设置列表模板 pdlContents.ItemTemplate = new DataListTemplate(DisplayInfo.ItemTemplate, DisplayInfo.SelectedItems, DisplayInfo.SelectedValues, DisplayInfo.SeparatorRepeatTemplate, DisplayInfo.SeparatorRepeat, _pageInfo, EContextType.Channel, _contextInfo); if (!string.IsNullOrEmpty(DisplayInfo.HeaderTemplate)) { pdlContents.HeaderTemplate = new SeparatorTemplate(DisplayInfo.HeaderTemplate); } if (!string.IsNullOrEmpty(DisplayInfo.FooterTemplate)) { pdlContents.FooterTemplate = new SeparatorTemplate(DisplayInfo.FooterTemplate); } if (!string.IsNullOrEmpty(DisplayInfo.SeparatorTemplate)) { pdlContents.SeparatorTemplate = new SeparatorTemplate(DisplayInfo.SeparatorTemplate); } if (!string.IsNullOrEmpty(DisplayInfo.AlternatingItemTemplate)) { pdlContents.AlternatingItemTemplate = new DataListTemplate(DisplayInfo.AlternatingItemTemplate, DisplayInfo.SelectedItems, DisplayInfo.SelectedValues, DisplayInfo.SeparatorRepeatTemplate, DisplayInfo.SeparatorRepeat, _pageInfo, EContextType.Channel, _contextInfo); } pdlContents.DataSource = objPage; pdlContents.DataKeyField = ChannelAttribute.Id; pdlContents.DataBind(); if (pdlContents.Items.Count > 0) { parsedContent = ControlUtils.GetControlRenderHtml(pdlContents); } } } } } catch (Exception ex) { parsedContent = StlParserUtility.GetStlErrorMessage(ElementName, _stlPageChannelsElement, ex); } //还原翻页为0,使得其他列表能够正确解析ItemIndex _contextInfo.PageItemIndex = 0; return(StlParserUtility.GetBackHtml(parsedContent, _pageInfo)); }
public void Page_Load(object sender, EventArgs e) { if (IsForbidden) { return; } var permissions = PermissionsManager.GetPermissions(Body.AdministratorName); PageUtils.CheckRequestParameter("PublishmentSystemID"); var nodeId = Body.IsQueryExists("NodeID") ? Body.GetQueryInt("NodeID", PublishmentSystemId) : PublishmentSystemId; _nodeInfo = NodeManager.GetNodeInfo(PublishmentSystemId, nodeId); _tableStyle = NodeManager.GetTableStyle(PublishmentSystemInfo, _nodeInfo); _tableName = NodeManager.GetTableName(PublishmentSystemInfo, _nodeInfo); _relatedIdentities = RelatedIdentities.GetChannelRelatedIdentities(PublishmentSystemId, nodeId); _tableStyleInfoList = TableStyleManager.GetTableStyleInfoList(_tableStyle, _tableName, _relatedIdentities); _attributesOfDisplay = TranslateUtils.StringCollectionToStringCollection(NodeManager.GetContentAttributesOfDisplay(PublishmentSystemId, nodeId)); if (_nodeInfo.Additional.IsPreviewContents) { new Action(() => { DataProvider.ContentDao.DeletePreviewContents(PublishmentSystemId, _tableName, _nodeInfo); }).BeginInvoke(null, null); } if (Body.IsQueryExists("TheNodeID") && (Body.IsQueryExists("Subtract") || Body.IsQueryExists("Add"))) { var theNodeId = Body.GetQueryInt("TheNodeID"); if (PublishmentSystemId != theNodeId) { var isSubtract = Body.IsQueryExists("Subtract"); DataProvider.NodeDao.UpdateTaxis(PublishmentSystemId, theNodeId, isSubtract); Body.AddSiteLog(PublishmentSystemId, theNodeId, 0, "栏目排序" + (isSubtract ? "上升" : "下降"), $"栏目:{NodeManager.GetNodeName(PublishmentSystemId, theNodeId)}"); } } SpContents.ControlToPaginate = RptContents; RptContents.ItemDataBound += rptContents_ItemDataBound; SpContents.ItemsPerPage = PublishmentSystemInfo.Additional.PageSize; var administratorName = AdminUtility.IsViewContentOnlySelf(Body.AdministratorName, PublishmentSystemId, nodeId) ? Body.AdministratorName : string.Empty; if (Body.IsQueryExists("SearchType")) { var owningNodeIdList = new List <int> { nodeId }; SpContents.SelectCommand = DataProvider.ContentDao.GetSelectCommend(_tableStyle, _tableName, PublishmentSystemId, nodeId, permissions.IsSystemAdministrator, owningNodeIdList, Body.GetQueryString("SearchType"), Body.GetQueryString("Keyword"), Body.GetQueryString("DateFrom"), string.Empty, false, ETriState.All, false, false, false, administratorName); } else { SpContents.SelectCommand = BaiRongDataProvider.ContentDao.GetSelectCommend(_tableName, nodeId, ETriState.All, administratorName); } SpContents.SortField = BaiRongDataProvider.ContentDao.GetSortFieldName(); SpContents.SortMode = SortMode.DESC; if (Body.IsQueryExists("strDirection")) { SpContents.SortField = "AddDate"; SpContents.SortMode = Body.GetQueryString("strDirection").Equals("0") ? SortMode.ASC : SortMode.DESC; } //分页的时候,不去查询总条数,直接使用栏目的属性:ContentNum SpContents.IsQueryTotalCount = false; SpContents.TotalCount = _nodeInfo.ContentNum; RptChannels.DataSource = DataProvider.NodeDao.GetNodeIdListByScopeType(_nodeInfo, EScopeType.Children, string.Empty, string.Empty); RptChannels.ItemDataBound += rptChannels_ItemDataBound; if (!IsPostBack) { var nodeName = NodeManager.GetNodeNameNavigation(PublishmentSystemId, nodeId).Replace(">", "/"); BreadCrumbWithItemTitle(AppManager.Cms.LeftMenu.IdContent, "栏目及内容", nodeName, string.Empty); var url = PageUtils.GetCmsUrl(nameof(PageContentChannel), null); LtlContentButtons.Text = WebUtils.GetContentCommands(Body.AdministratorName, PublishmentSystemInfo, _nodeInfo, PageUrl, url, false); LtlChannelButtons.Text = WebUtils.GetChannelCommands(Body.AdministratorName, PublishmentSystemInfo, _nodeInfo, PageUrl, url); SpContents.DataBind(); RptChannels.DataBind(); if (_tableStyleInfoList != null) { foreach (var styleInfo in _tableStyleInfoList) { if (styleInfo.IsVisible) { var listitem = new ListItem(styleInfo.DisplayName, styleInfo.AttributeName); SearchType.Items.Add(listitem); } } } //添加隐藏属性 SearchType.Items.Add(new ListItem("内容ID", ContentAttribute.Id)); SearchType.Items.Add(new ListItem("添加者", ContentAttribute.AddUserName)); SearchType.Items.Add(new ListItem("最后修改者", ContentAttribute.LastEditUserName)); SearchType.Items.Add(new ListItem("内容组", ContentAttribute.ContentGroupNameCollection)); if (Body.IsQueryExists("SearchType")) { DateFrom.Text = Body.GetQueryString("DateFrom"); ControlUtils.SelectListItems(SearchType, Body.GetQueryString("SearchType")); Keyword.Text = Body.GetQueryString("Keyword"); LtlContentButtons.Text += @" <script> $(document).ready(function() { $('#contentSearch').show(); }); </script> "; } LtlColumnHeadRows.Text = ContentUtility.GetColumnHeadRowsHtml(_tableStyleInfoList, _attributesOfDisplay, _tableStyle, PublishmentSystemInfo); LtlCommandHeadRows.Text = ContentUtility.GetCommandHeadRowsHtml(Body.AdministratorName, _tableStyle, PublishmentSystemInfo, _nodeInfo); } }
public void Page_Load(object sender, EventArgs e) { if (IsForbidden) { return; } if (string.IsNullOrEmpty(AuthRequest.GetQueryString("startDate"))) { _begin = DateTime.Now.AddMonths(-1); _end = DateTime.Now; } else { _begin = TranslateUtils.ToDateTime(AuthRequest.GetQueryString("startDate")); _end = TranslateUtils.ToDateTime(AuthRequest.GetQueryString("endDate")); } var siteIdList = SiteManager.GetSiteIdListOrderByLevel(); if (SiteId == 0 && siteIdList.Count > 0) { PageUtils.Redirect(GetRedirectUrl(siteIdList[0], DateUtils.GetDateAndTimeString(_begin), DateUtils.GetDateAndTimeString(_end))); return; } if (IsPostBack) { return; } VerifySystemPermissions(ConfigManager.SettingsPermissions.Chart); foreach (var siteId in siteIdList) { var siteInfo = SiteManager.GetSiteInfo(siteId); DdlSiteId.Items.Add(new ListItem(siteInfo.SiteName, siteId.ToString())); } ControlUtils.SelectSingleItem(DdlSiteId, SiteId.ToString()); TbStartDate.Text = DateUtils.GetDateAndTimeString(_begin); TbEndDate.Text = DateUtils.GetDateAndTimeString(_end); if (SiteInfo == null) { PhAnalysis.Visible = false; return; } var ds = DataProvider.ContentDao.GetDataSetOfAdminExcludeRecycle(SiteInfo.TableName, SiteId, _begin, _end); if (ds == null || ds.Tables.Count <= 0) { return; } var dt = ds.Tables[0]; if (dt.Rows.Count <= 0) { return; } foreach (DataRow dr in dt.Rows) { SetXHashtableUser(dr["userName"].ToString(), dr["userName"].ToString()); SetYHashtableUser(dr["userName"].ToString(), TranslateUtils.ToInt(dr["addCount"].ToString()), YTypeNew); SetYHashtableUser(dr["userName"].ToString(), TranslateUtils.ToInt(dr["updateCount"].ToString()), YTypeUpdate); } foreach (var key in _userNameList) { var yValueNew = GetYHashtableUser(key, YTypeNew); var yValueUpdate = GetYHashtableUser(key, YTypeUpdate); StrArray += $@" xArrayNew.push('{GetXHashtableUser(key)}'); yArrayNew.push('{yValueNew}'); yArrayUpdate.push('{yValueUpdate}');"; } SpContents.ControlToPaginate = RptContents; RptContents.ItemDataBound += RptContents_ItemDataBound; SpContents.ItemsPerPage = StringUtils.Constants.PageSize; SpContents.SortField = "UserName"; SpContents.SortMode = SortMode.DESC; SpContents.SelectCommand = DataProvider.ContentDao.GetSqlStringOfAdminExcludeRecycle(SiteInfo.TableName, SiteId, _begin, _end); SpContents.DataBind(); }
private static string ParseImpl(PageInfo pageInfo, ContextInfo contextInfo, ListInfo listInfo) { var parsedContent = string.Empty; var type = listInfo.Others.Get(Type.Name); if (string.IsNullOrEmpty(type)) { type = BackgroundContentAttribute.ImageUrl; } var contextType = EContextType.Each; IEnumerable dataSource = null; var contentInfo = contextInfo.ContentInfo; if (contentInfo != null) { var eachList = new List <string>(); if (!string.IsNullOrEmpty(contentInfo.GetString(type))) { eachList.Add(contentInfo.GetString(type)); } var extendAttributeName = ContentAttribute.GetExtendAttributeName(type); var extendValues = contentInfo.GetString(extendAttributeName); if (!string.IsNullOrEmpty(extendValues)) { foreach (var extendValue in TranslateUtils.StringCollectionToStringList(extendValues)) { eachList.Add(extendValue); } } if (listInfo.StartNum > 1 || listInfo.TotalNum > 0) { if (listInfo.StartNum > 1) { var count = listInfo.StartNum - 1; if (count > eachList.Count) { count = eachList.Count; } eachList.RemoveRange(0, count); } if (listInfo.TotalNum > 0) { if (listInfo.TotalNum < eachList.Count) { eachList.RemoveRange(listInfo.TotalNum, eachList.Count - listInfo.TotalNum); } } } dataSource = eachList; } if (listInfo.Layout == ELayout.None) { var rptContents = new Repeater { ItemTemplate = new RepeaterTemplate(listInfo.ItemTemplate, listInfo.SelectedItems, listInfo.SelectedValues, listInfo.SeparatorRepeatTemplate, listInfo.SeparatorRepeat, pageInfo, contextType, contextInfo) }; if (!string.IsNullOrEmpty(listInfo.HeaderTemplate)) { rptContents.HeaderTemplate = new SeparatorTemplate(listInfo.HeaderTemplate); } if (!string.IsNullOrEmpty(listInfo.FooterTemplate)) { rptContents.FooterTemplate = new SeparatorTemplate(listInfo.FooterTemplate); } if (!string.IsNullOrEmpty(listInfo.SeparatorTemplate)) { rptContents.SeparatorTemplate = new SeparatorTemplate(listInfo.SeparatorTemplate); } if (!string.IsNullOrEmpty(listInfo.AlternatingItemTemplate)) { rptContents.AlternatingItemTemplate = new RepeaterTemplate(listInfo.AlternatingItemTemplate, listInfo.SelectedItems, listInfo.SelectedValues, listInfo.SeparatorRepeatTemplate, listInfo.SeparatorRepeat, pageInfo, contextType, contextInfo); } rptContents.DataSource = dataSource; rptContents.DataBind(); if (rptContents.Items.Count > 0) { parsedContent = ControlUtils.GetControlRenderHtml(rptContents); } } else { var pdlContents = new ParsedDataList(); TemplateUtility.PutListInfoToMyDataList(pdlContents, listInfo); pdlContents.ItemTemplate = new DataListTemplate(listInfo.ItemTemplate, listInfo.SelectedItems, listInfo.SelectedValues, listInfo.SeparatorRepeatTemplate, listInfo.SeparatorRepeat, pageInfo, contextType, contextInfo); if (!string.IsNullOrEmpty(listInfo.HeaderTemplate)) { pdlContents.HeaderTemplate = new SeparatorTemplate(listInfo.HeaderTemplate); } if (!string.IsNullOrEmpty(listInfo.FooterTemplate)) { pdlContents.FooterTemplate = new SeparatorTemplate(listInfo.FooterTemplate); } if (!string.IsNullOrEmpty(listInfo.SeparatorTemplate)) { pdlContents.SeparatorTemplate = new SeparatorTemplate(listInfo.SeparatorTemplate); } if (!string.IsNullOrEmpty(listInfo.AlternatingItemTemplate)) { pdlContents.AlternatingItemTemplate = new DataListTemplate(listInfo.AlternatingItemTemplate, listInfo.SelectedItems, listInfo.SelectedValues, listInfo.SeparatorRepeatTemplate, listInfo.SeparatorRepeat, pageInfo, contextType, contextInfo); } pdlContents.DataSource = dataSource; pdlContents.DataBind(); if (pdlContents.Items.Count > 0) { parsedContent = ControlUtils.GetControlRenderHtml(pdlContents); } } return(parsedContent); }
public void Page_Load(object sender, EventArgs e) { if (IsForbidden) { return; } PageUtils.CheckRequestParameter("siteId"); if (IsPostBack) { return; } VerifySystemPermissions(ConfigManager.SettingsPermissions.Site); if (SiteInfo.IsRoot) { PhParentId.Visible = false; } else { PhParentId.Visible = true; DdlParentId.Items.Add(new ListItem("<无上级站点>", "0")); var siteIdList = SiteManager.GetSiteIdList(); var mySystemInfoArrayList = new ArrayList(); var parentWithChildren = new Hashtable(); foreach (var siteId in siteIdList) { if (siteId == SiteId) { continue; } var siteInfo = SiteManager.GetSiteInfo(siteId); if (siteInfo.IsRoot == false) { if (siteInfo.ParentId == 0) { mySystemInfoArrayList.Add(siteInfo); } else { var children = new ArrayList(); if (parentWithChildren.Contains(siteInfo.ParentId)) { children = (ArrayList)parentWithChildren[siteInfo.ParentId]; } children.Add(siteInfo); parentWithChildren[siteInfo.ParentId] = children; } } } foreach (SiteInfo siteInfo in mySystemInfoArrayList) { AddSite(DdlParentId, siteInfo, parentWithChildren, 0); } ControlUtils.SelectSingleItem(DdlParentId, SiteInfo.ParentId.ToString()); } var tableNameList = SiteManager.GetSiteTableNames(); if (tableNameList.Count > 0) { RblTableRule.Items.Add(ETableRuleUtils.GetListItem(ETableRule.Choose, true)); RblTableRule.Items.Add(ETableRuleUtils.GetListItem(ETableRule.HandWrite, false)); PhTableChoose.Visible = true; PhTableHandWrite.Visible = false; foreach (var tableName in tableNameList) { DdlTableChoose.Items.Add(new ListItem(tableName, tableName)); } } else { RblTableRule.Items.Add(ETableRuleUtils.GetListItem(ETableRule.HandWrite, false)); PhTableChoose.Visible = false; PhTableHandWrite.Visible = false; } TbTaxis.Text = SiteInfo.Taxis.ToString(); RblIsCheckContentUseLevel.Items.Add(new ListItem("默认审核机制", false.ToString())); RblIsCheckContentUseLevel.Items.Add(new ListItem("多级审核机制", true.ToString())); if (SiteInfo == null) { PageUtils.RedirectToErrorPage("站点不存在,请确认后再试!"); return; } TbSiteName.Text = SiteInfo.SiteName; ControlUtils.SelectSingleItem(RblIsCheckContentUseLevel, SiteInfo.Additional.IsCheckContentLevel.ToString()); if (SiteInfo.Additional.IsCheckContentLevel) { ControlUtils.SelectSingleItem(DdlCheckContentLevel, SiteInfo.Additional.CheckContentLevel.ToString()); PhCheckContentLevel.Visible = true; } else { PhCheckContentLevel.Visible = false; } if (!string.IsNullOrEmpty(SiteInfo.SiteDir)) { TbSiteDir.Text = PathUtils.GetDirectoryName(SiteInfo.SiteDir, false); } if (SiteInfo.IsRoot) { PhSiteDir.Visible = false; } ControlUtils.SelectSingleItem(DdlTableChoose, SiteInfo.TableName); BtnSubmit.Attributes.Add("onclick", PageLoading()); }
public void Page_Load(object sender, EventArgs e) { if (IsForbidden) { return; } var permissions = PermissionsManager.GetPermissions(Body.AdministratorName); var mainPublishmentSystemInfo = PublishmentSystemManager.GetPublishmentSystemInfo(1); PageUtils.CheckRequestParameter("PublishmentSystemID", "NodeID"); var nodeID = Body.GetQueryInt("NodeID"); var childNodeId = Body.GetQueryInt("ChildNodeId"); relatedIdentities = RelatedIdentities.GetChannelRelatedIdentities(PublishmentSystemId, nodeID); nodeInfo = NodeManager.GetNodeInfo(1, nodeID); tableName = NodeManager.GetTableName(mainPublishmentSystemInfo, nodeInfo); tableStyle = NodeManager.GetTableStyle(mainPublishmentSystemInfo, nodeInfo); styleInfoList = TableStyleManager.GetTableStyleInfoList(tableStyle, tableName, relatedIdentities); var styleInfoList2 = TableStyleManager.GetTableStyleInfoList(tableStyle, "siteserver_Node", relatedIdentities); Dictionary <string, string> category = DataProvider.NodeDao.GetNodeIdListLevel(2, nodeID); int contentNum = 0; if (nodeInfo.Additional.IsPreviewContents) { new Action(() => { DataProvider.ContentDao.DeletePreviewContents(PublishmentSystemId, tableName, nodeInfo); }).BeginInvoke(null, null); } if (!HasChannelPermissions(nodeID, AppManager.Cms.Permission.Channel.ContentView, AppManager.Cms.Permission.Channel.ContentAdd, AppManager.Cms.Permission.Channel.ContentEdit, AppManager.Cms.Permission.Channel.ContentDelete, AppManager.Cms.Permission.Channel.ContentTranslate)) { if (!Body.IsAdministratorLoggin) { PageUtils.RedirectToLoginPage(); return; } PageUtils.RedirectToErrorPage("您无此栏目的操作权限!"); return; } attributesOfDisplay = TranslateUtils.StringCollectionToStringCollection(NodeManager.GetContentAttributesOfDisplay(PublishmentSystemId, nodeID)); //this.attributesOfDisplay = TranslateUtils.StringCollectionToStringCollection(this.nodeInfo.Additional.ContentAttributesOfDisplay); spContents.ControlToPaginate = rptContents; rptContents.ItemDataBound += rptContents_ItemDataBound; spContents.ItemsPerPage = PublishmentSystemInfo.Additional.PageSize; var administratorName = AdminUtility.IsViewContentOnlySelf(Body.AdministratorName, PublishmentSystemId, nodeID) ? Body.AdministratorName : string.Empty; if (Body.IsQueryExists("SearchType") && Body.IsQueryExists("ChildNodeId")) { List <int> owningNodeIdList = new List <int> { nodeID, 3, 4, 6, 9 }; spContents.SelectCommand = DataProvider.ContentDao.GetSelectCommend(tableStyle, tableName, PublishmentSystemId, nodeID, permissions.IsSystemAdministrator, owningNodeIdList, Body.GetQueryString("SearchType"), Body.GetQueryString("Keyword"), Body.GetQueryString("DateFrom"), string.Empty, false, ETriState.All, false, false, false, administratorName); } else { var test = tableName; List <int> nodeList = new List <int>(); nodeList.Add(nodeID); var firstChildList = DataProvider.NodeDao.GetNodeIdListByParentId(1, nodeID); if (firstChildList != null && firstChildList.Count > 0) { nodeList.AddRange(firstChildList); foreach (var firstchild in firstChildList) { var secondList = DataProvider.NodeDao.GetNodeIdListByParentId(1, firstchild); if (secondList != null && secondList.Count > 0) { nodeList.AddRange(secondList); } } } var nodeCollectionIdStr = string.Empty; foreach (int nodeId in nodeList) { nodeCollectionIdStr = nodeCollectionIdStr + nodeId + ','; contentNum = contentNum + DataProvider.NodeDao.GetNodeInfo(nodeId).ContentNum; } nodeCollectionIdStr = nodeCollectionIdStr.TrimEnd(','); spContents.SelectCommand = "select * from model_voluntaryservice where NodeId>0"; } spContents.SortField = BaiRongDataProvider.ContentDao.GetSortFieldName(); spContents.SortMode = SortMode.DESC; spContents.OrderByString = "ORDER BY Taxis Desc"; //分页的时候,不去查询总条数,直接使用栏目的属性:ContentNum spContents.IsQueryTotalCount = false; spContents.TotalCount = contentNum;//nodeInfo.ContentNum; if (!IsPostBack) { var nodeName = NodeManager.GetNodeNameNavigation(PublishmentSystemId, nodeID); //BreadCrumbWithItemTitle(AppManager.Cms.LeftMenu.IdContent, "内容管理", nodeName, string.Empty); ltlContentButtons.Text = WebUtils.GetContentCommandsStandard(Body.AdministratorName, PublishmentSystemInfo, nodeInfo, PageUrlReturn, GetRedirectUrl(base.PublishmentSystemId, nodeInfo.NodeId), false); spContents.DataBind(); if (styleInfoList != null) { foreach (var styleInfo in styleInfoList) { if (styleInfo.IsVisible) { var listitem = new ListItem(styleInfo.DisplayName, styleInfo.AttributeName); SearchType.Items.Add(listitem); } } } var listitemAll = new ListItem("全部", nodeID.ToString()); ChannelCategory.Items.Add(listitemAll); if (category != null) { foreach (var chanelCategory in category) { var listitem = new ListItem(chanelCategory.Key, chanelCategory.Value); ChannelCategory.Items.Add(listitem); } } //添加隐藏属性 SearchType.Items.Add(new ListItem("内容ID", ContentAttribute.Id)); SearchType.Items.Add(new ListItem("添加者", ContentAttribute.AddUserName)); SearchType.Items.Add(new ListItem("最后修改者", ContentAttribute.LastEditUserName)); SearchType.Items.Add(new ListItem("内容组", ContentAttribute.ContentGroupNameCollection)); if (Body.IsQueryExists("SearchType")) { DateFrom.Text = Body.GetQueryString("DateFrom"); ControlUtils.SelectListItems(SearchType, Body.GetQueryString("SearchType")); Keyword.Text = Body.GetQueryString("Keyword"); ltlContentButtons.Text += @" <script> $(document).ready(function() { $('#contentSearch').show(); }); </script> "; } ltlColumnHeadRows.Text = ContentUtility.GetColumnHeadRowsHtml(styleInfoList, attributesOfDisplay, tableStyle, PublishmentSystemInfo); ltlCommandHeadRows.Text = ContentUtility.GetCommandHeadRowsHtml(Body.AdministratorName, tableStyle, PublishmentSystemInfo, nodeInfo); } }
public Control FindControlBySelfAndChildren(string controlId) { return(ControlUtils.FindControlBySelfAndChildren(controlId, this)); }
private void uc_Loaded(object sender, RoutedEventArgs e) { _cvs = ControlUtils.FindVisualParent <Canvas>(this); UpdateTTPivot(new Point(0, 0)); }
public override void DataBind() { if (this._bound) { return; } _bound = true; _itemUniqueName = ControlUtils.GetBoundedDataField(this.NamingContainer, "UniqueName").ToString(); if (_Image == null) { if (ThumbImage) { _Image = ControlUtils.GetBoundedDataField(this.NamingContainer, "ThumbImage"); } else { _Image = ControlUtils.GetBoundedDataField(this.NamingContainer, "Image" + number.ToString()); } } if (_Image != null && _Image.ToString() != "") { switch (Type) { case ImageType.Resize: bigImage = string.Format("{0}/{3}/{1}/{2}", lw.CTE.Folders.ProductsImages, "Large", _Image, _itemUniqueName ); this._Src = string.Format("ImageResizer.axd?src={0}&width={1}&height={2}&fillColor={3}", bigImage, this.Width, this.Height, FillColor.ToArgb(), WebContext.Root); break; case ImageType.Thumb: case ImageType.Medium: case ImageType.Large: default: this._Src = string.Format("{4}/{0}/{3}/{1}/{2}", lw.CTE.Folders.ProductsImages, this.Type, _Image, _itemUniqueName, WebContext.Root ); break; } } else if (Type == ImageType.Thumb) { if (HideIfNoImage) { this.Visible = false; } this._Src = "/images/image-not-available.gif"; } if (_Title == null) { _Title = ControlUtils.GetBoundedDataField(this.NamingContainer, "Title"); } if (_Title != null) { this.Attributes["Title"] = _Title.ToString(); } base.DataBind(); }
public void Page_Load(object sender, EventArgs e) { if (IsForbidden) { return; } PageUtils.CheckRequestParameter("PublishmentSystemID", "NodeID", "ReturnUrl"); _nodeId = Body.GetQueryInt("NodeID"); _returnUrl = StringUtils.ValueFromUrl(PageUtils.FilterSqlAndXss(Body.GetQueryString("ReturnUrl"))); //if (!base.HasChannelPermissions(this.nodeID, AppManager.CMS.Permission.Channel.ChannelAdd)) //{ // PageUtils.RedirectToErrorPage("您没有添加栏目的权限!"); // return; //} var parentNodeInfo = NodeManager.GetNodeInfo(PublishmentSystemId, _nodeId); if (parentNodeInfo.Additional.IsChannelAddable == false) { PageUtils.RedirectToErrorPage("此栏目不能添加子栏目!"); return; } channelControl = (ChannelAuxiliaryControl)FindControl("ControlForAuxiliary"); if (!IsPostBack) { BreadCrumb(AppManager.Cms.LeftMenu.IdContent, "添加栏目", string.Empty); NodeManager.AddListItems(ParentNodeID.Items, PublishmentSystemInfo, true, true, true, Body.AdministratorName); ControlUtils.SelectListItems(ParentNodeID, _nodeId.ToString()); var contentModelInfoList = ContentModelManager.GetContentModelInfoList(PublishmentSystemInfo); foreach (var modelInfo in contentModelInfoList) { ContentModelID.Items.Add(new ListItem(modelInfo.ModelName, modelInfo.ModelId)); } ControlUtils.SelectListItems(ContentModelID, parentNodeInfo.ContentModelId); channelControl.SetParameters(null, false, IsPostBack); NavigationPicPath.Attributes.Add("onchange", GetShowImageScript("preview_NavigationPicPath", PublishmentSystemInfo.PublishmentSystemUrl)); var showPopWinString = ModalFilePathRule.GetOpenWindowString(PublishmentSystemId, _nodeId, true, ChannelFilePathRule.ClientID); CreateChannelRule.Attributes.Add("onclick", showPopWinString); showPopWinString = ModalFilePathRule.GetOpenWindowString(PublishmentSystemId, _nodeId, false, ContentFilePathRule.ClientID); CreateContentRule.Attributes.Add("onclick", showPopWinString); showPopWinString = ModalSelectImage.GetOpenWindowString(PublishmentSystemInfo, NavigationPicPath.ClientID); SelectImage.Attributes.Add("onclick", showPopWinString); showPopWinString = ModalUploadImage.GetOpenWindowString(PublishmentSystemId, NavigationPicPath.ClientID); UploadImage.Attributes.Add("onclick", showPopWinString); IsChannelAddable.Items[0].Value = true.ToString(); IsChannelAddable.Items[1].Value = false.ToString(); IsContentAddable.Items[0].Value = true.ToString(); IsContentAddable.Items[1].Value = false.ToString(); ELinkTypeUtils.AddListItems(LinkType); NodeGroupNameCollection.DataSource = DataProvider.NodeGroupDao.GetDataSource(PublishmentSystemId); ChannelTemplateID.DataSource = DataProvider.TemplateDao.GetDataSourceByType(PublishmentSystemId, ETemplateType.ChannelTemplate); ContentTemplateID.DataSource = DataProvider.TemplateDao.GetDataSourceByType(PublishmentSystemId, ETemplateType.ContentTemplate); DataBind(); ChannelTemplateID.Items.Insert(0, new ListItem("<未设置>", "0")); ChannelTemplateID.Items[0].Selected = true; ContentTemplateID.Items.Insert(0, new ListItem("<未设置>", "0")); ContentTemplateID.Items[0].Selected = true; Content.SetParameters(PublishmentSystemInfo, NodeAttribute.Content, null, false, IsPostBack); } else { channelControl.SetParameters(Request.Form, false, IsPostBack); } }
public void Page_Load(object sender, EventArgs e) { if (IsForbidden) { return; } var permissions = PermissionsManager.GetPermissions(Body.AdministratorName); PageUtils.CheckRequestParameter("PublishmentSystemID"); _nodeId = Body.GetQueryInt("NodeID"); if (_nodeId == 0) { _nodeId = PublishmentSystemId; } var nodeInfo = NodeManager.GetNodeInfo(PublishmentSystemId, this._nodeId); _tableStyle = NodeManager.GetTableStyle(PublishmentSystemInfo, nodeInfo); var tableName = NodeManager.GetTableName(PublishmentSystemInfo, nodeInfo); _relatedIdentities = RelatedIdentities.GetChannelRelatedIdentities(PublishmentSystemId, this._nodeId); _tableStyleInfoList = TableStyleManager.GetTableStyleInfoList(_tableStyle, tableName, _relatedIdentities); spContents.ControlToPaginate = rptContents; if (string.IsNullOrEmpty(Body.GetQueryString("NodeID"))) { if (TranslateUtils.ToInt(PageNum.SelectedValue) == 0) { spContents.ItemsPerPage = PublishmentSystemInfo.Additional.PageSize; } else { spContents.ItemsPerPage = TranslateUtils.ToInt(PageNum.SelectedValue); } spContents.SelectCommand = DataProvider.ContentDao.GetSelectCommend(_tableStyle, tableName, PublishmentSystemId, _nodeId, permissions.IsSystemAdministrator, ProductPermissionsManager.Current.OwningNodeIdList, SearchType.SelectedValue, Keyword.Text, DateFrom.Text, DateTo.Text, true, ETriState.All, false, true); } else { if (Body.GetQueryInt("PageNum") == 0) { spContents.ItemsPerPage = PublishmentSystemInfo.Additional.PageSize; } else { spContents.ItemsPerPage = Body.GetQueryInt("PageNum"); } spContents.SelectCommand = DataProvider.ContentDao.GetSelectCommend(_tableStyle, tableName, PublishmentSystemId, _nodeId, permissions.IsSystemAdministrator, ProductPermissionsManager.Current.OwningNodeIdList, Body.GetQueryString("SearchType"), Body.GetQueryString("Keyword"), Body.GetQueryString("DateFrom"), Body.GetQueryString("DateTo"), true, ETriState.All, false, true); } spContents.OrderByString = ETaxisTypeUtils.GetOrderByString(_tableStyle, ETaxisType.OrderByIdDesc); rptContents.ItemDataBound += rptContents_ItemDataBound; if (!IsPostBack) { BreadCrumb(AppManager.Cms.LeftMenu.IdContent, "内容回收站", AppManager.Cms.Permission.WebSite.ContentTrash); if (Body.IsQueryExists("IsDeleteAll")) { BaiRongDataProvider.ContentDao.DeleteContentsByTrash(PublishmentSystemId, tableName); Body.AddSiteLog(PublishmentSystemId, "清空回收站"); SuccessMessage("成功清空回收站!"); AddWaitAndRedirectScript(PageUrl); return; } else if (Body.IsQueryExists("IsRestore")) { var idsDictionary = ContentUtility.GetIDsDictionary(Request.QueryString); foreach (var nodeID in idsDictionary.Keys) { var contentIDArrayList = idsDictionary[nodeID]; DataProvider.ContentDao.TrashContents(PublishmentSystemId, NodeManager.GetTableName(PublishmentSystemInfo, nodeID), contentIDArrayList); } Body.AddSiteLog(PublishmentSystemId, "从回收站还原内容"); SuccessMessage("成功还原内容!"); AddWaitAndRedirectScript(PageUrl); return; } else if (Body.IsQueryExists("IsRestoreAll")) { DataProvider.ContentDao.RestoreContentsByTrash(PublishmentSystemId, tableName); Body.AddSiteLog(PublishmentSystemId, "从回收站还原所有内容"); SuccessMessage("成功还原所有内容!"); AddWaitAndRedirectScript(PageUrl); return; } NodeManager.AddListItems(NodeIDDropDownList.Items, PublishmentSystemInfo, true, false, Body.AdministratorName); if (_tableStyleInfoList != null) { foreach (var styleInfo in _tableStyleInfoList) { if (styleInfo.IsVisible) { var listitem = new ListItem(styleInfo.DisplayName, styleInfo.AttributeName); SearchType.Items.Add(listitem); } } } //添加隐藏属性 SearchType.Items.Add(new ListItem("内容ID", ContentAttribute.Id)); SearchType.Items.Add(new ListItem("添加者", ContentAttribute.AddUserName)); SearchType.Items.Add(new ListItem("最后修改者", ContentAttribute.LastEditUserName)); if (Body.IsQueryExists("NodeID")) { if (PublishmentSystemId != _nodeId) { ControlUtils.SelectListItems(NodeIDDropDownList, _nodeId.ToString()); } ControlUtils.SelectListItems(PageNum, Body.GetQueryString("PageNum")); ControlUtils.SelectListItems(SearchType, Body.GetQueryString("SearchType")); Keyword.Text = Body.GetQueryString("Keyword"); DateFrom.Text = Body.GetQueryString("DateFrom"); DateTo.Text = Body.GetQueryString("DateTo"); } spContents.DataBind(); } if (!HasChannelPermissions(this._nodeId, AppManager.Cms.Permission.Channel.ContentDelete)) { Delete.Visible = false; DeleteAll.Visible = false; } else { Delete.Attributes.Add("onclick", PageContentDelete.GetRedirectClickStringForMultiChannels(PublishmentSystemId, true, PageUrl)); DeleteAll.Attributes.Add("onclick", PageUtils.GetRedirectStringWithConfirm(PageUtils.AddQueryString(PageUrl, "IsDeleteAll", "True"), "确实要清空回收站吗?")); } Restore.Attributes.Add("onclick", PageUtils.GetRedirectStringWithCheckBoxValue(PageUtils.AddQueryString(PageUrl, "IsRestore", "True"), "IDsCollection", "IDsCollection", "请选择需要还原的内容!")); RestoreAll.Attributes.Add("onclick", PageUtils.GetRedirectStringWithConfirm(PageUtils.AddQueryString(PageUrl, "IsRestoreAll", "True"), "确实要还原所有内容吗?")); }
private static string ParseImpl(XmlNode node, PageInfo pageInfo, ContextInfo contextInfo, HtmlAnchor stlAnchor, string type, string emptyText, string tipText, int wordNum, bool isKeyboard) { string parsedContent; string successTemplateString; string failureTemplateString; StlInnerUtility.GetYesNo(node, pageInfo, out successTemplateString, out failureTemplateString); if (string.IsNullOrEmpty(successTemplateString)) { var nodeInfo = NodeManager.GetNodeInfo(pageInfo.PublishmentSystemId, contextInfo.ChannelId); if (type.ToLower().Equals(TypePreviousChannel.ToLower()) || type.ToLower().Equals(TypeNextChannel.ToLower())) { var taxis = nodeInfo.Taxis; var isNextChannel = !StringUtils.EqualsIgnoreCase(type, TypePreviousChannel); var siblingNodeId = DataProvider.NodeDao.GetNodeIdByParentIdAndTaxis(nodeInfo.ParentId, taxis, isNextChannel); if (siblingNodeId != 0) { var siblingNodeInfo = NodeManager.GetNodeInfo(pageInfo.PublishmentSystemId, siblingNodeId); var url = PageUtility.GetChannelUrl(pageInfo.PublishmentSystemInfo, siblingNodeInfo); if (url.Equals(PageUtils.UnclickedUrl)) { stlAnchor.Target = string.Empty; } stlAnchor.HRef = url; if (string.IsNullOrEmpty(node.InnerXml)) { stlAnchor.InnerHtml = NodeManager.GetNodeName(pageInfo.PublishmentSystemId, siblingNodeId); if (wordNum > 0) { stlAnchor.InnerHtml = StringUtils.MaxLengthText(stlAnchor.InnerHtml, wordNum); } } else { contextInfo.ChannelId = siblingNodeId; var innerBuilder = new StringBuilder(node.InnerXml); StlParserManager.ParseInnerContent(innerBuilder, pageInfo, contextInfo); stlAnchor.InnerHtml = innerBuilder.ToString(); } } } else if (type.ToLower().Equals(TypePreviousContent.ToLower()) || type.ToLower().Equals(TypeNextContent.ToLower())) { if (contextInfo.ContentId != 0) { var taxis = contextInfo.ContentInfo.Taxis; var isNextContent = !StringUtils.EqualsIgnoreCase(type, TypePreviousContent); var tableStyle = NodeManager.GetTableStyle(pageInfo.PublishmentSystemInfo, contextInfo.ChannelId); var tableName = NodeManager.GetTableName(pageInfo.PublishmentSystemInfo, contextInfo.ChannelId); var siblingContentId = BaiRongDataProvider.ContentDao.GetContentId(tableName, contextInfo.ChannelId, taxis, isNextContent); if (siblingContentId != 0) { var siblingContentInfo = DataProvider.ContentDao.GetContentInfo(tableStyle, tableName, siblingContentId); var url = PageUtility.GetContentUrl(pageInfo.PublishmentSystemInfo, siblingContentInfo); if (url.Equals(PageUtils.UnclickedUrl)) { stlAnchor.Target = string.Empty; } stlAnchor.HRef = url; if (isKeyboard) { var keyCode = isNextContent ? 39 : 37; var scriptContent = new StringBuilder(); pageInfo.AddPageScriptsIfNotExists(PageInfo.Components.Jquery); scriptContent.Append($@"<script language=""javascript"" type=""text/javascript""> $(document).keydown(function(event){{ if(event.keyCode=={keyCode}){{location = '{url}';}} }}); </script> "); var nextOrPrevious = isNextContent ? "nextContent" : "previousContent"; pageInfo.SetPageScripts(nextOrPrevious, scriptContent.ToString(), true); } if (string.IsNullOrEmpty(node.InnerXml)) { stlAnchor.InnerHtml = siblingContentInfo.Title; if (wordNum > 0) { stlAnchor.InnerHtml = StringUtils.MaxLengthText(stlAnchor.InnerHtml, wordNum); } } else { var innerBuilder = new StringBuilder(node.InnerXml); contextInfo.ContentId = siblingContentId; StlParserManager.ParseInnerContent(innerBuilder, pageInfo, contextInfo); stlAnchor.InnerHtml = innerBuilder.ToString(); } } } } parsedContent = string.IsNullOrEmpty(stlAnchor.HRef) ? emptyText : ControlUtils.GetControlRenderHtml(stlAnchor); } else { var nodeInfo = NodeManager.GetNodeInfo(pageInfo.PublishmentSystemId, contextInfo.ChannelId); var isSuccess = false; var theContextInfo = contextInfo.Clone(); if (type.ToLower().Equals(TypePreviousChannel.ToLower()) || type.ToLower().Equals(TypeNextChannel.ToLower())) { var taxis = nodeInfo.Taxis; var isNextChannel = !StringUtils.EqualsIgnoreCase(type, TypePreviousChannel); var siblingNodeId = DataProvider.NodeDao.GetNodeIdByParentIdAndTaxis(nodeInfo.ParentId, taxis, isNextChannel); if (siblingNodeId != 0) { isSuccess = true; theContextInfo.ContextType = EContextType.Channel; theContextInfo.ChannelId = siblingNodeId; } } else if (type.ToLower().Equals(TypePreviousContent.ToLower()) || type.ToLower().Equals(TypeNextContent.ToLower())) { if (contextInfo.ContentId != 0) { var taxis = contextInfo.ContentInfo.Taxis; var isNextContent = !StringUtils.EqualsIgnoreCase(type, TypePreviousContent); var tableName = NodeManager.GetTableName(pageInfo.PublishmentSystemInfo, contextInfo.ChannelId); var siblingContentId = BaiRongDataProvider.ContentDao.GetContentId(tableName, contextInfo.ChannelId, taxis, isNextContent); if (siblingContentId != 0) { isSuccess = true; theContextInfo.ContextType = EContextType.Content; theContextInfo.ContentId = siblingContentId; theContextInfo.ContentInfo = null; } } } parsedContent = isSuccess ? successTemplateString : failureTemplateString; if (!string.IsNullOrEmpty(parsedContent)) { var innerBuilder = new StringBuilder(parsedContent); StlParserManager.ParseInnerContent(innerBuilder, pageInfo, theContextInfo); parsedContent = innerBuilder.ToString(); } } parsedContent = tipText + parsedContent; return(parsedContent); }
protected override void OnLoad(EventArgs e) { base.OnLoad(e); try { if (ForumId < 1) { Response.Redirect(NavigateUrl(TabId)); } if (ForumInfo == null) { Response.Redirect(NavigateUrl(TabId)); } if (ForumInfo.Active == false) { Response.Redirect(NavigateUrl(TabId)); } this.AppRelativeVirtualPath = "~/"; MyTheme = MainSettings.Theme; MyThemePath = Page.ResolveUrl("~/DesktopModules/ActiveForums/themes/" + MyTheme); int defaultTemplateId = ForumInfo.TopicsTemplateId; if (DefaultTopicsViewTemplateId >= 0) { defaultTemplateId = DefaultTopicsViewTemplateId; } string TopicsTemplate = string.Empty; if (UseTemplatePath && !(TemplatePath == string.Empty)) { TopicsTemplate = Utilities.GetFileContent(TemplatePath + "TopicsView.htm"); TopicsTemplate = Utilities.ParseSpacer(TopicsTemplate); } else { TopicsTemplate = DataCache.GetCachedTemplate(MainSettings.TemplateCache, ModuleId, "TopicsView", defaultTemplateId); } bool loadComplete = false; if (TopicsTemplate.Contains("[NOTOOLBAR]")) { if (HttpContext.Current.Items.Contains("ShowToolbar")) { HttpContext.Current.Items["ShowToolbar"] = false; } else { HttpContext.Current.Items.Add("ShowToolbar", false); } TopicsTemplate = TopicsTemplate.Replace("[NOTOOLBAR]", string.Empty); } TopicsTemplate = TopicsTemplate.Replace("[PORTALID]", PortalId.ToString()); TopicsTemplate = TopicsTemplate.Replace("[MODULEID]", ForumModuleId.ToString()); TopicsTemplate = TopicsTemplate.Replace("[TABID]", ForumTabId.ToString()); TopicsTemplate = TopicsTemplate.Replace("[AF:CONTROL:FORUMID]", ForumId.ToString()); TopicsTemplate = TopicsTemplate.Replace("[AF:CONTROL:FORUMGROUPID]", ForumGroupId.ToString()); TopicsTemplate = TopicsTemplate.Replace("[AF:CONTROL:PARENTFORUMID]", ParentForumId.ToString()); PageSize = MainSettings.PageSize; if (UserId > 0) { PageSize = UserDefaultPageSize; } if (PageSize < 5) { PageSize = 10; } if (PageId == 1) { RowIndex = 0; } else { RowIndex = ((PageId * PageSize) - PageSize); } string sort = SortColumns.ReplyCreated; if (TopicsTemplate.Contains("[AF:SORT:TOPICCREATED]")) { sort = SortColumns.TopicCreated; TopicsTemplate = TopicsTemplate.Replace("[AF:SORT:TOPICCREATED]", string.Empty); } TopicsTemplate = CheckControls(TopicsTemplate); TopicsTemplate = TopicsTemplate.Replace("[AF:SORT:REPLYCREATED]", string.Empty); if (TopicsTemplate.Contains("[TOPICS]")) { DataSet ds = DataProvider.Instance().UI_TopicsView(PortalId, ModuleId, ForumId, UserId, RowIndex, PageSize, UserInfo.IsSuperUser, sort); if (ds.Tables.Count > 0) { drForum = ds.Tables[0].Rows[0]; drSecurity = ds.Tables[1].Rows[0]; dtSubForums = ds.Tables[2]; dtTopics = ds.Tables[3]; if (PageId == 1) { dtAnnounce = ds.Tables[4]; } bView = Permissions.HasPerm(drSecurity["CanView"].ToString(), ForumUser.UserRoles); bRead = Permissions.HasPerm(drSecurity["CanRead"].ToString(), ForumUser.UserRoles); //bCreate = Permissions.HasPerm(drSecurity["CanCreate"].ToString(), ForumUser.UserRoles); bEdit = Permissions.HasPerm(drSecurity["CanEdit"].ToString(), ForumUser.UserRoles); bDelete = Permissions.HasPerm(drSecurity["CanDelete"].ToString(), ForumUser.UserRoles); //bReply = Permissions.HasPerm(drSecurity["CanReply"].ToString(), ForumUser.UserRoles); bPoll = Permissions.HasPerm(drSecurity["CanPoll"].ToString(), ForumUser.UserRoles); bSubscribe = Permissions.HasPerm(drSecurity["CanSubscribe"].ToString(), ForumUser.UserRoles); bModMove = Permissions.HasPerm(drSecurity["CanModMove"].ToString(), ForumUser.UserRoles); bModSplit = Permissions.HasPerm(drSecurity["CanModSplit"].ToString(), ForumUser.UserRoles); bModDelete = Permissions.HasPerm(drSecurity["CanModDelete"].ToString(), ForumUser.UserRoles); bModApprove = Permissions.HasPerm(drSecurity["CanModApprove"].ToString(), ForumUser.UserRoles); bModEdit = Permissions.HasPerm(drSecurity["CanModEdit"].ToString(), ForumUser.UserRoles); bModPin = Permissions.HasPerm(drSecurity["CanModPin"].ToString(), ForumUser.UserRoles); bModLock = Permissions.HasPerm(drSecurity["CanModLock"].ToString(), ForumUser.UserRoles); bModApprove = Permissions.HasPerm(drSecurity["CanModApprove"].ToString(), ForumUser.UserRoles); ControlUtils ctlUtils = new ControlUtils(); sGroupURL = ctlUtils.BuildUrl(ForumTabId, ForumModuleId, ForumInfo.ForumGroup.PrefixURL, string.Empty, ForumInfo.ForumGroupId, -1, -1, -1, string.Empty, 1, -1, SocialGroupId); sForumURL = ctlUtils.BuildUrl(ForumTabId, ForumModuleId, ForumInfo.ForumGroup.PrefixURL, ForumInfo.PrefixURL, ForumInfo.ForumGroupId, ForumInfo.ForumID, -1, -1, string.Empty, 1, -1, SocialGroupId); if (bView) { ForumName = drForum["ForumName"].ToString(); GroupName = drForum["GroupName"].ToString(); ForumGroupId = Convert.ToInt32(drForum["ForumGroupId"]); //TopicsTemplateId = CInt(drForum("TopicsTemplateId")) try { bAllowRSS = Convert.ToBoolean(drForum["AllowRSS"]); } catch { bAllowRSS = false; } if (bRead == false) { bAllowRSS = false; } TopicRowCount = Convert.ToInt32(drForum["TopicRowCount"]); if (UserId > 0) { IsSubscribedForum = Convert.ToBoolean(((Convert.ToInt32(drForum["IsSubscribedForum"]) > 0) ? true : false)); } if (MainSettings.UseSkinBreadCrumb) { Environment.UpdateBreadCrumb(Page.Controls, "<a href=\"" + sGroupURL + "\">" + GroupName + "</a>"); TopicsTemplate = TopicsTemplate.Replace("<div class=\"afcrumb\">[FORUMMAINLINK] > [FORUMGROUPLINK]</div>", string.Empty); } if (TopicsTemplate.Contains("[META]")) { MetaTemplate = TemplateUtils.GetTemplateSection(TopicsTemplate, "[META]", "[/META]"); TopicsTemplate = TemplateUtils.ReplaceSubSection(TopicsTemplate, string.Empty, "[META]", "[/META]"); } //Parse Meta Template if (!(string.IsNullOrEmpty(MetaTemplate))) { MetaTemplate = MetaTemplate.Replace("[FORUMNAME]", ForumName); MetaTemplate = MetaTemplate.Replace("[GROUPNAME]", GroupName); string pageName = string.Empty; DotNetNuke.Entities.Portals.PortalSettings settings = DotNetNuke.Entities.Portals.PortalController.GetCurrentPortalSettings(); if (settings.ActiveTab.Title.Length == 0) { pageName = Server.HtmlEncode(settings.ActiveTab.TabName); } else { pageName = Server.HtmlEncode(settings.ActiveTab.Title); } MetaTemplate = MetaTemplate.Replace("[PAGENAME]", pageName); MetaTemplate = MetaTemplate.Replace("[PORTALNAME]", settings.PortalName); MetaTemplate = MetaTemplate.Replace("[TAGS]", string.Empty); if (MetaTemplate.Contains("[TOPICSUBJECT:")) { string pattern = "(\\[TOPICSUBJECT:(.+?)\\])"; Regex regExp = new Regex(pattern); MatchCollection matches = null; matches = regExp.Matches(MetaTemplate); foreach (Match m in matches) { MetaTemplate = MetaTemplate.Replace(m.Value, string.Empty); } } MetaTemplate = MetaTemplate.Replace("[TOPICSUBJECT]", string.Empty); if (MetaTemplate.Contains("[BODY:")) { string pattern = "(\\[BODY:(.+?)\\])"; Regex regExp = new Regex(pattern); MatchCollection matches = null; matches = regExp.Matches(MetaTemplate); foreach (Match m in matches) { int iLen = Convert.ToInt32(m.Groups[2].Value); if (ForumInfo.ForumDesc.Length > iLen) { MetaTemplate = MetaTemplate.Replace(m.Value, ForumInfo.ForumDesc.Substring(0, iLen) + "..."); } else { MetaTemplate = MetaTemplate.Replace(m.Value, ForumInfo.ForumDesc); } } } MetaTemplate = MetaTemplate.Replace("[BODY]", Utilities.StripHTMLTag(ForumInfo.ForumDesc)); MetaTitle = TemplateUtils.GetTemplateSection(MetaTemplate, "[TITLE]", "[/TITLE]").Replace("[TITLE]", string.Empty).Replace("[/TITLE]", string.Empty); MetaTitle = MetaTitle.TruncateAtWord(SEOConstants.MaxMetaTitleLength); MetaDescription = TemplateUtils.GetTemplateSection(MetaTemplate, "[DESCRIPTION]", "[/DESCRIPTION]").Replace("[DESCRIPTION]", string.Empty).Replace("[/DESCRIPTION]", string.Empty); MetaDescription = MetaDescription.TruncateAtWord(SEOConstants.MaxMetaDescriptionLength); MetaKeywords = TemplateUtils.GetTemplateSection(MetaTemplate, "[KEYWORDS]", "[/KEYWORDS]").Replace("[KEYWORDS]", string.Empty).Replace("[/KEYWORDS]", string.Empty); } BindTopics(TopicsTemplate); } else { Response.Redirect(NavigateUrl(TabId), true); } try { DotNetNuke.Framework.CDefault tempVar = this.BasePage; Environment.UpdateMeta(ref tempVar, MetaTitle, MetaDescription, MetaKeywords); } catch (Exception ex) { } } else { Response.Redirect(NavigateUrl(TabId), true); } if (Session["modal_View"] != null) { //LoadModal(Session["modal_View"].ToString(), Session["modal_options"].ToString()); } } else { ForumController fc = new ForumController(); string fs = fc.GetForumsForUser(ForumUser.UserRoles, PortalId, ModuleId, "CanEdit"); if (!(string.IsNullOrEmpty(fs))) { bModEdit = true; } TopicsTemplate = ParseControls(TopicsTemplate); TopicsTemplate = Utilities.LocalizeControl(TopicsTemplate); this.Controls.Add(this.ParseControl(TopicsTemplate)); LinkControls(this.Controls); } } catch (Exception exc) { RenderMessage("[RESX:Error:LoadingTopics]", exc.Message, exc); } }
public string Render() { StringBuilder sb = new StringBuilder(); Data.CommonDB db = new Data.CommonDB(); string sHost = Utilities.GetHost(); if (sHost.EndsWith("/")) { sHost = sHost.Substring(0, sHost.Length - 1); } ControlUtils ctlUtils = new ControlUtils(); string forumPrefix = string.Empty; string groupPrefix = string.Empty; //Dim _forumGroupId As Integer = -1 if (ParentForumId == -1) { ParentForumId = ForumId; } string groupTemplate = TemplateUtils.GetTemplateSection(ItemTemplate, "[AF:DIR:FORUMGROUP]", "[/AF:DIR:FORUMGROUP]"); string forumTemplate = TemplateUtils.GetTemplateSection(ItemTemplate, "[AF:DIR:FORUM]", "[/AF:DIR:FORUM]"); string subForumTemplate = TemplateUtils.GetTemplateSection(ItemTemplate, "[AF:DIR:SUBFORUM]", "[/AF:DIR:SUBFORUM]"); bool useFriendlyUrl = Utilities.IsRewriteLoaded(); int currGroup = -1; string gtmp = string.Empty; string ftmp = string.Empty; string subtmp = string.Empty; using (IDataReader dr = db.ForumContent_List(PortalId, ModuleId, ForumGroupId, ForumId, ParentForumId)) { //ParentForum Section dr.Read(); //SubForums dr.NextResult(); dr.Read(); //Topics in ParentForum dr.NextResult(); string catKey = string.Empty; int count = 0; int catCount = 0; sb.Append("<ul>"); while (dr.Read()) { if (catKey != dr["CategoryName"].ToString() + dr["CategoryId"].ToString()) { if (count > 0) { sb.Replace("[CATCOUNT]", catCount.ToString()); sb.Append("</ul></li>"); count = 0; catCount = 0; } sb.Append("<li class=\"category\" id=\"afcat-" + dr["CategoryId"].ToString() + "\">"); sb.Append("<em>[CATCOUNT]</em>"); sb.Append("<span>" + dr["CategoryName"].ToString() + "</span>"); sb.Append("<ul>"); catKey = dr["CategoryName"].ToString() + dr["CategoryId"].ToString(); } //Dim Params As String() = {"aff=" & ForumId, "fcc=" & dr("TopicId").ToString} if (TopicId == Convert.ToInt32(dr["TopicId"].ToString())) { sb.Append("<li class=\"fcv-selected\">"); sb.Replace("<li class=\"category\" id=\"afcat-" + dr["CategoryId"].ToString() + "\">", "<li class=\"category cat-selected\" id=\"afcat-" + dr["CategoryId"].ToString() + "\">"); } else { sb.Append("<li>"); } catCount += 1; //Dim Params As String() = {ParamKeys.ForumId & "=" & ForumId, ParamKeys.TopicId & "=" & TopicId, ParamKeys.ViewType & "=topic"} string[] Params = {ParamKeys.TopicId + "=" + dr["TopicId"].ToString()}; //Dim sTopicURL As String = ctlUtils.BuildUrl(TabId, ModuleId, groupPrefix, forumPrefix, ForumGroupId, ForumId, Integer.Parse(dr("TopicId").ToString), dr("URL").ToString, -1, -1, String.Empty, 1) string sTopicURL = ctlUtils.TopicURL(dr, TabId, ModuleId); sb.Append("<a href=\"" + sTopicURL + "\"><span>" + dr["Subject"].ToString() + "</span></a></li>"); if (TopicId > 0) { if (Convert.ToInt32(dr["TopicId"].ToString()) == TopicId) { // RenderTopic(dr) } } count += 1; } sb.Replace("[CATCOUNT]", catCount.ToString()); if (count > 0) { sb.Append("</ul></li>"); } sb.Append("</ul>"); dr.Close(); } return sb.ToString(); }