Ejemplo n.º 1
0
        /// -----------------------------------------------------------------------------
        /// <summary>
        /// InjectModule injects the module into the Pane
        /// </summary>
        /// <param name="module">The module to inject</param>
        /// <param name="pane">The pane</param>
        /// -----------------------------------------------------------------------------
        public bool InjectModule(Pane pane, ModuleInfo module)
        {
            bool bSuccess = true;

            //try to inject the module into the pane
            try
            {
                if (PortalSettings.ActiveTab.TabID == PortalSettings.UserTabId || PortalSettings.ActiveTab.ParentId == PortalSettings.UserTabId)
                {
                    var profileModule = ModuleControlFactory.LoadModuleControl(Page, module) as IProfileModule;
                    if (profileModule == null || profileModule.DisplayModule)
                    {
                        pane.InjectModule(module);
                    }
                }
                else
                {
                    pane.InjectModule(module);
                }
            }
            catch (ThreadAbortException)
            {
                //Response.Redirect may called in module control's OnInit method, so it will cause ThreadAbortException, no need any action here.
            }
            catch (Exception ex)
            {
                Exceptions.LogException(ex);
                bSuccess = false;
            }
            return(bSuccess);
        }
Ejemplo n.º 2
0
        /// -----------------------------------------------------------------------------
        /// <summary>
        /// InjectModule injects the module into the Pane
        /// </summary>
        /// <param name="module">The module to inject</param>
        /// <param name="pane">The pane</param>
        /// <history>
        ///     [cnurse]	12/04/2007  created
        ///     [cnurse]    04/17/2009  Refactored to use SkinAdapter
        /// </history>
        /// -----------------------------------------------------------------------------
        public bool InjectModule(Pane pane, ModuleInfo module)
        {
            bool bSuccess = true;

            //try to inject the module into the pane
            try
            {
                if (PortalSettings.ActiveTab.TabID == PortalSettings.UserTabId || PortalSettings.ActiveTab.ParentId == PortalSettings.UserTabId)
                {
                    var profileModule = ModuleControlFactory.LoadModuleControl(Page, module) as IProfileModule;
                    if (profileModule == null || profileModule.DisplayModule)
                    {
                        pane.InjectModule(module);
                    }
                }
                else
                {
                    pane.InjectModule(module);
                }
            }
            catch (Exception ex)
            {
                Exceptions.LogException(ex);
                bSuccess = false;
            }
            return(bSuccess);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 绑定页面上需要加载的模块
        /// </summary>
        public void BindModule(DNNGo_ThemePlugin_MenuRowItem RowItem)
        {
            ModuleController objModules          = new ModuleController();
            ModuleInfo       ModuleConfiguration = objModules.GetModule(RowItem.BindModuleID, RowItem.BindTabID);

            if (ModuleConfiguration != null && ModuleConfiguration.ModuleID > 0)
            {
                //这里可以加上代码控制标题是否显示
                if (RowItem.MenuDisplayTitle == 1)
                {
                    BindString("<h3 class=\"submenu_title\">{0}</h3>", ModuleConfiguration.ModuleTitle);
                }

                BindString("<div class=\"menucontent\"> ");

                try
                {
                    //phContentHTML.Controls.Add(ModuleControlFactory.LoadModuleControl(Page, ModuleConfiguration));

                    //PortalModuleBase _Control = ControlUtilities.LoadControl<PortalModuleBase>(this, ModuleConfiguration.ModuleControl.ControlSrc);
                    //_Control.ID = String.Format("{0}_{1}", ModuleConfiguration.ModuleID, Path.GetFileNameWithoutExtension(ModuleConfiguration.ModuleControl.ControlSrc));
                    //_Control.ModuleContext.Configuration = ModuleConfiguration;
                    //_Control.ModuleConfiguration = ModuleConfiguration;
                    //phContentHTML.Controls.Add(_Control);

                    var control = ModuleControlFactory.LoadModuleControl(Page, ModuleConfiguration);
                    if (control != null)
                    {
                        control.ID = String.Format("{0}_{1}", ModuleConfiguration.ModuleID, Path.GetFileNameWithoutExtension(ModuleConfiguration.ModuleControl.ControlSrc));
                        phContentHTML.Controls.Add(control);
                    }
                }
                catch
                { }



                BindString("</div>");
            }
        }
Ejemplo n.º 4
0
        protected override void OnInit(EventArgs e)
        {
            base.OnInit(e);
            try
            {
                chkAllTabs.CheckedChanged            += OnAllTabsCheckChanged;
                chkInheritPermissions.CheckedChanged += OnInheritPermissionsChanged;
                chkWebSlice.CheckedChanged           += OnWebSliceCheckChanged;
                cboCacheProvider.TextChanged         += OnCacheProviderIndexChanged;
                cmdDelete.Click += OnDeleteClick;
                cmdUpdate.Click += OnUpdateClick;

                JavaScript.RequestRegistration(CommonJs.DnnPlugins);

                //get ModuleId
                if ((Request.QueryString["ModuleId"] != null))
                {
                    _moduleId = Int32.Parse(Request.QueryString["ModuleId"]);
                }
                if (Module.ContentItemId == Null.NullInteger && Module.ModuleID != Null.NullInteger)
                {
                    //This tab does not have a valid ContentItem
                    ModuleController.Instance.CreateContentItem(Module);

                    ModuleController.Instance.UpdateModule(Module);
                }

                //Verify that the current user has access to edit this module
                if (!ModulePermissionController.HasModuleAccess(SecurityAccessLevel.Edit, "MANAGE", Module))
                {
                    if (!(IsSharedViewOnly() && TabPermissionController.CanAddContentToPage()))
                    {
                        Response.Redirect(Globals.AccessDeniedURL(), true);
                    }
                }
                if (Module != null)
                {
                    //get module
                    TabModuleId = Module.TabModuleID;

                    //get Settings Control
                    ModuleControlInfo moduleControlInfo = ModuleControlController.GetModuleControlByControlKey("Settings", Module.ModuleDefID);

                    if (moduleControlInfo != null)
                    {
                        _control = ModuleControlFactory.LoadSettingsControl(Page, Module, moduleControlInfo.ControlSrc);

                        var settingsControl = _control as ISettingsControl;
                        if (settingsControl != null)
                        {
                            hlSpecificSettings.Text = Localization.GetString("ControlTitle_settings",
                                                                             settingsControl.LocalResourceFile);
                            if (String.IsNullOrEmpty(hlSpecificSettings.Text))
                            {
                                hlSpecificSettings.Text =
                                    String.Format(Localization.GetString("ControlTitle_settings", LocalResourceFile),
                                                  Module.DesktopModule.FriendlyName);
                            }
                            pnlSpecific.Controls.Add(_control);
                        }
                    }
                }
            }
            catch (Exception err)
            {
                Exceptions.ProcessModuleLoadException(this, err);
            }
        }
Ejemplo n.º 5
0
        /// -----------------------------------------------------------------------------
        /// <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()
        {
            var tabController = new TabController();

            //redirect to a specific tab based on name
            if (!String.IsNullOrEmpty(Request.QueryString["tabname"]))
            {
                TabInfo tab = tabController.GetTabByName(Request.QueryString["TabName"], ((PortalSettings)HttpContext.Current.Items["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-2013                                                          -->",
                                         Environment.NewLine,
                                         "<!-- by DNN Corporation                                                               -->",
                                         Environment.NewLine,
                                         "<!--**********************************************************************************-->",
                                         Environment.NewLine);
            }
            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));
            }

            //set page title
            string strTitle = PortalSettings.PortalName;

            if (IsPopUp)
            {
                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 = slaveModule.ModuleControl.ControlSrc.Replace(Path.GetFileName(slaveModule.ModuleControl.ControlSrc), "") + Localization.LocalResourceDirectory + "/" +
                                                Path.GetFileName(slaveModule.ModuleControl.ControlSrc);
                    var title = Localization.LocalizeControlTitle(control);

                    strTitle += string.Concat(" > ", PortalSettings.ActiveTab.LocalizedTabName);
                    strTitle += string.Concat(" > ", title);
                }
                else
                {
                    strTitle += string.Concat(" > ", PortalSettings.ActiveTab.LocalizedTabName);
                }
            }
            else
            {
                foreach (TabInfo tab in PortalSettings.ActiveTab.BreadCrumbs)
                {
                    strTitle += string.Concat(" > ", tab.TabName);
                }

                //tab title override
                if (!string.IsNullOrEmpty(PortalSettings.ActiveTab.Title))
                {
                    strTitle = PortalSettings.ActiveTab.Title;
                }
            }
            Title = strTitle;

            //set the background image if there is one selected
            if (!IsPopUp && 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
            if (PortalSettings.ActiveTab.RefreshInterval > 0 && Request.QueryString["ctl"] == null)
            {
                MetaRefresh.Content = PortalSettings.ActiveTab.RefreshInterval.ToString();
            }
            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
            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 && !IsPopUp)
            {
                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)
            {
                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);
            }
        }
Ejemplo n.º 6
0
        /// -----------------------------------------------------------------------------
        /// <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(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].ToLowerInvariant())
                        {
                        case "tabid":
                        case "tabname":
                            break;

                        default:
                            parameters.Add(
                                Request.QueryString.Keys[intParam] + "=" + Request.QueryString[intParam]);
                            break;
                        }
                    }
                    Response.Redirect(NavigationManager.NavigateURL(tab.TabID, Null.NullString, parameters.ToArray()), true);
                }
                else
                {
                    //404 Error - Redirect to ErrorPage
                    Exceptions.ProcessHttpException(Request);
                }
            }
            string cacheability = Request.IsAuthenticated ? Host.AuthenticatedCacheability : Host.UnauthenticatedCacheability;

            switch (cacheability)
            {
            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;
            }

            //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;
                    string extension = Path.GetExtension(slaveModule.ModuleControl.ControlSrc.ToLowerInvariant());
                    switch (extension)
                    {
                    case ".mvc":
                        var segments = slaveModule.ModuleControl.ControlSrc.Replace(".mvc", "").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(" > ", 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;
            }

            //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

            Generator = "";


            //META Robots - hide it inside popups and if PageHeadText of current tab already contains a robots meta tag
            if (!UrlUtils.InPopUp() &&
                !(HeaderTextRegex.IsMatch(PortalSettings.ActiveTab.PageHeadText) ||
                  HeaderTextRegex.IsMatch(PortalSettings.PageHeadText)))
            {
                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 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);
            }

            // Cookie Consent
            if (PortalSettings.ShowCookieConsent)
            {
                ClientAPI.RegisterClientVariable(this, "cc_morelink", 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(Page, "~/Resources/Shared/Components/CookieConsent/cookieconsent.min.js", FileOrder.Js.DnnControls);
                ClientResourceManager.RegisterStyleSheet(Page, "~/Resources/Shared/Components/CookieConsent/cookieconsent.min.css", FileOrder.Css.ResourceCss);
                ClientResourceManager.RegisterScript(Page, "~/js/dnn.cookieconsent.js", FileOrder.Js.DefaultPriority);
            }
        }
Ejemplo n.º 7
0
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            AdminActionsJSON  = "[]";
            CustomActionsJSON = "[]";
            Panes             = "[]";
            try
            {
                SupportsQuickSettings = false;
                DisplayQuickSettings  = false;
                ModuleTitle           = ModuleContext.Configuration.ModuleTitle;
                var moduleDefinitionId   = ModuleContext.Configuration.ModuleDefID;
                var quickSettingsControl = ModuleControlController.GetModuleControlByControlKey("QuickSettings", moduleDefinitionId);

                if (quickSettingsControl != null)
                {
                    SupportsQuickSettings = true;
                    var control = ModuleControlFactory.LoadModuleControl(Page, ModuleContext.Configuration, "QuickSettings", quickSettingsControl.ControlSrc);
                    control.ID += ModuleContext.ModuleId;
                    quickSettings.Controls.Add(control);

                    DisplayQuickSettings = ModuleContext.Configuration.ModuleSettings.GetValueOrDefault("QS_FirstLoad", true);
                    ModuleController.Instance.UpdateModuleSetting(ModuleContext.ModuleId, "QS_FirstLoad", "False");

                    ClientResourceManager.RegisterScript(Page, "~/admin/menus/ModuleActions/dnnQuickSettings.js");
                }

                if (ActionRoot.Visible)
                {
                    //Add Menu Items
                    foreach (ModuleAction rootAction in ActionRoot.Actions)
                    {
                        //Process Children
                        var actions = new List <ModuleAction>();
                        foreach (ModuleAction action in rootAction.Actions)
                        {
                            if (action.Visible)
                            {
                                if ((EditMode && Globals.IsAdminControl() == false) ||
                                    (action.Secure != SecurityAccessLevel.Anonymous && action.Secure != SecurityAccessLevel.View))
                                {
                                    if (!action.Icon.Contains("://") &&
                                        !action.Icon.StartsWith("/") &&
                                        !action.Icon.StartsWith("~/"))
                                    {
                                        action.Icon = "~/images/" + action.Icon;
                                    }
                                    if (action.Icon.StartsWith("~/"))
                                    {
                                        action.Icon = Globals.ResolveUrl(action.Icon);
                                    }

                                    actions.Add(action);

                                    if (String.IsNullOrEmpty(action.Url))
                                    {
                                        validIDs.Add(action.ID);
                                    }
                                }
                            }
                        }

                        var oSerializer = new JavaScriptSerializer();
                        if (rootAction.Title == Localization.GetString("ModuleGenericActions.Action", Localization.GlobalResourceFile))
                        {
                            AdminActionsJSON = oSerializer.Serialize(actions);
                        }
                        else
                        {
                            if (rootAction.Title == Localization.GetString("ModuleSpecificActions.Action", Localization.GlobalResourceFile))
                            {
                                CustomActionsJSON = oSerializer.Serialize(actions);
                            }
                            else
                            {
                                SupportsMove = (actions.Count > 0);
                                Panes        = oSerializer.Serialize(PortalSettings.ActiveTab.Panes);
                            }
                        }
                    }
                    IsShared = ModuleContext.Configuration.AllTabs ||
                               PortalGroupController.Instance.IsModuleShared(ModuleContext.ModuleId, PortalController.Instance.GetPortal(PortalSettings.PortalId)) ||
                               TabController.Instance.GetTabsByModuleID(ModuleContext.ModuleId).Count > 1;
                }
            }
            catch (Exception exc) //Module failed to load
            {
                Exceptions.ProcessModuleLoadException(this, exc);
            }
        }