Exemplo n.º 1
0
        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("");
        }
Exemplo n.º 2
0
        /// -----------------------------------------------------------------------------
        /// <summary>
        /// Page_Load runs when the control is loaded
        /// </summary>
        /// <remarks>
        /// </remarks>
        /// <history>
        ///     [cnurse]	9/8/2004	Created
        ///		[jhenning]	9/6/2005	Utilizingnew EnableMinMax function
        /// </history>
        /// -----------------------------------------------------------------------------
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            cmdHelp.Click += cmdHelp_Click;

            try
            {
                DNNClientAPI.EnableMinMax(cmdHelp, pnlHelp, true, DNNClientAPI.MinMaxPersistanceType.None);
                if (String.IsNullOrEmpty(_HelpKey))
                {
                    //Set Help Key to the Resource Key plus ".Help"
                    _HelpKey = _ResourceKey + ".Help";
                }
                string helpText = Localization.GetString(_HelpKey, this);
                if (!String.IsNullOrEmpty(helpText))
                {
                    HelpText = helpText;
                }
            }
            catch (Exception exc) //Module failed to load
            {
                Exceptions.ProcessModuleLoadException(this, exc);
            }
        }
        /// -----------------------------------------------------------------------------
        /// <summary>
        /// Runs just before the control is rendered
        /// </summary>
        /// -----------------------------------------------------------------------------
        protected override void OnPreRender(EventArgs e)
        {
            if (_itemChanged)
            {
                //Rebind the control to the DataSource to make sure that the dependent
                //editors are updated
                DataBind();
            }
            if (String.IsNullOrEmpty(CssClass))
            {
                CssClass = "dnnForm";
            }

            //Find the Min/Max buttons
            if (GroupByMode == GroupByMode.Section && (_sections != null))
            {
                foreach (DictionaryEntry key in _sections)
                {
                    var tbl  = (Table)key.Value;
                    var icon = (Image)key.Key;
                    DNNClientAPI.EnableMinMax(icon, tbl, false, IconController.IconURL("Minus", "12X15"), IconController.IconURL("Plus", "12X15"), DNNClientAPI.MinMaxPersistanceType.Page);
                }
            }
            base.OnPreRender(e);
        }
Exemplo n.º 4
0
 /// <summary>
 /// Allows the scroll position on the page to be moved to the top of the passed in control.
 /// </summary>
 /// <param name="objControl">Control to scroll to</param>
 /// <remarks>
 /// </remarks>
 public void ScrollToControl(Control objControl)
 {
     if (ClientAPI.BrowserSupportsFunctionality(ClientAPI.ClientFunctionality.Positioning))
     {
         ClientAPI.RegisterClientReference(this, ClientAPI.ClientNamespaceReferences.dnn_dom_positioning); //client side needs to calculate the top of a particluar control (elementTop)
         ClientAPI.RegisterClientVariable(this, "ScrollToControl", objControl.ClientID, true);
         DNNClientAPI.AddBodyOnloadEventHandler(Page, "__dnn_setScrollTop();");
     }
 }
 /// -----------------------------------------------------------------------------
 /// <summary>
 /// Initialize the Scrolltop html control which controls the open / closed nature of each module
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 /// <remarks>
 /// </remarks>
 /// <history>
 ///     [sun1]	1/19/2004	Created
 ///		[jhenning] 3/23/2005 No longer passing in parameter to __dnn_setScrollTop, instead pulling value from textbox on client
 /// </history>
 /// -----------------------------------------------------------------------------
 protected override void OnLoad(EventArgs e)
 {
     base.OnLoad(e);
     if (!String.IsNullOrEmpty(ScrollTop.Value))
     {
         DNNClientAPI.AddBodyOnloadEventHandler(Page, "__dnn_setScrollTop();");
         ScrollTop.Value = ScrollTop.Value;
     }
 }
Exemplo n.º 6
0
 /// -----------------------------------------------------------------------------
 /// <summary>
 /// Allows the scroll position on the page to be moved to the top of the passed in control.
 /// </summary>
 /// <param name="objControl">Control to scroll to.</param>
 /// -----------------------------------------------------------------------------
 public void ScrollToControl(Control objControl)
 {
     if (ClientAPI.BrowserSupportsFunctionality(ClientAPI.ClientFunctionality.Positioning))
     {
         JavaScript.RegisterClientReference(this, ClientAPI.ClientNamespaceReferences.dnn_dom_positioning);
         ClientAPI.RegisterClientVariable(this, "ScrollToControl", objControl.ClientID, true);
         DNNClientAPI.SetScrollTop(this.Page);
     }
 }
Exemplo n.º 7
0
 /// -----------------------------------------------------------------------------
 /// <summary>
 /// Allows the scroll position on the page to be moved to the top of the passed in control.
 /// </summary>
 /// <param name="objControl">Control to scroll to</param>
 /// <remarks>
 /// </remarks>
 /// <history>
 ///     [Jon Henning]	3/30/2005	Created
 /// </history>
 /// -----------------------------------------------------------------------------
 public void ScrollToControl(Control objControl)
 {
     if (ClientAPI.BrowserSupportsFunctionality(ClientAPI.ClientFunctionality.Positioning))
     {
         ClientAPI.RegisterClientReference(this, ClientAPI.ClientNamespaceReferences.dnn_dom_positioning);
         ClientAPI.RegisterClientVariable(this, "ScrollToControl", objControl.ClientID, true);
         DNNClientAPI.AddBodyOnloadEventHandler(Page, "__dnn_setScrollTop();");
     }
 }
Exemplo n.º 8
0
        protected void Page_Load(Object sender, EventArgs e)
        {
            HtmlInputHidden scrolltop = (HtmlInputHidden)Page.FindControl("ScrollTop");

            if (!String.IsNullOrEmpty(scrolltop.Value))
            {
                DNNClientAPI.AddBodyOnloadEventHandler(Page, "__dnn_setScrollTop();");
                scrolltop.Value = scrolltop.Value;
            }
        }
Exemplo n.º 9
0
        /// -----------------------------------------------------------------------------
        /// <summary>
        /// Initialize the Scrolltop html control which controls the open / closed nature of each module
        /// </summary>
        /// <param name="e"></param>
        /// <remarks>
        /// </remarks>
        /// -----------------------------------------------------------------------------
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            ManageInstallerFiles();

            if (!String.IsNullOrEmpty(ScrollTop.Value))
            {
                DNNClientAPI.SetScrollTop(Page);
                ScrollTop.Value = ScrollTop.Value;
            }
        }
Exemplo n.º 10
0
 protected override void OnPreRender(EventArgs e)
 {
     //Set initial value
     base.OnPreRender(e);
     DNNClientAPI.EnableMinMax(imgVisibility,
                               rowControlPanel,
                               PortalSettings.DefaultControlPanelVisibility,
                               Globals.ApplicationPath + "/images/collapse.gif",
                               Globals.ApplicationPath + "/images/expand.gif",
                               DNNClientAPI.MinMaxPersistanceType.Personalization,
                               "Usability",
                               "ControlPanelVisible" + PortalSettings.PortalId);
 }
Exemplo n.º 11
0
        /// <Summary>
        /// OnLoad runs just before the Control is rendered, and makes sure that any
        /// properties are set properly before the control is rendered
        /// </Summary>
        protected override void OnPreRender(EventArgs e)
        {
            //Make sure the Child Controls are created before assigning any properties
            this.EnsureChildControls();

            //Set up client-side script
            DNNClientAPI.EnableMinMax(cmdHelp, pnlHelp, true, DNNClientAPI.MinMaxPersistanceType.None);

            if (EditControl != null)
            {
                label.Attributes.Add("for", EditControl.ClientID);
            }
        }
Exemplo n.º 12
0
        protected void Page_PreRender(object sender, EventArgs e)
        {
            if (ModuleContent != null && PortalModule != null && IsAdminControlOrTab == false)
            {
                switch (PortalModule.ModuleConfiguration.Visibility)
                {
                case VisibilityState.Maximized:
                    DNNClientAPI.EnableMinMax(cmdVisibility, ModuleContent, PortalModule.ModuleId, PortalModule.ModuleConfiguration.Visibility == VisibilityState.Minimized, MinIconLoc, MaxIconLoc, DNNClientAPI.MinMaxPersistanceType.Cookie, this.AnimationFrames);
                    break;

                case VisibilityState.Minimized:

                    DNNClientAPI.EnableMinMax(cmdVisibility, ModuleContent, PortalModule.ModuleId, PortalModule.ModuleConfiguration.Visibility == VisibilityState.Minimized, MinIconLoc, MaxIconLoc, DNNClientAPI.MinMaxPersistanceType.Cookie, this.AnimationFrames);
                    break;
                }
            }
        }
Exemplo n.º 13
0
        /// <Summary>Renders the SectionHeadControl</Summary>
        protected void Page_PreRender(object sender, EventArgs e)
        {
            try
            {
                HtmlControl ctl = (HtmlControl)this.Parent.FindControl(Section);
                if (ctl != null)
                {
                    DNNClientAPI.EnableMinMax(imgIcon, ctl, !IsExpanded, Page.ResolveUrl(MinImageUrl), Page.ResolveUrl(MaxImageUrl), DNNClientAPI.MinMaxPersistanceType.Page);
                }

                //optionlly show hr
                pnlRule.Visible = _includeRule;
            }
            catch (Exception exc) //Module failed to load
            {
                Exceptions.ProcessModuleLoadException(this, exc);
            }
        }
Exemplo n.º 14
0
        /// <Summary>Page_Load runs when the control is loaded</Summary>
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                DNNClientAPI.EnableMinMax(cmdHelp, pnlHelp, true, DNNClientAPI.MinMaxPersistanceType.None);

                //get the localised text
                if (String.IsNullOrEmpty(_ResourceKey))
                {
                    //Set Resource Key to the ID of the control
                    _ResourceKey = this.ID;
                }
                string localText = GetLocalizedText(_ResourceKey, this);
                if (!String.IsNullOrEmpty(localText))
                {
                    this.Text = localText + _Suffix;
                }

                if (String.IsNullOrEmpty(_HelpKey))
                {
                    //Set Help Key to the Resource Key plus ".Help"
                    _HelpKey = _ResourceKey + ".Help";
                }
                string helpText = GetLocalizedText(_HelpKey, this);
                if (!String.IsNullOrEmpty(helpText))
                {
                    this.HelpText = helpText;
                }

                //find the reference control in the parents Controls collection
                if (!String.IsNullOrEmpty(ControlName))
                {
                    Control c = this.Parent.FindControl(ControlName);
                    if (c != null)
                    {
                        label.Attributes["for"] = c.ClientID;
                    }
                }
            }
            catch (Exception exc) //Module failed to load
            {
                Exceptions.ProcessModuleLoadException(this, exc);
            }
        }
Exemplo n.º 15
0
        /// -----------------------------------------------------------------------------
        /// <summary>
        /// Initialize the Scrolltop html control which controls the open / closed nature of each module
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        /// <remarks>
        /// </remarks>
        /// <history>
        ///     [sun1]	1/19/2004	Created
        ///		[jhenning] 3/23/2005 No longer passing in parameter to __dnn_setScrollTop, instead pulling value from textbox on client
        /// </history>
        /// -----------------------------------------------------------------------------
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            //add js of Getting Started Page
            if (GettingStartedTabId > -1 && IsPage(GettingStartedTabId) && Request["ctl"] == null)
            {
                var scriptManager = ScriptManager.GetCurrent(Page);
                if (scriptManager == null)
                {
                    scriptManager = new ScriptManager();
                    Page.Form.Controls.AddAt(0, scriptManager);
                }

                scriptManager.EnablePageMethods = true;

                var gettingStartedFilePath = HttpContext.Current.IsDebuggingEnabled
                                        ? "~/js/Debug/dnn.gettingstarted.js"
                                        : "~/js/dnn.gettingstarted.js";

                ClientResourceManager.RegisterScript(this, gettingStartedFilePath);
                Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "PageCurrentPortalAliasUrl", "var pageCurrentPortalAliasUrl = '" + CurrentPortalAliasUrl + "';", true);
                Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "PageCurrentDomainUrl", "var pageCurrentDomainUrl = '" + CurrentDomainUrl + "';", true);
                Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "PageCurrentPortalId", "var pageCurrentPortalId = " + PortalSettings.PortalId + ";", true);
                Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "GettingStartedPageTitle", "var gettingStartedPageTitle = '" + GettingStartedTitle + "';", true);
            }

            if (ShowGettingStartedPage)
            {
                DNNClientAPI.ShowModalPage(Page, GettingStartedPageUrl);
                Services.Upgrade.Upgrade.DeleteInstallerFiles();
            }
            else if (Request.Cookies["AdvSettingsPopup"] != null && Request.Cookies["AdvSettingsPopup"].Value == "true" && !HttpContext.Current.Request.Url.AbsoluteUri.ToLower().Contains("popup"))
            {
                DNNClientAPI.ShowModalPage(Page, AdvancedSettingsPageUrl);
            }

            if (!String.IsNullOrEmpty(ScrollTop.Value))
            {
                DNNClientAPI.SetScrollTop(Page);
                ScrollTop.Value = ScrollTop.Value;
            }
        }
Exemplo n.º 16
0
        /// <Summary>Runs just before the control is rendered</Summary>
        protected override void OnPreRender(EventArgs e)
        {
            if (_ItemChanged)
            {
                //Rebind the control to the DataSource to make sure that the dependent
                //editors are updated
                DataBind();
            }

            //Find the Min/Max buttons
            if (GroupByMode == GroupByMode.Section && (_Sections != null))
            {
                foreach (DictionaryEntry key in _Sections)
                {
                    Table tbl  = (Table)key.Value;
                    Image icon = (Image)key.Key;
                    DNNClientAPI.EnableMinMax(icon, tbl, false, Page.ResolveUrl("~/images/minus.gif"), Page.ResolveUrl("~/images/plus.gif"), DNNClientAPI.MinMaxPersistanceType.Page);
                }
            }
            base.OnPreRender(e);
        }
Exemplo n.º 17
0
 protected override void OnPreRender(EventArgs e)
 {
     base.OnPreRender(e);
     if (ModuleContent != null && ModuleControl != null && !Globals.IsAdminControl())
     {
         switch (ModuleControl.ModuleContext.Configuration.Visibility)
         {
         case VisibilityState.Maximized:
         case VisibilityState.Minimized:
             DNNClientAPI.EnableMinMax(cmdVisibility,
                                       ModuleContent,
                                       ModuleControl.ModuleContext.ModuleId,
                                       ModuleControl.ModuleContext.Configuration.Visibility == VisibilityState.Minimized,
                                       MinIconLoc,
                                       MaxIconLoc,
                                       DNNClientAPI.MinMaxPersistanceType.Cookie,
                                       AnimationFrames);
             break;
         }
     }
 }
        /// -----------------------------------------------------------------------------
        /// <summary>
        /// Renders the SectionHeadControl
        /// </summary>
        /// <param name="e"></param>
        /// <remarks>
        /// </remarks>
        /// <history>
        ///     [VMasanas]	04/11/2004	Moved code from Page_Load to PreRender so all other properties are set.
        ///             This allows to inject this control dynamically on a page using LoadControl
        ///		[jhenning]	09/06/2005 Utilizing ClientAPI EnableMinMax
        /// </history>
        /// -----------------------------------------------------------------------------
        protected override void OnPreRender(EventArgs e)
        {
            base.OnPreRender(e);

            try
            {
                var ctl = (HtmlControl)Parent.FindControl(Section);
                if (ctl != null)
                {
                    lblTitle.Attributes.Add("onclick", imgIcon.ClientID + ".click();");
                    lblTitle.Attributes.Add("style", "cursor: pointer");
                    DNNClientAPI.EnableMinMax(imgIcon, ctl, !IsExpanded, Page.ResolveUrl(MinImageUrl), Page.ResolveUrl(MaxImageUrl), DNNClientAPI.MinMaxPersistanceType.Page);
                }

                //optionlly show hr
                pnlRule.Visible = _includeRule;
            }
            catch (Exception exc) //Module failed to load
            {
                Exceptions.ProcessModuleLoadException(this, exc);
            }
        }
Exemplo n.º 19
0
        /// <Summary>Page_Load runs when the control is loaded</Summary>
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                DNNClientAPI.EnableMinMax(cmdHelp, pnlHelp, true, DNNClientAPI.MinMaxPersistanceType.None);

                if (_HelpKey == "")
                {
                    //Set Help Key to the Resource Key plus ".Help"
                    _HelpKey = _ResourceKey + ".Help";
                }
                string helpText = GetLocalizedText(_HelpKey, this);
                if (!String.IsNullOrEmpty(helpText))
                {
                    this.HelpText = helpText;
                }
            }
            catch (Exception exc)  //Module failed to load
            {
                Exceptions.ProcessModuleLoadException(this, exc);
            }
        }
Exemplo n.º 20
0
        /// -----------------------------------------------------------------------------
        /// <summary>
        /// InjectModule injects a Module (and its container) into the Pane
        /// </summary>
        /// <param name="module">The Module</param>
        /// -----------------------------------------------------------------------------
        public void InjectModule(ModuleInfo module)
        {
            _containerWrapperControl = new HtmlGenericControl("div");
            PaneControl.Controls.Add(_containerWrapperControl);

            //inject module classes
            string classFormatString   = "DnnModule DnnModule-{0} DnnModule-{1}";
            string sanitizedModuleName = Null.NullString;

            if (!String.IsNullOrEmpty(module.DesktopModule.ModuleName))
            {
                sanitizedModuleName = Globals.CreateValidClass(module.DesktopModule.ModuleName, false);
            }

            if (IsVesionableModule(module))
            {
                classFormatString += " DnnVersionableControl";
            }

            _containerWrapperControl.Attributes["class"] = String.Format(classFormatString, sanitizedModuleName, module.ModuleID);

            try
            {
                if (!Globals.IsAdminControl() && PortalSettings.InjectModuleHyperLink)
                {
                    _containerWrapperControl.Controls.Add(new LiteralControl("<a name=\"" + module.ModuleID + "\"></a>"));
                }

                //Load container control
                Containers.Container container = LoadModuleContainer(module);

                //Add Container to Dictionary
                Containers.Add(container.ID, container);

                // hide anything of type ActionsMenu - as we're injecting our own menu now.
                container.InjectActionMenu = (container.Controls.OfType <ActionBase>().Count() == 0);
                if (!container.InjectActionMenu)
                {
                    foreach (var actionControl in container.Controls.OfType <IActionControl>())
                    {
                        if (actionControl is ActionsMenu)
                        {
                            Control control = actionControl as Control;
                            if (control != null)
                            {
                                control.Visible            = false;
                                container.InjectActionMenu = true;
                            }
                        }
                    }
                }

                if (Globals.IsLayoutMode() && Globals.IsAdminControl() == false)
                {
                    //provide Drag-N-Drop capabilities
                    var     dragDropContainer = new Panel();
                    Control title             = container.FindControl("dnnTitle");
                    //Assume that the title control is named dnnTitle.  If this becomes an issue we could loop through the controls looking for the title type of skin object
                    dragDropContainer.ID = container.ID + "_DD";
                    _containerWrapperControl.Controls.Add(dragDropContainer);

                    //inject the container into the page pane - this triggers the Pre_Init() event for the user control
                    dragDropContainer.Controls.Add(container);

                    if (title != null)
                    {
                        if (title.Controls.Count > 0)
                        {
                            title = title.Controls[0];
                        }
                    }

                    //enable drag and drop
                    if (title != null)
                    {
                        //The title ID is actually the first child so we need to make sure at least one child exists
                        DNNClientAPI.EnableContainerDragAndDrop(title, dragDropContainer, module.ModuleID);
                        ClientAPI.RegisterPostBackEventHandler(PaneControl, "MoveToPane", ModuleMoveToPanePostBack, false);
                    }
                }
                else
                {
                    _containerWrapperControl.Controls.Add(container);
                    if (Globals.IsAdminControl())
                    {
                        _containerWrapperControl.Attributes["class"] += " DnnModule-Admin";
                    }
                }

                //Attach Module to Container
                container.SetModuleConfiguration(module);

                //display collapsible page panes
                if (PaneControl.Visible == false)
                {
                    PaneControl.Visible = true;
                }
            }
            catch (ThreadAbortException)
            {
                //Response.Redirect may called in module control's OnInit method, so it will cause ThreadAbortException, no need any action here.
            }
            catch (Exception exc)
            {
                var lex = new ModuleLoadException(string.Format(Skin.MODULEADD_ERROR, PaneControl.ID), exc);
                if (TabPermissionController.CanAdminPage())
                {
                    //only display the error to administrators
                    _containerWrapperControl.Controls.Add(new ErrorContainer(PortalSettings, Skin.MODULELOAD_ERROR, lex).Container);
                }
                Exceptions.LogException(exc);
                throw lex;
            }
        }