public static string Culture() { string sCulture = Sql.ToString(HttpContext.Current.Application["CONFIG.default_language"]); DataView vwLanguages = new DataView(SplendidCache.Languages()); vwLanguages.RowFilter = "NAME = '" + sCulture + "'"; if (vwLanguages.Count > 0) { sCulture = Sql.ToString(vwLanguages[0]["NAME"]); } if (Sql.IsEmptyString(sCulture)) { sCulture = "en-US"; } return(L10N.NormalizeCulture(sCulture)); }
// 12/22/2007 Paul. Inside the timer event, there is no current context, so we need to pass the application. public static string Culture(HttpApplicationState Application) { string sCulture = Sql.ToString(Application["CONFIG.default_language"]); // 12/22/2007 Paul. The cache is not available when we are inside the timer event. if (HttpContext.Current != null && HttpContext.Current.Cache != null) { DataView vwLanguages = new DataView(SplendidCache.Languages()); vwLanguages.RowFilter = "NAME = '" + sCulture + "'"; if (vwLanguages.Count > 0) { sCulture = Sql.ToString(vwLanguages[0]["NAME"]); } } if (Sql.IsEmptyString(sCulture)) { sCulture = "en-US"; } return(L10N.NormalizeCulture(sCulture)); }
public static XmlDocument InitUserPreferences(string sUSER_PREFERENCES) { XmlDocument xml = null; try { xml = new XmlDocument(); if (!sUSER_PREFERENCES.StartsWith("<?xml ")) { sUSER_PREFERENCES = XmlUtil.ConvertFromPHP(sUSER_PREFERENCES); } xml.LoadXml(sUSER_PREFERENCES); HttpApplicationState Application = HttpContext.Current.Application; string sCulture = L10N.NormalizeCulture(XmlUtil.SelectSingleNode(xml, "culture")); string sTheme = XmlUtil.SelectSingleNode(xml, "theme"); string sDateFormat = XmlUtil.SelectSingleNode(xml, "dateformat"); string sTimeFormat = XmlUtil.SelectSingleNode(xml, "timeformat"); string sTimeZone = XmlUtil.SelectSingleNode(xml, "timezone"); string sCurrencyID = XmlUtil.SelectSingleNode(xml, "currency_id"); if (Sql.IsEmptyString(sCulture)) { XmlUtil.SetSingleNode(xml, "culture", SplendidDefaults.Culture()); } if (Sql.IsEmptyString(sTheme)) { XmlUtil.SetSingleNode(xml, "theme", SplendidDefaults.Theme()); } if (Sql.IsEmptyString(sDateFormat)) { XmlUtil.SetSingleNode(xml, "dateformat", SplendidDefaults.DateFormat()); } // 11/12/2005 Paul. "m" is not valid for .NET month formatting. Must use MM. // 11/12/2005 Paul. Require 4 digit year. Otherwise default date in Pipeline of 12/31/2100 would get converted to 12/31/00. if (SplendidDefaults.IsValidDateFormat(sDateFormat)) { XmlUtil.SetSingleNode(xml, "dateformat", SplendidDefaults.DateFormat(sDateFormat)); } if (Sql.IsEmptyString(sTimeFormat)) { XmlUtil.SetSingleNode(xml, "timeformat", SplendidDefaults.TimeFormat()); } if (Sql.IsEmptyString(sCurrencyID)) { XmlUtil.SetSingleNode(xml, "currency_id", SplendidDefaults.CurrencyID()); } // 09/01/2006 Paul. Only use timez if provided. Otherwise we will default to GMT. if (Sql.IsEmptyString(sTimeZone) && !Sql.IsEmptyString(XmlUtil.SelectSingleNode(xml, "timez"))) { int nTimez = Sql.ToInteger(XmlUtil.SelectSingleNode(xml, "timez")); sTimeZone = SplendidDefaults.TimeZone(nTimez); XmlUtil.SetSingleNode(xml, "timezone", sTimeZone); } // 09/01/2006 Paul. Default TimeZone was not getting set properly. if (Sql.IsEmptyString(sTimeZone)) { sTimeZone = SplendidDefaults.TimeZone(); XmlUtil.SetSingleNode(xml, "timezone", sTimeZone); } } catch (Exception ex) { SplendidError.SystemError(new StackTrace(true).GetFrame(0), ex.Message); } return(xml); }