コード例 #1
0
        /// -----------------------------------------------------------------------------
        /// <summary>
        /// The GetWriter method instantiates the relevant PackageWriter Installer.
        /// </summary>
        /// <param name="package">The associated PackageInfo instance.</param>
        /// <returns></returns>
        /// -----------------------------------------------------------------------------
        public static PackageWriterBase GetWriter(PackageInfo package)
        {
            PackageWriterBase writer = null;

            switch (package.PackageType)
            {
            case "Auth_System":
                writer = new AuthenticationPackageWriter(package);
                break;

            case "Module":
                writer = new ModulePackageWriter(package);
                break;

            case "Container":
                writer = new ContainerPackageWriter(package);
                break;

            case "Skin":
                writer = new SkinPackageWriter(package);
                break;

            case "CoreLanguagePack":
            case "ExtensionLanguagePack":
                writer = new LanguagePackWriter(package);
                break;

            case "SkinObject":
                writer = new SkinControlPackageWriter(package);
                break;

            case "Provider":
                writer = new ProviderPackageWriter(package);
                break;

            case "Library":
                writer = new LibraryPackageWriter(package);
                break;

            case "Widget":
                writer = new WidgetPackageWriter(package);
                break;

            default:
                // PackageType is defined in the List
                var           listController = new ListController();
                ListEntryInfo entry          = listController.GetListEntryInfo("PackageWriter", package.PackageType);

                if (entry != null && !string.IsNullOrEmpty(entry.Text))
                {
                    // The class for the Installer is specified in the Text property
                    writer = (PackageWriterBase)Reflection.CreateObject(entry.Text, "PackageWriter_" + entry.Value);
                }

                break;
            }

            return(writer);
        }
コード例 #2
0
        private void CreatePackage(PackageInfo package, int dependentPackageID, string basePath, string fileName, bool createZip)
        {
            string manifest;

            Locale language     = LocaleController.Instance.GetLocale(cboLanguage.SelectedValue);
            var    languagePack = new LanguagePackInfo();

            languagePack.LanguageID         = language.LanguageId;
            languagePack.DependentPackageID = dependentPackageID;

            if (dependentPackageID == -2)
            {
                package.PackageType = "CoreLanguagePack";
            }
            else
            {
                package.PackageType = "ExtensionLanguagePack";
            }
            package.Name         += " " + language.Text;
            package.FriendlyName += " " + language.Text;

            packageWriter              = PackageWriterFactory.GetWriter(package) as DotNetNuke.Services.Installer.Writers.LanguagePackWriter;
            packageWriter.Language     = language;
            packageWriter.LanguagePack = languagePack;
            packageWriter.BasePath     = basePath;
            packageWriter.GetFiles(false);

            if (packageWriter.Files.Count > 0)
            {
                _IsPackCreated = true;
                if (createZip)
                {
                    manifest = packageWriter.WriteManifest(true);
                    fileName = fileName + "." + package.Version.ToString(3) + "." + language.Code + ".zip";
                    packageWriter.CreatePackage(fileName, package.Name + ".dnn", manifest, true);
                }
                else if (!_Manifest.Contains(string.Format(@"package name=""{0}""", package.Name)))
                {
                    packageWriter.BasePath = "";
                    _Manifest += packageWriter.WriteManifest(true);
                    foreach (KeyValuePair <string, InstallFile> kvp in packageWriter.Files)
                    {
                        _Files[kvp.Key] = kvp.Value;
                    }
                }
            }
            else
            {
                _IsPackCreated = false;
            }
        }
コード例 #3
0
        private void CreateFullPackage()
        {
            Locale language = LocaleController.Instance.GetLocale(cboLanguage.SelectedValue);
            var    Package  = new PackageInfo();

            Package.Name        = Globals.CleanFileName(txtFileName.Text);
            Package.Version     = DotNetNukeContext.Current.Application.Version;
            Package.License     = Util.PACKAGE_NoLicense;
            Package.PackageType = "CoreLanguagePack";

            _Files = new Dictionary <string, InstallFile>();
            CreateCorePackage(false);
            foreach (DesktopModuleInfo desktopModule in DesktopModuleController.GetDesktopModules(Null.NullInteger).Values)
            {
                if (!desktopModule.FolderName.StartsWith("Admin/"))
                {
                    CreateModulePackage(desktopModule, false);
                }
            }
            foreach (PackageInfo provider in PackageController.Instance.GetExtensionPackages(Null.NullInteger, p => p.PackageType == "Provider"))
            {
                CreateProviderPackage(provider, false);
            }
            foreach (PackageInfo authSystem in PackageController.Instance.GetExtensionPackages(Null.NullInteger, p => p.PackageType == "Auth_System"))
            {
                CreateAuthSystemPackage(authSystem, false);
            }
            foreach (PackageInfo library in PackageController.Instance.GetExtensionPackages(Null.NullInteger, p => p.PackageType == "Library" || p.PackageType == "EvoqConnector"))
            {
                //only generate if a folder name is known for the library
                if (library.FolderName != null)
                {
                    CreateLibraryPackage(library, false);
                }
            }

            string fileName = Path.Combine(BasePath, "ResourcePack." + Package.Name);

            fileName = fileName + "." + Package.Version.ToString(3) + "." + language.Code + ".zip";

            packageWriter          = PackageWriterFactory.GetWriter(Package) as DotNetNuke.Services.Installer.Writers.LanguagePackWriter;
            packageWriter.Language = language;
            packageWriter.BasePath = "";
            foreach (KeyValuePair <string, InstallFile> kvp in _Files)
            {
                packageWriter.Files.Add(kvp.Key, kvp.Value);
            }
            packageWriter.CreatePackage(fileName, Package.Name + " " + language.Text + ".dnn", _Manifest, true);
        }
コード例 #4
0
        /// -----------------------------------------------------------------------------
        /// <summary>
        /// The GetWriter method instantiates the relevant PackageWriter Installer
        /// </summary>
        /// <param name="package">The associated PackageInfo instance</param>
        /// <history>
        /// 	[cnurse]	01/31/2008  created
        /// </history>
        /// -----------------------------------------------------------------------------
        public static PackageWriterBase GetWriter(PackageInfo package)
        {
            PackageWriterBase writer = null;
            switch (package.PackageType)
            {
                case "Auth_System":
                    writer = new AuthenticationPackageWriter(package);
                    break;
                case "Module":
                    writer = new ModulePackageWriter(package);
                    break;
                case "Container":
                    writer = new ContainerPackageWriter(package);
                    break;
                case "Skin":
                    writer = new SkinPackageWriter(package);
                    break;
                case "CoreLanguagePack":
                case "ExtensionLanguagePack":
                    writer = new LanguagePackWriter(package);
                    break;
                case "SkinObject":
                    writer = new SkinControlPackageWriter(package);
                    break;
                case "Provider":
                    writer = new ProviderPackageWriter(package);
                    break;
                case "Library":
                    writer = new LibraryPackageWriter(package);
                    break;
                case "Widget":
                    writer = new WidgetPackageWriter(package);
                    break;
                default:
                    //PackageType is defined in the List
                    var listController = new ListController();
                    ListEntryInfo entry = listController.GetListEntryInfo("PackageWriter", package.PackageType);

                    if (entry != null && !string.IsNullOrEmpty(entry.Text))
                    {
						//The class for the Installer is specified in the Text property
                        writer = (PackageWriterBase) Reflection.CreateObject(entry.Text, "PackageWriter_" + entry.Value);
                    }
                    break;
            }
            return writer;
        }
コード例 #5
0
ファイル: Installer.cs プロジェクト: hungnt-me/Dnn.Platform
        public static XPathNavigator ConvertLegacyNavigator(XPathNavigator rootNav, InstallerInfo info)
        {
            XPathNavigator nav = null;

            var packageType = Null.NullString;
            if (rootNav.Name == "dotnetnuke")
            {
                packageType = Util.ReadAttribute(rootNav, "type");
            }
            else if (rootNav.Name.ToLower() == "languagepack")
            {
                packageType = "LanguagePack";
            }

            XPathDocument legacyDoc;
            string legacyManifest;
            switch (packageType.ToLower())
            {
                case "module":
                    var sb = new StringBuilder();
                    var writer = XmlWriter.Create(sb, XmlUtils.GetXmlWriterSettings(ConformanceLevel.Fragment));

                    //Write manifest start element
                    PackageWriterBase.WriteManifestStartElement(writer);

                    //Legacy Module - Process each folder
                    foreach (XPathNavigator folderNav in rootNav.Select("folders/folder"))
                    {
                        var modulewriter = new ModulePackageWriter(folderNav, info);
                        modulewriter.WriteManifest(writer, true);
                    }

                    //Write manifest end element
                    PackageWriterBase.WriteManifestEndElement(writer);

                    //Close XmlWriter
                    writer.Close();

                    //Load manifest into XPathDocument for processing
                    legacyDoc = new XPathDocument(new StringReader(sb.ToString()));

                    //Parse the package nodes
                    nav = legacyDoc.CreateNavigator().SelectSingleNode("dotnetnuke");
                    break;
                case "languagepack":
                    //Legacy Language Pack
                    var languageWriter = new LanguagePackWriter(rootNav, info);
                    info.LegacyError = languageWriter.LegacyError;
                    if (string.IsNullOrEmpty(info.LegacyError))
                    {
                        legacyManifest = languageWriter.WriteManifest(false);
                        legacyDoc = new XPathDocument(new StringReader(legacyManifest));

                        //Parse the package nodes
                        nav = legacyDoc.CreateNavigator().SelectSingleNode("dotnetnuke");
                    }
                    break;
                case "skinobject":
                    //Legacy Skin Object
                    var skinControlwriter = new SkinControlPackageWriter(rootNav, info);
                    legacyManifest = skinControlwriter.WriteManifest(false);
                    legacyDoc = new XPathDocument(new StringReader(legacyManifest));

                    //Parse the package nodes
                    nav = legacyDoc.CreateNavigator().SelectSingleNode("dotnetnuke");
                    break;
            }

            return nav;
        }
コード例 #6
0
        public static void ProcessLegacyLanguages()
        {
            string filePath = Globals.ApplicationMapPath + Localization.Localization.SupportedLocalesFile.Substring(1).Replace("/", "\\");
            if (File.Exists(filePath))
            {
                var doc = new XPathDocument(filePath);

                //Check for Browser and Url settings
                XPathNavigator browserNav = doc.CreateNavigator().SelectSingleNode("root/browserDetection");
                if (browserNav != null)
                {
                    HostController.Instance.Update("EnableBrowserLanguage", Util.ReadAttribute(browserNav, "enabled", false, null, Null.NullString, "true"));
                }
                XPathNavigator urlNav = doc.CreateNavigator().SelectSingleNode("root/languageInUrl");
                if (urlNav != null)
                {
                    HostController.Instance.Update("EnableUrlLanguage", Util.ReadAttribute(urlNav, "enabled", false, null, Null.NullString, "true"));
                }
				
                //Process each language
                foreach (XPathNavigator nav in doc.CreateNavigator().Select("root/language"))
                {
                    if (nav.NodeType != XPathNodeType.Comment)
                    {
                        var language = new Locale();
                        language.Text = Util.ReadAttribute(nav, "name");
                        language.Code = Util.ReadAttribute(nav, "key");
                        language.Fallback = Util.ReadAttribute(nav, "fallback");
                        //Save Language
                        Localization.Localization.SaveLanguage(language);
                        if (language.Code != Localization.Localization.SystemLocale)
                        {
                            //Create a Package
                            var package = new PackageInfo(new InstallerInfo())
                                {
                                    Name = language.Text,
                                    FriendlyName = language.Text,
                                    Description = Null.NullString,
                                    Version = new Version(1, 0, 0),
                                    PackageType = "CoreLanguagePack",
                                    License = Util.PACKAGE_NoLicense
                                };

                            //Create a LanguagePackWriter
                            var packageWriter = new LanguagePackWriter(language, package);

                            //Save the manifest
                            package.Manifest = packageWriter.WriteManifest(true);

                            //Save Package
                            PackageController.Instance.SaveExtensionPackage(package);

                            var languagePack = new LanguagePackInfo
                                {
                                    LanguageID = language.LanguageId,
                                    PackageID = package.PackageID,
                                    DependentPackageID = -2
                                };
                            LanguagePackController.SaveLanguagePack(languagePack);
                        }
                    }
                }
            }
			
            //Process Portal Locales files
            foreach (PortalInfo portal in PortalController.Instance.GetPortals())
            {
                int portalID = portal.PortalID;
                filePath = string.Format(Globals.ApplicationMapPath + Localization.Localization.ApplicationResourceDirectory.Substring(1).Replace("/", "\\") + "\\Locales.Portal-{0}.xml", portalID);

                if (File.Exists(filePath))
                {
                    var doc = new XPathDocument(filePath);

                    //Check for Browser and Url settings
                    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 LocaleController.Instance.GetLocales(Null.NullInteger).Values)
                    {
                        string code = installedLanguage.Code;
                        bool bFound = false;

                        //Check if this language is "inactive"
                        foreach (XPathNavigator inactiveNav in doc.CreateNavigator().Select("locales/inactive/locale"))
                        {
                            if (inactiveNav.Value == code)
                            {
                                bFound = true;
                                break;
                            }
                        }
                        if (!bFound)
                        {
							//Language is enabled - add to portal
                            Localization.Localization.AddLanguageToPortal(portalID, installedLanguage.LanguageId, false);
                        }
                    }
                }
                else
                {
                    foreach (Locale installedLanguage in LocaleController.Instance.GetLocales(Null.NullInteger).Values)
                    {
						//Language is enabled - add to portal
                        Localization.Localization.AddLanguageToPortal(portalID, installedLanguage.LanguageId, false);
                    }
                }
            }
        }