/// <summary> /// Loads the brandings from the config file /// </summary> public static void RetrieveBrandings() { try { XDocument xDoc = XDocument.Load(path); /* Load Brandings */ log.Debug("Retrieving brandings from the config file"); var brandings = from s in xDoc.Descendants("branding").Elements() select s; // Clear our current static brandings Brandings._staticBrandings = new List<BrandingSettings>(); // Everything here should be a base URL or default foreach (var b in brandings) { log.DebugFormat("Found host {0} in brandings", b.Name.LocalName); BrandingSettings newBranding = new BrandingSettings(); newBranding.DisplayName = b.Element("DisplayName").Value; newBranding.CopyrightNotice = b.Element("Copyright").Value; newBranding.LoginTitle = b.Element("LoginTitle").Value; newBranding.LoginMessage = b.Element("LoginMessage").Value; newBranding.SupportNumber = b.Element("SupportNumber").Value; newBranding.BaseURL = b.Name.LocalName; if (b.Name.LocalName == "default") newBranding.IsDefault = true; Brandings._staticBrandings.Add(newBranding); } } catch (Exception ex) { log.ErrorFormat("Error retrieving brandings from config file. Error: {0}", ex.ToString()); } }
/// <summary> /// Returns the default branding if it couldn't find a matching URL /// </summary> /// <returns></returns> private static BrandingSettings RetrieveDefaultBranding() { var defaultBranding = (from b in Brandings._staticBrandings where b.IsDefault select b).FirstOrDefault(); if (defaultBranding != null) return defaultBranding; else { // Seems we can't find the default branding so we will compile a new one at runtime BrandingSettings branding = new BrandingSettings(); branding.DisplayName = "CloudPanel"; branding.CopyrightNotice = ""; branding.LoginTitle = "Welcome to CloudPanel"; branding.LoginMessage = "Please login"; // Add to the list for next time Brandings._staticBrandings.Add(branding); return branding; } }