/// <summary> /// Read the Path dir and returns an ArrayList with all the Themes found. /// Static because the list is Always the same. /// </summary> /// <returns> /// A list of theme items. /// </returns> public static List <ThemeItem> GetPublicThemes() { List <ThemeItem> baseThemeList; if (!CurrentCache.Exists(Key.ThemeList(Path))) { // Initialize array // Try to read directories from public theme path var themes = Directory.Exists(Path) ? Directory.GetDirectories(Path) : new string[0]; // Ignore CVS and SVN. baseThemeList = themes.Select(t1 => new ThemeItem { Name = t1.Substring(Path.Length + 1) }).Where( t => t.Name != "CVS" && t.Name != "_svn").ToList(); CurrentCache.Insert(Key.ThemeList(Path), baseThemeList, new CacheDependency(Path)); } else { baseThemeList = (List <ThemeItem>)CurrentCache.Get(Key.ThemeList(Path)); } return(baseThemeList); }
/// <summary> /// Read the Path dir and returns an ArrayList with all the Layouts found. /// Static because the list is Always the same. /// </summary> /// <returns> /// A list of public layouts. /// </returns> public static List <LayoutItem> GetPublicLayouts() { // Jes1111 - 27-02-2005 - new version - correct caching List <LayoutItem> baseLayoutList; if (!CurrentCache.Exists(Key.LayoutList(Path))) { // Try to read directories from public Layout path var layouts = Directory.Exists(Path) ? Directory.GetDirectories(Path) : new string[0]; // Ignore CVS and SVN baseLayoutList = layouts.Select(layout => new LayoutItem { Name = layout.Substring(Path.Length + 1) }) .Where(layout => layout.Name != "CVS" && layout.Name != "_svn" && layout.Name != ".svn") .ToList(); CurrentCache.Insert(Key.LayoutList(Path), baseLayoutList, new CacheDependency(Path)); } else { baseLayoutList = (List <LayoutItem>)CurrentCache.Get(Key.LayoutList(Path)); } return(baseLayoutList); }
/// <summary> /// The GetModuleSettings Method returns a hashtable of /// custom module specific settings from the database. This method is /// used by some user control modules to access misc settings. /// </summary> /// <param name="moduleID">The module ID.</param> /// <param name="_baseSettings">The _base settings.</param> /// <returns></returns> public static Hashtable GetModuleSettings(int moduleID, Hashtable _baseSettings) { if (!CurrentCache.Exists(Key.ModuleSettings(moduleID))) { // Get Settings for this module from the database Hashtable _settings = new Hashtable(); // Create Instance of Connection and Command Object using (SqlConnection myConnection = Config.SqlConnectionString) { using (SqlCommand myCommand = new SqlCommand("rb_GetModuleSettings", myConnection)) { // Mark the Command as a SPROC myCommand.CommandType = CommandType.StoredProcedure; // Add Parameters to SPROC SqlParameter parameterModuleID = new SqlParameter(strATModuleID, SqlDbType.Int, 4); parameterModuleID.Value = moduleID; myCommand.Parameters.Add(parameterModuleID); // Execute the command myConnection.Open(); using (SqlDataReader dr = myCommand.ExecuteReader(CommandBehavior.CloseConnection)) { while (dr.Read()) { _settings[dr["SettingName"].ToString()] = dr["SettingValue"].ToString(); } } } } foreach (string key in _baseSettings.Keys) { if (_settings[key] != null) { SettingItem s = ((SettingItem)_baseSettings[key]); if (_settings[key].ToString().Length != 0) { s.Value = _settings[key].ToString(); } } } CurrentCache.Insert(Key.ModuleSettings(moduleID), _baseSettings); } else { _baseSettings = (Hashtable)CurrentCache.Get(Key.ModuleSettings(moduleID)); } return(_baseSettings); }
/// <summary> /// Productses the specified tab. /// </summary> /// <param name="tab">The tab.</param> /// <returns></returns> private bool products(int tab) { if (!AutoShopDetect) { return(false); } if (!CurrentCache.Exists(Key.TabNavigationSettings(tab, "Shop"))) { PortalSettings portalSettings = (PortalSettings)HttpContext.Current.Items["PortalSettings"]; bool exists = new ModulesDB().ExistModuleProductsInPage(tab, portalSettings.PortalID); CurrentCache.Insert(Key.TabNavigationSettings(tab, "Shop"), exists); } return((bool)CurrentCache.Get(Key.TabNavigationSettings(tab, "Shop"))); }
/// <summary> /// Gets the administrative division's name in the specified language if available. It not, gets the default one. /// </summary> /// <param name="administrativeDivisionName"></param> /// <param name="c">a <code>System.Globalization.CultureInfo</code> describing the language we want the name for</param> /// <returns> /// A <code>string</code> containing the localized name. /// </returns> public override string GetAdministrativeDivisionName(string administrativeDivisionName, CultureInfo c) { var cacheKey = string.Format("ADMINISTRATIVEDIVISIONNAME_{0} - {1}", administrativeDivisionName, c.TwoLetterISOLanguageName); if (CurrentCache.Get(cacheKey) == null) { var result = this.GetLocalizedDisplayName("ADMINISTRATIVEDIVISIONNAME_" + administrativeDivisionName, c); if (string.IsNullOrEmpty(result)) { result = administrativeDivisionName; } CurrentCache.Insert(cacheKey, result); } return((string)CurrentCache.Get(cacheKey)); }
/// <summary> /// Gets the states's name in the specified language if available. It not, gets the default one. /// </summary> /// <param name="stateId"></param> /// <param name="c">a <code>System.Globalization.CultureInfo</code> describing the language we want the name for</param> /// <returns> /// A <code>string</code> containing the localized name. /// </returns> /// <exception cref="StateNotFoundException">If the state is not found</exception> public override string GetStateDisplayName(int stateId, CultureInfo c) { var cacheKey = string.Format("STATENAME_{0} - {1}", stateId, c.TwoLetterISOLanguageName); if (CurrentCache.Get(cacheKey) == null) { var result = this.GetLocalizedDisplayName("STATENAME_" + stateId, c); if (string.IsNullOrEmpty(result)) { result = this.GetState(stateId).NeutralName; } CurrentCache.Insert(cacheKey, result); } return((string)CurrentCache.Get(cacheKey)); }
/// <summary> /// Gets the display name of the country. /// </summary> /// <param name="countryId">The country id.</param> /// <param name="c">The c.</param> /// <returns></returns> public override string GetCountryDisplayName(string countryId, CultureInfo c) { var cacheKey = string.Format("COUNTRY_{0} - {1}", countryId, c.TwoLetterISOLanguageName); if (CurrentCache.Get(cacheKey) == null) { var result = this.GetLocalizedDisplayName("COUNTRY_" + countryId, c); if (string.IsNullOrEmpty(result)) { result = this.GetCountry(countryId).NeutralName; } CurrentCache.Insert(cacheKey, result); } return((string)CurrentCache.Get(cacheKey)); }
/// <summary> /// <see cref="Rainbow.Framework.Providers.Geographic.GeographicProvider.GetAdministrativeDivisionName( string, System.Globalization.CultureInfo )"/> /// </summary> public override string GetAdministrativeDivisionName(string administrativeDivisionName, System.Globalization.CultureInfo c) { string cacheKey = "ADMINISTRATIVEDIVISIONNAME_" + administrativeDivisionName + " - " + c.TwoLetterISOLanguageName; if (CurrentCache.Get(cacheKey) == null) { string result = GetLocalizedDisplayName("ADMINISTRATIVEDIVISIONNAME_" + administrativeDivisionName, c); if (string.IsNullOrEmpty(result)) { result = administrativeDivisionName; } CurrentCache.Insert(cacheKey, result); } return(( string )CurrentCache.Get(cacheKey)); }
/// <summary> /// <see cref="Rainbow.Framework.Providers.Geographic.GeographicProvider.GetStateDisplayName( int, System.Globalization.CultureInfo )"/> /// </summary> public override string GetStateDisplayName(int stateID, System.Globalization.CultureInfo c) { string cacheKey = "STATENAME_" + stateID + " - " + c.TwoLetterISOLanguageName; if (CurrentCache.Get(cacheKey) == null) { string result = GetLocalizedDisplayName("STATENAME_" + stateID, c); if (string.IsNullOrEmpty(result)) { result = this.GetState(stateID).NeutralName; } CurrentCache.Insert(cacheKey, result); } return(( string )CurrentCache.Get(cacheKey)); }
/// <summary> /// Gets the image menu. /// </summary> /// <returns> /// A System.Collections.Hashtable value... /// </returns> private Hashtable GetImageMenu() { Hashtable imageMenuFiles; if (!CurrentCache.Exists(Key.ImageMenuList(this.PortalSettings.CurrentLayout))) { imageMenuFiles = new Hashtable { { General.GetString("PAGESETTINGS_SITEDEFAULT", "(Site Default)"), string.Empty } }; var layoutManager = new LayoutManager(this.PortalPath); var menuDirectory = Path.WebPathCombine( layoutManager.PortalLayoutPath, this.PortalSettings.CurrentLayout); if (Directory.Exists(menuDirectory)) { menuDirectory = Path.WebPathCombine(menuDirectory, "menuimages"); } else { menuDirectory = Path.WebPathCombine( LayoutManager.Path, this.PortalSettings.CurrentLayout, "menuimages"); } if (Directory.Exists(menuDirectory)) { var menuImages = (new DirectoryInfo(menuDirectory)).GetFiles("*.gif"); foreach (var fi in menuImages.Where(fi => fi.Name != "spacer.gif" && fi.Name != "icon_arrow.gif")) { imageMenuFiles.Add(fi.Name, fi.Name); } } CurrentCache.Insert(Key.ImageMenuList(this.PortalSettings.CurrentLayout), imageMenuFiles, null); } else { imageMenuFiles = (Hashtable)CurrentCache.Get(Key.ImageMenuList(this.PortalSettings.CurrentLayout)); } return(imageMenuFiles); }
/// <summary> /// Read the Path dir and returns /// an ArrayList with all the Themes found, public and privates /// </summary> /// <returns></returns> public ArrayList GetPrivateThemes() { ArrayList privateThemeList; if (!CurrentCache.Exists(Key.ThemeList(PortalThemePath))) { privateThemeList = new ArrayList(); string[] themes; // Try to read directories from private theme path if (Directory.Exists(PortalThemePath)) { themes = Directory.GetDirectories(PortalThemePath); } else { themes = new string[0]; } for (int i = 0; i <= themes.GetUpperBound(0); i++) { ThemeItem t = new ThemeItem(); t.Name = themes[i].Substring(PortalThemePath.Length + 1); if (t.Name != "CVS" && t.Name != "_svn") //Ignore CVS { privateThemeList.Add(t); } } CurrentCache.Insert(Key.ThemeList(PortalThemePath), privateThemeList, new CacheDependency(PortalThemePath)); //Debug.WriteLine("Storing privateThemeList in Cache: item count is " + privateThemeList.Count.ToString()); } else { privateThemeList = (ArrayList)CurrentCache.Get(Key.ThemeList(PortalThemePath)); //Debug.WriteLine("Retrieving privateThemeList from Cache: item count is " + privateThemeList.Count.ToString()); } return(privateThemeList); }
/// <summary> /// Gets the image menu. /// </summary> /// <returns>A System.Collections.Hashtable value...</returns> private Hashtable GetImageMenu() { Hashtable imageMenuFiles; if (!CurrentCache.Exists(Key.ImageMenuList(portalSettings.CurrentLayout))) { imageMenuFiles = new Hashtable(); imageMenuFiles.Add("-Default-", string.Empty); string menuDirectory = string.Empty; LayoutManager layoutManager = new LayoutManager(PortalPath); menuDirectory = Path.WebPathCombine(layoutManager.PortalLayoutPath, portalSettings.CurrentLayout); if (Directory.Exists(menuDirectory)) { menuDirectory = Path.WebPathCombine(menuDirectory, "menuimages"); } else { menuDirectory = Path.WebPathCombine(LayoutManager.Path, portalSettings.CurrentLayout, "menuimages"); } if (Directory.Exists(menuDirectory)) { FileInfo[] menuImages = (new DirectoryInfo(menuDirectory)).GetFiles("*.gif"); foreach (FileInfo fi in menuImages) { if (fi.Name != "spacer.gif" && fi.Name != "icon_arrow.gif") { imageMenuFiles.Add(fi.Name, fi.Name); } } } CurrentCache.Insert(Key.ImageMenuList(portalSettings.CurrentLayout), imageMenuFiles, null); } else { imageMenuFiles = (Hashtable)CurrentCache.Get(Key.ImageMenuList(portalSettings.CurrentLayout)); } return(imageMenuFiles); }
/// <summary> /// Read the Path dir and returns an ArrayList with all the Themes found. /// Static because the list is Always the same. /// </summary> /// <returns></returns> public static ArrayList GetPublicThemes() { ArrayList baseThemeList; if (!CurrentCache.Exists(Key.ThemeList(Path))) { //Initialize array baseThemeList = new ArrayList(); string[] themes; // Try to read directories from public theme path if (Directory.Exists(Path)) { themes = Directory.GetDirectories(Path); } else { themes = new string[0]; } for (int i = 0; i < themes.Length; i++) { ThemeItem t = new ThemeItem(); t.Name = themes[i].Substring(Path.Length + 1); if (t.Name != "CVS" && t.Name != "_svn") //Ignore CVS and _svn folders { baseThemeList.Add(t); } } CurrentCache.Insert(Key.ThemeList(Path), baseThemeList, new CacheDependency(Path)); } else { baseThemeList = (ArrayList)CurrentCache.Get(Key.ThemeList(Path)); } return(baseThemeList); }
/// <summary> /// Read the Path dir and returns /// an ArrayList with all the Themes found, public and privates /// </summary> /// <returns> /// A list of theme items. /// </returns> public List <ThemeItem> GetPrivateThemes() { List <ThemeItem> privateThemeList; if (!CurrentCache.Exists(Key.ThemeList(this.PortalThemePath))) { privateThemeList = new List <ThemeItem>(); // Try to read directories from private theme path var themes = Directory.Exists(this.PortalThemePath) ? Directory.GetDirectories(this.PortalThemePath) : new string[0]; for (var i = 0; i <= themes.GetUpperBound(0); i++) { var t = new ThemeItem { Name = themes[i].Substring(this.PortalThemePath.Length + 1) }; // Ignore CVS and SVN if (t.Name != "CVS" && t.Name != "_svn") { privateThemeList.Add(t); } } CurrentCache.Insert( Key.ThemeList(this.PortalThemePath), privateThemeList, new CacheDependency(this.PortalThemePath)); // Debug.WriteLine("Storing privateThemeList in Cache: item count is " + privateThemeList.Count.ToString()); } else { privateThemeList = (List <ThemeItem>)CurrentCache.Get(Key.ThemeList(this.PortalThemePath)); // Debug.WriteLine("Retrieving privateThemeList from Cache: item count is " + privateThemeList.Count.ToString()); } return(privateThemeList); }
/// <summary> /// Gets module settings. /// </summary> /// <param name="moduleId"> /// The module id. /// </param> /// <param name="baseSettings"> /// The base settings. /// </param> /// <returns> /// A hash table. /// </returns> /// <remarks> /// </remarks> public static Dictionary <string, ISettingItem> GetModuleSettings( int moduleId, Dictionary <string, ISettingItem> baseSettings) { if (!CurrentCache.Exists(Key.ModuleSettings(moduleId))) { var hashtable = new Hashtable(); using (var connection = Config.SqlConnectionString) using (var command = new SqlCommand("rb_GetModuleSettings", connection)) { command.CommandType = CommandType.StoredProcedure; var parameter = new SqlParameter("@ModuleID", SqlDbType.Int, 4) { Value = moduleId }; command.Parameters.Add(parameter); connection.Open(); using (var reader = command.ExecuteReader(CommandBehavior.CloseConnection)) { while (reader.Read()) { hashtable[reader["SettingName"].ToString()] = reader["SettingValue"].ToString(); } } } foreach (var key in baseSettings.Keys.Where(key => hashtable[key] != null).Where( key => hashtable[key].ToString().Length != 0)) { baseSettings[key].Value = hashtable[key]; } CurrentCache.Insert(Key.ModuleSettings(moduleId), baseSettings); return(baseSettings); } baseSettings = (Dictionary <string, ISettingItem>)CurrentCache.Get(Key.ModuleSettings(moduleId)); return(baseSettings); }
/// <summary> /// Loads the theme. /// </summary> /// <param name="CurrentWebPath">The current web path.</param> /// <returns>A bool value...</returns> private bool LoadTheme(string CurrentWebPath) { CurrentTheme.WebPath = CurrentWebPath; //if (!Rainbow.Framework.Settings.Cache.CurrentCache.Exists (Rainbow.Framework.Settings.Cache.Key.CurrentTheme(CurrentWebPath))) if (!CurrentCache.Exists(Key.CurrentTheme(CurrentTheme.Path))) { if (File.Exists(CurrentTheme.ThemeFileName)) { if (LoadXml(CurrentTheme.ThemeFileName)) { //Rainbow.Framework.Settings.Cache.CurrentCache.Insert(Rainbow.Framework.Settings.Cache.Key.CurrentTheme(CurrentWebPath), CurrentTheme, new CacheDependency(CurrentTheme.ThemeFileName)); CurrentCache.Insert(Key.CurrentTheme(CurrentTheme.Path), CurrentTheme, new CacheDependency(CurrentTheme.Path)); } else { // failed return(false); } } else { //Return fail return(false); } } else { //CurrentTheme = (Theme) Rainbow.Framework.Settings.Cache.CurrentCache.Get (Rainbow.Framework.Settings.Cache.Key.CurrentTheme(CurrentWebPath)); CurrentTheme = (Theme)CurrentCache.Get(Key.CurrentTheme(CurrentTheme.Path)); } CurrentTheme.WebPath = CurrentWebPath; return(true); }
/// <summary> /// Loads the theme. /// </summary> /// <param name="currentWebPath"> /// The current web path. /// </param> /// <returns> /// A bool value... /// </returns> private bool LoadTheme(string currentWebPath) { this.currentTheme.WebPath = currentWebPath; // if (!Appleseed.Framework.Settings.Cache.CurrentCache.Exists (Appleseed.Framework.Settings.Cache.Key.CurrentTheme(CurrentWebPath))) if (!CurrentCache.Exists(Key.CurrentTheme(this.currentTheme.Path))) { if (File.Exists(this.currentTheme.ThemeFileName)) { if (this.LoadXml(this.currentTheme.ThemeFileName)) { // Appleseed.Framework.Settings.Cache.CurrentCache.Insert(Appleseed.Framework.Settings.Cache.Key.CurrentTheme(CurrentWebPath), CurrentTheme, new CacheDependency(CurrentTheme.ThemeFileName)); CurrentCache.Insert( Key.CurrentTheme(this.currentTheme.Path), this.currentTheme, new CacheDependency(this.currentTheme.Path)); } else { // failed return(false); } } else { // Return fail return(false); } } else { // CurrentTheme = (Theme) Appleseed.Framework.Settings.Cache.CurrentCache.Get (Appleseed.Framework.Settings.Cache.Key.CurrentTheme(CurrentWebPath)); this.currentTheme = (Theme)CurrentCache.Get(Key.CurrentTheme(this.currentTheme.Path)); } this.currentTheme.WebPath = currentWebPath; return(true); }
/// <summary> /// /// </summary> /// <returns></returns> public ArrayList GetPrivateLayouts() { ArrayList privateLayoutList; if (!CurrentCache.Exists(Key.LayoutList(PortalLayoutPath))) { privateLayoutList = new ArrayList(); string[] layouts; // Try to read directories from private theme path if (Directory.Exists(PortalLayoutPath)) { layouts = Directory.GetDirectories(PortalLayoutPath); } else { layouts = new string[0]; } for (int i = 0; i <= layouts.GetUpperBound(0); i++) { LayoutItem t = new LayoutItem(); t.Name = layouts[i].Substring(PortalLayoutPath.Length + 1); if (t.Name != "CVS" && t.Name != "_svn") //Ignore CVS { privateLayoutList.Add(t); } } CurrentCache.Insert(Key.LayoutList(PortalLayoutPath), privateLayoutList, new CacheDependency(PortalLayoutPath)); } else { privateLayoutList = (ArrayList)CurrentCache.Get(Key.LayoutList(PortalLayoutPath)); } return(privateLayoutList); }
/// <summary> /// Gets the private layouts. /// </summary> /// <returns> /// A list of private layouts. /// </returns> public List <LayoutItem> GetPrivateLayouts() { List <LayoutItem> privateLayoutList; if (!CurrentCache.Exists(Key.LayoutList(this.PortalLayoutPath))) { privateLayoutList = new List <LayoutItem>(); // Try to read directories from private theme path var layouts = Directory.Exists(this.PortalLayoutPath) ? Directory.GetDirectories(this.PortalLayoutPath) : new string[0]; for (var i = 0; i <= layouts.GetUpperBound(0); i++) { var t = new LayoutItem { Name = layouts[i].Substring(this.PortalLayoutPath.Length + 1) }; // Ignore CVS if (t.Name != "CVS" && t.Name != "_svn" && t.Name != ".svn") { privateLayoutList.Add(t); } } CurrentCache.Insert( Key.LayoutList(this.PortalLayoutPath), privateLayoutList, new CacheDependency(this.PortalLayoutPath)); } else { privateLayoutList = (List <LayoutItem>)CurrentCache.Get(Key.LayoutList(this.PortalLayoutPath)); } return(privateLayoutList); }
/// <summary> /// The PageSettings.GetPageCustomSettings Method returns a hashtable of /// custom Page specific settings from the database. This method is /// used by Portals to access misc Page settings. /// </summary> /// <param name="pageID">The page ID.</param> /// <returns></returns> public Hashtable GetPageCustomSettings(int pageID) { Hashtable _baseSettings; if (!CurrentCache.Exists(Key.TabSettings(pageID))) { _baseSettings = GetPageBaseSettings(); // Get Settings for this Page from the database Hashtable _settings = new Hashtable(); // Create Instance of Connection and Command Object using (SqlConnection myConnection = Config.SqlConnectionString) { using (SqlCommand myCommand = new SqlCommand("rb_GetTabCustomSettings", myConnection)) { // Mark the Command as a SPROC myCommand.CommandType = CommandType.StoredProcedure; // Add Parameters to SPROC SqlParameter parameterPageID = new SqlParameter("@TabID", SqlDbType.Int, 4); parameterPageID.Value = pageID; myCommand.Parameters.Add(parameterPageID); // Execute the command myConnection.Open(); SqlDataReader dr = myCommand.ExecuteReader(CommandBehavior.CloseConnection); try { while (dr.Read()) { _settings[dr["SettingName"].ToString()] = dr["SettingValue"].ToString(); } } finally { dr.Close(); //by Manu, fixed bug 807858 myConnection.Close(); } } } // Thierry (Tiptopweb) // TODO : put back the cache in GetPageBaseSettings() and reset values not found in the database foreach (string key in _baseSettings.Keys) { if (_settings[key] != null) { SettingItem s = ((SettingItem)_baseSettings[key]); if (_settings[key].ToString().Length != 0) { s.Value = _settings[key].ToString(); } } else //by Manu // Thierry (Tiptopweb), see the comment in Hashtable GetPageBaseSettings() // this is not resetting key not found in the database { SettingItem s = ((SettingItem)_baseSettings[key]); //s.Value = string.Empty; 3_aug_2004 Cory Isakson. This line caused an error with booleans } } CurrentCache.Insert(Key.TabSettings(pageID), _baseSettings); } else { _baseSettings = (Hashtable)CurrentCache.Get(Key.TabSettings(pageID)); } return(_baseSettings); }
/// <summary> /// The PageSettings.GetPageCustomSettings Method returns a hash table of /// custom Page specific settings from the database. This method is /// used by Portals to access misc Page settings. /// </summary> /// <param name="pageId"> /// The page ID. /// </param> /// <returns> /// The hash table. /// </returns> public Dictionary <string, ISettingItem> GetPageCustomSettings(int pageId) { Dictionary <string, ISettingItem> baseSettings; if (CurrentCache.Exists(Key.TabSettings(pageId))) { baseSettings = (Dictionary <string, ISettingItem>)CurrentCache.Get(Key.TabSettings(pageId)); } else { baseSettings = this.GetPageBaseSettings(); // Get Settings for this Page from the database var settings = new Hashtable(); // Create Instance of Connection and Command Object using (var connection = Config.SqlConnectionString) using (var command = new SqlCommand("rb_GetTabCustomSettings", connection)) { // Mark the Command as a SPROC command.CommandType = CommandType.StoredProcedure; // Add Parameters to SPROC var parameterPageId = new SqlParameter("@TabID", SqlDbType.Int, 4) { Value = pageId }; command.Parameters.Add(parameterPageId); // Execute the command connection.Open(); var dr = command.ExecuteReader(CommandBehavior.CloseConnection); try { while (dr.Read()) { settings[dr["SettingName"].ToString()] = dr["SettingValue"].ToString(); } } finally { dr.Close(); // by Manu, fixed bug 807858 connection.Close(); } } // Thierry (Tiptopweb) // TODO : put back the cache in GetPageBaseSettings() and reset values not found in the database // REVIEW: This code is duplicated in portal settings. foreach (var key in baseSettings.Keys.Where(key => settings[key] != null).Where( key => settings[key].ToString().Length != 0)) { baseSettings[key].Value = settings[key]; } CurrentCache.Insert(Key.TabSettings(pageId), baseSettings); } return(baseSettings); }
/// <summary> /// Handles OnLoad event at Page level<br/> /// Performs OnLoad actions that are common to all Pages. /// </summary> /// <param name="e"></param> protected override void OnLoad(EventArgs e) { base.OnLoad (e); // load the dedicated CSS if ( !this.IsCssFileRegistered("SmartError") ) this.RegisterCssFile("Mod_SmartError"); ArrayList storedError = null; StringBuilder sb = new StringBuilder(); // to build response text int _httpStatusCode = (int)HttpStatusCode.InternalServerError; // default value string _renderedEvent = string.Empty; string validStatus = "301;307;403;404;410;500;501;502;503;504"; if ( Request.QueryString[0] != null ) { // is this a "MagicUrl" request if ( Request.QueryString[0].StartsWith("404;http://") ) { Hashtable magicUrlList = null; string redirectUrl = string.Empty; string qPart = string.Empty; int qPartPos = Request.QueryString[0].LastIndexOf("/") + 1 ; qPart = qPartPos < Request.QueryString[0].Length ? Request.QueryString[0].Substring(qPartPos) : string.Empty; if ( qPart.Length > 0 ) { if ( Utils.IsInteger(qPart) ) redirectUrl = HttpUrlBuilder.BuildUrl(Int32.Parse(qPart)); else { magicUrlList = GetMagicUrlList(Portal.UniqueID); if ( magicUrlList != null && magicUrlList.ContainsKey(HttpUtility.HtmlEncode(qPart)) ) { redirectUrl = HttpUtility.HtmlDecode(magicUrlList[HttpUtility.HtmlEncode(qPart)].ToString()); if ( Utils.IsInteger(redirectUrl) ) redirectUrl = HttpUrlBuilder.BuildUrl(Int32.Parse(redirectUrl)); } } if ( redirectUrl.Length != 0 ) Response.Redirect(redirectUrl, true); else _httpStatusCode = (int)HttpStatusCode.NotFound; } } // get status code from querystring else if ( Utils.IsInteger(Request.QueryString[0]) && validStatus.IndexOf(Request.QueryString[0]) > -1 ) { _httpStatusCode = int.Parse(Request.QueryString[0]); } } // get stored error if (Request.QueryString["eid"] != null && Request.QueryString["eid"].Length > 0) { storedError = (ArrayList)CurrentCache.Get(Request.QueryString["eid"]); } if ( storedError != null && storedError[_RENDEREDEVENT_] != null ) _renderedEvent = storedError[_RENDEREDEVENT_].ToString(); else _renderedEvent = @"<p>No exception event stored or cache has expired.</p>"; // get home link string homeUrl = HttpUrlBuilder.BuildUrl(); // try localizing message try { switch ( _httpStatusCode ) { case (int)HttpStatusCode.NotFound : // 404 case (int)HttpStatusCode.Gone : // 410 case (int)HttpStatusCode.MovedPermanently : // 301 case (int)HttpStatusCode.TemporaryRedirect : // 307 sb.AppendFormat("<h3>{0}</h3>",General.GetString("SMARTERROR_404HEADING","Page Not Found", null)); sb.AppendFormat("<p>{0}</p>",General.GetString("SMARTERROR_404TEXT","We're sorry, but there is no page that matches your entry. It is possible you typed the address incorrectly, or the page may no longer exist. You may wish to try another entry or choose from the links below, which we hope will help you find what you’re looking for.", null)); break; case (int)HttpStatusCode.Forbidden : // 403 sb.AppendFormat("<h3>{0}</h3>",General.GetString("SMARTERROR_403HEADING","Not Authorised", null)); sb.AppendFormat("<p>{0}</p>",General.GetString("SMARTERROR_403TEXT","You do not have the required authority for the requested page or action.", null)); break; default : sb.AppendFormat("<h3>{0}</h3>",General.GetString("SMARTERROR_500HEADING","Our Apologies", null)); sb.AppendFormat("<p>{0}</p>",General.GetString("SMARTERROR_500TEXT","We're sorry, but we were unable to service your request. It's possible that the problem is a temporary condition.", null)); break; } sb.AppendFormat("<p><a href=\"{0}\">{1}</a></p>", homeUrl,General.GetString("HOME","Home Page",null)); } catch // default to english message { switch ( _httpStatusCode ) { case (int)HttpStatusCode.NotFound : sb.Append("<h3>Page Not Found</h3>"); sb.Append("<p>We're sorry, but there is no page that matches your entry. It is possible you typed the address incorrectly, or the page may no longer exist. You may wish to try another entry or choose from the links below, which we hope will help you find what you’re looking for.</p>"); break; case (int)HttpStatusCode.Forbidden : sb.Append("<h3>Not Authorised</h3>"); sb.Append("<p>You do not have the required authority for the requested page or action.</p>"); break; default : sb.Append("<h3>Our Apologies</h3>"); sb.AppendFormat("<p>We're sorry, but we were unable to service your request. It's possible that the problem is a temporary condition.</p>"); break; } sb.AppendFormat("<p><a href=\"{0}\">{1}</a></p>",homeUrl, "Home Page"); } // find out if user is on allowed IP Address if ( Request.UserHostAddress != null && Request.UserHostAddress.Length > 0 ) { // construct IPList string[] lockKeyHolders = Config.LockKeyHolders.Split(new char[]{';'}); //ConfigurationSettings.AppSettings["LockKeyHolders"].Split(new char[]{';'}); IPList ipList = new IPList(); try { foreach ( string lockKeyHolder in lockKeyHolders ) { if ( lockKeyHolder.IndexOf("-") > -1 ) ipList.AddRange(lockKeyHolder.Substring(0, lockKeyHolder.IndexOf("-")), lockKeyHolder.Substring(lockKeyHolder.IndexOf("-") + 1)); else ipList.Add(lockKeyHolder); } // check if requestor's IP address is in allowed list if ( ipList.CheckNumber(Request.UserHostAddress) ) { // we can show error details sb.AppendFormat("<h3>{0} - {1}</h3>",General.GetString("SMARTERROR_SUPPORTDETAILS_HEADING","Support Details", null), _httpStatusCode.ToString()); sb.Append(_renderedEvent); } } catch { // if there was a problem, let's assume that user is not authorised } } PageContent.Controls.Add(new LiteralControl(sb.ToString())); Response.StatusCode = _httpStatusCode; Response.Cache.SetCacheability(HttpCacheability.NoCache); }
/// <summary> /// Read the Path dir and returns an ArrayList with all the Layouts found. /// Static because the list is Always the same. /// </summary> /// <returns></returns> public static ArrayList GetPublicLayouts() { // Jes1111 - 27-02-2005 - new version - correct caching ArrayList baseLayoutList; if (!CurrentCache.Exists(Key.LayoutList(Path))) { // initialize array baseLayoutList = new ArrayList(); string[] layouts; // Try to read directories from public Layout path if (Directory.Exists(Path)) { layouts = Directory.GetDirectories(Path); } else { layouts = new string[0]; } for (int i = 0; i < layouts.Length; i++) { LayoutItem t = new LayoutItem(); t.Name = layouts[i].Substring(Path.Length + 1); if (t.Name != "CVS" && t.Name != "_svn") //Ignore CVS { baseLayoutList.Add(t); } } CurrentCache.Insert(Key.LayoutList(Path), baseLayoutList, new CacheDependency(Path)); } else { baseLayoutList = (ArrayList)CurrentCache.Get(Key.LayoutList(Path)); } return(baseLayoutList); // Jes1111 - old version // if (LayoutManager.cachedLayoutsList == null) // { // //Initialize array // ArrayList layoutsList = new ArrayList(); // // string[] layouts; // // // Try to read directories from public Layout path // if (Directory.Exists(Path)) // { // layouts = Directory.GetDirectories(Path); // } // else // { // layouts = new string[0]; // } // // for (int i = 0; i < layouts.Length; i++) // { // LayoutItem t = new LayoutItem(); // t.Name = layouts[i].Substring(Path.Length + 1); // if(t.Name != "CVS") //Ignore CVS // layoutsList.Add(t); // } // // //store list in cache // lock (typeof(LayoutManager)) // { // if (LayoutManager.cachedLayoutsList == null) // { // LayoutManager.cachedLayoutsList = layoutsList; // } // } // } // // return LayoutManager.cachedLayoutsList; }