예제 #1
0
        /// -----------------------------------------------------------------------------
        /// <summary>
        /// InitialiseHostSettings gets the Host Settings from the Install Template
        /// </summary>
        /// <remarks>
        /// </remarks>
        ///	<param name="xmlTemplate">The install Templae</param>
        ///	<param name="writeFeedback">a flag to determine whether to output feedback</param>
        /// <history>
        /// [cnurse]	02/16/2007	created
        /// </history>
        /// -----------------------------------------------------------------------------
        public static void InitialiseHostSettings(XmlDocument xmlTemplate, bool writeFeedback)
        {
            XmlNode node = xmlTemplate.SelectSingleNode("//dotnetnuke/settings");
            if ((node != null))
            {
                if (writeFeedback)
                {
                    HtmlUtils.WriteFeedback(HttpContext.Current.Response, 0, "Loading Host Settings:<br>");
                }

                HostSettingsController objController = new HostSettingsController();

                //Parse the Settings nodes
                foreach (XmlNode settingNode in node.ChildNodes)
                {
                    string strSettingName = settingNode.Name;
                    string strSettingValue = settingNode.InnerText;
                    XmlAttribute SecureAttrib = settingNode.Attributes["Secure"];
                    bool SettingIsSecure = false;
                    if ((SecureAttrib != null))
                    {
                        if (SecureAttrib.Value.ToLower() == "true")
                        {
                            SettingIsSecure = true;
                        }
                    }

                    string strDomainName = Globals.GetDomainName(HttpContext.Current.Request);

                    switch (strSettingName)
                    {
                        case "HostURL":
                            if (string.IsNullOrEmpty(strSettingValue))
                            {
                                strSettingValue = strDomainName;
                            }
                            break;
                        case "HostEmail":
                            if (string.IsNullOrEmpty(strSettingValue))
                            {
                                strSettingValue = "support@" + strDomainName;

                                //Remove any folders
                                strSettingValue = strSettingValue.Substring(0, strSettingValue.IndexOf("/"));

                                //Remove port number
                                if (strSettingValue.IndexOf(":") != -1)
                                {
                                    strSettingValue = strSettingValue.Substring(0, strSettingValue.IndexOf(":"));
                                }
                            }

                            break;
                    }


                    objController.UpdateHostSetting(strSettingName, strSettingValue, SettingIsSecure);
                }
                //Need to clear the cache to pick up new HostSettings from the SQLDataProvider script
                DataCache.RemoveCache("GetHostSettings");
            }
        }
예제 #2
0
 public static void ProcessLegacyLanguages()
 {
     string filePath = Common.Globals.ApplicationMapPath + Localization.Localization.SupportedLocalesFile.Substring(1).Replace("/", "\\");
     if (File.Exists(filePath))
     {
         XPathDocument doc = new XPathDocument(filePath);
         HostSettingsController controller = new HostSettingsController();
         XPathNavigator browserNav = doc.CreateNavigator().SelectSingleNode("root/browserDetection");
         if (browserNav != null)
         {
             controller.UpdateHostSetting("EnableBrowserLanguage", Util.ReadAttribute(browserNav, "enabled", false, null, Null.NullString, "true"));
         }
         XPathNavigator urlNav = doc.CreateNavigator().SelectSingleNode("root/languageInUrl");
         if (urlNav != null)
         {
             controller.UpdateHostSetting("EnableUrlLanguage", Util.ReadAttribute(urlNav, "enabled", false, null, Null.NullString, "true"));
         }
         foreach (XPathNavigator nav in doc.CreateNavigator().Select("root/language"))
         {
             if (nav.NodeType != XPathNodeType.Comment)
             {
                 Locale language = new Locale();
                 language.Text = Util.ReadAttribute(nav, "name");
                 language.Code = Util.ReadAttribute(nav, "key");
                 language.Fallback = Util.ReadAttribute(nav, "fallback");
                 if (language.Code != Localization.Localization.SystemLocale)
                 {
                     PackageInfo package = new PackageInfo(new InstallerInfo());
                     package.Name = language.Text;
                     package.FriendlyName = language.Text;
                     package.Description = Null.NullString;
                     package.Version = new Version(1, 0, 0);
                     package.PackageType = "CoreLanguagePack";
                     package.License = Util.PACKAGE_NoLicense;
                     LanguagePackWriter packageWriter = new LanguagePackWriter(language, package);
                     package.Manifest = packageWriter.WriteManifest(true);
                     PackageController.SavePackage(package);
                     Localization.Localization.SaveLanguage(language);
                     LanguagePackInfo languagePack = new LanguagePackInfo();
                     languagePack.LanguageID = language.LanguageID;
                     languagePack.PackageID = package.PackageID;
                     languagePack.DependentPackageID = -2;
                     LanguagePackController.SaveLanguagePack(languagePack);
                 }
             }
         }
     }
     foreach (PortalInfo portal in new PortalController().GetPortals())
     {
         int portalID = portal.PortalID;
         filePath = string.Format(Common.Globals.ApplicationMapPath + Localization.Localization.ApplicationResourceDirectory.Substring(1).Replace("/", "\\") + "\\Locales.Portal-{0}.xml", portalID.ToString());
         if (File.Exists(filePath))
         {
             XPathDocument doc = new XPathDocument(filePath);
             XPathNavigator browserNav = doc.CreateNavigator().SelectSingleNode("locales/browserDetection");
             if (browserNav != null)
             {
                 PortalController.UpdatePortalSetting(portalID, "EnableBrowserLanguage", Util.ReadAttribute(browserNav, "enabled", false, null, Null.NullString, "true"));
             }
             XPathNavigator urlNav = doc.CreateNavigator().SelectSingleNode("locales/languageInUrl");
             if (urlNav != null)
             {
                 PortalController.UpdatePortalSetting(portalID, "EnableUrlLanguage", Util.ReadAttribute(urlNav, "enabled", false, null, Null.NullString, "true"));
             }
             foreach (Locale installedLanguage in Localization.Localization.GetLocales(Null.NullInteger).Values)
             {
                 string code = installedLanguage.Code;
                 bool bFound = false;
                 foreach (XPathNavigator inactiveNav in doc.CreateNavigator().Select("locales/inactive/locale"))
                 {
                     if (inactiveNav.Value == code)
                     {
                         bFound = true;
                         break;
                     }
                 }
                 if (!bFound)
                 {
                     Localization.Localization.AddLanguageToPortal(portalID, installedLanguage.LanguageID, false);
                 }
             }
         }
         else
         {
             foreach (Locale installedLanguage in Localization.Localization.GetLocales(Null.NullInteger).Values)
             {
                 Localization.Localization.AddLanguageToPortal(portalID, installedLanguage.LanguageID, false);
             }
         }
     }
 }