/// <summary> /// Check's to see if the item being loaded in this module should be displayed on this tabid/moduleid, if not does a 301 redirect to the proper page. /// </summary> private void CheckItemUrl() { if (VersionInfoObject != null) { //check to see if this Item should be redirected to a different URL if (Utility.HasValue(VersionInfoObject.Url) && (VersionInfoObject.Url != Request.Url.ToString())) { //do our redirect now Response.Status = "301 Moved Permanently"; Response.RedirectLocation = VersionInfoObject.GetItemExternalUrl; } //check if we're on the correct URL before progressing if (VersionInfoObject.ForceDisplayOnPage() && (TabId != VersionInfoObject.DisplayTabId) && !IsAdmin) { Response.Status = "301 Moved Permanently"; Response.RedirectLocation = GetItemLinkUrl(VersionInfoObject.ItemId); } else if (VersionInfoObject.ForceDisplayOnPage() && (TabId != VersionInfoObject.DisplayTabId) && IsAdmin) { lblPublishMessages.Text = Localization.GetString("PublishForceAdminMessage", LocalSharedResourceFile); divPublishNotifications.Visible = true; } } }
protected void CallUpdateApprovalStatus() { if (!VersionInfoObject.IsNew) { VersionInfoObject.ApprovalStatusId = Convert.ToInt32(ddlApprovalStatus.SelectedValue, CultureInfo.InvariantCulture); VersionInfoObject.ApprovalComments = txtApprovalComments.Text.Trim().Length > 0 ? txtApprovalComments.Text.Trim() : Localization.GetString("DefaultApprovalComment", LocalResourceFile); VersionInfoObject.UpdateApprovalStatus(); Response.Redirect(BuildVersionsUrl(), false); } }
protected void CallUpdateApprovalStatus() { if (!VersionInfoObject.IsNew) { VersionInfoObject.ApprovalStatusId = Convert.ToInt32(ApprovalStatusDropDownList.SelectedValue, CultureInfo.InvariantCulture); VersionInfoObject.ApprovalComments = txtApprovalComments.Text.Trim().Length > 0 ? txtApprovalComments.Text.Trim() : Localization.GetString("DefaultApprovalComment", LocalResourceFile); VersionInfoObject.UpdateApprovalStatus(); //Utility.ClearPublishCache(PortalId); Response.Redirect(BuildVersionsUrl(), false); //redirect to the versions list for this item. } }
private void BtnShowRelatedItemClick(object sender, EventArgs e) { divRelatedLinks.Visible = true; Article[] related = VersionInfoObject.GetRelatedArticles(PortalId); if (related.Length == 0) { //what to do? } else { lstItems.DataSource = related; lstItems.DataBind(); } }
/// <summary> /// Record a Viewing. /// </summary> private void RecordView() { if (!VersionInfoObject.IsNew) { string referrer = string.Empty; if (HttpContext.Current.Request.UrlReferrer != null) { referrer = HttpContext.Current.Request.UrlReferrer.ToString(); } string url = string.Empty; if (HttpContext.Current.Request.RawUrl != null) { url = HttpContext.Current.Request.RawUrl; } VersionInfoObject.AddView(UserId, TabId, HttpContext.Current.Request.UserHostAddress); } }
private void Page_Load(object sender, EventArgs e) { if (e == null) { throw new ArgumentNullException("e"); } try { btnShowRelatedItem.Visible = false; divRelatedLinks.Visible = false; var related = new List <Article>(VersionInfoObject.GetRelatedArticles(PortalId)); ItemVersionSetting parentRelationshipSetting = ItemVersionSetting.GetItemVersionSetting(VersionInfoObject.ItemVersionId, "ArticleSettings", "IncludeParentCategoryArticles", PortalId); if (parentRelationshipSetting != null && Convert.ToBoolean(parentRelationshipSetting.PropertyValue, CultureInfo.InvariantCulture)) { int parentCategoryId = Category.GetParentCategory(VersionInfoObject.ItemId, PortalId); if (parentCategoryId > 0) { //get all articles in the same category, then removes this current article from that list. BD List <Article> categoryArticles = Category.GetCategoryArticles(parentCategoryId, PortalId); categoryArticles.RemoveAll(a => a.ItemId == VersionInfoObject.ItemId); related.AddRange(categoryArticles); } } if (related.Count < 1) { btnShowRelatedItem.Visible = false; divRelatedLinks.Visible = false; LinksPopulated = false; } else { lstItems.DataSource = related; lstItems.DataBind(); divRelatedLinks.Visible = true; LinksPopulated = true; } } catch (Exception exc) { Exceptions.ProcessModuleLoadException(this, exc); } }
public string BuildAddArticleUrl() { if (ItemId <= -1) { return(string.Empty); } int parentCategoryId = -1; if (!VersionInfoObject.IsNew) { parentCategoryId = VersionInfoObject.ItemTypeId == ItemType.Category.GetId() ? VersionInfoObject.ItemId : VersionInfoObject.GetParentCategoryId(); } return(DotNetNuke.Common.Globals.NavigateURL( TabId, string.Empty, "ctl=" + Utility.AdminContainer, "mid=" + ModuleId.ToString(CultureInfo.InvariantCulture), "adminType=articleedit", "parentId=" + parentCategoryId.ToString(CultureInfo.InvariantCulture), "returnUrl=" + HttpUtility.UrlEncode(Request.RawUrl))); }
private void ConfigureChildControls() { if (VersionInfoObject.IsNew) { return; } //check if items are enabled. if (DisplayEmailAFriend && VersionInfoObject.IsNew == false) { ea = (EmailAFriend)LoadControl(EmailControlToLoad); ea.ModuleConfiguration = ModuleConfiguration; ea.ID = Path.GetFileNameWithoutExtension(EmailControlToLoad); ea.VersionInfoObject = VersionInfoObject; phEmailAFriend.Controls.Add(ea); } if (DisplayPrinterFriendly && VersionInfoObject.IsNew == false) { pf = (PrinterFriendlyButton)LoadControl(PrinterControlToLoad); pf.ModuleConfiguration = ModuleConfiguration; pf.ID = Path.GetFileNameWithoutExtension(PrinterControlToLoad); phPrinterFriendly.Controls.Add(pf); } if (DisplayRelatedLinks) { ral = (RelatedArticleLinksBase)LoadControl(RelatedArticlesControlToLoad); ral.ModuleConfiguration = ModuleConfiguration; ral.ID = Path.GetFileNameWithoutExtension(RelatedArticlesControlToLoad); phRelatedArticles.Controls.Add(ral); } if (DisplayRelatedArticle) { Article a = VersionInfoObject.GetRelatedArticle(PortalId); if (a != null) { ad = (ArticleDisplay)LoadControl(ArticleControlToLoad); ad.ModuleConfiguration = ModuleConfiguration; ad.ID = Path.GetFileNameWithoutExtension(ArticleControlToLoad); ad.Overrideable = false; ad.UseCache = true; ad.DisplayPrinterFriendly = false; ad.DisplayRelatedArticle = false; ad.DisplayRelatedLinks = false; ad.DisplayEmailAFriend = false; ad.SetItemId(a.ItemId); ad.DisplayTitle = false; phRelatedArticle.Controls.Add(ad); divRelatedArticle.Visible = true; } else { divRelatedArticle.Visible = false; } } if (RatingDisplayOption.Equals(RatingDisplayOption.Enable) || RatingDisplayOption.Equals(RatingDisplayOption.ReadOnly)) { //get the upnlRating setting ItemVersionSetting rtSetting = ItemVersionSetting.GetItemVersionSetting(VersionInfoObject.ItemVersionId, "upnlRating", "Visible", PortalId); if (rtSetting != null) { upnlRating.Visible = Convert.ToBoolean(rtSetting.PropertyValue, CultureInfo.InvariantCulture); } if (upnlRating.Visible) { //lblRatingMessage.Visible = true; //TODO: re-enable ratings lblRatingMessage.Visible = false; //TODO: re-enable ratings //ajaxRating.MaxRating = MaximumRating; var avgRating = (int)Math.Round(((Article)VersionInfoObject).AverageRating); //ajaxRating.CurrentRating = (avgRating > MaximumRating ? MaximumRating : (avgRating < 0 ? 0 : avgRating)); //ajaxRating.ReadOnly = RatingDisplayOption.Equals(RatingDisplayOption.ReadOnly); } } btnComment.Visible = DisplayCommentsLink; if (IsCommentsEnabled) { btnComment.NavigateUrl = Request.RawUrl + "#CommentEntry"; if (!UseForumComments || (DisplayPublishComments && !VersionInfoObject.IsNew)) { pnlComments.Visible = pnlCommentDisplay.Visible = true; commentDisplay = (CommentDisplayBase)LoadControl(CommentsControlToLoad); commentDisplay.ModuleConfiguration = ModuleConfiguration; commentDisplay.ID = Path.GetFileNameWithoutExtension(CommentsControlToLoad); commentDisplay.ArticleId = VersionInfoObject.ItemId; phCommentsDisplay.Controls.Add(commentDisplay); } if (UseForumComments) { pnlComments.Visible = true; mvCommentDisplay.SetActiveView(vwForumComments); ItemVersionSetting forumThreadIdSetting = ItemVersionSetting.GetItemVersionSetting(VersionInfoObject.ItemVersionId, "ArticleSetting", "CommentForumThreadId", PortalId); if (forumThreadIdSetting != null) { lnkGoToForum.Visible = true; lnkGoToForum.NavigateUrl = ForumProvider.GetInstance(PortalId).GetThreadUrl(Convert.ToInt32(forumThreadIdSetting.PropertyValue, CultureInfo.InvariantCulture)); } else { btnForumComment.Visible = true; } } } ConfigureTags(); }
private void CmdUpdateClick(object sender, EventArgs e) { try { var av = (Article)VersionInfoObject; txtMessage.Text = string.Empty; bool error = false; //Removed the check for the Item Description length as we no longer have a restriction on this //if (TextBoxMaxLengthExceeded(this.itemEditControl.DescriptionText, "Article Description", 4000)) //{ // error = true; //} if (TextBoxMaxLengthExceeded(txtVersionDescription.Text, "Version Description", 8000)) { error = true; } if (!parentCategoryRelationship.IsValid) { error = true; txtMessage.Text += Localization.GetString("ErrorSelectCategory.Text", LocalResourceFile); } if (!itemApprovalStatus.IsValid && itemApprovalStatus.Visible) { error = true; txtMessage.Text += Localization.GetString("ErrorApprovalStatus.Text", LocalResourceFile); } if (!itemEditControl.IsValid) { error = true; txtMessage.Text += itemEditControl.ErrorMessage; } if (Convert.ToInt32(ddlDisplayTabId.SelectedValue, CultureInfo.InvariantCulture) > -1) { VersionInfoObject.DisplayTabId = Convert.ToInt32(ddlDisplayTabId.SelectedValue, CultureInfo.InvariantCulture); } else { error = true; txtMessage.Text += Localization.GetString("ErrorDisplayPage.Text", LocalResourceFile); } if (error) { txtMessage.Visible = true; return; } av.ArticleText = TeArticleText.Text; av.VersionDescription = txtVersionDescription.Text; av.VersionNumber = txtVersionNumber.Text; av.Description = itemEditControl.DescriptionText; //we need to look at making moduleid be configurable at anytime, not just on item creation, this makes previewing items impossible //if (av.IsNew) int newModuleId = Utility.GetModuleIdFromDisplayTabId(VersionInfoObject.DisplayTabId, PortalId, Utility.DnnFriendlyModuleName); if (newModuleId > 0) { VersionInfoObject.ModuleId = newModuleId; } else { newModuleId = Utility.GetModuleIdFromDisplayTabId(VersionInfoObject.DisplayTabId, PortalId, Utility.DnnFriendlyModuleNameTextHTML); if (newModuleId > 0) { VersionInfoObject.ModuleId = newModuleId; } } //create a relationship var irel = new ItemRelationship { RelationshipTypeId = Util.RelationshipType.ItemToParentCategory.GetId() }; int[] ids = parentCategoryRelationship.GetSelectedItemIds(); //check for parent category, if none then add a relationship for Top Level Item if (ids.Length > 0) { irel.ParentItemId = ids[0]; VersionInfoObject.Relationships.Add(irel); } foreach (int i in relatedCategoryRelationships.GetSelectedItemIds()) { var irco = new ItemRelationship { RelationshipTypeId = Util.RelationshipType.ItemToRelatedCategory.GetId(), ParentItemId = i }; av.Relationships.Add(irco); } if (AllowTags) { av.Tags.Clear(); //Add the tags to the ItemTagCollection foreach (Tag t in Tag.ParseTags(tagEntryControl.TagList, PortalId)) { ItemTag it = ItemTag.Create(); it.TagId = Convert.ToInt32(t.TagId, CultureInfo.InvariantCulture); av.Tags.Add(it); } } if (av.Description == string.Empty) { //trim article text to populate description if (!Utility.HasValue(av.Description) || !Utility.HasValue(av.MetaDescription)) { string description = DotNetNuke.Common.Utilities.HtmlUtils.StripTags(av.ArticleText, false); if (!Utility.HasValue(av.Description)) { av.Description = Utility.TrimDescription(3997, description) + "...";// description + "..."; } } } //auto populate the meta description if it's not populated already if (!Utility.HasValue(av.MetaDescription)) { string description = DotNetNuke.Common.Utilities.HtmlUtils.StripTags(av.Description, false); av.MetaDescription = Utility.TrimDescription(399, description); } //Save the ItemVersionSettings SaveSettings(); //approval status av.ApprovalStatusId = chkUseApprovals.Checked && UseApprovals ? itemApprovalStatus.ApprovalStatusId : ApprovalStatus.Approved.GetId(); VersionInfoObject.Save(UserId); string returnUrl = Server.UrlDecode(Request.QueryString["returnUrl"]); if (!Utility.HasValue(returnUrl)) { Response.Redirect(Globals.NavigateURL(TabId, "", "", "ctl=" + Utility.AdminContainer, "mid=" + ModuleId.ToString(CultureInfo.InvariantCulture), "adminType=itemCreated", "itemId=" + VersionInfoObject.ItemId.ToString(CultureInfo.InvariantCulture)), true); } else { Response.Redirect(returnUrl); } } catch (Exception exc) { Exceptions.ProcessModuleLoadException(this, exc); } }
private void CmdUpdateClick(object sender, EventArgs e) { try { txtMessage.Text = string.Empty; bool error = false; //create a relationship var irel = new ItemRelationship { RelationshipTypeId = Util.RelationshipType.ItemToParentCategory.GetId() }; int[] ids = parentCategoryRelationships.GetSelectedItemIds(); //check for parent category, if none then add a relationship for Top Level Item if (ids.Length == 0) { //add relationship to TLC irel.RelationshipTypeId = Util.RelationshipType.CategoryToTopLevelCategory.GetId(); irel.ParentItemId = TopLevelCategoryItemType.Category.GetId(); VersionInfoObject.Relationships.Add(irel); } else { irel.ParentItemId = ids[0]; VersionInfoObject.Relationships.Add(irel); } //check for parent category, if none then add a relationship for Top Level Item //foreach (int i in this.irRelated.GetSelectedItemIds()) //{ // ItemRelationship irco = ItemRelationship.Create(); // irco.RelationshipTypeId = Util.RelationshipType.ItemToRelatedCategory.GetId(); // irco.ParentItemId = i; // VersionInfoObject.Relationships.Add(irco); //} if (itemEditControl.IsValid == false) { error = true; txtMessage.Text += itemEditControl.ErrorMessage; } if (Convert.ToInt32(ddlDisplayTabId.SelectedValue, CultureInfo.InvariantCulture) < -1) { error = true; txtMessage.Text += Localization.GetString("ChooseAPage", LocalResourceFile); } if (Convert.ToInt32(ddlChildDisplayTabId.SelectedValue, CultureInfo.InvariantCulture) == -1) { error = true; txtMessage.Text += Localization.GetString("ChooseChildPage", LocalResourceFile); } if (!itemApprovalStatus.IsValid) { txtMessage.Text += Localization.GetString("ChooseApprovalStatus", LocalResourceFile); } if (error) { txtMessage.Visible = true; return; } VersionInfoObject.Description = itemEditControl.DescriptionText; //auto populate the meta description if it's not populated already if (!Utility.HasValue(VersionInfoObject.MetaDescription)) { string description = DotNetNuke.Common.Utilities.HtmlUtils.StripTags(VersionInfoObject.Description, false); VersionInfoObject.MetaDescription = Utility.TrimDescription(399, description); } if (VersionInfoObject.IsNew) { VersionInfoObject.ModuleId = ModuleId; } int sortCount = 0; foreach (int i in featuredArticlesRelationships.GetSelectedItemIds()) { var irArticleso = new ItemRelationship { RelationshipTypeId = Util.RelationshipType.ItemToFeaturedItem.GetId(), ParentItemId = i }; if (Utility.HasValue(featuredArticlesRelationships.GetAdditionalSetting("startDate", i.ToString(CultureInfo.InvariantCulture)))) { irArticleso.StartDate = featuredArticlesRelationships.GetAdditionalSetting("startDate", i.ToString(CultureInfo.InvariantCulture)); } if (Utility.HasValue(featuredArticlesRelationships.GetAdditionalSetting("endDate", i.ToString(CultureInfo.InvariantCulture)))) { irArticleso.EndDate = featuredArticlesRelationships.GetAdditionalSetting("endDate", i.ToString(CultureInfo.InvariantCulture)); } irArticleso.SortOrder = sortCount; sortCount++; VersionInfoObject.Relationships.Add(irArticleso); } SaveSettings(); //approval status if (chkUseApprovals.Checked && UseApprovals) { VersionInfoObject.ApprovalStatusId = itemApprovalStatus.ApprovalStatusId; } else { VersionInfoObject.ApprovalStatusId = ApprovalStatus.Approved.GetId(); } VersionInfoObject.Save(UserId); if (SecurityFilter.IsSecurityEnabled(PortalId)) { categoryPermissions.CategoryId = VersionInfoObject.ItemId; categoryPermissions.Save(); } if (chkResetChildDisplayTabs.Checked) { ((Category)VersionInfoObject).CascadeChildDisplayTab(UserId); } string returnUrl = Server.UrlDecode(Request.QueryString["returnUrl"]); if (!Utility.HasValue(returnUrl)) { Response.Redirect(Globals.NavigateURL(TabId, "", "", "ctl=" + Utility.AdminContainer, "mid=" + ModuleId, "adminType=itemCreated", "itemId=" + VersionInfoObject.ItemId), true); } else { Response.Redirect(returnUrl); } } catch (Exception ex) { Exceptions.ProcessModuleLoadException(this, ex); } }
private void Page_Load(object sender, EventArgs e) { try { LocalizeCollapsePanels(); //because we're in the Edit options turn off caching DotNetNuke.UI.Utilities.ClientAPI.AddButtonConfirm(cmdDelete, Localization.GetString("DeleteConfirm", LocalResourceFile)); var cv = (Category)VersionInfoObject; if (!Page.IsPostBack) { rblDisplayOnCurrentPage.Items.Add(new ListItem(Localization.GetString("CurrentPage", LocalResourceFile), true.ToString(CultureInfo.InvariantCulture))); rblDisplayOnCurrentPage.Items.Add(new ListItem(Localization.GetString("SpecificPage", LocalResourceFile), false.ToString(CultureInfo.InvariantCulture))); txtSortOrder.Text = cv.SortOrder.ToString(CultureInfo.CurrentCulture); txtCategoryId.Text = cv.ItemId.ToString(CultureInfo.CurrentCulture); cmdDelete.Visible = false; //check if new or edit if (VersionInfoObject.IsNew) { txtCategoryId.Visible = false; lblCategoryId.Visible = false; if (ParentId != -1) { Category parent = Category.GetCategory(ParentId, PortalId); parentCategoryRelationships.AddToSelectedItems(parent); } } trCategoryId.Visible = ShowItemIds; //check if the DisplayTabId should be set. //chkDisplayOnCurrentPage ItemVersionSetting cpSetting = ItemVersionSetting.GetItemVersionSetting(VersionInfoObject.ItemVersionId, "CategorySettings", "DisplayOnCurrentPage", PortalId); if (cpSetting != null) { rblDisplayOnCurrentPage.SelectedValue = VersionInfoObject.DisplayOnCurrentPage().ToString(CultureInfo.InvariantCulture); if (VersionInfoObject.DisplayOnCurrentPage()) { chkForceDisplayTab.Checked = false; chkForceDisplayTab.Visible = false; lblForceDisplayTab.Visible = false; ddlDisplayTabId.Enabled = false; } else { chkForceDisplayTab.Visible = true; lblForceDisplayTab.Visible = true; ddlDisplayTabId.Enabled = true; } } else if (VersionInfoObject.DisplayTabId < 0) { rblDisplayOnCurrentPage.SelectedValue = false.ToString(CultureInfo.InvariantCulture); chkForceDisplayTab.Checked = false; chkForceDisplayTab.Visible = true; lblForceDisplayTab.Visible = true; ddlDisplayTabId.Enabled = true; } else { rblDisplayOnCurrentPage.SelectedValue = false.ToString(CultureInfo.InvariantCulture); chkForceDisplayTab.Visible = true; lblForceDisplayTab.Visible = true; ddlDisplayTabId.Enabled = true; } chkForceDisplayTab.Checked = VersionInfoObject.ForceDisplayOnPage(); LoadCommentForumsDropDown(); LoadCategoryDisplayTabDropDown(); LoadChildDisplayTabDropDown(); ItemVersionSetting useApprovals = ItemVersionSetting.GetItemVersionSetting(VersionInfoObject.ItemVersionId, "chkUseApprovals", "Checked", PortalId); chkUseApprovals.Checked = useApprovals == null || Convert.ToBoolean(useApprovals.PropertyValue, CultureInfo.InvariantCulture); chkUseApprovals.Visible = IsAdmin && UseApprovals; phApproval.Visible = UseApprovals && chkUseApprovals.Checked; lblNotUsingApprovals.Visible = !UseApprovals || !chkUseApprovals.Checked; //itemversionsetting for external RSS feed //provide the ability to define an external RSS feed for a category. ItemVersionSetting rssSetting = ItemVersionSetting.GetItemVersionSetting(VersionInfoObject.ItemVersionId, "CategorySettings", "RssUrl", PortalId); if (rssSetting != null) { txtRssUrl.Text = rssSetting.PropertyValue; } } else { cv.SortOrder = Convert.ToInt32(txtSortOrder.Text, CultureInfo.InvariantCulture); VersionInfoObject.DisplayTabId = Convert.ToInt32(ddlDisplayTabId.SelectedValue, CultureInfo.InvariantCulture); cv.ChildDisplayTabId = Convert.ToInt32(ddlChildDisplayTabId.SelectedValue, CultureInfo.InvariantCulture); } } catch (Exception exc) { Exceptions.ProcessModuleLoadException(this, exc); } }