/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
- // Author: Joe Audette
- // Created: 2009-05-04
- // Last Modified: 2010-05-23
- //
- // The use and distribution terms for this software are covered by the
- // Common Public License 1.0 (http://opensource.org/licenses/cpl.php)
- // which can be found in the file CPL.TXT at the root of this distribution.
- // By using this software in any fashion, you are agreeing to be bound by
- // the terms of this license.
- //
- // You must not remove this notice, or any other, from this software.
-
- using System;
- using System.Globalization;
- using System.Web.UI;
- using mojoPortal.Business;
- using mojoPortal.Business.WebHelpers;
- using mojoPortal.Web.Framework;
- using Resources;
-
- namespace mojoPortal.Web.BlogUI
- {
- public partial class FeedLinksControl : UserControl
- {
- private int pageId = -1;
- private int moduleId = -1;
- private string siteRoot = string.Empty;
- private BlogConfiguration config = new BlogConfiguration();
- private string imageSiteRoot = string.Empty;
- private SiteSettings siteSettings = null;
- protected string addThisAccountId = string.Empty;
- protected string RssImageFile = WebConfigSettings.RSSImageFileName;
-
-
- public int PageId
- {
- get { return pageId; }
- set { pageId = value; }
- }
-
- public int ModuleId
- {
- get { return moduleId; }
- set { moduleId = value; }
- }
-
- public string SiteRoot
- {
- get { return siteRoot; }
- set { siteRoot = value; }
- }
-
- //public string ImageSiteRoot
- //{
- // get { return imageSiteRoot; }
- // set { imageSiteRoot = value; }
- //}
-
- public BlogConfiguration Config
- {
- get { return config; }
- set { config = value; }
- }
-
-
-
- protected void Page_Load(object sender, EventArgs e)
- {
-
-
- }
-
- protected override void OnPreRender(EventArgs e)
- {
- if (this.Visible)
- {
- if (pageId == -1) { return; }
- if (moduleId == -1) { return; }
-
- LoadSettings();
- PopulateLabels();
- SetupLinks();
- }
-
-
- base.OnPreRender(e);
-
- }
-
- private void SetupLinks()
- {
- if (siteSettings == null) { return; }
-
- lnkRSS.HRef = GetRssUrl();
- imgRSS.Src = Page.ResolveUrl("~/Data/SiteImages/" + RssImageFile);
-
- lnkAddThisRss.HRef = "http://www.addthis.com/feed.php?pub="
- + addThisAccountId + "&h1=" + Server.UrlEncode(GetRssUrl())
- + "&t1=";
-
- imgAddThisRss.Src = config.AddThisRssButtonImageUrl;
-
- lnkAddMSN.HRef = "http://my.msn.com/addtomymsn.armx?id=rss&ut=" + GetRssUrl();
-
- imgMSNRSS.Src = Page.ResolveUrl("~/Data/SiteImages/rss_mymsn.gif");
-
- lnkAddToLive.HRef = "http://www.live.com/?add=" + Server.UrlEncode(GetRssUrl());
-
- imgAddToLive.Src = Page.ResolveUrl("~/Data/SiteImages/addtolive.gif");
-
- lnkAddYahoo.HRef = "http://e.my.yahoo.com/config/promo_content?.module=ycontent&.url="
- + GetRssUrl();
-
- imgYahooRSS.Src = Page.ResolveUrl("~/Data/SiteImages/addtomyyahoo2.gif");
-
- lnkAddGoogle.HRef = "http://fusion.google.com/add?feedurl="
- + GetRssUrl();
-
- imgGoogleRSS.Src = Page.ResolveUrl("~/Data/SiteImages/googleaddrss.gif");
-
- liOdiogoPodcast.Visible = (config.OdiogoPodcastUrl.Length > 0);
- lnkOdiogoPodcast.HRef = config.OdiogoPodcastUrl;
- lnkOdiogoPodcastTextLink.NavigateUrl = config.OdiogoPodcastUrl;
- imgOdiogoPodcast.Src = Page.ResolveUrl("~/Data/SiteImages/podcast.png");
-
-
-
-
- }
-
- private string GetRssUrl()
- {
- if ((config.FeedburnerFeedUrl.Length > 0) && (!BlogConfiguration.UseRedirectForFeedburner)) { return config.FeedburnerFeedUrl; }
- if (WebConfigSettings.UseUrlReWriting)
- {
- return SiteRoot + "/blog" + ModuleId.ToInvariantString() + "rss.aspx";
- }
- else
- {
- return SiteRoot + "/Blog/RSS.aspx?pageid=" + pageId.ToInvariantString()
- + "&mid=" + ModuleId.ToInvariantString();
- }
-
- }
-
- private void PopulateLabels()
- {
- lnkRSS.Title = BlogResources.BlogRSSLinkTitle;
- lnkAddThisRss.Title = BlogResources.BlogAddThisSubscribeAltText;
- lnkAddMSN.Title = BlogResources.BlogModuleAddToMyMSNLink;
- lnkAddYahoo.Title = BlogResources.BlogModuleAddToMyYahooLink;
- lnkAddGoogle.Title = BlogResources.BlogModuleAddToGoogleLink;
- lnkAddToLive.Title = BlogResources.BlogModuleAddToWindowsLiveLink;
- lnkOdiogoPodcast.Title = BlogResources.PodcastLink;
- lnkOdiogoPodcastTextLink.Text = BlogResources.PodcastLink;
-
- }
-
- private void LoadSettings()
- {
- siteSettings = CacheHelper.GetCurrentSiteSettings();
- if (siteSettings == null) { return; }
-
- //siteRoot = siteSettings.SiteRoot;
- siteRoot = SiteUtils.GetNavigationSiteRoot();
-
- if (config.AddThisAccountId.Length > 0)
- {
- addThisAccountId = config.AddThisAccountId;
- }
- else
- {
- addThisAccountId = siteSettings.AddThisDotComUsername;
- }
-
- liAddThisRss.Visible = (addThisAccountId.Length > 0);
-
- liAddThisRss.Visible = (config.ShowAddFeedLinks && (addThisAccountId.Length > 0));
- liAddGoogle.Visible = config.ShowAddFeedLinks;
- liAddMSN.Visible = config.ShowAddFeedLinks;
- liAddYahoo.Visible = config.ShowAddFeedLinks;
- liAddToLive.Visible = config.ShowAddFeedLinks;
-
- if (liAddThisRss.Visible)
- {
- liAddGoogle.Visible = false;
- liAddMSN.Visible = false;
- liAddYahoo.Visible = false;
- liAddToLive.Visible = false;
-
- }
-
- //if (imageSiteRoot.Length == 0) { imageSiteRoot = WebUtils.GetSiteRoot(); }
-
- }
-
-
- }
- }