public LanguageComponentWriter(LanguagePackInfo languagePack, string basePath, Dictionary<string, InstallFile> files, PackageInfo package) : base(basePath, files, package) { _Language = Localization.Localization.GetLocaleByID(languagePack.LanguageID); _PackageType = languagePack.PackageType; _DependentPackageID = languagePack.DependentPackageID; }
public static void SaveLanguagePack(LanguagePackInfo languagePack) { Services.Log.EventLog.EventLogController objEventLog = new Services.Log.EventLog.EventLogController(); if (languagePack.LanguagePackID == Null.NullInteger) { languagePack.LanguagePackID = DataProvider.Instance().AddLanguagePack(languagePack.PackageID, languagePack.LanguageID, languagePack.DependentPackageID, UserController.GetCurrentUserInfo().UserID); objEventLog.AddLog(languagePack, PortalController.GetCurrentPortalSettings(), UserController.GetCurrentUserInfo().UserID, "", Log.EventLog.EventLogController.EventLogType.LANGUAGEPACK_CREATED); } else { DataProvider.Instance().UpdateLanguagePack(languagePack.LanguagePackID, languagePack.PackageID, languagePack.LanguageID, languagePack.DependentPackageID, UserController.GetCurrentUserInfo().UserID); objEventLog.AddLog(languagePack, PortalController.GetCurrentPortalSettings(), UserController.GetCurrentUserInfo().UserID, "", Log.EventLog.EventLogController.EventLogType.LANGUAGEPACK_UPDATED); } }
public static void DeleteLanguagePack(LanguagePackInfo languagePack) { if (languagePack.PackageType == LanguagePackType.Core) { Locale language = Localization.GetLocaleByID(languagePack.LanguageID); if (language != null) { Localization.DeleteLanguage(language); } } DataProvider.Instance().DeleteLanguagePack(languagePack.LanguagePackID); Services.Log.EventLog.EventLogController objEventLog = new Services.Log.EventLog.EventLogController(); objEventLog.AddLog(languagePack, PortalController.GetCurrentPortalSettings(), UserController.GetCurrentUserInfo().UserID, "", Log.EventLog.EventLogController.EventLogType.LANGUAGEPACK_DELETED); }
public LanguagePackWriter(PackageInfo package) : base(package) { _LanguagePack = LanguagePackController.GetLanguagePackByPackage(package.PackageID); if (LanguagePack != null) { _Language = Localization.Localization.GetLocaleByID(_LanguagePack.LanguageID); if (LanguagePack.PackageType == LanguagePackType.Core) { BasePath = Null.NullString; } else { PackageInfo dependendentPackage = PackageController.GetPackage(LanguagePack.DependentPackageID); PackageWriterBase dependentPackageWriter = PackageWriterFactory.GetWriter(dependendentPackage); BasePath = dependentPackageWriter.BasePath; } } else { BasePath = Null.NullString; } }
public static int AddPackage(PackageInfo package, bool includeDetail) { int packageID = provider.AddPackage(package.PortalID, package.Name, package.FriendlyName, package.Description, package.PackageType, package.Version.ToString(3), package.License, package.Manifest, package.Owner, package.Organization, package.Url, package.Email, package.ReleaseNotes, package.IsSystemPackage, UserController.GetCurrentUserInfo().UserID); Services.Log.EventLog.EventLogController objEventLog = new Services.Log.EventLog.EventLogController(); objEventLog.AddLog(package, PortalController.GetCurrentPortalSettings(), UserController.GetCurrentUserInfo().UserID, "", Services.Log.EventLog.EventLogController.EventLogType.PACKAGE_CREATED); if (includeDetail) { Locale locale; LanguagePackInfo languagePack; switch (package.PackageType) { case "Auth_System": AuthenticationInfo authSystem = new AuthenticationInfo(); authSystem.AuthenticationType = package.Name; authSystem.IsEnabled = Null.NullBoolean; authSystem.PackageID = packageID; AuthenticationController.AddAuthentication(authSystem); break; case "Container": case "Skin": SkinPackageInfo skinPackage = new SkinPackageInfo(); skinPackage.SkinName = package.Name; skinPackage.PackageID = packageID; skinPackage.SkinType = package.PackageType; SkinController.AddSkinPackage(skinPackage); break; case "CoreLanguagePack": locale = Localization.Localization.GetLocale(PortalController.GetCurrentPortalSettings().DefaultLanguage); languagePack = new LanguagePackInfo(); languagePack.PackageID = packageID; languagePack.LanguageID = locale.LanguageID; languagePack.DependentPackageID = -2; LanguagePackController.SaveLanguagePack(languagePack); break; case "ExtensionLanguagePack": locale = Localization.Localization.GetLocale(PortalController.GetCurrentPortalSettings().DefaultLanguage); languagePack = new LanguagePackInfo(); languagePack.PackageID = packageID; languagePack.LanguageID = locale.LanguageID; languagePack.DependentPackageID = Null.NullInteger; LanguagePackController.SaveLanguagePack(languagePack); break; case "Module": DesktopModuleInfo desktopModule = new DesktopModuleInfo(); desktopModule.PackageID = packageID; desktopModule.ModuleName = package.Name; desktopModule.FriendlyName = package.FriendlyName; desktopModule.FolderName = package.Name; desktopModule.Description = package.Description; desktopModule.Version = package.Version.ToString(3); desktopModule.SupportedFeatures = 0; int desktopModuleId = DesktopModuleController.SaveDesktopModule(desktopModule, false, true); if (desktopModuleId > Null.NullInteger) { DesktopModuleController.AddDesktopModuleToPortals(desktopModuleId); } break; case "SkinObject": SkinControlInfo skinControl = new SkinControlInfo(); skinControl.PackageID = packageID; skinControl.ControlKey = package.Name; SkinControlController.SaveSkinControl(skinControl); break; } } return packageID; }
private void ReadLegacyManifest(System.Xml.XPath.XPathNavigator manifestNav) { string fileName = Null.NullString; string filePath = Null.NullString; string sourceFileName = Null.NullString; string resourcetype = Null.NullString; string moduleName = Null.NullString; foreach (XPathNavigator fileNav in manifestNav.Select("Files/File")) { fileName = Util.ReadAttribute(fileNav, "FileName".ToLowerInvariant()); resourcetype = Util.ReadAttribute(fileNav, "FileType"); moduleName = Util.ReadAttribute(fileNav, "ModuleName".ToLowerInvariant()); sourceFileName = Path.Combine(resourcetype, Path.Combine(moduleName, fileName)); string extendedExtension = "." + Language.Code.ToLowerInvariant() + ".resx"; switch (resourcetype) { case "GlobalResource": filePath = "App_GlobalResources"; _IsCore = true; break; case "ControlResource": filePath = "Controls\\App_LocalResources"; break; case "AdminResource": _IsCore = true; switch (moduleName) { case "authentication": filePath = "DesktopModules\\Admin\\Authentication\\App_LocalResources"; break; case "controlpanel": filePath = "Admin\\ControlPanel\\App_LocalResources"; break; case "files": filePath = "DesktopModules\\Admin\\FileManager\\App_LocalResources"; break; case "host": switch (fileName.Replace(extendedExtension, "")) { case "authentication.ascx": filePath = ""; break; case "friendlyurls.ascx": filePath = "DesktopModules\\Admin\\HostSettings\\App_LocalResources"; break; case "hostsettings.ascx": filePath = "DesktopModules\\Admin\\HostSettings\\App_LocalResources"; break; case "requestfilters.ascx": filePath = "DesktopModules\\Admin\\HostSettings\\App_LocalResources"; break; case "solutions.ascx": filePath = "DesktopModules\\Admin\\Solutions\\App_LocalResources"; break; } break; case "lists": filePath = "DesktopModules\\Admin\\Lists\\App_LocalResources"; break; case "localization": switch (fileName.Replace(extendedExtension, "")) { case "languageeditor.ascx": filePath = "DesktopModules\\Admin\\Extensions\\Editors\\App_LocalResources"; break; case "languageeditorext.ascx": filePath = "DesktopModules\\Admin\\Extensions\\Editors\\App_LocalResources"; break; case "timezoneeditor.ascx": filePath = "DesktopModules\\Admin\\Extensions\\Editors\\App_LocalResources"; break; case "resourceverifier.ascx": filePath = "DesktopModules\\Admin\\Extensions\\Editors\\App_LocalResources"; break; default: filePath = ""; break; } break; case "log": filePath = "DesktopModules\\Admin\\SiteLog\\App_LocalResources"; break; case "logging": filePath = "DesktopModules\\Admin\\LogViewer\\App_LocalResources"; break; case "moduledefinitions": switch (fileName.Replace(extendedExtension, "")) { case "editmodulecontrol.ascx": filePath = "DesktopModules\\Admin\\Extensions\\Editors\\App_LocalResources"; break; case "importmoduledefinition.ascx": filePath = "DesktopModules\\Admin\\Extensions\\Editors\\App_LocalResources"; break; case "timezoneeditor.ascx": filePath = "DesktopModules\\Admin\\Extensions\\Editors\\App_LocalResources"; break; default: filePath = ""; break; } break; case "modules": filePath = "Admin\\Modules\\App_LocalResources"; break; case "packages": filePath = "DesktopModules\\Admin\\Extensions\\App_LocalResources"; break; case "portal": switch (fileName.Replace(extendedExtension, "")) { case "editportalalias.ascx": filePath = "DesktopModules\\Admin\\Portals\\App_LocalResources"; break; case "portalalias.ascx": filePath = "DesktopModules\\Admin\\Portals\\App_LocalResources"; break; case "portals.ascx": filePath = "DesktopModules\\Admin\\Portals\\App_LocalResources"; break; case "privacy.ascx": filePath = "Admin\\Portal\\App_LocalResources"; break; case "signup.ascx": filePath = "DesktopModules\\Admin\\Portals\\App_LocalResources"; break; case "sitesettings.ascx": filePath = "DesktopModules\\Admin\\Portals\\App_LocalResources"; break; case "sitewizard.ascx": filePath = "DesktopModules\\Admin\\SiteWizard\\App_LocalResources"; break; case "sql.ascx": filePath = "DesktopModules\\Admin\\SQL\\App_LocalResources"; break; case "systemmessages.ascx": filePath = ""; break; case "template.ascx": filePath = "DesktopModules\\Admin\\Portals\\App_LocalResources"; break; case "terms.ascx": filePath = "Admin\\Portal\\App_LocalResources"; break; } break; case "scheduling": filePath = "DesktopModules\\Admin\\Scheduler\\App_LocalResources"; break; case "search": switch (fileName.Replace(extendedExtension, "")) { case "inputsettings.ascx": filePath = "DesktopModules\\Admin\\SearchInput\\App_LocalResources"; break; case "resultssettings.ascx": filePath = "DesktopModules\\Admin\\SearchResults\\App_LocalResources"; break; case "searchadmin.ascx": filePath = "DesktopModules\\Admin\\SearchAdmin\\App_LocalResources"; break; case "searchinput.ascx": filePath = "DesktopModules\\Admin\\SearchInput\\App_LocalResources"; break; case "searchresults.ascx": filePath = "DesktopModules\\Admin\\SearchResults\\App_LocalResources"; break; } break; case "security": switch (fileName.Replace(extendedExtension, "")) { case "accessdenied.ascx": filePath = "Admin\\Security\\App_LocalResources"; break; case "authenticationsettings.ascx": filePath = ""; break; case "editgroups.ascx": filePath = "DesktopModules\\Admin\\Security\\App_LocalResources"; break; case "editroles.ascx": filePath = "DesktopModules\\Admin\\Security\\App_LocalResources"; break; case "register.ascx": filePath = ""; break; case "roles.ascx": filePath = "DesktopModules\\Admin\\Security\\App_LocalResources"; break; case "securityroles.ascx": filePath = "DesktopModules\\Admin\\Security\\App_LocalResources"; break; case "sendpassword.ascx": filePath = "Admin\\Security\\App_LocalResources"; break; case "signin.ascx": filePath = ""; break; } break; case "skins": switch (fileName.Replace(extendedExtension, "")) { case "attributes.ascx": filePath = "DesktopModules\\Admin\\SkinDesigner\\App_LocalResources"; break; case "editskins.ascx": filePath = "DesktopModules\\Admin\\Extensions\\Editors\\App_LocalResources"; break; default: filePath = "Admin\\Skins\\App_LocalResources"; break; } break; case "syndication": filePath = "DesktopModules\\Admin\\FeedExplorer\\App_LocalResources"; break; case "tabs": switch (fileName.Replace(extendedExtension, "")) { case "export.ascx": filePath = "Admin\\Tabs\\App_LocalResources"; break; case "import.ascx": filePath = "Admin\\Tabs\\App_LocalResources"; break; case "managetabs.ascx": filePath = "DesktopModules\\Admin\\Tabs\\App_LocalResources"; break; case "recyclebin.ascx": filePath = "DesktopModules\\Admin\\RecycleBin\\App_LocalResources"; break; case "tabs.ascx": filePath = "DesktopModules\\Admin\\Tabs\\App_LocalResources"; break; } break; case "users": switch (fileName.Replace(extendedExtension, "")) { case "bulkemail.ascx": filePath = "DesktopModules\\Admin\\Newsletters\\App_LocalResources"; fileName = "Newsletter.ascx" + extendedExtension; break; case "editprofiledefinition.ascx": filePath = "DesktopModules\\Admin\\Security\\App_LocalResources"; break; case "manageusers.ascx": filePath = "DesktopModules\\Admin\\Security\\App_LocalResources"; break; case "memberservices.ascx": filePath = "DesktopModules\\Admin\\Security\\App_LocalResources"; break; case "membership.ascx": filePath = "DesktopModules\\Admin\\Security\\App_LocalResources"; break; case "password.ascx": filePath = "DesktopModules\\Admin\\Security\\App_LocalResources"; break; case "profile.ascx": filePath = "DesktopModules\\Admin\\Security\\App_LocalResources"; break; case "profiledefinitions.ascx": filePath = "DesktopModules\\Admin\\Security\\App_LocalResources"; break; case "user.ascx": filePath = "DesktopModules\\Admin\\Security\\App_LocalResources"; break; case "users.ascx": filePath = "DesktopModules\\Admin\\Security\\App_LocalResources"; break; case "usersettings.ascx": filePath = "DesktopModules\\Admin\\Security\\App_LocalResources"; break; case "viewprofile.ascx": filePath = "Admin\\Users\\App_LocalResources"; break; } break; case "vendors": switch (fileName.Replace(extendedExtension, "")) { case "adsense.ascx": filePath = ""; break; case "editadsense.ascx": filePath = ""; break; case "affiliates.ascx": filePath = "DesktopModules\\Admin\\Vendors\\App_LocalResources"; break; case "banneroptions.ascx": filePath = "DesktopModules\\Admin\\Banners\\App_LocalResources"; break; case "banners.ascx": filePath = "DesktopModules\\Admin\\Vendors\\App_LocalResources"; break; case "displaybanners.ascx": filePath = "DesktopModules\\Admin\\Banners\\App_LocalResources"; break; case "editaffiliate.ascx": filePath = "DesktopModules\\Admin\\Vendors\\App_LocalResources"; break; case "editbanner.ascx": filePath = "DesktopModules\\Admin\\Vendors\\App_LocalResources"; break; case "editvendors.ascx": filePath = "DesktopModules\\Admin\\Vendors\\App_LocalResources"; break; case "vendors.ascx": filePath = "DesktopModules\\Admin\\Vendors\\App_LocalResources"; break; } break; } break; case "LocalResource": filePath = Path.Combine("DesktopModules", Path.Combine(moduleName, "App_LocalResources")); if (!_IsCore && _LanguagePack == null) { Locale locale = Localization.Localization.GetLocale(_Language.Code); if (locale == null) { LegacyError = "CoreLanguageError"; } else { foreach (KeyValuePair<int, DesktopModuleInfo> kvp in DesktopModuleController.GetDesktopModules(Null.NullInteger)) { if (kvp.Value.FolderName.ToLowerInvariant() == moduleName) { PackageInfo dependentPackage = PackageController.GetPackage(kvp.Value.PackageID); Package.Name += "_" + dependentPackage.Name; Package.FriendlyName += " " + dependentPackage.FriendlyName; _LanguagePack = new LanguagePackInfo(); _LanguagePack.DependentPackageID = dependentPackage.PackageID; _LanguagePack.LanguageID = locale.LanguageID; break; } } if (_LanguagePack == null) { LegacyError = "DependencyError"; } } } break; case "ProviderResource": filePath = Path.Combine("Providers", Path.Combine(moduleName, "App_LocalResources")); break; case "InstallResource": filePath = "Install\\App_LocalResources"; break; } if (!string.IsNullOrEmpty(filePath)) { AddFile(Path.Combine(filePath, fileName), sourceFileName); } } }
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); } } } }