/// <summary> /// Toes the show. /// </summary> /// <param name="text"> /// The text. /// </param> /// <returns> /// </returns> /// <remarks> /// </remarks> private Control ToShow(string text) { var module = 0; if (text.StartsWith(TokenModule)) { module = int.Parse(text.Substring(TokenModule.Length)); } else if (text.StartsWith(TokenPortalModule)) { module = int.Parse(text.Substring(TokenPortalModule.Length)); } else { return(new LiteralControl(text)); } PortalModuleControl portalModule; var controlPath = string.Empty; using (var dr = ModuleSettings.GetModuleDefinitionByID(module)) { if (dr.Read()) { controlPath = string.Format("{0}/{1}", Framework.Settings.Path.ApplicationRoot, dr["DesktopSrc"]); } } try { if (string.IsNullOrEmpty(controlPath)) { return(new LiteralControl(string.Format("Module '{0}' not found! ", module))); } portalModule = (PortalModuleControl)this.Page.LoadControl(controlPath); // Sets portal ID portalModule.PortalID = this.PortalID; var m = new ModuleSettings { ModuleID = module, PageID = this.ModuleConfiguration.PageID, PaneName = this.ModuleConfiguration.PaneName, ModuleTitle = this.ModuleConfiguration.ModuleTitle, AuthorizedEditRoles = string.Empty, AuthorizedViewRoles = string.Empty, AuthorizedAddRoles = string.Empty, AuthorizedDeleteRoles = string.Empty, AuthorizedPropertiesRoles = string.Empty, CacheTime = this.ModuleConfiguration.CacheTime, ModuleOrder = this.ModuleConfiguration.ModuleOrder, ShowMobile = this.ModuleConfiguration.ShowMobile, DesktopSrc = controlPath }; portalModule.ModuleConfiguration = m; portalModule.Settings["MODULESETTINGS_APPLY_THEME"].Value = false; portalModule.Settings["MODULESETTINGS_SHOW_TITLE"].Value = false; } catch (Exception ex) { ErrorHandler.Publish( LogLevel.Warn, string.Format("Shortcut: Unable to load control '{0}'!", controlPath), ex); return (new LiteralControl( string.Format("<br><span class=NormalRed>Unable to load control '{0}'!<br>", controlPath))); } portalModule.PropertiesUrl = string.Empty; portalModule.AddUrl = string.Empty; // Readonly portalModule.AddText = string.Empty; // Readonly portalModule.EditUrl = string.Empty; // Readonly portalModule.EditText = string.Empty; // Readonly portalModule.OriginalModuleID = this.ModuleID; CurrentCache.Remove(Key.ModuleSettings(module)); return(portalModule); }
private Control toShow(string text) { int module = 0; if (text.StartsWith(tokenModule)) { module = int.Parse(text.Substring(tokenModule.Length)); } else if (text.StartsWith(tokenPortalModule)) { module = int.Parse(text.Substring(tokenPortalModule.Length)); } else { return(new LiteralControl(text.ToString())); } PortalModuleControl portalModule; string ControlPath = string.Empty; using (SqlDataReader dr = ModuleSettings.GetModuleDefinitionByID(module)) { if (dr.Read()) { ControlPath = Rainbow.Settings.Path.ApplicationRoot + "/" + dr["DesktopSrc"].ToString(); } } try { if (ControlPath == null || ControlPath.Length == 0) { return(new LiteralControl("Module '" + module + "' not found! ")); } portalModule = (PortalModuleControl)Page.LoadControl(ControlPath); //Sets portal ID portalModule.PortalID = PortalID; ModuleSettings m = new ModuleSettings(); m.ModuleID = module; m.TabID = this.ModuleConfiguration.TabID; m.PaneName = this.ModuleConfiguration.PaneName; m.ModuleTitle = this.ModuleConfiguration.ModuleTitle; m.AuthorizedEditRoles = string.Empty; m.AuthorizedViewRoles = string.Empty; m.AuthorizedAddRoles = string.Empty; m.AuthorizedDeleteRoles = string.Empty; m.AuthorizedPropertiesRoles = string.Empty; m.CacheTime = this.ModuleConfiguration.CacheTime; m.ModuleOrder = this.ModuleConfiguration.ModuleOrder; m.ShowMobile = this.ModuleConfiguration.ShowMobile; m.DesktopSrc = ControlPath; portalModule.ModuleConfiguration = m; portalModule.Settings["MODULESETTINGS_APPLY_THEME"] = false; portalModule.Settings["MODULESETTINGS_SHOW_TITLE"] = false; } catch (Exception ex) { Rainbow.Configuration.ErrorHandler.HandleException("Shortcut: Unable to load control '" + ControlPath + "'!", ex); return(new LiteralControl("<br><span class=NormalRed>" + "Unable to load control '" + ControlPath + "'!" + "<br>")); } portalModule.PropertiesUrl = string.Empty; portalModule.AddUrl = string.Empty; //Readonly portalModule.AddText = string.Empty; //Readonly portalModule.EditUrl = string.Empty; //Readonly portalModule.EditText = string.Empty; //Readonly portalModule.OriginalModuleID = this.ModuleID; Rainbow.Settings.Cache.CurrentCache.Remove(Rainbow.Settings.Cache.Key.ModuleSettings(module)); return(portalModule); }
private void Page_Load(object sender, System.EventArgs e) { /* Remove the IsPostBack check to allow contained controls to interpret the event * to resolve issue #860424 * Author: Cemil Ayvaz * Email : [email protected] * Date : 2004-06-01 * * if(!IsPostBack) * { */ string ControlPath = string.Empty; //Try to get info on linked control int LinkedModuleID = Int32.Parse(Settings["LinkedModule"].ToString()); SqlDataReader dr = ModuleSettings.GetModuleDefinitionByID(LinkedModuleID); try { if (dr.Read()) { ControlPath = Rainbow.Settings.Path.ApplicationRoot + "/" + dr["DesktopSrc"].ToString(); } } finally { dr.Close(); } //Load control PortalModuleControl portalModule; try { if (ControlPath == null || ControlPath.Length == 0) { PlaceHolderModule.Controls.Add(new LiteralControl("Module '" + LinkedModuleID + "' not found! Use Admin panel to add a linked control.")); return; } portalModule = (PortalModuleControl)Page.LoadControl(ControlPath); //Sets portal ID portalModule.PortalID = PortalID; //Update settings ModuleSettings m = new ModuleSettings(); m.ModuleID = LinkedModuleID; m.TabID = this.ModuleConfiguration.TabID; m.PaneName = this.ModuleConfiguration.PaneName; m.ModuleTitle = this.ModuleConfiguration.ModuleTitle; m.AuthorizedEditRoles = string.Empty; //Readonly m.AuthorizedViewRoles = string.Empty; //Readonly m.AuthorizedAddRoles = string.Empty; //Readonly m.AuthorizedDeleteRoles = string.Empty; //Readonly m.AuthorizedPropertiesRoles = this.ModuleConfiguration.AuthorizedPropertiesRoles; m.CacheTime = this.ModuleConfiguration.CacheTime; m.ModuleOrder = this.ModuleConfiguration.ModuleOrder; m.ShowMobile = this.ModuleConfiguration.ShowMobile; m.DesktopSrc = ControlPath; m.MobileSrc = string.Empty; //Not supported yet // added [email protected] m.SupportCollapsable = this.ModuleConfiguration.SupportCollapsable; portalModule.ModuleConfiguration = m; portalModule.Settings["MODULESETTINGS_APPLY_THEME"] = this.Settings["MODULESETTINGS_APPLY_THEME"]; portalModule.Settings["MODULESETTINGS_THEME"] = this.Settings["MODULESETTINGS_THEME"]; // added so ShowTitle is independent of the Linked Module portalModule.Settings["MODULESETTINGS_SHOW_TITLE"] = this.Settings["MODULESETTINGS_SHOW_TITLE"]; // added so that shortcut works for module "print this..." feature PlaceHolderModule.ID = "Shortcut"; // added so AllowCollapsable -- [email protected] portalModule.Settings["AllowCollapsable"] = this.Settings["AllowCollapsable"]; //Add control to the page PlaceHolderModule.Controls.Add(portalModule); } catch (Exception ex) { Rainbow.Configuration.ErrorHandler.HandleException("Shortcut: Unable to load control '" + ControlPath + "'!", ex); PlaceHolderModule.Controls.Add(new LiteralControl("<br><span class=NormalRed>" + "Unable to load control '" + ControlPath + "'!" + "<br>")); PlaceHolderModule.Controls.Add(new LiteralControl(ex.Message)); return; //The controls has failed! } //Set title portalModule.PropertiesUrl = HttpUrlBuilder.BuildUrl("~/DesktopModules/Admin/PropertyPage.aspx", TabID, "mID=" + ModuleID.ToString()); portalModule.PropertiesText = "PROPERTIES"; portalModule.AddUrl = string.Empty; //Readonly portalModule.AddText = string.Empty; //Readonly portalModule.EditUrl = string.Empty; //Readonly portalModule.EditText = string.Empty; //Readonly // jes1111 portalModule.OriginalModuleID = this.ModuleID; Rainbow.Settings.Cache.CurrentCache.Remove(Rainbow.Settings.Cache.Key.ModuleSettings(LinkedModuleID)); }
/// <summary> /// Raises the <see cref="E:System.Web.UI.Control.Init"/> event. /// </summary> /// <param name="e">An <see cref="T:System.EventArgs"/> object that contains the event data.</param> /// <remarks></remarks> protected override void OnInit(EventArgs e) { var controlPath = string.Empty; // Try to get info on linked control var linkedModuleId = Int32.Parse(this.Settings["LinkedModule"].ToString()); var dr = ModuleSettings.GetModuleDefinitionByID(linkedModuleId); try { if (dr.Read()) { controlPath = string.Format("{0}/{1}", Path.ApplicationRoot, dr["DesktopSrc"]); } } finally { dr.Close(); } // Load control PortalModuleControl portalModule = null; try { if (controlPath.Length == 0) { this.PlaceHolderModule.Controls.Add( new LiteralControl( string.Format("Module '{0}' not found! Use Admin panel to add a linked control.", linkedModuleId))); portalModule = new PortalModuleControl(); } else { if (controlPath.ToLowerInvariant().Trim().EndsWith(".ascx")) { portalModule = (PortalModuleControl)this.Page.LoadControl(controlPath); } else // MVC { var strArray = controlPath.Split( new[] { '/', '\\' }, StringSplitOptions.RemoveEmptyEntries); int index = 1; if (!Path.ApplicationRoot.Equals(string.Empty)) { index++; } var areaName = (strArray[index].ToLower() == "views") ? string.Empty : strArray[index]; var controllerName = strArray[strArray.Length - 2]; var actionName = strArray[strArray.Length - 1]; // var ns = strArray[2]; portalModule = (PortalModuleControl)this.Page.LoadControl("~/DesktopModules/CoreModules/MVC/MVCModule.ascx"); ((MVCModuleControl)portalModule).ControllerName = controllerName; ((MVCModuleControl)portalModule).ActionName = actionName; ((MVCModuleControl)portalModule).AreaName = areaName; ((MVCModuleControl)portalModule).ModID = linkedModuleId; ((MVCModuleControl)portalModule).Initialize(); } // Sets portal ID portalModule.PortalID = this.PortalID; // Update settings var m = new ModuleSettings { ModuleID = linkedModuleId, PageID = this.ModuleConfiguration.PageID, PaneName = this.ModuleConfiguration.PaneName, ModuleTitle = this.ModuleConfiguration.ModuleTitle, AuthorizedEditRoles = string.Empty, // read only AuthorizedViewRoles = string.Empty, // read only AuthorizedAddRoles = string.Empty, // read only AuthorizedDeleteRoles = string.Empty, // read only AuthorizedPropertiesRoles = this.ModuleConfiguration.AuthorizedPropertiesRoles, CacheTime = this.ModuleConfiguration.CacheTime, ModuleOrder = this.ModuleConfiguration.ModuleOrder, ShowMobile = this.ModuleConfiguration.ShowMobile, DesktopSrc = controlPath, MobileSrc = string.Empty, // not supported yet SupportCollapsable = this.ModuleConfiguration.SupportCollapsable }; // added [email protected] portalModule.ModuleConfiguration = m; portalModule.Settings["MODULESETTINGS_APPLY_THEME"] = this.Settings["MODULESETTINGS_APPLY_THEME"]; portalModule.Settings["MODULESETTINGS_THEME"] = this.Settings["MODULESETTINGS_THEME"]; // added so ShowTitle is independent of the Linked Module portalModule.Settings["MODULESETTINGS_SHOW_TITLE"] = this.Settings["MODULESETTINGS_SHOW_TITLE"]; // added so that shortcut works for module "print this..." feature this.PlaceHolderModule.ID = "Shortcut"; // added so AllowCollapsable -- [email protected] if (portalModule.Settings.ContainsKey("AllowCollapsable")) { portalModule.Settings["AllowCollapsable"] = this.Settings["AllowCollapsable"]; } // Add control to the page this.PlaceHolderModule.Controls.Add(portalModule); } } catch (Exception ex) { ErrorHandler.Publish(LogLevel.Error, string.Format("Shortcut: Unable to load control '{0}'!", controlPath), ex); this.PlaceHolderModule.Controls.Add( new LiteralControl( string.Format("<br /><span class=\"NormalRed\">Unable to load control '{0}'!</span><br />", controlPath))); this.PlaceHolderModule.Controls.Add(new LiteralControl(ex.Message)); return; // The controls has failed! } // Set title portalModule.PropertiesUrl = HttpUrlBuilder.BuildUrl( "~/DesktopModules/CoreModules/Admin/PropertyPage.aspx", this.PageID, "mID=" + this.ModuleID); portalModule.PropertiesText = "PROPERTIES"; portalModule.AddUrl = string.Empty; // Readonly portalModule.AddText = string.Empty; // Readonly portalModule.EditUrl = string.Empty; // Readonly portalModule.EditText = string.Empty; // Readonly // jes1111 portalModule.OriginalModuleID = this.ModuleID; CurrentCache.Remove(Key.ModuleSettings(linkedModuleId)); base.OnInit(e); }