#region Copyright // // DotNetNuke´┐Ż - http://www.dotnetnuke.com // Copyright (c) 2002-2014 // by DotNetNuke Corporation // // Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated // documentation files (the "Software"), to deal in the Software without restriction, including without limitation // the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and // to permit persons to whom the Software is furnished to do so, subject to the following conditions: // // The above copyright notice and this permission notice shall be included in all copies or substantial portions // of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED // TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF // CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. #endregion #region Usings using System; using System.Collections.Generic; using System.Globalization; using System.IO; using System.Text; using System.Text.RegularExpressions; using System.Web; using System.Web.UI; using System.Web.UI.HtmlControls; using System.Web.UI.WebControls; using DotNetNuke.Application; using DotNetNuke.Common.Utilities; using DotNetNuke.Entities.Host; using DotNetNuke.Entities.Portals; using DotNetNuke.Entities.Tabs; using DotNetNuke.Entities.Users; using DotNetNuke.Framework.JavaScriptLibraries; using DotNetNuke.Instrumentation; using DotNetNuke.Security.Permissions; using DotNetNuke.Services.Exceptions; using DotNetNuke.Services.FileSystem; using DotNetNuke.Services.Localization; using DotNetNuke.Services.Log.SiteLog; using DotNetNuke.Services.Personalization; using DotNetNuke.Services.Vendors; using DotNetNuke.UI; using DotNetNuke.UI.Internals; using DotNetNuke.UI.Modules; using DotNetNuke.UI.Skins.Controls; using DotNetNuke.UI.Utilities; using DotNetNuke.Web.Client.ClientResourceManagement; using Globals = DotNetNuke.Common.Globals; #endregion namespace DotNetNuke.Framework { using Web.Client; /// ----------------------------------------------------------------------------- /// Project : DotNetNuke /// Class : CDefault /// /// ----------------------------------------------------------------------------- /// /// /// /// /// /// /// [sun1] 1/19/2004 Created /// /// ----------------------------------------------------------------------------- public partial class DefaultPage : CDefault, IClientAPICallbackEventHandler { private static readonly ILog Logger = LoggerSource.Instance.GetLogger(typeof (DefaultPage)); #region Properties /// ----------------------------------------------------------------------------- /// /// Property to allow the programmatic assigning of ScrollTop position /// /// /// /// /// /// [Jon Henning] 3/23/2005 Created /// /// ----------------------------------------------------------------------------- public int PageScrollTop { get { int pageScrollTop = Null.NullInteger; if (ScrollTop != null && !String.IsNullOrEmpty(ScrollTop.Value) && Regex.IsMatch(ScrollTop.Value, "^\\d+$")) { pageScrollTop = Convert.ToInt32(ScrollTop.Value); } return pageScrollTop; } set { ScrollTop.Value = value.ToString(); } } protected string HtmlAttributeList { get { if ((HtmlAttributes != null) && (HtmlAttributes.Count > 0)) { var attr = new StringBuilder(); foreach (string attributeName in HtmlAttributes.Keys) { if ((!String.IsNullOrEmpty(attributeName)) && (HtmlAttributes[attributeName] != null)) { string attributeValue = HtmlAttributes[attributeName]; if ((attributeValue.IndexOf(",") > 0)) { var attributeValues = attributeValue.Split(','); for (var attributeCounter = 0; attributeCounter <= attributeValues.Length - 1; attributeCounter++) { attr.Append(string.Concat(" ", attributeName, "=\"", attributeValues[attributeCounter], "\"")); } } else { attr.Append(string.Concat(" ", attributeName, "=\"", attributeValue, "\"")); } } } return attr.ToString(); } return string.Empty; } } public string CurrentSkinPath { get { return ((PortalSettings)HttpContext.Current.Items["PortalSettings"]).ActiveTab.SkinPath; } } #endregion #region IClientAPICallbackEventHandler Members public string RaiseClientAPICallbackEvent(string eventArgument) { var dict = ParsePageCallBackArgs(eventArgument); if (dict.ContainsKey("type")) { if (DNNClientAPI.IsPersonalizationKeyRegistered(dict["namingcontainer"] + ClientAPI.CUSTOM_COLUMN_DELIMITER + dict["key"]) == false) { throw new Exception(string.Format("This personalization key has not been enabled ({0}:{1}). Make sure you enable it with DNNClientAPI.EnableClientPersonalization", dict["namingcontainer"], dict["key"])); } switch ((DNNClientAPI.PageCallBackType)Enum.Parse(typeof(DNNClientAPI.PageCallBackType), dict["type"])) { case DNNClientAPI.PageCallBackType.GetPersonalization: return Personalization.GetProfile(dict["namingcontainer"], dict["key"]).ToString(); case DNNClientAPI.PageCallBackType.SetPersonalization: Personalization.SetProfile(dict["namingcontainer"], dict["key"], dict["value"]); return dict["value"]; default: throw new Exception("Unknown Callback Type"); } } return string.Empty; } #endregion #region Private Methods /// ----------------------------------------------------------------------------- /// /// /// /// /// - Obtain PortalSettings from Current Context /// - redirect to a specific tab based on name /// - if first time loading this page then reload to avoid caching /// - set page title and stylesheet /// - check to see if we should show the Assembly Version in Page Title /// - set the background image if there is one selected /// - set META tags, copyright, keywords and description /// /// /// [sun1] 1/19/2004 Created /// /// ----------------------------------------------------------------------------- private void InitializePage() { //Configure the ActiveTab with Skin/Container information PortalSettingsController.Instance().ConfigureActiveTab(PortalSettings); //redirect to a specific tab based on name if (!String.IsNullOrEmpty(Request.QueryString["tabname"])) { TabInfo tab = TabController.Instance.GetTabByName(Request.QueryString["TabName"], PortalSettings.PortalId); if (tab != null) { var parameters = new List(); //maximum number of elements for (int intParam = 0; intParam <= Request.QueryString.Count - 1; intParam++) { switch (Request.QueryString.Keys[intParam].ToLower()) { case "tabid": case "tabname": break; default: parameters.Add( Request.QueryString.Keys[intParam] + "=" + Request.QueryString[intParam]); break; } } Response.Redirect(Globals.NavigateURL(tab.TabID, Null.NullString, parameters.ToArray()), true); } else { //404 Error - Redirect to ErrorPage Exceptions.ProcessHttpException(Request); } } if (Request.IsAuthenticated) { switch (Host.AuthenticatedCacheability) { case "0": Response.Cache.SetCacheability(HttpCacheability.NoCache); break; case "1": Response.Cache.SetCacheability(HttpCacheability.Private); break; case "2": Response.Cache.SetCacheability(HttpCacheability.Public); break; case "3": Response.Cache.SetCacheability(HttpCacheability.Server); break; case "4": Response.Cache.SetCacheability(HttpCacheability.ServerAndNoCache); break; case "5": Response.Cache.SetCacheability(HttpCacheability.ServerAndPrivate); break; } } //page comment if (Host.DisplayCopyright) { Comment += string.Concat(Environment.NewLine, "", Environment.NewLine, "", Environment.NewLine, "", Environment.NewLine, "", Environment.NewLine); } //Only insert the header control if a comment is needed if(!String.IsNullOrWhiteSpace(Comment)) Page.Header.Controls.AddAt(0, new LiteralControl(Comment)); if (PortalSettings.ActiveTab.PageHeadText != Null.NullString && !Globals.IsAdminControl()) { Page.Header.Controls.Add(new LiteralControl(PortalSettings.ActiveTab.PageHeadText)); } if (!string.IsNullOrEmpty(PortalSettings.PageHeadText)) { metaPanel.Controls.Add(new LiteralControl(PortalSettings.PageHeadText)); } //set page title if (UrlUtils.InPopUp()) { var strTitle = new StringBuilder(PortalSettings.PortalName); var slaveModule = UIUtilities.GetSlaveModule(PortalSettings.ActiveTab.TabID); //Skip is popup is just a tab (no slave module) if (slaveModule.DesktopModuleID != Null.NullInteger) { var control = ModuleControlFactory.CreateModuleControl(slaveModule) as IModuleControl; control.LocalResourceFile = string.Concat( slaveModule.ModuleControl.ControlSrc.Replace(Path.GetFileName(slaveModule.ModuleControl.ControlSrc), string.Empty), Localization.LocalResourceDirectory, "/", Path.GetFileName(slaveModule.ModuleControl.ControlSrc)); var title = Localization.LocalizeControlTitle(control); strTitle.Append(string.Concat(" > ", PortalSettings.ActiveTab.LocalizedTabName)); strTitle.Append(string.Concat(" > ", title)); } else { strTitle.Append(string.Concat(" > ", PortalSettings.ActiveTab.LocalizedTabName)); } //Set to page Title = strTitle.ToString(); } else { //If tab is named, use that title, otherwise build it out via breadcrumbs if (!string.IsNullOrEmpty(PortalSettings.ActiveTab.Title)) { Title = PortalSettings.ActiveTab.Title; } else { //Elected for SB over true concatenation here due to potential for long nesting depth var strTitle = new StringBuilder(PortalSettings.PortalName); foreach (TabInfo tab in PortalSettings.ActiveTab.BreadCrumbs) { strTitle.Append(string.Concat(" > ", tab.TabName)); } Title = strTitle.ToString(); } } //set the background image if there is one selected if (!UrlUtils.InPopUp() && FindControl("Body") != null) { if (!string.IsNullOrEmpty(PortalSettings.BackgroundFile)) { var fileInfo = GetBackgroundFileInfo(); var url = FileManager.Instance.GetUrl(fileInfo); ((HtmlGenericControl)FindControl("Body")).Attributes["style"] = string.Concat("background-image: url('", url, "')"); } } //META Refresh // Only autorefresh the page if we are in VIEW-mode and if we aren't displaying some module's subcontrol. if (PortalSettings.ActiveTab.RefreshInterval > 0 && this.PortalSettings.UserMode == PortalSettings.Mode.View && Request.QueryString["ctl"] == null) { MetaRefresh.Content = PortalSettings.ActiveTab.RefreshInterval.ToString(); MetaRefresh.Visible = true; } else { MetaRefresh.Visible = false; } //META description if (!string.IsNullOrEmpty(PortalSettings.ActiveTab.Description)) { Description = PortalSettings.ActiveTab.Description; } else { Description = PortalSettings.Description; } //META keywords if (!string.IsNullOrEmpty(PortalSettings.ActiveTab.KeyWords)) { KeyWords = PortalSettings.ActiveTab.KeyWords; } else { KeyWords = PortalSettings.KeyWords; } if (Host.DisplayCopyright) { KeyWords += ",DotNetNuke,DNN"; } //META copyright if (!string.IsNullOrEmpty(PortalSettings.FooterText)) { Copyright = PortalSettings.FooterText.Replace("[year]", DateTime.Now.Year.ToString()); } else { Copyright = string.Concat("Copyright (c) ", DateTime.Now.Year, " by ", PortalSettings.PortalName); } //META generator if (Host.DisplayCopyright) { Generator = "DotNetNuke "; } else { Generator = ""; } //META Robots - hide it inside popups and if PageHeadText of current tab already contains a robots meta tag if (!UrlUtils.InPopUp() && !Regex.IsMatch(PortalSettings.ActiveTab.PageHeadText, "])+name=('|\")robots('|\")", RegexOptions.IgnoreCase | RegexOptions.Multiline) && !Regex.IsMatch(PortalSettings.PageHeadText, "])+name=('|\")robots('|\")", RegexOptions.IgnoreCase | RegexOptions.Multiline) ) { MetaRobots.Visible = true; var allowIndex = true; if ((PortalSettings.ActiveTab.TabSettings.ContainsKey("AllowIndex") && bool.TryParse(PortalSettings.ActiveTab.TabSettings["AllowIndex"].ToString(), out allowIndex) && !allowIndex) || (Request.QueryString["ctl"] != null && (Request.QueryString["ctl"] == "Login" || Request.QueryString["ctl"] == "Register"))) { MetaRobots.Content = "NOINDEX, NOFOLLOW"; } else { MetaRobots.Content = "INDEX, FOLLOW"; } } //NonProduction Label Injection if (NonProductionVersion() && Host.DisplayBetaNotice && !UrlUtils.InPopUp()) { string versionString = string.Format(" ({0} Version: {1})", DotNetNukeContext.Current.Application.Status, DotNetNukeContext.Current.Application.Version); Title += versionString; } //register DNN SkinWidgets Inititialization scripts if (PortalSettings.EnableSkinWidgets & !UrlUtils.InPopUp()) { jQuery.RequestRegistration(); // don't use the new API to register widgets until we better understand their asynchronous script loading requirements. ClientAPI.RegisterStartUpScript(Page, "initWidgets", string.Format("", ResolveUrl("~/Resources/Shared/scripts/initWidgets.js"))); } //register the custom stylesheet of current page if (PortalSettings.ActiveTab.TabSettings.ContainsKey("CustomStylesheet") && !string.IsNullOrEmpty(PortalSettings.ActiveTab.TabSettings["CustomStylesheet"].ToString())) { var customStylesheet = Path.Combine(PortalSettings.HomeDirectory, PortalSettings.ActiveTab.TabSettings["CustomStylesheet"].ToString()); ClientResourceManager.RegisterStyleSheet(this, customStylesheet); } } /// ----------------------------------------------------------------------------- /// /// Look for skin level doctype configuration file, and inject the value into the top of default.aspx /// when no configuration if found, the doctype for versions prior to 4.4 is used to maintain backwards compatibility with existing skins. /// Adds xmlns and lang parameters when appropiate. /// /// The currently loading skin /// /// /// [cathal] 11/29/2006 Created /// [cniknet] 05/20/2009 Refactored to use HtmlAttributes collection /// /// ----------------------------------------------------------------------------- private void SetSkinDoctype() { string strLang = CultureInfo.CurrentCulture.ToString(); string strDocType = PortalSettings.ActiveTab.SkinDoctype; if (strDocType.Contains("XHTML 1.0")) { //XHTML 1.0 HtmlAttributes.Add("xml:lang", strLang); HtmlAttributes.Add("lang", strLang); HtmlAttributes.Add("xmlns", "http://www.w3.org/1999/xhtml"); } else if (strDocType.Contains("XHTML 1.1")) { //XHTML 1.1 HtmlAttributes.Add("xml:lang", strLang); HtmlAttributes.Add("xmlns", "http://www.w3.org/1999/xhtml"); } else { //other HtmlAttributes.Add("lang", strLang); } //Find the placeholder control and render the doctype skinDocType.Text = PortalSettings.ActiveTab.SkinDoctype; attributeList.Text = HtmlAttributeList; } /// ----------------------------------------------------------------------------- /// /// /// /// /// - manage affiliates /// - log visit to site /// /// /// [sun1] 1/19/2004 Created /// /// ----------------------------------------------------------------------------- private void ManageRequest() { //affiliate processing int affiliateId = -1; if (Request.QueryString["AffiliateId"] != null) { if (Regex.IsMatch(Request.QueryString["AffiliateId"], "^\\d+$")) { affiliateId = Int32.Parse(Request.QueryString["AffiliateId"]); var objAffiliates = new AffiliateController(); objAffiliates.UpdateAffiliateStats(affiliateId, 1, 0); //save the affiliateid for acquisitions if (Request.Cookies["AffiliateId"] == null) //do not overwrite { var objCookie = new HttpCookie("AffiliateId", affiliateId.ToString("D")) { Expires = DateTime.Now.AddYears(1), Path = (!string.IsNullOrEmpty(Globals.ApplicationPath) ? Globals.ApplicationPath : "/") }; Response.Cookies.Add(objCookie); } } } //site logging if (PortalSettings.SiteLogHistory != 0) { //get User ID //URL Referrer string urlReferrer = ""; try { if (Request.UrlReferrer != null) { urlReferrer = Request.UrlReferrer.ToString(); } } catch (Exception exc) { Logger.Error(exc); } string strSiteLogStorage = Host.SiteLogStorage; int intSiteLogBuffer = Host.SiteLogBuffer; //log visit var objSiteLogs = new SiteLogController(); UserInfo objUserInfo = UserController.Instance.GetCurrentUserInfo(); objSiteLogs.AddSiteLog(PortalSettings.PortalId, objUserInfo.UserID, urlReferrer, Request.Url.ToString(), Request.UserAgent, Request.UserHostAddress, Request.UserHostName, PortalSettings.ActiveTab.TabID, affiliateId, intSiteLogBuffer, strSiteLogStorage); } } private void ManageFavicon() { string headerLink = FavIcon.GetHeaderLink(PortalSettings.PortalId); if (!String.IsNullOrEmpty(headerLink)) { Page.Header.Controls.Add(new Literal { Text = headerLink }); } } //I realize the parsing of this is rather primitive. A better solution would be to use json serialization //unfortunately, I don't have the time to write it. When we officially adopt MS AJAX, we will get this type of //functionality and this should be changed to utilize it for its plumbing. private Dictionary ParsePageCallBackArgs(string strArg) { string[] aryVals = strArg.Split(new[] { ClientAPI.COLUMN_DELIMITER }, StringSplitOptions.None); var objDict = new Dictionary(); if (aryVals.Length > 0) { objDict.Add("type", aryVals[0]); switch ( (DNNClientAPI.PageCallBackType)Enum.Parse(typeof(DNNClientAPI.PageCallBackType), objDict["type"])) { case DNNClientAPI.PageCallBackType.GetPersonalization: objDict.Add("namingcontainer", aryVals[1]); objDict.Add("key", aryVals[2]); break; case DNNClientAPI.PageCallBackType.SetPersonalization: objDict.Add("namingcontainer", aryVals[1]); objDict.Add("key", aryVals[2]); objDict.Add("value", aryVals[3]); break; } } return objDict; } /// /// check if a warning about account defaults needs to be rendered /// /// localised error message /// /// /// [cathal] 2/28/2007 Created /// private string RenderDefaultsWarning() { var warningLevel = Request.QueryString["runningDefault"]; var warningMessage = string.Empty; switch (warningLevel) { case "1": warningMessage = Localization.GetString("InsecureAdmin.Text", Localization.SharedResourceFile); break; case "2": warningMessage = Localization.GetString("InsecureHost.Text", Localization.SharedResourceFile); break; case "3": warningMessage = Localization.GetString("InsecureDefaults.Text", Localization.SharedResourceFile); break; } return warningMessage; } private IFileInfo GetBackgroundFileInfo() { string cacheKey = String.Format(Common.Utilities.DataCache.PortalCacheKey, PortalSettings.PortalId, "BackgroundFile"); var file = CBO.GetCachedObject(new CacheItemArgs(cacheKey, Common.Utilities.DataCache.PortalCacheTimeOut, Common.Utilities.DataCache.PortalCachePriority), GetBackgroundFileInfoCallBack); return file; } private IFileInfo GetBackgroundFileInfoCallBack(CacheItemArgs itemArgs) { return FileManager.Instance.GetFile(PortalSettings.PortalId, PortalSettings.BackgroundFile); } #endregion #region Protected Methods protected bool NonProductionVersion() { return DotNetNukeContext.Current.Application.Status != ReleaseMode.Stable; } /// ----------------------------------------------------------------------------- /// /// Contains the functionality to populate the Root aspx page with controls /// /// /// /// - obtain PortalSettings from Current Context /// - set global page settings. /// - initialise reference paths to load the cascading style sheets /// - add skin control placeholder. This holds all the modules and content of the page. /// /// ----------------------------------------------------------------------------- protected override void OnInit(EventArgs e) { base.OnInit(e); //set global page settings InitializePage(); //load skin control and register UI js UI.Skins.Skin ctlSkin; if (PortalSettings.EnablePopUps) { ctlSkin = UrlUtils.InPopUp() ? UI.Skins.Skin.GetPopUpSkin(this) : UI.Skins.Skin.GetSkin(this); //register popup js JavaScript.RequestRegistration(CommonJs.jQueryUI); var popupFilePath = HttpContext.Current.IsDebuggingEnabled ? "~/js/Debug/dnn.modalpopup.js" : "~/js/dnn.modalpopup.js"; ClientResourceManager.RegisterScript(this, popupFilePath, FileOrder.Js.DnnModalPopup); } else { ctlSkin = UI.Skins.Skin.GetSkin(this); } // DataBind common paths for the client resource loader ClientResourceLoader.DataBind(); //check for and read skin package level doctype SetSkinDoctype(); //Manage disabled pages if (PortalSettings.ActiveTab.DisableLink) { if (TabPermissionController.CanAdminPage()) { var heading = Localization.GetString("PageDisabled.Header"); var message = Localization.GetString("PageDisabled.Text"); UI.Skins.Skin.AddPageMessage(ctlSkin, heading, message, ModuleMessage.ModuleMessageType.YellowWarning); } else { if (PortalSettings.HomeTabId > 0) { Response.Redirect(Globals.NavigateURL(PortalSettings.HomeTabId), true); } else { Response.Redirect(Globals.GetPortalDomainName(PortalSettings.PortalAlias.HTTPAlias, Request, true), true); } } } //Manage canonical urls if (PortalSettings.PortalAliasMappingMode == PortalSettings.PortalAliasMapping.CanonicalUrl) { string primaryHttpAlias = null; if (Config.GetFriendlyUrlProvider() == "advanced") //advanced mode compares on the primary alias as set during alias identification { if (PortalSettings.PrimaryAlias != null && PortalSettings.PortalAlias != null) { if (string.Compare(PortalSettings.PrimaryAlias.HTTPAlias, PortalSettings.PortalAlias.HTTPAlias, StringComparison.InvariantCulture ) != 0) { primaryHttpAlias = PortalSettings.PrimaryAlias.HTTPAlias; } } } else //other modes just depend on the default alias { if (string.Compare(PortalSettings.PortalAlias.HTTPAlias, PortalSettings.DefaultPortalAlias, StringComparison.InvariantCulture ) != 0) primaryHttpAlias = PortalSettings.DefaultPortalAlias; } if (primaryHttpAlias != null && string.IsNullOrEmpty(CanonicalLinkUrl))//a primary http alias was identified { var originalurl = Context.Items["UrlRewrite:OriginalUrl"].ToString(); CanonicalLinkUrl = originalurl.Replace(PortalSettings.PortalAlias.HTTPAlias, primaryHttpAlias); } } //check if running with known account defaults if (Request.IsAuthenticated && string.IsNullOrEmpty(Request.QueryString["runningDefault"]) == false) { var userInfo = HttpContext.Current.Items["UserInfo"] as UserInfo; //only show message to default users if ((userInfo.Username.ToLower() == "admin") || (userInfo.Username.ToLower() == "host")) { var messageText = RenderDefaultsWarning(); var messageTitle = Localization.GetString("InsecureDefaults.Title", Localization.GlobalResourceFile); UI.Skins.Skin.AddPageMessage(ctlSkin, messageTitle, messageText, ModuleMessage.ModuleMessageType.RedError); } } //add CSS links ClientResourceManager.RegisterDefaultStylesheet(this, string.Concat(Globals.HostPath, "default.css")); ClientResourceManager.RegisterIEStylesheet(this, string.Concat(Globals.HostPath, "ie.css")); ClientResourceManager.RegisterStyleSheet(this, string.Concat(ctlSkin.SkinPath, "skin.css"), FileOrder.Css.SkinCss); ClientResourceManager.RegisterStyleSheet(this, ctlSkin.SkinSrc.Replace(".ascx", ".css"), FileOrder.Css.SpecificSkinCss); //add skin to page SkinPlaceHolder.Controls.Add(ctlSkin); ClientResourceManager.RegisterStyleSheet(this, string.Concat(PortalSettings.HomeDirectory, "portal.css"), FileOrder.Css.PortalCss); //add Favicon ManageFavicon(); //ClientCallback Logic ClientAPI.HandleClientAPICallbackEvent(this); //add viewstateuserkey to protect against CSRF attacks if (User.Identity.IsAuthenticated) { ViewStateUserKey = User.Identity.Name; } //set the async postback timeout. if (AJAX.IsEnabled()) { AJAX.GetScriptManager(this).AsyncPostBackTimeout = Host.AsyncTimeout; } } /// ----------------------------------------------------------------------------- /// /// Initialize the Scrolltop html control which controls the open / closed nature of each module /// /// /// /// /// ----------------------------------------------------------------------------- protected override void OnLoad(EventArgs e) { base.OnLoad(e); ManageGettingStarted(); ManageInstallerFiles(); if (!String.IsNullOrEmpty(ScrollTop.Value)) { DNNClientAPI.SetScrollTop(Page); ScrollTop.Value = ScrollTop.Value; } } protected override void OnPreRender(EventArgs evt) { base.OnPreRender(evt); //process the current request if (!Globals.IsAdminControl()) { ManageRequest(); } //Set the Head tags metaPanel.Visible = !UrlUtils.InPopUp(); if (!UrlUtils.InPopUp()) { MetaGenerator.Content = Generator; MetaGenerator.Visible = (!String.IsNullOrEmpty(Generator)); MetaAuthor.Content = PortalSettings.PortalName; /* * Never show to be html5 compatible and stay backward compatible * * MetaCopyright.Content = Copyright; * MetaCopyright.Visible = (!String.IsNullOrEmpty(Copyright)); */ MetaKeywords.Content = KeyWords; MetaKeywords.Visible = (!String.IsNullOrEmpty(KeyWords)); MetaDescription.Content = Description; MetaDescription.Visible = (!String.IsNullOrEmpty(Description)); } Page.Header.Title = Title; if (!string.IsNullOrEmpty(PortalSettings.AddCompatibleHttpHeader)) { Page.Response.AddHeader("X-UA-Compatible", PortalSettings.AddCompatibleHttpHeader); } if (!string.IsNullOrEmpty(CanonicalLinkUrl)) { //Add Canonical using the primary alias var canonicalLink = new HtmlLink(); canonicalLink.Href = CanonicalLinkUrl; canonicalLink.Attributes.Add("rel", "canonical"); // Add the HtmlLink to the Head section of the page. Page.Header.Controls.Add(canonicalLink); } } protected override void Render(HtmlTextWriter writer) { if (PortalSettings.UserMode == PortalSettings.Mode.Edit) { var editClass = "dnnEditState"; var bodyClass = Body.Attributes["class"]; if (!string.IsNullOrEmpty(bodyClass)) { Body.Attributes["class"] = string.Format("{0} {1}", bodyClass, editClass); } else { Body.Attributes["class"] = editClass; } } base.Render(writer); } #endregion } }