PageRenderTime 45ms CodeModel.GetById 19ms RepoModel.GetById 1ms app.codeStats 0ms

/mojoPortal.Features.UI/Blog/Controls/FeedLinksControl.ascx.cs

#
C# | 199 lines | 131 code | 50 blank | 18 comment | 15 complexity | 651d9854af31a2490df4a673ae598044 MD5 | raw file
Possible License(s): LGPL-2.1, Apache-2.0, BSD-3-Clause, CPL-1.0, CC-BY-SA-3.0, GPL-2.0
  1. // Author: Joe Audette
  2. // Created: 2009-05-04
  3. // Last Modified: 2010-05-23
  4. //
  5. // The use and distribution terms for this software are covered by the
  6. // Common Public License 1.0 (http://opensource.org/licenses/cpl.php)
  7. // which can be found in the file CPL.TXT at the root of this distribution.
  8. // By using this software in any fashion, you are agreeing to be bound by
  9. // the terms of this license.
  10. //
  11. // You must not remove this notice, or any other, from this software.
  12. using System;
  13. using System.Globalization;
  14. using System.Web.UI;
  15. using mojoPortal.Business;
  16. using mojoPortal.Business.WebHelpers;
  17. using mojoPortal.Web.Framework;
  18. using Resources;
  19. namespace mojoPortal.Web.BlogUI
  20. {
  21. public partial class FeedLinksControl : UserControl
  22. {
  23. private int pageId = -1;
  24. private int moduleId = -1;
  25. private string siteRoot = string.Empty;
  26. private BlogConfiguration config = new BlogConfiguration();
  27. private string imageSiteRoot = string.Empty;
  28. private SiteSettings siteSettings = null;
  29. protected string addThisAccountId = string.Empty;
  30. protected string RssImageFile = WebConfigSettings.RSSImageFileName;
  31. public int PageId
  32. {
  33. get { return pageId; }
  34. set { pageId = value; }
  35. }
  36. public int ModuleId
  37. {
  38. get { return moduleId; }
  39. set { moduleId = value; }
  40. }
  41. public string SiteRoot
  42. {
  43. get { return siteRoot; }
  44. set { siteRoot = value; }
  45. }
  46. //public string ImageSiteRoot
  47. //{
  48. // get { return imageSiteRoot; }
  49. // set { imageSiteRoot = value; }
  50. //}
  51. public BlogConfiguration Config
  52. {
  53. get { return config; }
  54. set { config = value; }
  55. }
  56. protected void Page_Load(object sender, EventArgs e)
  57. {
  58. }
  59. protected override void OnPreRender(EventArgs e)
  60. {
  61. if (this.Visible)
  62. {
  63. if (pageId == -1) { return; }
  64. if (moduleId == -1) { return; }
  65. LoadSettings();
  66. PopulateLabels();
  67. SetupLinks();
  68. }
  69. base.OnPreRender(e);
  70. }
  71. private void SetupLinks()
  72. {
  73. if (siteSettings == null) { return; }
  74. lnkRSS.HRef = GetRssUrl();
  75. imgRSS.Src = Page.ResolveUrl("~/Data/SiteImages/" + RssImageFile);
  76. lnkAddThisRss.HRef = "http://www.addthis.com/feed.php?pub="
  77. + addThisAccountId + "&h1=" + Server.UrlEncode(GetRssUrl())
  78. + "&t1=";
  79. imgAddThisRss.Src = config.AddThisRssButtonImageUrl;
  80. lnkAddMSN.HRef = "http://my.msn.com/addtomymsn.armx?id=rss&ut=" + GetRssUrl();
  81. imgMSNRSS.Src = Page.ResolveUrl("~/Data/SiteImages/rss_mymsn.gif");
  82. lnkAddToLive.HRef = "http://www.live.com/?add=" + Server.UrlEncode(GetRssUrl());
  83. imgAddToLive.Src = Page.ResolveUrl("~/Data/SiteImages/addtolive.gif");
  84. lnkAddYahoo.HRef = "http://e.my.yahoo.com/config/promo_content?.module=ycontent&.url="
  85. + GetRssUrl();
  86. imgYahooRSS.Src = Page.ResolveUrl("~/Data/SiteImages/addtomyyahoo2.gif");
  87. lnkAddGoogle.HRef = "http://fusion.google.com/add?feedurl="
  88. + GetRssUrl();
  89. imgGoogleRSS.Src = Page.ResolveUrl("~/Data/SiteImages/googleaddrss.gif");
  90. liOdiogoPodcast.Visible = (config.OdiogoPodcastUrl.Length > 0);
  91. lnkOdiogoPodcast.HRef = config.OdiogoPodcastUrl;
  92. lnkOdiogoPodcastTextLink.NavigateUrl = config.OdiogoPodcastUrl;
  93. imgOdiogoPodcast.Src = Page.ResolveUrl("~/Data/SiteImages/podcast.png");
  94. }
  95. private string GetRssUrl()
  96. {
  97. if ((config.FeedburnerFeedUrl.Length > 0) && (!BlogConfiguration.UseRedirectForFeedburner)) { return config.FeedburnerFeedUrl; }
  98. if (WebConfigSettings.UseUrlReWriting)
  99. {
  100. return SiteRoot + "/blog" + ModuleId.ToInvariantString() + "rss.aspx";
  101. }
  102. else
  103. {
  104. return SiteRoot + "/Blog/RSS.aspx?pageid=" + pageId.ToInvariantString()
  105. + "&mid=" + ModuleId.ToInvariantString();
  106. }
  107. }
  108. private void PopulateLabels()
  109. {
  110. lnkRSS.Title = BlogResources.BlogRSSLinkTitle;
  111. lnkAddThisRss.Title = BlogResources.BlogAddThisSubscribeAltText;
  112. lnkAddMSN.Title = BlogResources.BlogModuleAddToMyMSNLink;
  113. lnkAddYahoo.Title = BlogResources.BlogModuleAddToMyYahooLink;
  114. lnkAddGoogle.Title = BlogResources.BlogModuleAddToGoogleLink;
  115. lnkAddToLive.Title = BlogResources.BlogModuleAddToWindowsLiveLink;
  116. lnkOdiogoPodcast.Title = BlogResources.PodcastLink;
  117. lnkOdiogoPodcastTextLink.Text = BlogResources.PodcastLink;
  118. }
  119. private void LoadSettings()
  120. {
  121. siteSettings = CacheHelper.GetCurrentSiteSettings();
  122. if (siteSettings == null) { return; }
  123. //siteRoot = siteSettings.SiteRoot;
  124. siteRoot = SiteUtils.GetNavigationSiteRoot();
  125. if (config.AddThisAccountId.Length > 0)
  126. {
  127. addThisAccountId = config.AddThisAccountId;
  128. }
  129. else
  130. {
  131. addThisAccountId = siteSettings.AddThisDotComUsername;
  132. }
  133. liAddThisRss.Visible = (addThisAccountId.Length > 0);
  134. liAddThisRss.Visible = (config.ShowAddFeedLinks && (addThisAccountId.Length > 0));
  135. liAddGoogle.Visible = config.ShowAddFeedLinks;
  136. liAddMSN.Visible = config.ShowAddFeedLinks;
  137. liAddYahoo.Visible = config.ShowAddFeedLinks;
  138. liAddToLive.Visible = config.ShowAddFeedLinks;
  139. if (liAddThisRss.Visible)
  140. {
  141. liAddGoogle.Visible = false;
  142. liAddMSN.Visible = false;
  143. liAddYahoo.Visible = false;
  144. liAddToLive.Visible = false;
  145. }
  146. //if (imageSiteRoot.Length == 0) { imageSiteRoot = WebUtils.GetSiteRoot(); }
  147. }
  148. }
  149. }