예제 #1
0
파일: Pane.cs 프로젝트: misterPaul0/Curt
        /// -----------------------------------------------------------------------------
        /// <summary>
        /// ProcessPane processes the Attributes for the PaneControl
        /// </summary>
        /// <history>
        ///     [cnurse]	12/05/2007	Created
        /// </history>
        /// -----------------------------------------------------------------------------
        public void ProcessPane()
        {
            if (PaneControl != null)
            {
                //remove excess skin non-validating attributes
                PaneControl.Attributes.Remove("ContainerType");
                PaneControl.Attributes.Remove("ContainerName");
                PaneControl.Attributes.Remove("ContainerSrc");

                if (Globals.IsLayoutMode())
                {
                    PaneControl.Visible = true;

                    //display pane border
                    string cssclass = PaneControl.Attributes["class"];
                    if (string.IsNullOrEmpty(cssclass))
                    {
                        PaneControl.Attributes["class"] = CPaneOutline;
                    }
                    else
                    {
                        PaneControl.Attributes["class"] = cssclass.Replace(CPaneOutline, "").Trim().Replace("  ", " ") + " " + CPaneOutline;
                    }
                    //display pane name
                    var ctlLabel = new Label {
                        Text = "<center>" + Name + "</center><br />", CssClass = "SubHead"
                    };
                    PaneControl.Controls.AddAt(0, ctlLabel);
                }
                else
                {
                    if (TabPermissionController.CanAddContentToPage() && PaneControl.Visible == false)
                    {
                        PaneControl.Visible = true;
                    }

                    if (CanCollapsePane())
                    {
                        //This pane has no controls so set the width to 0
                        if (PaneControl.Attributes["style"] != null)
                        {
                            PaneControl.Attributes.Remove("style");
                        }
                        if (PaneControl.Attributes["class"] != null)
                        {
                            PaneControl.Attributes["class"] = PaneControl.Attributes["class"] + " DNNEmptyPane";
                        }
                        else
                        {
                            PaneControl.Attributes["class"] = "DNNEmptyPane";
                        }
                    }
                }
            }
        }
예제 #2
0
        private bool ProcessMasterModules()
        {
            bool success = true;

            if (TabPermissionController.CanViewPage())
            {
                // We need to ensure that Content Item exists since in old versions Content Items are not needed for tabs
                this.EnsureContentItemForTab(this.PortalSettings.ActiveTab);

                // Versioning checks.
                if (!TabController.CurrentPage.HasAVisibleVersion)
                {
                    this.HandleAccesDenied(true);
                }

                int urlVersion;
                if (TabVersionUtils.TryGetUrlVersion(out urlVersion))
                {
                    if (!TabVersionUtils.CanSeeVersionedPages())
                    {
                        this.HandleAccesDenied(false);
                        return(true);
                    }

                    if (TabVersionController.Instance.GetTabVersions(TabController.CurrentPage.TabID).All(tabVersion => tabVersion.Version != urlVersion))
                    {
                        this.Response.Redirect(this.NavigationManager.NavigateURL(this.PortalSettings.ErrorPage404, string.Empty, "status=404"));
                    }
                }

                // check portal expiry date
                if (!this.CheckExpired())
                {
                    if ((this.PortalSettings.ActiveTab.StartDate < DateAndTime.Now && this.PortalSettings.ActiveTab.EndDate > DateAndTime.Now) || TabPermissionController.CanAdminPage() || Globals.IsLayoutMode())
                    {
                        foreach (var objModule in PortalSettingsController.Instance().GetTabModules(this.PortalSettings))
                        {
                            success = this.ProcessModule(objModule);
                        }
                    }
                    else
                    {
                        this.HandleAccesDenied(false);
                    }
                }
                else
                {
                    AddPageMessage(
                        this,
                        string.Empty,
                        string.Format(Localization.GetString("ContractExpired.Error"), this.PortalSettings.PortalName, Globals.GetMediumDate(this.PortalSettings.ExpiryDate.ToString(CultureInfo.InvariantCulture)), this.PortalSettings.Email),
                        ModuleMessage.ModuleMessageType.RedError);
                }
            }
            else
            {
                // If request localized page which haven't complete translate yet, redirect to default language version.
                var redirectUrl = Globals.AccessDeniedURL(Localization.GetString("TabAccess.Error"));

                // Current locale will use default if did'nt find any
                Locale currentLocale = LocaleController.Instance.GetCurrentLocale(this.PortalSettings.PortalId);
                if (this.PortalSettings.ContentLocalizationEnabled &&
                    TabController.CurrentPage.CultureCode != currentLocale.Code)
                {
                    redirectUrl = new LanguageTokenReplace {
                        Language = currentLocale.Code
                    }.ReplaceEnvironmentTokens("[URL]");
                }

                this.Response.Redirect(redirectUrl, true);
            }

            return(success);
        }
예제 #3
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;
            }
        }
예제 #4
0
        /// -----------------------------------------------------------------------------
        /// <summary>
        /// ProcessPane processes the Attributes for the PaneControl.
        /// </summary>
        /// -----------------------------------------------------------------------------
        public void ProcessPane()
        {
            if (this.PaneControl != null)
            {
                // remove excess skin non-validating attributes
                this.PaneControl.Attributes.Remove("ContainerType");
                this.PaneControl.Attributes.Remove("ContainerName");
                this.PaneControl.Attributes.Remove("ContainerSrc");

                if (Globals.IsLayoutMode())
                {
                    this.PaneControl.Visible = true;

                    // display pane border
                    string cssclass = this.PaneControl.Attributes["class"];
                    if (string.IsNullOrEmpty(cssclass))
                    {
                        this.PaneControl.Attributes["class"] = CPaneOutline;
                    }
                    else
                    {
                        this.PaneControl.Attributes["class"] = cssclass.Replace(CPaneOutline, string.Empty).Trim().Replace("  ", " ") + " " + CPaneOutline;
                    }

                    // display pane name
                    var ctlLabel = new Label {
                        Text = "<center>" + this.Name + "</center><br />", CssClass = "SubHead"
                    };
                    this.PaneControl.Controls.AddAt(0, ctlLabel);
                }
                else
                {
                    if (this.PaneControl.Visible == false && TabPermissionController.CanAddContentToPage())
                    {
                        this.PaneControl.Visible = true;
                    }

                    if (this.CanCollapsePane())
                    {
                        // This pane has no controls so set the width to 0
                        if (this.PaneControl.Attributes["style"] != null)
                        {
                            this.PaneControl.Attributes.Remove("style");
                        }

                        if (this.PaneControl.Attributes["class"] != null)
                        {
                            this.PaneControl.Attributes["class"] = this.PaneControl.Attributes["class"] + " DNNEmptyPane";
                        }
                        else
                        {
                            this.PaneControl.Attributes["class"] = "DNNEmptyPane";
                        }
                    }

                    // Add support for drag and drop
                    if (Globals.IsEditMode()) // this call also checks for permission
                    {
                        if (this.PaneControl.Attributes["class"] != null)
                        {
                            this.PaneControl.Attributes["class"] = this.PaneControl.Attributes["class"] + " dnnSortable";
                        }
                        else
                        {
                            this.PaneControl.Attributes["class"] = "dnnSortable";
                        }
                    }
                }
            }
        }
예제 #5
0
        private bool ProcessMasterModules()
        {
            bool success = true;

            if (TabPermissionController.CanViewPage())
            {
                //check portal expiry date
                if (!CheckExpired())
                {
                    if ((PortalSettings.ActiveTab.StartDate < DateAndTime.Now && PortalSettings.ActiveTab.EndDate > DateAndTime.Now) || TabPermissionController.CanAdminPage() || Globals.IsLayoutMode())
                    {
                        //dynamically populate the panes with modules
                        if (PortalSettings.ActiveTab.Modules.Count > 0)
                        {
                            foreach (ModuleInfo objModule in PortalSettings.ActiveTab.Modules)
                            {
                                success = ProcessModule(objModule);
                            }
                        }
                    }
                    else
                    {
                        AddPageMessage(this, "", Localization.GetString("TabAccess.Error"), ModuleMessage.ModuleMessageType.YellowWarning);
                    }
                }
                else
                {
                    AddPageMessage(this,
                                   "",
                                   string.Format(Localization.GetString("ContractExpired.Error"), PortalSettings.PortalName, Globals.GetMediumDate(PortalSettings.ExpiryDate.ToString()), PortalSettings.Email),
                                   ModuleMessage.ModuleMessageType.RedError);
                }
            }
            else
            {
                Response.Redirect(Globals.AccessDeniedURL(Localization.GetString("TabAccess.Error")), true);
            }
            return(success);
        }
예제 #6
0
        private bool ProcessMasterModules()
        {
            bool success = true;

            if (TabPermissionController.CanViewPage())
            {
                // Versioning checks.
                if (!TabController.CurrentPage.HasAVisibleVersion)
                {
                    Response.Redirect(Globals.NavigateURL(PortalSettings.ErrorPage404, string.Empty, "status=404"));
                }

                int urlVersion;
                if (TabVersionUtils.TryGetUrlVersion(out urlVersion))
                {
                    if (!TabVersionUtils.CanSeeVersionedPages())
                    {
                        AddPageMessage(this, "", Localization.GetString("TabAccess.Error"),
                                       ModuleMessage.ModuleMessageType.YellowWarning);
                        return(true);
                    }

                    if (TabVersionController.Instance.GetTabVersions(TabController.CurrentPage.TabID).All(tabVersion => tabVersion.Version != urlVersion))
                    {
                        Response.Redirect(Globals.NavigateURL(PortalSettings.ErrorPage404, string.Empty, "status=404"));
                    }
                }

                //check portal expiry date
                if (!CheckExpired())
                {
                    if ((PortalSettings.ActiveTab.StartDate < DateAndTime.Now && PortalSettings.ActiveTab.EndDate > DateAndTime.Now) || TabPermissionController.CanAdminPage() || Globals.IsLayoutMode())
                    {
                        // Check for MVC async call
                        if (Request.QueryString.AllKeys.Contains("moduleId") &&
                            Request.QueryString.AllKeys.Contains("controller") &
                            Request.QueryString.AllKeys.Contains("action") &&
                            Request.QueryString.AllKeys.Contains("async") &&
                            Request.QueryString["async"].ToLower() == "true")
                        {
                            // Get module ID
                            var moduleId = 0;
                            success = int.TryParse(Request.QueryString["moduleId"], out moduleId);

                            if (success)
                            {
                                // Get module info
                                foreach (var objModule in PortalSettingsController.Instance().GetTabModules(PortalSettings))
                                {
                                    if (objModule.ModuleID == moduleId)
                                    {
                                        // process only this module
                                        success = ProcessModule(objModule);
                                    }
                                }
                            }
                        }
                        else
                        {
                            foreach (var objModule in PortalSettingsController.Instance().GetTabModules(PortalSettings))
                            {
                                success = ProcessModule(objModule);
                            }
                        }
                    }
                    else
                    {
                        AddPageMessage(this, "", Localization.GetString("TabAccess.Error"), ModuleMessage.ModuleMessageType.YellowWarning);
                    }
                }
                else
                {
                    AddPageMessage(this,
                                   "",
                                   string.Format(Localization.GetString("ContractExpired.Error"), PortalSettings.PortalName, Globals.GetMediumDate(PortalSettings.ExpiryDate.ToString()), PortalSettings.Email),
                                   ModuleMessage.ModuleMessageType.RedError);
                }
            }
            else
            {
                //If request localized page which haven't complete translate yet, redirect to default language version.
                var    redirectUrl   = Globals.AccessDeniedURL(Localization.GetString("TabAccess.Error"));
                Locale defaultLocale = LocaleController.Instance.GetDefaultLocale(PortalSettings.PortalId);
                if (PortalSettings.ContentLocalizationEnabled &&
                    TabController.CurrentPage.CultureCode != defaultLocale.Code)
                {
                    redirectUrl = new LanguageTokenReplace {
                        Language = defaultLocale.Code
                    }.ReplaceEnvironmentTokens("[URL]");
                }

                Response.Redirect(redirectUrl, true);
            }
            return(success);
        }
예제 #7
0
파일: Skin.cs 프로젝트: misterPaul0/Curt
        private bool ProcessModule(ModuleInfo module)
        {
            bool success = true;

            if (ModulePermissionController.CanViewModule(module) && module.IsDeleted == false &&
                ((module.StartDate < DateTime.Now && module.EndDate > DateTime.Now) || Globals.IsLayoutMode() || Globals.IsEditMode()))
            {
                Pane pane = GetPane(module);

                if (pane != null)
                {
                    success = InjectModule(pane, module);
                }
                else
                {
                    var lex = new ModuleLoadException(Localization.GetString("PaneNotFound.Error"));
                    Controls.Add(new ErrorContainer(PortalSettings, MODULELOAD_ERROR, lex).Container);
                    Exceptions.LogException(lex);
                }
            }
            return(success);
        }
예제 #8
0
        private bool ProcessMasterModules()
        {
            bool success = true;

            if (TabPermissionController.CanViewPage())
            {
                // Versioning checks.
                if (!TabController.CurrentPage.HasAVisibleVersion)
                {
                    Response.Redirect(Globals.NavigateURL(PortalSettings.ErrorPage404, string.Empty, "status=404"));
                }

                int urlVersion;
                if (TabVersionUtils.TryGetUrlVersion(out urlVersion))
                {
                    if (!TabVersionUtils.CanSeeVersionedPages())
                    {
                        AddPageMessage(this, "", Localization.GetString("TabAccess.Error"),
                                       ModuleMessage.ModuleMessageType.YellowWarning);
                        return(true);
                    }

                    if (TabVersionController.Instance.GetTabVersions(TabController.CurrentPage.TabID).All(tabVersion => tabVersion.Version != urlVersion))
                    {
                        Response.Redirect(Globals.NavigateURL(PortalSettings.ErrorPage404, string.Empty, "status=404"));
                    }
                }

                //check portal expiry date
                if (!CheckExpired())
                {
                    if ((PortalSettings.ActiveTab.StartDate < DateAndTime.Now && PortalSettings.ActiveTab.EndDate > DateAndTime.Now) || TabPermissionController.CanAdminPage() || Globals.IsLayoutMode())
                    {
                        foreach (var objModule in PortalSettingsController.Instance().GetTabModules(PortalSettings))
                        {
                            success = ProcessModule(objModule);
                        }
                    }
                    else
                    {
                        AddPageMessage(this, "", Localization.GetString("TabAccess.Error"), ModuleMessage.ModuleMessageType.YellowWarning);
                    }
                }
                else
                {
                    AddPageMessage(this,
                                   "",
                                   string.Format(Localization.GetString("ContractExpired.Error"), PortalSettings.PortalName, Globals.GetMediumDate(PortalSettings.ExpiryDate.ToString()), PortalSettings.Email),
                                   ModuleMessage.ModuleMessageType.RedError);
                }
            }
            else
            {
                Response.Redirect(Globals.AccessDeniedURL(Localization.GetString("TabAccess.Error")), true);
            }
            return(success);
        }