private void RegisterPersonaBarStyleSheet() { ClientResourceManager.RegisterStyleSheet(Page, "~/DesktopModules/admin/Dnn.PersonaBar/css/personaBarContainer.css"); }
/// <summary> /// </summary> protected void Page_PreRender(object sender, EventArgs e) { ClientResourceManager.RegisterStyleSheet(this.Page, this.ControlPath + "../Resources/css/view.css"); ClientResourceManager.RegisterScript(this.Page, this.ControlPath + "../Resources/js/view.js"); }
protected void RegisterViewScript(string path, int order = 0) { ClientResourceManager.RegisterScript(Page, ResolveUrl(HccApp.ViewsVirtualPath + "/Scripts/" + path), FileOrder.Js.DefaultPriority + 10 + order); }
//Use selected skin's webcontrol skin if one exists //or use _default skin's webcontrol skin if one exists //or use embedded skin public static void ApplySkin(Control telerikControl, string fallBackEmbeddedSkinName, string controlName, string webControlSkinSubFolderName) { PropertyInfo skinProperty = null; PropertyInfo enableEmbeddedSkinsProperty = null; bool skinApplied = false; try { skinProperty = telerikControl.GetType().GetProperty("Skin"); enableEmbeddedSkinsProperty = telerikControl.GetType().GetProperty("EnableEmbeddedSkins"); if ((string.IsNullOrEmpty(controlName))) { controlName = telerikControl.GetType().BaseType.Name; if ((controlName.StartsWith("Rad") || controlName.StartsWith("Dnn"))) { controlName = controlName.Substring(3); } } string skinVirtualFolder = ""; if (PortalSettings.Current != null) { skinVirtualFolder = PortalSettings.Current.ActiveTab.SkinPath.Replace('\\', '/').Replace("//", "/"); } else { skinVirtualFolder = telerikControl.ResolveUrl("~/Portals/_default/skins/_default/Aphelia"); // developer skin Aphelia } string skinName = ""; string webControlSkinName = ""; if (skinProperty != null) { var v = skinProperty.GetValue(telerikControl, null); if (v != null) { webControlSkinName = v.ToString(); } } if (string.IsNullOrEmpty(webControlSkinName)) { webControlSkinName = "default"; } if ((skinVirtualFolder.EndsWith("/"))) { skinVirtualFolder = skinVirtualFolder.Substring(0, skinVirtualFolder.Length - 1); } int lastIndex = skinVirtualFolder.LastIndexOf("/"); if ((lastIndex > -1 && skinVirtualFolder.Length > lastIndex)) { skinName = skinVirtualFolder.Substring(skinVirtualFolder.LastIndexOf("/") + 1); } string systemWebControlSkin = string.Empty; if ((!string.IsNullOrEmpty(skinName) && !string.IsNullOrEmpty(skinVirtualFolder))) { systemWebControlSkin = HttpContext.Current.Server.MapPath(skinVirtualFolder); systemWebControlSkin = Path.Combine(systemWebControlSkin, "WebControlSkin"); systemWebControlSkin = Path.Combine(systemWebControlSkin, skinName); systemWebControlSkin = Path.Combine(systemWebControlSkin, webControlSkinSubFolderName); systemWebControlSkin = Path.Combine(systemWebControlSkin, string.Format("{0}.{1}.css", controlName, webControlSkinName)); //Check if the selected skin has the webcontrol skin if ((!File.Exists(systemWebControlSkin))) { systemWebControlSkin = ""; } //No skin, try default folder if ((string.IsNullOrEmpty(systemWebControlSkin))) { skinVirtualFolder = telerikControl.ResolveUrl("~/Portals/_default/Skins/_default"); skinName = "Default"; if ((skinVirtualFolder.EndsWith("/"))) { skinVirtualFolder = skinVirtualFolder.Substring(0, skinVirtualFolder.Length - 1); } if ((!string.IsNullOrEmpty(skinName) && !string.IsNullOrEmpty(skinVirtualFolder))) { systemWebControlSkin = HttpContext.Current.Server.MapPath(skinVirtualFolder); systemWebControlSkin = Path.Combine(systemWebControlSkin, "WebControlSkin"); systemWebControlSkin = Path.Combine(systemWebControlSkin, skinName); systemWebControlSkin = Path.Combine(systemWebControlSkin, webControlSkinSubFolderName); systemWebControlSkin = Path.Combine(systemWebControlSkin, string.Format("{0}.{1}.css", controlName, webControlSkinName)); if ((!File.Exists(systemWebControlSkin))) { systemWebControlSkin = ""; } } } } if ((!string.IsNullOrEmpty(systemWebControlSkin))) { string filePath = Path.Combine(skinVirtualFolder, "WebControlSkin"); filePath = Path.Combine(filePath, skinName); filePath = Path.Combine(filePath, webControlSkinSubFolderName); filePath = Path.Combine(filePath, string.Format("{0}.{1}.css", controlName, webControlSkinName)); filePath = filePath.Replace('\\', '/').Replace("//", "/").TrimEnd('/'); if (HttpContext.Current != null && HttpContext.Current.Handler is Page) { ClientResourceManager.RegisterStyleSheet(HttpContext.Current.Handler as Page, filePath); } if (((skinProperty != null) && (enableEmbeddedSkinsProperty != null))) { skinApplied = true; skinProperty.SetValue(telerikControl, webControlSkinName, null); enableEmbeddedSkinsProperty.SetValue(telerikControl, false, null); } } } catch (Exception ex) { Exceptions.LogException(ex); } if (skinProperty != null && enableEmbeddedSkinsProperty != null && !skinApplied) { if ((string.IsNullOrEmpty(fallBackEmbeddedSkinName))) { fallBackEmbeddedSkinName = "Simple"; } //Set fall back skin Embedded Skin skinProperty.SetValue(telerikControl, fallBackEmbeddedSkinName, null); enableEmbeddedSkinsProperty.SetValue(telerikControl, true, null); } }
/// ----------------------------------------------------------------------------- /// <summary> /// /// </summary> /// <remarks> /// - 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 /// </remarks> /// <history> /// [sun1] 1/19/2004 Created /// </history> /// ----------------------------------------------------------------------------- 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 <string>(); //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, "<!-- DNN Platform - http://www.dnnsoftware.com -->", Environment.NewLine, "<!-- Copyright (c) 2002-2015, by DNN Corporation -->", 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, "<meta([^>])+name=('|\")robots('|\")", RegexOptions.IgnoreCase | RegexOptions.Multiline) && !Regex.IsMatch(PortalSettings.PageHeadText, "<meta([^>])+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("<script type=\"text/javascript\" src=\"{0}\" ></script>", 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); } }
/// <summary> /// Requests that a JavaScript file be registered on the client browser. /// </summary> /// <param name="filePath">The relative file path to the JavaScript resource.</param> /// <param name="priority">The relative priority in which the file should be loaded.</param> public void DnnJsInclude(string filePath, FileOrder.Js priority) { ClientResourceManager.RegisterScript(this.DnnPage, filePath, priority); }
protected void Page_PreRender(object sender, EventArgs e) { ClientResourceManager.RegisterStyleSheet(this.Page, base.ControlPath + "resources/css/module.css"); }
/// ----------------------------------------------------------------------------- /// <summary> /// ClearCache runs when the clear cache button is clicked /// </summary> /// <remarks> /// </remarks> /// <history> /// [cnurse] 9/27/2004 Updated to reflect design changes for Help, 508 support /// and localisation /// </history> /// ----------------------------------------------------------------------------- protected void ClearCache(object sender, EventArgs e) { DataCache.ClearCache(); ClientResourceManager.ClearCache(); Response.Redirect(Request.RawUrl, true); }
private void RegisterJavaScript() { jQuery.RequestRegistration(); //TODO: probably should check if we need to use HTTPS or not ClientResourceManager.RegisterScript(Page, "/portals/_default/skins/multifunction/js/ob/orangebox.min.js"); // default priority and provider }
protected override void OnInit(EventArgs e) { ClientResourceManager.RegisterScript(Page, "~/DesktopModules/DigitalAssets/ClientScripts/dnn.DigitalAssets.SearchBox.js", FileOrder.Js.DefaultPriority + 10); }
private void RegisterFields(bool bootstrap) { bool allFields = string.IsNullOrEmpty(VirtualDirectory); List <string> fieldTypes = new List <string>(); if (!allFields) { JToken options = GetOptions(); if (options != null) { fieldTypes = FieldTypes(options); } } if (allFields || fieldTypes.Contains("address")) { string apikey = OpenContentControllerFactory.Instance.OpenContentGlobalSettingsController(PortalId).GetGoogleApiKey(); ClientResourceManager.RegisterScript(Page, "//maps.googleapis.com/maps/api/js?v=3.exp&libraries=places" + (string.IsNullOrEmpty(apikey) ? "" : "&key=" + apikey), FileOrder.Js.DefaultPriority); } if (allFields || fieldTypes.Contains("imagecropper") || fieldTypes.Contains("imagecrop") || fieldTypes.Contains("imagecrop2")) { ClientResourceManager.RegisterScript(Page, "~/DesktopModules/OpenContent/js/cropper/cropper.js", FileOrder.Js.DefaultPriority); ClientResourceManager.RegisterStyleSheet(Page, "~/DesktopModules/OpenContent/js/cropper/cropper.css", FileOrder.Css.DefaultPriority); } if (allFields || fieldTypes.Contains("select2") || fieldTypes.Contains("image2") || fieldTypes.Contains("file2") || fieldTypes.Contains("url2") || fieldTypes.Contains("mlimage2") || fieldTypes.Contains("mlfile2") || fieldTypes.Contains("mlurl2") || fieldTypes.Contains("mlfolder2") || fieldTypes.Contains("imagecrop2") ) { ClientResourceManager.RegisterScript(Page, "~/DesktopModules/OpenContent/js/select2/select2.js", FileOrder.Js.DefaultPriority); ClientResourceManager.RegisterStyleSheet(Page, "~/DesktopModules/OpenContent/js/select2/select2.css", FileOrder.Css.DefaultPriority); if (bootstrap) { ClientResourceManager.RegisterStyleSheet(Page, "~/DesktopModules/OpenContent/js/select2/select2-bootstrap.min.css", FileOrder.Css.DefaultPriority + 1); } } //<!-- bootstrap datetimepicker for date, time and datetime controls --> //<dnncl:DnnJsInclude ID="DnnJsInclude13" runat="server" FilePath="~/DesktopModules/OpenContent/js/lib/moment/min/moment-with-locales.min.js" Priority="106" ForceProvider="DnnPageHeaderProvider" /> //<dnncl:DnnJsInclude ID="DnnJsInclude14" runat="server" FilePath="~/DesktopModules/OpenContent/js/lib/eonasdan-bootstrap-datetimepicker/build/js/bootstrap-datetimepicker.min.js" Priority="106" ForceProvider="DnnPageHeaderProvider" /> //<dnncl:DnnCssInclude ID="DnnCssInclude2" runat="server" FilePath="~/DesktopModules/OpenContent/js/lib/eonasdan-bootstrap-datetimepicker/build/css/bootstrap-datetimepicker.css" AddTag="false" /> if (allFields || fieldTypes.Contains("date") || fieldTypes.Contains("datetime") || fieldTypes.Contains("time")) { ClientResourceManager.RegisterScript(Page, "~/DesktopModules/OpenContent/js/lib/moment/min/moment-with-locales.min.js", FileOrder.Js.DefaultPriority, "DnnPageHeaderProvider"); ClientResourceManager.RegisterScript(Page, "~/DesktopModules/OpenContent/js/lib/eonasdan-bootstrap-datetimepicker/build/js/bootstrap-datetimepicker.min.js", FileOrder.Js.DefaultPriority + 1, "DnnPageHeaderProvider"); ClientResourceManager.RegisterStyleSheet(Page, "~/DesktopModules/OpenContent/js/lib/eonasdan-bootstrap-datetimepicker/build/css/bootstrap-datetimepicker.css", FileOrder.Css.DefaultPriority); } if (allFields || fieldTypes.Contains("ckeditor") || fieldTypes.Contains("mlckeditor")) { //var form = Page.FindControl("Form"); //if (form.FindControl("CKDNNporid") == null) { if (CKEditorIngoThaWatchaIsInstalled()) { ClientResourceManager.RegisterScript(Page, "~/Providers/HtmlEditorProviders/CKEditor/ckeditor.js", FileOrder.Js.DefaultPriority); DotNetNuke.UI.Utilities.ClientAPI.RegisterClientVariable(Page, "PortalId", PortalId.ToString(), true); /* * var CKDNNporid = new HiddenField(); * CKDNNporid.ID = "CKDNNporid"; * CKDNNporid.ClientIDMode = ClientIDMode.Static; * form.Controls.Add(CKDNNporid); * CKDNNporid.Value = PortalId.ToString(); */ RegisterStartupScript("oc-ckdnnporid", string.Format(@"<input type=""hidden"" id=""CKDNNporid"" value=""{0}"">", PortalId), false); GenerateEditorLoadScript(PortalId); } else if (CKEditorDnnConnectIsInstalled()) { ClientResourceManager.RegisterScript(Page, "~/Providers/HtmlEditorProviders/DNNConnect.CKE/js/ckeditor/4.5.3/ckeditor.js", FileOrder.Js.DefaultPriority); DotNetNuke.UI.Utilities.ClientAPI.RegisterClientVariable(Page, "PortalId", PortalId.ToString(), true); /* * var CKDNNporid = new HiddenField(); * CKDNNporid.ID = "CKDNNporid"; * CKDNNporid.ClientIDMode = ClientIDMode.Static; * * form.Controls.Add(CKDNNporid); * CKDNNporid.Value = PortalId.ToString(); */ RegisterStartupScript("oc-ckdnnporid", string.Format(@"<input type=""hidden"" id=""CKDNNporid"" value=""{0}"">", PortalId), false); GenerateEditorLoadScript(PortalId); } else { Log.Logger.Warn("Failed to load CKEeditor. Please install a DNN CKEditor Provider."); } } } if (allFields || fieldTypes.Contains("icon")) { ClientResourceManager.RegisterScript(Page, "~/DesktopModules/OpenContent/js/fontIconPicker/jquery.fonticonpicker.min.js", FileOrder.Js.DefaultPriority, "DnnPageHeaderProvider"); ClientResourceManager.RegisterStyleSheet(Page, "~/DesktopModules/OpenContent/js/fontIconPicker/css/jquery.fonticonpicker.min.css", FileOrder.Css.DefaultPriority); ClientResourceManager.RegisterStyleSheet(Page, "~/DesktopModules/OpenContent/js/fontIconPicker/themes/grey-theme/jquery.fonticonpicker.grey.min.css", FileOrder.Css.DefaultPriority); ClientResourceManager.RegisterStyleSheet(Page, "~/DesktopModules/OpenContent/css/glyphicons/glyphicons.css", FileOrder.Css.DefaultPriority + 1); } if (allFields || fieldTypes.Contains("summernote")) { ClientResourceManager.RegisterScript(Page, "~/DesktopModules/OpenContent/js/summernote/summernote.min.js", FileOrder.Js.DefaultPriority, "DnnPageHeaderProvider"); ClientResourceManager.RegisterStyleSheet(Page, "~/DesktopModules/OpenContent/js/summernote/summernote.css", FileOrder.Css.DefaultPriority); } }
protected override void OnLoad(EventArgs e) { base.OnLoad(e); this.ddlMode.SelectedIndexChanged += this.ddlMode_SelectedIndexChanged; this.ddlUICulture.SelectedIndexChanged += this.ddlUICulture_SelectedIndexChanged; try { this.AdminPanel.Visible = false; this.AdvancedToolsPanel.Visible = false; if (this.ControlPanel.Visible && this.IncludeInControlHierarchy) { ClientResourceManager.RegisterStyleSheet(this.Page, "~/admin/ControlPanel/module.css"); ClientResourceManager.RegisterScript(this.Page, "~/Resources/ControlPanel/ControlPanel.debug.js"); } JavaScript.RequestRegistration(CommonJs.DnnPlugins); Control copyPageButton = this.CurrentPagePanel.FindControl("CopyPage"); if (copyPageButton != null) { copyPageButton.Visible = LocaleController.Instance.IsDefaultLanguage(LocaleController.Instance.GetCurrentLocale(this.PortalSettings.PortalId).Code); } if (this.Request.IsAuthenticated) { UserInfo user = UserController.Instance.GetCurrentUserInfo(); if (user != null) { bool isAdmin = user.IsInRole(PortalSettings.Current.AdministratorRoleName); this.AdminPanel.Visible = isAdmin; } } if (this.IsPageAdmin()) { this.ControlPanel.Visible = true; this.BodyPanel.Visible = true; if (DotNetNukeContext.Current.Application.Name == "DNNCORP.CE") { // Hide Support icon in CE this.AdminPanel.FindControl("SupportTickets").Visible = false; } else { // Show PE/XE tools this.AdvancedToolsPanel.Visible = true; } this.Localize(); if (!this.Page.IsPostBack) { UserInfo objUser = UserController.Instance.GetCurrentUserInfo(); if (objUser != null) { if (objUser.IsSuperUser) { this.hypMessage.ImageUrl = Upgrade.UpgradeIndicator(DotNetNukeContext.Current.Application.Version, this.Request.IsLocal, this.Request.IsSecureConnection); if (!string.IsNullOrEmpty(this.hypMessage.ImageUrl)) { this.hypMessage.ToolTip = Localization.GetString("hypUpgrade.Text", this.LocalResourceFile); this.hypMessage.NavigateUrl = Upgrade.UpgradeRedirect(); } } else { if (PortalSecurity.IsInRole(this.PortalSettings.AdministratorRoleName) && Host.DisplayCopyright) { this.hypMessage.ImageUrl = "~/images/branding/iconbar_logo.png"; this.hypMessage.ToolTip = DotNetNukeContext.Current.Application.Description; this.hypMessage.NavigateUrl = Localization.GetString("hypMessageUrl.Text", this.LocalResourceFile); } else { this.hypMessage.Visible = false; } if (!TabPermissionController.CanAddContentToPage()) { this.CommonTasksPanel.Visible = false; } } if (this.PortalSettings.AllowUserUICulture) { object oCulture = DotNetNuke.Services.Personalization.Personalization.GetProfile("Usability", "UICulture"); string currentCulture; if (oCulture != null) { currentCulture = oCulture.ToString(); } else { Localization l = new Localization(); currentCulture = l.CurrentUICulture; } // Localization.LoadCultureDropDownList(ddlUICulture, CultureDropDownTypes.NativeName, currentCulture); IEnumerable <ListItem> cultureListItems = Localization.LoadCultureInListItems(CultureDropDownTypes.NativeName, currentCulture, string.Empty, false); foreach (var cultureItem in cultureListItems) { this.ddlUICulture.AddItem(cultureItem.Text, cultureItem.Value); } var selectedCultureItem = this.ddlUICulture.FindItemByValue(currentCulture); if (selectedCultureItem != null) { selectedCultureItem.Selected = true; } // only show language selector if more than one language if (this.ddlUICulture.Items.Count > 1) { this.lblUILanguage.Visible = true; this.ddlUICulture.Visible = true; if (oCulture == null) { this.SetLanguage(true); } } } } this.SetMode(false); } } else if (this.IsModuleAdmin()) { this.ControlPanel.Visible = true; this.BodyPanel.Visible = false; this.adminMenus.Visible = false; if (!this.Page.IsPostBack) { this.SetMode(false); } } else { this.ControlPanel.Visible = false; } } catch (Exception exc) { Exceptions.ProcessModuleLoadException(this, exc); } }
public void AddScript(string scriptName) { ClientResourceManager.RegisterScript(Page, string.Format("~/DesktopModules/MVC/Connect/HitchARide/js/{0}", scriptName)); }
public void AddCss(string cssFile) { ClientResourceManager.RegisterStyleSheet(Page, string.Format("~/DesktopModules/MVC/Connect/HitchARide/css/{0}", cssFile)); }
/// <summary> /// Requests that a CSS file be registered on the client browser. Allows for overriding the default provider. /// </summary> /// <param name="filePath">The relative file path to the CSS resource.</param> /// <param name="priority">The relative priority in which the file should be loaded.</param> /// <param name="provider">The provider name to be used to render the css file on the page.</param> public void DnnCssInclude(string filePath, int priority, string provider) { ClientResourceManager.RegisterStyleSheet(this.DnnPage, filePath, priority, provider); }
public override string Process(string renderedTemplate) { if (HttpContext.Current == null || HttpContext.Current.CurrentHandler == null || !(HttpContext.Current.CurrentHandler is Page)) { return(renderedTemplate); } var page = (HttpContext.Current.CurrentHandler as Page); #region Handle Client Dependency injection #region Scripts var scriptMatches = ScriptDetection.Matches(renderedTemplate); var scriptMatchesToRemove = new List <Match>(); foreach (Match match in scriptMatches) { var optMatch = OptimizeDetection.Match(match.Value); if (!optMatch.Success) { continue; } var providerName = GetProviderName(optMatch, "body"); var prio = GetPriority(optMatch, (int)FileOrder.Js.DefaultPriority); if (prio <= 0) { continue; // don't register/remove if not within specs } // Register, then remember to remove later on ClientResourceManager.RegisterScript(page, match.Groups["Src"].Value, prio, providerName); scriptMatchesToRemove.Add(match); } scriptMatchesToRemove.Reverse(); scriptMatchesToRemove.ForEach(p => renderedTemplate = renderedTemplate.Remove(p.Index, p.Length)); #endregion #region Styles var styleMatches = StyleDetection.Matches(renderedTemplate); var styleMatchesToRemove = new List <Match>(); foreach (Match match in styleMatches) { var optMatch = OptimizeDetection.Match(match.Value); if (!optMatch.Success) { continue; } // skip If the Rel attribute is not stylesheet if (!StyleRelDetect.IsMatch(match.Value)) { continue; } var providerName = GetProviderName(optMatch, "head"); var prio = GetPriority(optMatch, (int)FileOrder.Css.DefaultPriority); if (prio <= 0) { continue; // don't register/remove if not within specs } // Register, then remember to remove later on ClientResourceManager.RegisterStyleSheet(page, match.Groups["Src"].Value, prio, providerName); styleMatchesToRemove.Add(match); } styleMatchesToRemove.Reverse(); styleMatchesToRemove.ForEach(p => renderedTemplate = renderedTemplate.Remove(p.Index, p.Length)); #endregion #endregion return(renderedTemplate); }
/// <summary> /// Requests that a JavaScript file be registered on the client browser. /// </summary> /// <param name="filePath">The relative file path to the JavaScript resource.</param> public void DnnJsInclude(string filePath) { ClientResourceManager.RegisterScript(this.DnnPage, filePath); }
protected override void OnInit(EventArgs e) { JavaScript.RequestRegistration(CommonJs.DnnPlugins); JavaScript.RequestRegistration(CommonJs.jQueryFileUpload); ServicesFramework.Instance.RequestAjaxAntiForgerySupport(); JavaScript.RequestRegistration(CommonJs.Knockout); ClientResourceManager.RegisterScript(this.Page, "~/DesktopModules/Journal/Scripts/journal.js"); ClientResourceManager.RegisterScript(this.Page, "~/DesktopModules/Journal/Scripts/journalcomments.js"); ClientResourceManager.RegisterScript(this.Page, "~/DesktopModules/Journal/Scripts/mentionsInput.js"); var isAdmin = this.UserInfo.IsInRole(RoleController.Instance.GetRoleById(this.PortalId, this.PortalSettings.AdministratorRoleId).RoleName); if (!this.Request.IsAuthenticated || (!this.UserInfo.IsSuperUser && !isAdmin && this.UserInfo.IsInRole("Unverified Users"))) { this.ShowEditor = false; } else { this.ShowEditor = this.EditorEnabled; } if (this.Settings.ContainsKey(Constants.DefaultPageSize)) { this.PageSize = Convert.ToInt16(this.Settings[Constants.DefaultPageSize]); } if (this.Settings.ContainsKey(Constants.MaxCharacters)) { this.MaxMessageLength = Convert.ToInt16(this.Settings[Constants.MaxCharacters]); } if (this.Settings.ContainsKey(Constants.AllowPhotos)) { this.AllowPhotos = Convert.ToBoolean(this.Settings[Constants.AllowPhotos]); } if (this.Settings.ContainsKey(Constants.AllowFiles)) { this.AllowFiles = Convert.ToBoolean(this.Settings[Constants.AllowFiles]); } this.ctlJournalList.Enabled = true; this.ctlJournalList.ProfileId = -1; this.ctlJournalList.PageSize = this.PageSize; this.ctlJournalList.ModuleId = this.ModuleId; ModuleInfo moduleInfo = this.ModuleContext.Configuration; foreach (var module in ModuleController.Instance.GetTabModules(this.TabId).Values) { if (module.ModuleDefinition.FriendlyName == "Social Groups") { if (this.GroupId == -1 && this.FilterMode == JournalMode.Auto) { this.ShowEditor = false; this.ctlJournalList.Enabled = false; } if (this.GroupId > 0) { RoleInfo roleInfo = RoleController.Instance.GetRoleById(moduleInfo.OwnerPortalID, this.GroupId); if (roleInfo != null) { if (this.UserInfo.IsInRole(roleInfo.RoleName)) { this.ShowEditor = true; this.CanComment = true; this.IsGroup = true; } else { this.ShowEditor = false; this.CanComment = false; } if (!roleInfo.IsPublic && !this.ShowEditor) { this.ctlJournalList.Enabled = false; } if (roleInfo.IsPublic && !this.ShowEditor) { this.ctlJournalList.Enabled = true; } if (roleInfo.IsPublic && this.ShowEditor) { this.ctlJournalList.Enabled = true; } if (roleInfo.IsPublic) { this.IsPublicGroup = true; } } else { this.ShowEditor = false; this.ctlJournalList.Enabled = false; } } } } if (!string.IsNullOrEmpty(this.Request.QueryString["userId"])) { this.ctlJournalList.ProfileId = Convert.ToInt32(this.Request.QueryString["userId"]); if (!this.UserInfo.IsSuperUser && !isAdmin && this.ctlJournalList.ProfileId != this.UserId) { this.ShowEditor = this.ShowEditor && Utilities.AreFriends(UserController.GetUserById(this.PortalId, this.ctlJournalList.ProfileId), this.UserInfo); } } else if (this.GroupId > 0) { this.ctlJournalList.SocialGroupId = Convert.ToInt32(this.Request.QueryString["groupId"]); } this.InitializeComponent(); base.OnInit(e); }
/// <summary> /// Requests that a JavaScript file be registered on the client browser. /// </summary> /// <param name="filePath">The relative file path to the JavaScript resource.</param> /// <param name="priority">The relative priority in which the file should be loaded.</param> /// <param name="provider">The name of the provider responsible for rendering the script output.</param> /// <param name="name">Name of framework like Bootstrap, Angular, etc.</param> /// <param name="version">Version nr of framework.</param> public void DnnJsInclude(string filePath, int priority, string provider, string name, string version) { ClientResourceManager.RegisterScript(this.DnnPage, filePath, priority, provider, name, version); }
internal string UpgradeModule(string version) { // Check if table "ToSIC_SexyContent_Templates" exists. // If it's gone, then PROBABLY skip all upgrade-codes incl. 8.11! var sql = @"SELECT COUNT(*) FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[ToSIC_SexyContent_Templates]') AND TYPE IN(N'U')"; var sqlConnection = new SqlConnection(ConfigurationManager.ConnectionStrings["SiteSqlServer"].ConnectionString); sqlConnection.Open(); var sqlCommand = new SqlCommand(sql, sqlConnection); var runDbChangesUntil811 = (int)sqlCommand.ExecuteScalar() == 1; // if there is one result row, this means the templates table still exists, we need to run changes before 08.11 sqlConnection.Close(); // if version is 01.00.00, the upgrade has to run because log files should be cleared if (!runDbChangesUntil811 && version != "01.00.00" && (new Version(version) <= new Version(8, 11, 0))) { _installLogger.LogStep(version, "Upgrade skipped because 00.99.00 install detected (installation of everything until and including 08.11 has been done by 00.99.00.SqlDataProvider)", true); _installLogger.LogVersionCompletedToPreventRerunningTheUpgrade(version); return(version); } _installLogger.LogStep(version, "UpgradeModule starting", false); // Configure Unity / eav, etc. Settings.EnsureSystemIsInitialized(); // new UnityConfig().Configure(); // Abort upgrade if it's already done - if version is 01.00.00, the module has probably been uninstalled - continue in this case. if (version != "01.00.00" && IsUpgradeComplete(version, "- Check on Start UpgradeModule")) { _installLogger.LogStep(version, "Apparently trying to update this version, but this versions upgrade is apparently compeleted, will abort"); throw new Exception("2sxc upgrade for version " + version + " started, but it looks like the upgrade for this version is already complete. Aborting upgrade."); } _installLogger.LogStep(version, "version / upgrade-complete test passed"); if (IsUpgradeRunning) { _installLogger.LogStep(version, "Apparently upgrade is running, will abort"); throw new Exception("2sxc upgrade for version " + version + " started, but the upgrade is already running. Aborting upgrade."); } _installLogger.LogStep(version, "is-upgrade-running test passed"); IsUpgradeRunning = true; _installLogger.LogStep(version, "----- Upgrade to " + version + " started -----"); try { switch (version) { case "01.00.00": // Make sure that log folder empty on new installations (could happen if 2sxc was already installed on a system) MaybeResetUpgradeLogsToStartAgainFromV1(); break; case "07.02.00": case "07.02.02": case "07.03.01": case "07.03.03": case "08.00.02": case "08.00.04": case "08.00.07": case "08.01.00": case "08.03.00": case "08.03.02": case "08.03.03": case "08.03.05": case "08.04.00": case "08.04.03": case "08.04.05": case "08.05.00": case "08.05.01": case "08.05.02": case "08.05.03": case "08.05.05": case "08.11.00": throw new Exception("Trying to upgrade a 7 or 8 version - which isn't supported in v9.20+. Please upgrade to the latest 8.12 or 9.15before trying to upgrade to a 9.20+"); // case "1X.xx.xx": //Helpers.ImportXmlSchemaOfVersion("1X.xx.xx", false); //new V9(version, _installLogger, Log).Version09xxxx(); // warning!!! when you add a new case, make sure you upgrade the version number on Settings.Installation.LastVersionWithServerChanges!!! } _installLogger.LogStep(version, "version-list check / switch done", false); // Increase ClientDependency version upon each upgrade (System and all Portals) // prevents browsers caching old JS and CSS files for editing, which could cause several errors // only set this on the last upgraded version, to prevent crazy updating the client-resource-cache while upgrading if (version == Settings.Installation.UpgradeVersionList.Last()) { _installLogger.LogStep(version, "ClientResourceManager- seems to be last item in version-list, will clear"); ClientResourceManager.UpdateVersion(); _installLogger.LogStep(version, "ClientResourceManager- done clearing"); UpdateUpgradeCompleteStatus(); _installLogger.LogStep(version, "updated upgrade-complete status"); } _installLogger.LogVersionCompletedToPreventRerunningTheUpgrade(version); _installLogger.LogStep(version, "----- Upgrade to " + version + " completed -----"); } catch (Exception e) { _installLogger.LogStep(version, "Upgrade failed - " + e.Message); throw; } finally { IsUpgradeRunning = false; } _installLogger.LogStep(version, "UpgradeModule done / returning"); return(version); }
private static void AddMessageWindow(Control ctrl) { ClientResourceManager.RegisterScript(ctrl.Page, ctrl.ResolveUrl("~/js/dnn.postbackconfirm.js")); }
/// ----------------------------------------------------------------------------- /// <summary> /// /// </summary> /// <remarks> /// - 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. /// </remarks> /// ----------------------------------------------------------------------------- private void InitializePage() { // There could be a pending installation/upgrade process if (InstallBlocker.Instance.IsInstallInProgress()) { Exceptions.ProcessHttpException(new HttpException(503, Localization.GetString("SiteAccessedWhileInstallationWasInProgress.Error", Localization.GlobalResourceFile))); } // Configure the ActiveTab with Skin/Container information PortalSettingsController.Instance().ConfigureActiveTab(this.PortalSettings); // redirect to a specific tab based on name if (!string.IsNullOrEmpty(this.Request.QueryString["tabname"])) { TabInfo tab = TabController.Instance.GetTabByName(this.Request.QueryString["TabName"], this.PortalSettings.PortalId); if (tab != null) { var parameters = new List <string>(); // maximum number of elements for (int intParam = 0; intParam <= this.Request.QueryString.Count - 1; intParam++) { switch (this.Request.QueryString.Keys[intParam].ToLowerInvariant()) { case "tabid": case "tabname": break; default: parameters.Add( this.Request.QueryString.Keys[intParam] + "=" + this.Request.QueryString[intParam]); break; } } this.Response.Redirect(this.NavigationManager.NavigateURL(tab.TabID, Null.NullString, parameters.ToArray()), true); } else { // 404 Error - Redirect to ErrorPage Exceptions.ProcessHttpException(this.Request); } } string cacheability = this.Request.IsAuthenticated ? Host.AuthenticatedCacheability : Host.UnauthenticatedCacheability; switch (cacheability) { case "0": this.Response.Cache.SetCacheability(HttpCacheability.NoCache); break; case "1": this.Response.Cache.SetCacheability(HttpCacheability.Private); break; case "2": this.Response.Cache.SetCacheability(HttpCacheability.Public); break; case "3": this.Response.Cache.SetCacheability(HttpCacheability.Server); break; case "4": this.Response.Cache.SetCacheability(HttpCacheability.ServerAndNoCache); break; case "5": this.Response.Cache.SetCacheability(HttpCacheability.ServerAndPrivate); break; } // Only insert the header control if a comment is needed if (!string.IsNullOrWhiteSpace(this.Comment)) { this.Page.Header.Controls.AddAt(0, new LiteralControl(this.Comment)); } if (this.PortalSettings.ActiveTab.PageHeadText != Null.NullString && !Globals.IsAdminControl()) { this.Page.Header.Controls.Add(new LiteralControl(this.PortalSettings.ActiveTab.PageHeadText)); } if (!string.IsNullOrEmpty(this.PortalSettings.PageHeadText)) { this.metaPanel.Controls.Add(new LiteralControl(this.PortalSettings.PageHeadText)); } // set page title if (UrlUtils.InPopUp()) { var strTitle = new StringBuilder(this.PortalSettings.PortalName); var slaveModule = UIUtilities.GetSlaveModule(this.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; string extension = Path.GetExtension(slaveModule.ModuleControl.ControlSrc.ToLowerInvariant()); switch (extension) { case ".mvc": var segments = slaveModule.ModuleControl.ControlSrc.Replace(".mvc", string.Empty).Split('/'); control.LocalResourceFile = string.Format( "~/DesktopModules/MVC/{0}/{1}/{2}.resx", slaveModule.DesktopModule.FolderName, Localization.LocalResourceDirectory, segments[0]); break; default: control.LocalResourceFile = string.Concat( slaveModule.ModuleControl.ControlSrc.Replace( Path.GetFileName(slaveModule.ModuleControl.ControlSrc), string.Empty), Localization.LocalResourceDirectory, "/", Path.GetFileName(slaveModule.ModuleControl.ControlSrc)); break; } var title = Localization.LocalizeControlTitle(control); strTitle.Append(string.Concat(" > ", this.PortalSettings.ActiveTab.LocalizedTabName)); strTitle.Append(string.Concat(" > ", title)); } else { strTitle.Append(string.Concat(" > ", this.PortalSettings.ActiveTab.LocalizedTabName)); } // Set to page this.Title = strTitle.ToString(); } else { // If tab is named, use that title, otherwise build it out via breadcrumbs if (!string.IsNullOrEmpty(this.PortalSettings.ActiveTab.Title)) { this.Title = this.PortalSettings.ActiveTab.Title; } else { // Elected for SB over true concatenation here due to potential for long nesting depth var strTitle = new StringBuilder(this.PortalSettings.PortalName); foreach (TabInfo tab in this.PortalSettings.ActiveTab.BreadCrumbs) { strTitle.Append(string.Concat(" > ", tab.TabName)); } this.Title = strTitle.ToString(); } } // set the background image if there is one selected if (!UrlUtils.InPopUp() && this.FindControl("Body") != null) { if (!string.IsNullOrEmpty(this.PortalSettings.BackgroundFile)) { var fileInfo = this.GetBackgroundFileInfo(); var url = FileManager.Instance.GetUrl(fileInfo); ((HtmlGenericControl)this.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 (this.PortalSettings.ActiveTab.RefreshInterval > 0 && this.PortalSettings.UserMode == PortalSettings.Mode.View && this.Request.QueryString["ctl"] == null) { this.MetaRefresh.Content = this.PortalSettings.ActiveTab.RefreshInterval.ToString(); this.MetaRefresh.Visible = true; } else { this.MetaRefresh.Visible = false; } // META description if (!string.IsNullOrEmpty(this.PortalSettings.ActiveTab.Description)) { this.Description = this.PortalSettings.ActiveTab.Description; } else { this.Description = this.PortalSettings.Description; } // META keywords if (!string.IsNullOrEmpty(this.PortalSettings.ActiveTab.KeyWords)) { this.KeyWords = this.PortalSettings.ActiveTab.KeyWords; } else { this.KeyWords = this.PortalSettings.KeyWords; } // META copyright if (!string.IsNullOrEmpty(this.PortalSettings.FooterText)) { this.Copyright = this.PortalSettings.FooterText.Replace("[year]", DateTime.Now.Year.ToString()); } else { this.Copyright = string.Concat("Copyright (c) ", DateTime.Now.Year, " by ", this.PortalSettings.PortalName); } // META generator this.Generator = string.Empty; // META Robots - hide it inside popups and if PageHeadText of current tab already contains a robots meta tag if (!UrlUtils.InPopUp() && !(HeaderTextRegex.IsMatch(this.PortalSettings.ActiveTab.PageHeadText) || HeaderTextRegex.IsMatch(this.PortalSettings.PageHeadText))) { this.MetaRobots.Visible = true; var allowIndex = true; if ((this.PortalSettings.ActiveTab.TabSettings.ContainsKey("AllowIndex") && bool.TryParse(this.PortalSettings.ActiveTab.TabSettings["AllowIndex"].ToString(), out allowIndex) && !allowIndex) || (this.Request.QueryString["ctl"] != null && (this.Request.QueryString["ctl"] == "Login" || this.Request.QueryString["ctl"] == "Register"))) { this.MetaRobots.Content = "NOINDEX, NOFOLLOW"; } else { this.MetaRobots.Content = "INDEX, FOLLOW"; } } // NonProduction Label Injection if (this.NonProductionVersion() && Host.DisplayBetaNotice && !UrlUtils.InPopUp()) { string versionString = string.Format(" ({0} Version: {1})", DotNetNukeContext.Current.Application.Status, DotNetNukeContext.Current.Application.Version); this.Title += versionString; } // register the custom stylesheet of current page if (this.PortalSettings.ActiveTab.TabSettings.ContainsKey("CustomStylesheet") && !string.IsNullOrEmpty(this.PortalSettings.ActiveTab.TabSettings["CustomStylesheet"].ToString())) { var customStylesheet = Path.Combine(this.PortalSettings.HomeDirectory, this.PortalSettings.ActiveTab.TabSettings["CustomStylesheet"].ToString()); ClientResourceManager.RegisterStyleSheet(this, customStylesheet); } // Cookie Consent if (this.PortalSettings.ShowCookieConsent) { ClientAPI.RegisterClientVariable(this, "cc_morelink", this.PortalSettings.CookieMoreLink, true); ClientAPI.RegisterClientVariable(this, "cc_message", Localization.GetString("cc_message", Localization.GlobalResourceFile), true); ClientAPI.RegisterClientVariable(this, "cc_dismiss", Localization.GetString("cc_dismiss", Localization.GlobalResourceFile), true); ClientAPI.RegisterClientVariable(this, "cc_link", Localization.GetString("cc_link", Localization.GlobalResourceFile), true); ClientResourceManager.RegisterScript(this.Page, "~/Resources/Shared/Components/CookieConsent/cookieconsent.min.js", FileOrder.Js.DnnControls); ClientResourceManager.RegisterStyleSheet(this.Page, "~/Resources/Shared/Components/CookieConsent/cookieconsent.min.css", FileOrder.Css.ResourceCss); ClientResourceManager.RegisterScript(this.Page, "~/js/dnn.cookieconsent.js", FileOrder.Js.DefaultPriority); } }
private void RegisterCss(Page page, string version, string path) { ClientResourceManager.RegisterStyleSheet(page, path); }
/// <summary> /// Restores client resource registrations from the <paramref name="cachedContent"/>. /// These are registrations that originated from <c>DnnJsInclude</c>, <c>DnnCssInclude</c>, and <c>JavaScriptLibraryInclude</c> controls. /// </summary> /// <param name="cachedContent">The HTML text of the cached module.</param> private void RestoreCachedClientResourceRegistrations(string cachedContent) { // parse the registered CDF from content var matches = CdfMatchRegex.Matches(cachedContent); if (matches.Count == 0) { return; } foreach (Match match in matches) { cachedContent = cachedContent.Replace(match.Value, string.Empty); var dependencyType = match.Groups["type"].Value.ToUpperInvariant(); var filePath = match.Groups["path"].Value; var forceProvider = string.Empty; var priority = Null.NullInteger; if (match.Groups["provider"].Success) { forceProvider = match.Groups["provider"].Value; } if (match.Groups["priority"].Success) { priority = Convert.ToInt32(match.Groups["priority"].Value); } switch (dependencyType) { case "JAVASCRIPT": if (string.IsNullOrEmpty(forceProvider)) { forceProvider = DefaultJsProvider; } if (priority == Null.NullInteger) { priority = (int)FileOrder.Js.DefaultPriority; } ClientResourceManager.RegisterScript(this.Page, filePath, priority, forceProvider); break; case "CSS": if (string.IsNullOrEmpty(forceProvider)) { forceProvider = DefaultCssProvider; } if (priority == Null.NullInteger) { priority = (int)FileOrder.Css.DefaultPriority; } ClientResourceManager.RegisterStyleSheet(this.Page, filePath, priority, forceProvider); break; case "JS-LIBRARY": var args = filePath.Split(new[] { ',', }, StringSplitOptions.None); if (string.IsNullOrEmpty(args[1])) { JavaScript.RequestRegistration(args[0]); } else if (string.IsNullOrEmpty(args[2])) { JavaScript.RequestRegistration(args[0], new Version(args[1])); } else { JavaScript.RequestRegistration(args[0], new Version(args[1]), (SpecificVersion)Enum.Parse(typeof(SpecificVersion), args[2])); } break; } } }
/// ----------------------------------------------------------------------------- /// <summary> /// Contains the functionality to populate the Root aspx page with controls /// </summary> /// <param name="e"></param> /// <remarks> /// - 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. /// </remarks> /// ----------------------------------------------------------------------------- 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; } }
/// <summary> /// Requests that a CSS file be registered on the client browser. /// </summary> /// <param name="filePath">The relative file path to the CSS resource.</param> public void DnnCssInclude(string filePath) { ClientResourceManager.RegisterStyleSheet(this.DnnPage, filePath); }
protected void RegisterStyleSheet(string path) { ClientResourceManager.RegisterStyleSheet(Page, ResolveUrl(path), FileOrder.Css.ModuleCss); }
/// <summary> /// Requests that a CSS file be registered on the client browser. Defaults to rendering in the page header. /// </summary> /// <param name="filePath">The relative file path to the CSS resource.</param> /// <param name="priority">The relative priority in which the file should be loaded.</param> public void DnnCssInclude(string filePath, FileOrder.Css priority) { ClientResourceManager.RegisterStyleSheet(this.DnnPage, filePath, priority); }
protected void RegisterScript(string path, int order = 0) { ClientResourceManager.RegisterScript(Page, ResolveUrl(ScriptsBasePath + path), FileOrder.Js.DefaultPriority + order); }
protected void Page_Load(object sender, EventArgs e) { ClientResourceManager.RegisterStyleSheet(Page, "~/DesktopModules/Admin/Languages/CLTools.css"); dummyGrid.Attributes.Add("style", "display:none"); }