private Containers.Container LoadNoContainer(ModuleInfo module) { string noContainerSrc = "[G]" + SkinController.RootContainer + "/_default/No Container.ascx"; Containers.Container container = null; // if the module specifies that no container should be used if (module.DisplayTitle == false) { // always display container if the current user is the administrator or the module is being used in an admin case bool displayTitle = ModulePermissionController.CanEditModuleContent(module) || Globals.IsAdminSkin(); // unless the administrator is in view mode if (displayTitle) { displayTitle = Personalization.GetUserMode() != PortalSettings.Mode.View; } if (displayTitle == false) { container = this.LoadContainerByPath(SkinController.FormatSkinSrc(noContainerSrc, this.PortalSettings)); } } return(container); }
/// ----------------------------------------------------------------------------- /// <summary> /// Creates a Module Host control using the ModuleConfiguration for the Module /// </summary> /// <remarks> /// </remarks> public ModuleHost(ModuleInfo moduleConfiguration, Skins.Skin skin, Containers.Container container) { ID = "ModuleContent"; Container = container; _moduleConfiguration = moduleConfiguration; Skin = skin; }
private Containers.Container LoadContainerFromPane() { Containers.Container container = null; string containerSrc; var validSrc = false; if ((PaneControl.Attributes["ContainerType"] != null) && (PaneControl.Attributes["ContainerName"] != null)) { containerSrc = "[" + PaneControl.Attributes["ContainerType"] + "]" + SkinController.RootContainer + "/" + PaneControl.Attributes["ContainerName"] + "/" + PaneControl.Attributes["ContainerSrc"]; validSrc = true; } else { containerSrc = PaneControl.Attributes["ContainerSrc"]; if (containerSrc.Contains("/") && !(containerSrc.ToLower().StartsWith("[g]") || containerSrc.ToLower().StartsWith("[l]"))) { containerSrc = string.Format(SkinController.IsGlobalSkin(PortalSettings.ActiveTab.SkinSrc) ? "[G]containers/{0}" : "[L]containers/{0}", containerSrc.TrimStart('/')); validSrc = true; } } if (validSrc) { containerSrc = SkinController.FormatSkinSrc(containerSrc, PortalSettings); container = LoadContainerByPath(containerSrc); } return(container); }
/// ----------------------------------------------------------------------------- /// <summary> /// LoadContainerByPath gets the Container from its Url(Path) /// </summary> /// <param name="containerPath">The Url to the Container control</param> /// <returns>A Container</returns> /// ----------------------------------------------------------------------------- private Containers.Container LoadContainerByPath(string containerPath) { if (containerPath.ToLower().IndexOf("/skins/") != -1 || containerPath.ToLower().IndexOf("/skins\\") != -1 || containerPath.ToLower().IndexOf("\\skins\\") != -1 || containerPath.ToLower().IndexOf("\\skins/") != -1) { throw new Exception(); } Containers.Container container = null; try { string containerSrc = containerPath; if (containerPath.IndexOf(Globals.ApplicationPath, StringComparison.InvariantCultureIgnoreCase) != -1) { containerPath = containerPath.Remove(0, Globals.ApplicationPath.Length); } container = ControlUtilities.LoadControl <Containers.Container>(PaneControl.Page, containerPath); container.ContainerSrc = containerSrc; //call databind so that any server logic in the container is executed container.DataBind(); } catch (Exception exc) { //could not load user control var lex = new ModuleLoadException(Skin.MODULELOAD_ERROR, exc); if (TabPermissionController.CanAdminPage()) { //only display the error to administrators _containerWrapperControl.Controls.Add(new ErrorContainer(PortalSettings, string.Format(Skin.CONTAINERLOAD_ERROR, containerPath), lex).Container); } Exceptions.LogException(lex); } return(container); }
private Containers.Container LoadContainerByPath(string ContainerPath) { if (ContainerPath.ToLower().IndexOf("/skins/") != -1 || ContainerPath.ToLower().IndexOf("/skins\\") != -1 || ContainerPath.ToLower().IndexOf("\\skins\\") != -1 || ContainerPath.ToLower().IndexOf("\\skins/") != -1) { throw new System.Exception(); } Containers.Container ctlContainer = null; try { string ContainerSrc = ContainerPath; if (ContainerPath.IndexOf(Common.Globals.ApplicationPath, StringComparison.InvariantCultureIgnoreCase) != -1) { ContainerPath = ContainerPath.Remove(0, Common.Globals.ApplicationPath.Length); } ctlContainer = ControlUtilities.LoadControl <Containers.Container>(PaneControl.Page, ContainerPath); ctlContainer.ContainerSrc = ContainerSrc; ctlContainer.DataBind(); } catch (Exception exc) { ModuleLoadException lex = new ModuleLoadException(Skin.MODULELOAD_ERROR, exc); if (TabPermissionController.CanAdminPage()) { PaneControl.Controls.Add(new ErrorContainer(PortalSettings, string.Format(Skin.CONTAINERLOAD_ERROR, ContainerPath), lex).Container); } Exceptions.LogException(lex); } return(ctlContainer); }
private Containers.Container LoadContainerFromPane() { Containers.Container container = null; string containerSrc; var validSrc = false; if ((this.PaneControl.Attributes["ContainerType"] != null) && (this.PaneControl.Attributes["ContainerName"] != null)) { containerSrc = "[" + this.PaneControl.Attributes["ContainerType"] + "]" + SkinController.RootContainer + "/" + this.PaneControl.Attributes["ContainerName"] + "/" + this.PaneControl.Attributes["ContainerSrc"]; validSrc = true; } else { containerSrc = this.PaneControl.Attributes["ContainerSrc"]; if (containerSrc.Contains("/") && !(containerSrc.StartsWith("[g]", StringComparison.InvariantCultureIgnoreCase) || containerSrc.StartsWith("[l]", StringComparison.InvariantCultureIgnoreCase))) { containerSrc = string.Format(SkinController.IsGlobalSkin(this.PortalSettings.ActiveTab.SkinSrc) ? "[G]containers/{0}" : "[L]containers/{0}", containerSrc.TrimStart('/')); validSrc = true; } } if (validSrc) { containerSrc = SkinController.FormatSkinSrc(containerSrc, this.PortalSettings); container = this.LoadContainerByPath(containerSrc); } return(container); }
public void InjectModule(ModuleInfo objModule) { bool bSuccess = true; try { if (!Common.Globals.IsAdminControl()) { PaneControl.Controls.Add(new LiteralControl("<a name=\"" + objModule.ModuleID.ToString() + "\"></a>")); } Containers.Container ctlContainer = LoadModuleContainer(objModule); Containers.Add(ctlContainer.ID, ctlContainer); if (Common.Globals.IsLayoutMode() && Common.Globals.IsAdminControl() == false) { Panel ctlDragDropContainer = new Panel(); System.Web.UI.Control ctlTitle = ctlContainer.FindControl("dnnTitle"); ctlDragDropContainer.ID = ctlContainer.ID + "_DD"; PaneControl.Controls.Add(ctlDragDropContainer); ctlDragDropContainer.Controls.Add(ctlContainer); if (ctlTitle != null) { if (ctlTitle.Controls.Count > 0) { ctlTitle = ctlTitle.Controls[0]; } } //if (ctlDragDropContainer != null && ctlTitle != null) //{ // ClientAPI.EnableContainerDragAndDrop(ctlTitle, ctlDragDropContainer, objModule.ModuleID); // ClientAPI.RegisterPostBackEventHandler(PaneControl, "MoveToPane", ModuleMoveToPanePostBack, false); //} } else { PaneControl.Controls.Add(ctlContainer); } ctlContainer.SetModuleConfiguration(objModule); if (PaneControl.Visible == false) { PaneControl.Visible = true; } } catch (Exception exc) { ModuleLoadException lex; lex = new ModuleLoadException(string.Format(Skin.MODULEADD_ERROR, PaneControl.ID.ToString()), exc); if (TabPermissionController.CanAdminPage()) { PaneControl.Controls.Add(new ErrorContainer(PortalSettings, Skin.MODULELOAD_ERROR, lex).Container); } Exceptions.LogException(exc); bSuccess = false; throw lex; } if (!bSuccess) { throw new ModuleLoadException(); } }
/// ----------------------------------------------------------------------------- /// <summary> /// LoadModuleContainer gets the Container for cookie /// </summary> /// <param name="request">Current Http Request.</param> /// <returns>A Container</returns> /// ----------------------------------------------------------------------------- private Containers.Container LoadContainerFromCookie(HttpRequest request) { Containers.Container container = null; HttpCookie cookie = request.Cookies["_ContainerSrc" + PortalSettings.PortalId]; if (cookie != null) { if (!String.IsNullOrEmpty(cookie.Value)) { container = LoadContainerByPath(SkinController.FormatSkinSrc(cookie.Value + ".ascx", PortalSettings)); } } return(container); }
private Containers.Container LoadContainerFromQueryString(ModuleInfo module, HttpRequest request) { Containers.Container container = null; int previewModuleId = -1; if (request.QueryString["ModuleId"] != null) { Int32.TryParse(request.QueryString["ModuleId"], out previewModuleId); } //load user container ( based on cookie ) if ((request.QueryString["ContainerSrc"] != null) && (module.ModuleID == previewModuleId || previewModuleId == -1)) { string containerSrc = SkinController.FormatSkinSrc(Globals.QueryStringDecode(request.QueryString["ContainerSrc"]) + ".ascx", PortalSettings); container = LoadContainerByPath(containerSrc); } return(container); }
/// ----------------------------------------------------------------------------- /// <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; } }
private Containers.Container LoadModuleContainer(ModuleInfo module) { var containerSrc = Null.NullString; var request = PaneControl.Page.Request; Containers.Container container = null; if (PortalSettings.EnablePopUps && UrlUtils.InPopUp()) { containerSrc = module.ContainerPath + "popUpContainer.ascx"; //Check Skin for a popup Container if (module.ContainerSrc == PortalSettings.ActiveTab.ContainerSrc) { if (File.Exists(HttpContext.Current.Server.MapPath(containerSrc))) { container = LoadContainerByPath(containerSrc); } } //error loading container - load default popup container if (container == null) { containerSrc = Globals.HostPath + "Containers/_default/popUpContainer.ascx"; container = LoadContainerByPath(containerSrc); } } else { container = (LoadContainerFromQueryString(module, request) ?? LoadContainerFromCookie(request)) ?? LoadNoContainer(module); if (container == null) { //Check Skin for Container var masterModules = PortalSettings.ActiveTab.ChildModules; if (masterModules.ContainsKey(module.ModuleID) && string.IsNullOrEmpty(masterModules[module.ModuleID].ContainerSrc)) { //look for a container specification in the skin pane if (PaneControl != null) { if ((PaneControl.Attributes["ContainerSrc"] != null)) { container = LoadContainerFromPane(); } } } } //else load assigned container if (container == null) { containerSrc = module.ContainerSrc; if (!String.IsNullOrEmpty(containerSrc)) { containerSrc = SkinController.FormatSkinSrc(containerSrc, PortalSettings); container = LoadContainerByPath(containerSrc); } } //error loading container - load from tab if (container == null) { containerSrc = PortalSettings.ActiveTab.ContainerSrc; if (!String.IsNullOrEmpty(containerSrc)) { containerSrc = SkinController.FormatSkinSrc(containerSrc, PortalSettings); container = LoadContainerByPath(containerSrc); } } //error loading container - load default if (container == null) { containerSrc = SkinController.FormatSkinSrc(SkinController.GetDefaultPortalContainer(), PortalSettings); container = LoadContainerByPath(containerSrc); } } //Set container path module.ContainerPath = SkinController.FormatSkinPath(containerSrc); //set container id to an explicit short name to reduce page payload container.ID = "ctr"; //make the container id unique for the page if (module.ModuleID > -1) { container.ID += module.ModuleID.ToString(); } return(container); }
public InvalidContainerSizeException(Containers.Container container, string message) : base(message) { Container = container; }
public InvalidContainerSizeException(Containers.Container container) : base() { Container = container; }
public InvalidContainerPositionException(Containers.Container container) : base() { Container = container; }
private Containers.Container LoadModuleContainer(ModuleInfo objModule) { Containers.Container ctlContainer = null; string containerSrc = Null.NullString; HttpRequest Request = PaneControl.Page.Request; int PreviewModuleId = -1; if (Request.QueryString["ModuleId"] != null) { Int32.TryParse(Request.QueryString["ModuleId"], out PreviewModuleId); } if ((Request.QueryString["ContainerSrc"] != null) && (objModule.ModuleID == PreviewModuleId || PreviewModuleId == -1)) { containerSrc = SkinController.FormatSkinSrc(Globals.QueryStringDecode(Request.QueryString["ContainerSrc"]) + ".ascx", PortalSettings); ctlContainer = LoadContainerByPath(containerSrc); } if (ctlContainer == null) { if (Request.Cookies["_ContainerSrc" + PortalSettings.PortalId.ToString()] != null) { if (!String.IsNullOrEmpty(Request.Cookies["_ContainerSrc" + PortalSettings.PortalId.ToString()].Value)) { containerSrc = SkinController.FormatSkinSrc(Request.Cookies["_ContainerSrc" + PortalSettings.PortalId.ToString()].Value + ".ascx", PortalSettings); ctlContainer = LoadContainerByPath(containerSrc); } } } if (ctlContainer == null) { if (objModule.DisplayTitle == false) { bool blnDisplayTitle = ModulePermissionController.CanEditModuleContent(objModule) || Globals.IsAdminSkin(); if (blnDisplayTitle == true) { blnDisplayTitle = (PortalSettings.UserMode != PortalSettings.Mode.View); } if (blnDisplayTitle == false) { containerSrc = SkinController.FormatSkinSrc("[G]" + SkinController.RootContainer + "/_default/No Container.ascx", PortalSettings); ctlContainer = LoadContainerByPath(containerSrc); } } } if (ctlContainer == null) { if (objModule.ContainerSrc == PortalSettings.ActiveTab.ContainerSrc) { if (PaneControl is HtmlControl) { HtmlControl objHtmlControl = (HtmlControl)PaneControl; if ((objHtmlControl.Attributes["ContainerSrc"] != null)) { bool validSrc = false; if ((objHtmlControl.Attributes["ContainerType"] != null) && (objHtmlControl.Attributes["ContainerName"] != null)) { containerSrc = "[" + objHtmlControl.Attributes["ContainerType"] + "]" + SkinController.RootContainer + "/" + objHtmlControl.Attributes["ContainerName"] + "/" + objHtmlControl.Attributes["ContainerSrc"]; validSrc = true; } else { containerSrc = objHtmlControl.Attributes["ContainerSrc"]; if (containerSrc.Contains("/")) { if (!(containerSrc.ToLower().StartsWith("[g]") || containerSrc.ToLower().StartsWith("[l]"))) { if (SkinController.IsGlobalSkin(PortalSettings.ActiveTab.SkinSrc)) { containerSrc = string.Format("[G]containers/{0}", containerSrc.TrimStart('/')); } else { containerSrc = string.Format("[L]containers/{0}", containerSrc.TrimStart('/')); } validSrc = true; } } } if (validSrc) { containerSrc = SkinController.FormatSkinSrc(containerSrc, PortalSettings); ctlContainer = LoadContainerByPath(containerSrc); } } } } } if (ctlContainer == null) { containerSrc = objModule.ContainerSrc; if (!String.IsNullOrEmpty(containerSrc)) { containerSrc = SkinController.FormatSkinSrc(containerSrc, PortalSettings); ctlContainer = LoadContainerByPath(containerSrc); } } if (ctlContainer == null) { containerSrc = SkinController.FormatSkinSrc(SkinController.GetDefaultPortalContainer(), PortalSettings); ctlContainer = LoadContainerByPath(containerSrc); } objModule.ContainerPath = SkinController.FormatSkinPath(containerSrc); ctlContainer.ID = "ctr"; if (objModule.ModuleID > -1) { ctlContainer.ID += objModule.ModuleID.ToString(); } return(ctlContainer); }