private Opml GetDefaultOpmlFeed() { var opmlFeed = new Opml(); string filePath = Config.GetPathToFile(Config.ConfigFileType.SolutionsExplorer); if (File.Exists(filePath)) { opmlFeed = Opml.LoadFromFile(filePath); } return(opmlFeed); }
protected override void OnLoad(EventArgs e) { var opmlFeed = new Opml(); string elementIdPrefix = ClientID; string instanceVarName = elementIdPrefix + "_feedBrowser"; if (((String.IsNullOrEmpty(OpmlUrl)) && (String.IsNullOrEmpty(OpmlFile)) && (String.IsNullOrEmpty(OpmlText)))) { opmlFeed = GetDefaultOpmlFeed(); } else { if ((!String.IsNullOrEmpty(OpmlText))) { var opmlDoc = new XmlDocument(); opmlDoc.LoadXml("<?xml version=\"1.0\" encoding=\"utf-8\"?><opml version=\"2.0\"><head /><body>" + OpmlText + "</body></opml>"); opmlFeed = Opml.LoadFromXml(opmlDoc); } else if ((!String.IsNullOrEmpty(OpmlUrl))) { opmlFeed = Opml.LoadFromUrl(new Uri(OpmlUrl)); } else { opmlFeed = Opml.LoadFromFile(OpmlFile); } } var script = new StringBuilder(); string tabInstanceVarName = instanceVarName + "_tabs"; script.Append("var " + tabInstanceVarName + " = new DotNetNuke.UI.WebControls.TabStrip.Strip(\"" + tabInstanceVarName + "\");"); script.Append("var " + instanceVarName + " = new DotNetNuke.UI.WebControls.FeedBrowser.Browser(\"" + instanceVarName + "\"," + tabInstanceVarName + ");"); script.Append(tabInstanceVarName + ".setResourcesFolderUrl(\"" + ResourcesFolderUrl + "\");"); script.Append(instanceVarName + ".setResourcesFolderUrl(\"" + ResourcesFolderUrl + "\");"); script.Append(instanceVarName + ".setElementIdPrefix(\"" + elementIdPrefix + "\");"); if ((!String.IsNullOrEmpty(Theme))) { script.Append(instanceVarName + ".setTheme(\"" + Theme + "\");"); } if ((!String.IsNullOrEmpty(RssProxyUrl))) { script.Append(instanceVarName + ".setRssProxyUrl(\"" + RssProxyUrl + "\");"); } if ((!String.IsNullOrEmpty(DefaultTemplate))) { script.Append(instanceVarName + ".setDefaultTemplate(\"" + DefaultTemplate + "\");"); } script.Append(instanceVarName + ".setAllowHtmlDescription("); if ((AllowHtmlDescription)) { script.Append("true"); } else { script.Append("false"); } script.Append(");"); string renderScript = GetRenderingScript(instanceVarName, opmlFeed.Outlines); bool includeFallbackScript = false; //Is there any OPML structure to render? if ((String.IsNullOrEmpty(renderScript))) { includeFallbackScript = true; script.Append(instanceVarName + ".setTabs(defaultFeedBrowser());"); } else { //Javascript function that renders the OPML structure script.Append("function " + instanceVarName + "customFeedBrowser() "); script.Append("{"); script.Append(" var " + instanceVarName + "tabs = [];"); script.Append(" with (DotNetNuke.UI.WebControls.FeedBrowser) "); script.Append(" {"); script.Append(renderScript); script.Append(" }"); script.Append(" return(" + instanceVarName + "tabs);"); script.Append("} "); script.Append(instanceVarName + ".setTabs(" + instanceVarName + "customFeedBrowser());"); } //NK 11/25/08 //This code has a jQuery dependency so it can't be loaded using standard client script registration //It must come later in the page which is why it is inline; also ClientScript buggy when used in webcontrols if (!Page.ClientScript.IsClientScriptBlockRegistered("FBHostUrl")) { Page.ClientScript.RegisterClientScriptBlock(GetType(), "FBHostUrl", "<script type=\"text/javascript\">var $dnn = new Object(); $dnn.hostUrl = '" + Globals.ResolveUrl("~/") + "';</script>"); output.Append("<script type=\"text/javascript\" src=\"" + Globals.ResolveUrl("~/Resources/Shared/scripts/init.js") + "\"></script>"); output.Append("<script type=\"text/javascript\" src=\"" + Globals.ResolveUrl("~/Resources/Shared/scripts/DotNetNukeAjaxShared.js") + "\"></script>"); output.Append("<script type=\"text/javascript\" src=\"" + Globals.ResolveUrl("~/Resources/TabStrip/scripts/tabstrip.js") + "\"></script>"); output.Append("<script type=\"text/javascript\" src=\"" + Globals.ResolveUrl("~/Resources/FeedBrowser/scripts/feedbrowser.js") + "\"></script>"); output.Append("<script type=\"text/javascript\" src=\"" + Globals.ResolveUrl("~/Resources/FeedBrowser/scripts/templates.js") + "\"></script>"); if ((includeFallbackScript)) { output.Append("<script type=\"text/javascript\" src=\"" + Globals.ResolveUrl("~/Resources/FeedBrowser/scripts/fallback.js") + "\"></script>"); } if ((!String.IsNullOrEmpty(StyleSheetUrl))) { script.Append(tabInstanceVarName + ".setStyleSheetUrl(\"" + StyleSheetUrl + "\");"); script.Append(instanceVarName + ".setStyleSheetUrl(\"" + StyleSheetUrl + "\");"); } } script.Append(instanceVarName + ".render();"); output.Append("<script type=\"text/javascript\">" + script + "</script>"); base.OnLoad(e); }