Ejemplo n.º 1
0
        /// -----------------------------------------------------------------------------
        /// <summary>
        /// This Constructor creates a new PackageInstaller instance
        /// </summary>
        /// <param name="package">A PackageInfo instance</param>
        /// <history>
        /// 	[cnurse]	01/21/2008  created
        /// </history>
        /// -----------------------------------------------------------------------------
        public PackageInstaller(PackageInfo package)
        {
            IsValid = true;
            DeleteFiles = Null.NullBoolean;
            Package = package;
            if (!string.IsNullOrEmpty(package.Manifest))
            {
				//Create an XPathDocument from the Xml
                var doc = new XPathDocument(new StringReader(package.Manifest));
                XPathNavigator nav = doc.CreateNavigator().SelectSingleNode("package");
                ReadComponents(nav);
            }
            else
            {
                ComponentInstallerBase installer = InstallerFactory.GetInstaller(package.PackageType);
                if (installer != null)
                {
					//Set package
                    installer.Package = package;

                    //Set type
                    installer.Type = package.PackageType;
                    _componentInstallers.Add(0, installer);
                }
            }
        }
Ejemplo n.º 2
0
        public WidgetPackageWriter(PackageInfo package) : base(package)
        {
            string company = package.Name;
            if(company.Contains("."))
            {
                company = company.Substring(0, company.IndexOf("."));
            }

            BasePath = Path.Combine("Resources\\Widgets\\User", company);
        }
        private void CreateCorePackage(bool createZip)
        {
            var Package = new PackageInfo();
            Package.Name = Globals.CleanFileName(txtFileName.Text);
            Package.Version = DotNetNukeContext.Current.Application.Version;
            Package.License = Util.PACKAGE_NoLicense;

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

            CreatePackage(Package, -2, "", fileName, createZip);
        }
Ejemplo n.º 4
0
        public ModulePackageWriter(DesktopModuleInfo desktopModule, XPathNavigator manifestNav, PackageInfo package) : base(package)
        {
            DesktopModule = desktopModule;

            Initialize(desktopModule.FolderName);
            if (manifestNav != null)
            {
                ReadLegacyManifest(manifestNav.SelectSingleNode("folders/folder"), false);
            }
            string physicalFolderPath = Path.Combine(Globals.ApplicationMapPath, BasePath);
            ProcessModuleFolders(physicalFolderPath, physicalFolderPath);
        }
Ejemplo n.º 5
0
 public ProviderPackageWriter(PackageInfo package) : base(package)
 {
     XmlDocument configDoc = Config.Load();
     XPathNavigator providerNavigator = configDoc.CreateNavigator().SelectSingleNode("/configuration/dotnetnuke/*/providers/add[@name='" + package.Name + "']");
     string providerPath = Null.NullString;
     if (providerNavigator != null)
     {
         providerPath = Util.ReadAttribute(providerNavigator, "providerPath");
     }
     if (!string.IsNullOrEmpty(providerPath))
     {
         BasePath = providerPath.Replace("~/", "").Replace("/", "\\");
     }
 }
        private void CreateAuthSystemPackage(PackageInfo authPackage, bool createZip)
        {
            var Package = new PackageInfo();
            Package.Name = authPackage.Name;
            Package.FriendlyName = authPackage.Name;
            Package.Version = authPackage.Version;
            Package.License = Util.PACKAGE_NoLicense;

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

            AuthenticationInfo authSystem = AuthenticationController.GetAuthenticationServiceByPackageID(authPackage.PackageID);
            string authPath = authSystem.LoginControlSrc.Substring(0, authSystem.LoginControlSrc.LastIndexOf("/"));
            CreatePackage(Package, authPackage.PackageID, authPath.Replace("/", "\\"), fileName, createZip);
        }
Ejemplo n.º 7
0
        private static PackageInfo CreateSkinPackage(SkinPackageInfo skin)
        {
			//Create a Package
            var package = new PackageInfo(new InstallerInfo());
            package.Name = skin.SkinName;
            package.FriendlyName = skin.SkinName;
            package.Description = Null.NullString;
            package.Version = new Version(1, 0, 0);
            package.PackageType = skin.SkinType;
            package.License = Util.PACKAGE_NoLicense;

            //See if the Skin is using a Namespace (or is a known skin)
            ParsePackageName(package);

            return package;
        }
        /// -----------------------------------------------------------------------------
        /// <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;
        }
        public SkinControlPackageWriter(XPathNavigator manifestNav, InstallerInfo installer)
        {
            SkinControl = new SkinControlInfo();

            //Create a Package
            Package = new PackageInfo(installer);

            ReadLegacyManifest(manifestNav, true);

            Package.Description = Null.NullString;
            Package.Version = new Version(1, 0, 0);
            Package.PackageType = "SkinObject";
            Package.License = Util.PACKAGE_NoLicense;

            BasePath = Path.Combine("DesktopModules", Package.Name.ToLower()).Replace("/", "\\");
            AppCodePath = Path.Combine("App_Code", Package.Name.ToLower()).Replace("/", "\\");
        }
Ejemplo n.º 10
0
        public ModulePackageWriter(XPathNavigator manifestNav, InstallerInfo installer)
        {
            DesktopModule = new DesktopModuleInfo();

            //Create a Package
            Package = new PackageInfo(installer);

            ReadLegacyManifest(manifestNav, true);

            Package.Name = DesktopModule.ModuleName;
            Package.FriendlyName = DesktopModule.FriendlyName;
            Package.Description = DesktopModule.Description;
            if (!string.IsNullOrEmpty(DesktopModule.Version))
            {
                Package.Version = new Version(DesktopModule.Version);
            }

            Package.PackageType = "Module";

            LegacyUtil.ParsePackageName(Package);

            Initialize(DesktopModule.FolderName);
        }
Ejemplo n.º 11
0
        public LanguagePackWriter(PackageInfo package) : base(package)
        {
            _LanguagePack = LanguagePackController.GetLanguagePackByPackage(package.PackageID);
            if (LanguagePack != null)
            {
                _Language = LocaleController.Instance.GetLocale(_LanguagePack.LanguageID);
                if (LanguagePack.PackageType == LanguagePackType.Core)
                {
                    BasePath = Null.NullString;
                }
                else
                {
					//Get the BasePath of the Dependent Package
                    PackageInfo dependendentPackage = PackageController.Instance.GetExtensionPackage(Null.NullInteger, p => p.PackageID == LanguagePack.DependentPackageID);
                    PackageWriterBase dependentPackageWriter = PackageWriterFactory.GetWriter(dependendentPackage);
                    BasePath = dependentPackageWriter.BasePath;
                }
            }
            else
            {
                BasePath = Null.NullString;
            }
        }
Ejemplo n.º 12
0
        public LanguagePackWriter(XPathNavigator manifestNav, InstallerInfo installer)
        {
            _Language = new Locale();
            XPathNavigator cultureNav = manifestNav.SelectSingleNode("Culture");
            _Language.Text = Util.ReadAttribute(cultureNav, "DisplayName");
            _Language.Code = Util.ReadAttribute(cultureNav, "Code");
            _Language.Fallback = Localization.Localization.SystemLocale;

            //Create a Package
            Package = new PackageInfo(installer);
            Package.Name = Language.Text;
            Package.FriendlyName = Language.Text;
            Package.Description = Null.NullString;
            Package.Version = new Version(1, 0, 0);
            Package.License = Util.PACKAGE_NoLicense;

            ReadLegacyManifest(manifestNav);

            if (_IsCore)
            {
                Package.PackageType = "CoreLanguagePack";
            }
            else
            {
                Package.PackageType = "ExtensionLanguagePack";
            }
            BasePath = Null.NullString;
        }
Ejemplo n.º 13
0
 public LanguagePackWriter(Locale language, PackageInfo package) : base(package)
 {
     _Language = language;
     BasePath = Null.NullString;
 }
        private void BindLanguageList()
        {
            try
            {
                var myResponseReader = UpdateService.GetLanguageList();
                //empty language list
                languageList.Items.Clear();

                //Loading into XML doc
                var xmlDoc = new XmlDocument();
                xmlDoc.Load(myResponseReader);
                var languages = xmlDoc.SelectNodes("available/language");
	            var packages = new List<PackageInfo>();

				if (languages != null)
				{
					foreach (XmlNode language in languages)
					{
						string cultureCode = "";
						string version = "";
						foreach (XmlNode child in language.ChildNodes)
						{
							if (child.Name == "culturecode")
							{
								cultureCode = child.InnerText;
							}

							if (child.Name == "version")
							{
								version = child.InnerText;
							}
						}
						if (!string.IsNullOrEmpty(cultureCode) && !string.IsNullOrEmpty(version) && version.Length == 6)
						{
							var myCIintl = new CultureInfo(cultureCode, true);
							version = version.Insert(4, ".").Insert(2, ".");
							var package = new PackageInfo { Name = "LanguagePack-" + myCIintl.Name, FriendlyName = myCIintl.NativeName };
							package.Name = myCIintl.NativeName;
							package.Description = cultureCode;
							Version ver = null;
							Version.TryParse(version, out ver);
							package.Version = ver;

							if (packages.Any(p => p.Name == package.Name))
							{
								var existPackage = packages.First(p => p.Name == package.Name);
								if (package.Version > existPackage.Version)
								{
									packages.Remove(existPackage);
									packages.Add(package);
								}
							}
							else
							{
								packages.Add(package);
							}
						}
					}
				}
				foreach (var package in packages)
                {
					var li = new ListItem { Value = package.Description, Text = package.Name };
		            languageList.AddItem(li.Text, li.Value);
		            RadComboBoxItem lastItem = languageList.Items[languageList.Items.Count - 1];
					if (DotNetNukeContext.Current.Application.Version.Major != package.Version.Major
						|| DotNetNukeContext.Current.Application.Version.Minor != package.Version.Minor
						|| DotNetNukeContext.Current.Application.Version.Build != package.Version.Build)
		            {
						lastItem.Attributes.Add("onclick", "javascript:LegacyLangaugePack('" + package.Version + "');");
		            }
                }
            }
            catch (Exception)
            {
                //suppress for now - need to decide what to do when webservice is unreachable
                //throw;
            }
            finally
            {
                //ensure there is always an en-us
                if (languageList.Items.FindItemByValue("en-US") == null)
                {
                    var myCIintl = new CultureInfo("en-US", true);
                    var li = new ListItem {Value = "en-US", Text = myCIintl.NativeName};
                    languageList.AddItem(li.Text, li.Value);
                    RadComboBoxItem lastItem = languageList.Items[languageList.Items.Count - 1];
                    lastItem.Attributes.Add("onclick", "javascript:ClearLegacyLangaugePack();");
                    languageList.Sort = RadComboBoxSort.Ascending;
                    languageList.Items.Sort();
                }
                var item = languageList.Items.FindItemByValue(_culture);
                languageList.SelectedIndex = item != null ? item.Index : languageList.Items.FindItemByValue("en-US").Index;
                languageList.Sort = RadComboBoxSort.Ascending;
                languageList.Items.Sort();
            }
        }
        private void BindGrid(string installPath, DataGrid grid)
        {
            var packages = new List<PackageInfo>();
            var invalidPackages = new List<string>();

            foreach (string file in Directory.GetFiles(installPath))
            {
                if (file.ToLower().EndsWith(".zip") || file.ToLower().EndsWith(".resources"))
                {
                    Stream inputStream = new FileStream(file, FileMode.Open, FileAccess.Read);
                    var unzip = new ZipInputStream(inputStream);

                    try
                    {
                        ZipEntry entry = unzip.GetNextEntry();

                        while (entry != null)
                        {
                            if (!entry.IsDirectory)
                            {
                                var fileName = entry.Name;
                                string extension = System.IO.Path.GetExtension(fileName);
                                if (extension.ToLower() == ".dnn" || extension.ToLower() == ".dnn5")
                                {
                                    //Manifest
                                    var manifestReader = new StreamReader(unzip);
                                    var manifest = manifestReader.ReadToEnd();

                                    var package = new PackageInfo();
                                    package.Manifest = manifest;
                                    if (!string.IsNullOrEmpty(manifest))
                                    {
                                        var doc = new XPathDocument(new StringReader(manifest));
                                        XPathNavigator rootNav = doc.CreateNavigator().SelectSingleNode("dotnetnuke");
                                        string packageType = String.Empty;
                                        if (rootNav.Name == "dotnetnuke")
                                        {
                                            packageType = XmlUtils.GetAttributeValue(rootNav, "type");
                                        }
                                        else if (rootNav.Name.ToLower() == "languagepack")
                                        {
                                            packageType = "LanguagePack";
                                        }
                                        XPathNavigator nav = null;
                                        switch (packageType.ToLower())
                                        {
                                            case "package":
                                                nav = rootNav.SelectSingleNode("packages/package");
                                                break;
                                            case "module":
                                            case "languagepack":
                                            case "skinobject":
                                                nav = Installer.ConvertLegacyNavigator(rootNav, new InstallerInfo()).SelectSingleNode("packages/package");
                                                break;
                                        }

                                        if (nav != null)
                                        {
                                            package.Name = XmlUtils.GetAttributeValue(nav, "name");
                                            package.PackageType = XmlUtils.GetAttributeValue(nav, "type");
                                            package.IsSystemPackage = XmlUtils.GetAttributeValueAsBoolean(nav, "isSystem", false);
                                            package.Version = new Version(XmlUtils.GetAttributeValue(nav, "version"));
                                            package.FriendlyName = XmlUtils.GetNodeValue(nav, "friendlyName");
                                            if (String.IsNullOrEmpty(package.FriendlyName))
                                            {
                                                package.FriendlyName = package.Name;
                                            }
                                            package.Description = XmlUtils.GetNodeValue(nav, "description");
                                            package.FileName = file.Replace(installPath + "\\", "");

                                            XPathNavigator foldernameNav = null;
                                            switch (package.PackageType)
                                            {
                                                case "Module":
                                                case "Auth_System":
                                                    foldernameNav = nav.SelectSingleNode("components/component/files");
                                                    if (foldernameNav != null) package.FolderName = Util.ReadElement(foldernameNav, "basePath").Replace('\\', '/');
                                                    break;
                                                case "Container":
                                                    foldernameNav = nav.SelectSingleNode("components/component/containerFiles");
                                                    if (foldernameNav != null) package.FolderName = Globals.glbContainersPath + Util.ReadElement(foldernameNav, "containerName").Replace('\\', '/');
                                                    break;
                                                case "Skin":
                                                    foldernameNav = nav.SelectSingleNode("components/component/skinFiles");
                                                    if (foldernameNav != null) package.FolderName = Globals.glbSkinsPath + Util.ReadElement(foldernameNav, "skinName").Replace('\\', '/');
                                                    break;
                                                default:
                                                    break;
                                            }

                                            XPathNavigator iconFileNav = nav.SelectSingleNode("iconFile");
                                            if (package.FolderName != string.Empty && iconFileNav != null)
                                            {

                                                if ((iconFileNav.Value != string.Empty) && (package.PackageType == "Module" || package.PackageType == "Auth_System" || package.PackageType == "Container" || package.PackageType == "Skin"))
                                                {
                                                    package.IconFile = package.FolderName + "/" + iconFileNav.Value;
                                                    package.IconFile = (!package.IconFile.StartsWith("~/")) ? "~/" + package.IconFile : package.IconFile;
                                                }
                                            }

                                            packages.Add(package);
                                        }
                                    }

                                    break;
                                }
                            }
                            entry = unzip.GetNextEntry();
                        }
                    }
                    catch (Exception)
                    {
                        invalidPackages.Add(file);
                    }
                    finally
                    {
                        unzip.Close();
                        unzip.Dispose();
                    }
                }
            }

            if (invalidPackages.Count > 0)
            {
                var pkgErrorsMsg = invalidPackages.Aggregate(string.Empty, (current, pkg) => current + (pkg + "<br />"));
                UI.Skins.Skin.AddModuleMessage(this, Localization.GetString("PackageErrors.Text", LocalResourceFile) + pkgErrorsMsg, ModuleMessage.ModuleMessageType.RedError);
            }

            grid.DataSource = packages;
            grid.DataBind();
        }
Ejemplo n.º 16
0
        /// -----------------------------------------------------------------------------
        /// <summary>
        /// This routine binds the package to the Property Editor
        /// </summary>
        /// <history>
        ///     [cnurse]   07/26/2007    Created
        /// </history>
        /// -----------------------------------------------------------------------------
        private void BindPackage()
        {
            CreateInstaller();
            if (Installer.IsValid)
            {
                if (_Installer.Packages.Count > 0)
                {
                    _Package = _Installer.Packages[0].Package;
                }

                //Bind Package Info
                packageForm.DataSource = _Package;
                packageForm.DataBind();

                //Bind License Info
                licenseForm.DataSource = _Package;
                licenseForm.DataBind();

                //Bind ReleaseNotes Info
                releaseNotesForm.DataSource = _Package;
                releaseNotesForm.DataBind();
            }
            else
            {
                //Error reading Manifest
                switch (wizInstall.ActiveStepIndex)
                {
                    case 0:
                        lblLoadMessage.Text = Localization.GetString("InstallError", LocalResourceFile);
                        phLoadLogs.Controls.Add(Installer.InstallerInfo.Log.GetLogsTable());
                        break;
                    case 3:
                        lblAcceptMessage.Text = Localization.GetString("InstallError", LocalResourceFile);
                        lblAcceptMessage.Visible = true;
                        phAcceptLogs.Controls.Add(Installer.InstallerInfo.Log.GetLogsTable());
                        break;
                }
            }
        }
Ejemplo n.º 17
0
        public static void ProcessLegacySkinControls()
        {
            foreach (SkinControlInfo skinControl in SkinControlController.GetSkinControls().Values)
            {
                if (skinControl.PackageID == Null.NullInteger)
                {
                    try
                    {
						//SkinControl is not affiliated with a Package
                        var package = new PackageInfo(new InstallerInfo());
                        package.Name = skinControl.ControlKey;

                        package.FriendlyName = skinControl.ControlKey;
                        package.Description = Null.NullString;
                        package.Version = new Version(1, 0, 0);
                        package.PackageType = "SkinObject";

                        //See if the SkinControl is using a "Namespace" for its name
                        ParsePackageName(package);

                        var skinControlWriter = new SkinControlPackageWriter(skinControl, package);
                        package.Manifest = skinControlWriter.WriteManifest(true);

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

                        //Update SkinControl with new PackageID
                        skinControl.PackageID = package.PackageID;

                        //Save SkinControl
                        SkinControlController.SaveSkinControl(skinControl);
                    }
                    catch (Exception exc)
                    {
                        Logger.Error(exc);

                    }
                }
            }
        }
Ejemplo n.º 18
0
 public static void ParsePackageName(PackageInfo package)
 {
     ParsePackageName(package, ".");
     if (string.IsNullOrEmpty(package.Owner))
     {
         ParsePackageName(package, "\\");
     }
     if (string.IsNullOrEmpty(package.Owner))
     {
         ParsePackageName(package, "_");
     }
     if (package.PackageType == "Module" && AdminModules.Contains(package.Name + ",") || package.PackageType == "Module" && CoreModules.Contains(package.Name + ",") ||
         (package.PackageType == "Container" || package.PackageType == "Skin") && KnownSkins.Contains(package.Name + ",") ||
         package.PackageType == "SkinObject" && KnownSkinObjects.Contains(package.Name + ","))
     {
         if (string.IsNullOrEmpty(package.Owner))
         {
             package.Owner = "DotNetNuke";
             package.Name = "DotNetNuke." + package.Name;
             switch (package.PackageType)
             {
                 case "Skin":
                     package.Name += ".Skin";
                     package.FriendlyName += " Skin";
                     break;
                 case "Container":
                     package.Name += ".Container";
                     package.FriendlyName += " Container";
                     break;
                 case "SkinObject":
                     package.Name += "SkinObject";
                     package.FriendlyName += " SkinObject";
                     break;
             }
         }
     }
     if (package.Owner == "DotNetNuke" || package.Owner == "DNN")
     {
         package.License = Localization.Localization.GetString("License", Localization.Localization.GlobalResourceFile);
         package.Organization = "DNN Corp.";
         package.Url = "http://www.dnnsoftware.com";
         package.Email = "*****@*****.**";
         package.ReleaseNotes = "There are no release notes for this version.";
     }
     else
     {
         package.License = Util.PACKAGE_NoLicense;
     }
 }
Ejemplo n.º 19
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);
                    }
                }
            }
        }
        /// <summary>
        /// </summary>
        /// <remarks>
        /// </remarks>
        /// <history>
        /// </history>
        private bool CreateModuleDefinition()
        {
            try
            {
                if (PackageController.Instance.GetExtensionPackage(Null.NullInteger, p => p.Name == GetClassName()) == null)
                {
                    var controlName = Null.NullString;

                    //Create module folder
                    CreateModuleFolder();

                    //Create module control
                    controlName = CreateModuleControl();
                    if (controlName != "")
                    {
                        //Create package
                        var objPackage = new PackageInfo();
                        objPackage.Name = GetClassName();
                        objPackage.FriendlyName = txtModule.Text;
                        objPackage.Description = txtDescription.Text;
                        objPackage.Version = new Version(1, 0, 0);
                        objPackage.PackageType = "Module";
                        objPackage.License = "";
                        objPackage.Owner = txtOwner.Text;
                        objPackage.Organization = txtOwner.Text;
                        objPackage.FolderName = "DesktopModules/" + GetFolderName();
                        objPackage.License = "The license for this package is not currently included within the installation file, please check with the vendor for full license details.";
                        objPackage.ReleaseNotes = "This package has no Release Notes.";
                        PackageController.Instance.SaveExtensionPackage(objPackage);

                        //Create desktopmodule
                        var objDesktopModules = new DesktopModuleController();
                        var objDesktopModule = new DesktopModuleInfo();
                        objDesktopModule.DesktopModuleID = Null.NullInteger;
                        objDesktopModule.ModuleName = GetClassName();
                        objDesktopModule.FolderName = GetFolderName();
                        objDesktopModule.FriendlyName = txtModule.Text;
                        objDesktopModule.Description = txtDescription.Text;
                        objDesktopModule.IsPremium = false;
                        objDesktopModule.IsAdmin = false;
                        objDesktopModule.Version = "01.00.00";
                        objDesktopModule.BusinessControllerClass = "";
                        objDesktopModule.CompatibleVersions = "";
                        objDesktopModule.Dependencies = "";
                        objDesktopModule.Permissions = "";
                        objDesktopModule.PackageID = objPackage.PackageID;
                        objDesktopModule.DesktopModuleID = objDesktopModules.AddDesktopModule(objDesktopModule);
                        objDesktopModule = objDesktopModules.GetDesktopModule(objDesktopModule.DesktopModuleID);

                        //Add OwnerName to the DesktopModule taxonomy and associate it with this module
                        var vocabularyId = -1;
                        var termId = -1;
                        var objTermController = DotNetNuke.Entities.Content.Common.Util.GetTermController();
                        var objTerms = objTermController.GetTermsByVocabulary("Module_Categories");
                        foreach (Term term in objTerms)
                        {
                            vocabularyId = term.VocabularyId;
                            if (term.Name == txtOwner.Text)
                            {
                                termId = term.TermId;
                            }
                        }
                        if (termId == -1)
                        {
                            termId = objTermController.AddTerm(new Term(vocabularyId) { Name = txtOwner.Text });
                        }
                        var objTerm = objTermController.GetTerm(termId);
                        var objContentController = DotNetNuke.Entities.Content.Common.Util.GetContentController();
                        var objContent = objContentController.GetContentItem(objDesktopModule.ContentItemId);
                        objTermController.AddTermToContent(objTerm, objContent);

                        //Add desktopmodule to all portals
                        DesktopModuleController.AddDesktopModuleToPortals(objDesktopModule.DesktopModuleID);

                        //Create module definition
                        var objModuleDefinition = new ModuleDefinitionInfo();
                        objModuleDefinition.ModuleDefID = Null.NullInteger;
                        objModuleDefinition.DesktopModuleID = objDesktopModule.DesktopModuleID;
                        // need core enhancement to have a unique DefinitionName  
                        objModuleDefinition.FriendlyName = GetClassName();
                        //objModuleDefinition.FriendlyName = txtModule.Text;
                        //objModuleDefinition.DefinitionName = GetClassName();
                        objModuleDefinition.DefaultCacheTime = 0;
                        objModuleDefinition.ModuleDefID = ModuleDefinitionController.SaveModuleDefinition(objModuleDefinition, false, true);

                        //Create modulecontrol
                        var objModuleControl = new ModuleControlInfo();
                        objModuleControl.ModuleControlID = Null.NullInteger;
                        objModuleControl.ModuleDefID = objModuleDefinition.ModuleDefID;
                        objModuleControl.ControlKey = "";
                        objModuleControl.ControlSrc = "DesktopModules/" + GetFolderName() + "/" + controlName;
                        objModuleControl.ControlTitle = "";
                        objModuleControl.ControlType = SecurityAccessLevel.View;
                        objModuleControl.HelpURL = "";
                        objModuleControl.IconFile = "";
                        objModuleControl.ViewOrder = 0;
                        objModuleControl.SupportsPartialRendering = false;
                        objModuleControl.SupportsPopUps = false;
                        ModuleControlController.AddModuleControl(objModuleControl);

                        //Update current module to reference new moduledefinition
                        var objModules = new ModuleController();
                        var objModule = objModules.GetModule(ModuleId, TabId, false);
                        objModule.ModuleDefID = objModuleDefinition.ModuleDefID;
                        objModule.ModuleTitle = txtModule.Text;

                        //HACK - need core enhancement to be able to update ModuleDefID
                        DotNetNuke.Data.DataProvider.Instance().ExecuteSQL("Update dbo.Modules set ModuleDefID = " + objModule.ModuleDefID.ToString() + " where ModuleID = " + ModuleId.ToString());

                        objModules.UpdateModule(objModule);

                        return true;
                    }
                    else
                    {
                        DotNetNuke.UI.Skins.Skin.AddModuleMessage(this, Localization.GetString("TemplateProblem.ErrorMessage", LocalResourceFile), ModuleMessage.ModuleMessageType.YellowWarning);
                        return false;
                    }
                }
                else
                {
                    DotNetNuke.UI.Skins.Skin.AddModuleMessage(this, Localization.GetString("AlreadyExists.ErrorMessage", LocalResourceFile), ModuleMessage.ModuleMessageType.YellowWarning);
                    return false;
                }
            }
            catch (Exception exc)
            {
                Exceptions.LogException(exc);
                DotNetNuke.UI.Skins.Skin.AddModuleMessage(this, exc.ToString(), ModuleMessage.ModuleMessageType.RedError);
                return false;
            }
        }
Ejemplo n.º 21
0
        private static void ParsePackageName(PackageInfo package, string separator)
        {
			//See if the Module is using a "Namespace" for its name
            int ownerIndex = package.Name.IndexOf(separator);
            if (ownerIndex > 0)
            {
                package.Owner = package.Name.Substring(0, ownerIndex);
            }
        }
Ejemplo n.º 22
0
        /// -----------------------------------------------------------------------------
        /// <summary>
        /// AddModuleDefinition adds a new Core Module Definition to the system
        /// </summary>
        /// <remarks>
        ///	This overload allows the caller to determine whether the module has a controller
        /// class
        /// </remarks>
        ///	<param name="desktopModuleName">The Friendly Name of the Module to Add</param>
        ///	<param name="description">Description of the Module</param>
        ///	<param name="moduleDefinitionName">The Module Definition Name</param>
        /// <param name="businessControllerClass">Business Control Class.</param>
        /// <param name="isPortable">Whether the module is enable for portals.</param>
        ///	<param name="premium">A flag representing whether the module is a Premium module</param>
        ///	<param name="admin">A flag representing whether the module is an Admin module</param>
        ///	<returns>The Module Definition Id of the new Module</returns>
        /// <history>
        /// 	[cnurse]	10/14/2004	documented
        ///     [cnurse]    11/11/2004  removed addition of Module Control (now in AddMOduleControl)
        /// </history>
        /// -----------------------------------------------------------------------------
        private static int AddModuleDefinition(string desktopModuleName, string description, string moduleDefinitionName, string businessControllerClass, bool isPortable, bool premium, bool admin)
        {
            DnnInstallLogger.InstallLogInfo(Localization.Localization.GetString("LogStart", Localization.Localization.GlobalResourceFile) + "AddModuleDefinition:" + desktopModuleName);
            // check if desktop module exists
            var desktopModule = DesktopModuleController.GetDesktopModuleByModuleName(desktopModuleName, Null.NullInteger);
            if (desktopModule == null)
            {
                var package = new PackageInfo
                                  {
                                      Description = description,
                                      FriendlyName = desktopModuleName,
                                      Name = string.Concat("DotNetNuke.", desktopModuleName),
                                      PackageType = "Module",
                                      Owner = "DNN",
                                      Organization = "DNN Corp.",
                                      Url = "http://www.dnnsoftware.com",
                                      Email = "*****@*****.**"
                                  };
                if (desktopModuleName == "Extensions" || desktopModuleName == "Skin Designer" || desktopModuleName == "Dashboard")
                {
                    package.IsSystemPackage = true;
                }
                package.Version = new Version(1, 0, 0);

                PackageController.Instance.SaveExtensionPackage(package);

                string moduleName = desktopModuleName.Replace(" ", "");
                desktopModule = new DesktopModuleInfo
                                    {
                                        DesktopModuleID = Null.NullInteger,
                                        PackageID = package.PackageID,
                                        FriendlyName = desktopModuleName,
                                        FolderName = "Admin/" + moduleName,
                                        ModuleName = moduleName,
                                        Description = description,
                                        Version = "01.00.00",
                                        BusinessControllerClass = businessControllerClass,
                                        IsPortable = isPortable,
                                        SupportedFeatures = 0
                                    };
                if ((isPortable))
                {
                    desktopModule.SupportedFeatures = 1;
                }
                desktopModule.IsPremium = premium;
                desktopModule.IsAdmin = admin;

                desktopModule.DesktopModuleID = DesktopModuleController.SaveDesktopModule(desktopModule, false, false);

                if (!premium)
                {
                    DesktopModuleController.AddDesktopModuleToPortals(desktopModule.DesktopModuleID);
                }
            }

            // check if module definition exists
            var moduleDefinition = ModuleDefinitionController.GetModuleDefinitionByFriendlyName(moduleDefinitionName, desktopModule.DesktopModuleID);
            if (moduleDefinition == null)
            {
                moduleDefinition = new ModuleDefinitionInfo { ModuleDefID = Null.NullInteger, DesktopModuleID = desktopModule.DesktopModuleID, FriendlyName = moduleDefinitionName };

                moduleDefinition.ModuleDefID = ModuleDefinitionController.SaveModuleDefinition(moduleDefinition, false, false);
            }
            return moduleDefinition.ModuleDefID;
        }
Ejemplo n.º 23
0
        /// -----------------------------------------------------------------------------
        /// <summary>
        /// The ReadManifest method reads the manifest file and parses it into components.
        /// </summary>
        /// <history>
        /// 	[cnurse]	07/24/2007  created
        /// </history>
        /// -----------------------------------------------------------------------------
        public override void ReadManifest(XPathNavigator manifestNav)
        {
            //Get Name Property
            Package.Name = Util.ReadAttribute(manifestNav, "name", Log, Util.EXCEPTION_NameMissing);

            //Get Type
            Package.PackageType = Util.ReadAttribute(manifestNav, "type", Log, Util.EXCEPTION_TypeMissing);

            //If Skin or Container then set PortalID
            if (Package.PackageType == "Skin" || Package.PackageType == "Container")
            {
                Package.PortalID = Package.InstallerInfo.PortalID;
            }
            CheckSecurity();
            if (!IsValid)
            {
                return;
            }
			
            //Attempt to get the Package from the Data Store (see if its installed)
            _installedPackage = PackageController.GetPackageByName(Package.PortalID, Package.Name);

            //Get IsSystem
            Package.IsSystemPackage = bool.Parse(Util.ReadAttribute(manifestNav, "isSystem", false, Log, "", bool.FalseString));

            //Get Version
            string strVersion = Util.ReadAttribute(manifestNav, "version", Log, Util.EXCEPTION_VersionMissing);
            ValidateVersion(strVersion);
            if (!IsValid)
            {
                return;
            }
            Log.AddInfo(Util.DNN_ReadingPackage + " - " + Package.PackageType + " - " + Package.Name);
            Package.FriendlyName = Util.ReadElement(manifestNav, "friendlyName", Package.Name);
            Package.Description = Util.ReadElement(manifestNav, "description");

            XPathNavigator foldernameNav = null;
            Package.FolderName = String.Empty;
            switch (Package.PackageType)
            {
                case "Module":
                    //In Dynamics moduels, a component:type=File can have a basePath pointing to the App_Conde folder. This is not a correct FolderName
                    //To ensure that FolderName is DesktopModules...
                    var folderNameValue = getSpecificFolderName(manifestNav, "components/component/files", "basePath", "DesktopModules");
                    if (!String.IsNullOrEmpty(folderNameValue)) Package.FolderName = folderNameValue.Replace('\\', '/');
                    break;
                case "Auth_System":
                    foldernameNav = manifestNav.SelectSingleNode("components/component/files");
                    if (foldernameNav != null) Package.FolderName = Util.ReadElement(foldernameNav, "basePath").Replace('\\', '/');
                    break;
                case "Container":
                    foldernameNav = manifestNav.SelectSingleNode("components/component/containerFiles");
                    if (foldernameNav != null) Package.FolderName = Globals.glbContainersPath +  Util.ReadElement(foldernameNav, "containerName").Replace('\\', '/');
                    break;
                case "Skin":
                    foldernameNav = manifestNav.SelectSingleNode("components/component/skinFiles");
                    if (foldernameNav != null) Package.FolderName = Globals.glbSkinsPath + Util.ReadElement(foldernameNav, "skinName").Replace('\\', '/');
                    break;
                default:
                    break;
            }

            //Get Icon
            XPathNavigator iconFileNav = manifestNav.SelectSingleNode("iconFile");
            if (iconFileNav != null)
            {
                if (iconFileNav.Value != string.Empty)
                {
                    if (iconFileNav.Value.StartsWith("~/"))
                    {
                        Package.IconFile = iconFileNav.Value;
                    }
                    else
                    {
                        Package.IconFile = (String.IsNullOrEmpty(Package.FolderName) ? "" :  Package.FolderName + "/") + iconFileNav.Value;
                        Package.IconFile = (!Package.IconFile.StartsWith("~/")) ? "~/" + Package.IconFile : Package.IconFile;
                    }
                }
            }
			//Get Author
            XPathNavigator authorNav = manifestNav.SelectSingleNode("owner");
            if (authorNav != null)
            {
                Package.Owner = Util.ReadElement(authorNav, "name");
                Package.Organization = Util.ReadElement(authorNav, "organization");
                Package.Url = Util.ReadElement(authorNav, "url");
                Package.Email = Util.ReadElement(authorNav, "email");
            }
			
            //Get License
            XPathNavigator licenseNav = manifestNav.SelectSingleNode("license");
            if (licenseNav != null)
            {
                string licenseSrc = Util.ReadAttribute(licenseNav, "src");
                if (string.IsNullOrEmpty(licenseSrc))
                {
					//Load from element
                    Package.License = licenseNav.Value;
                }
                else
                {
                    Package.License = ReadTextFromFile(licenseSrc);
                }
            }
            if (string.IsNullOrEmpty(Package.License))
            {
				//Legacy Packages have no license
                Package.License = Util.PACKAGE_NoLicense;
            }
			
            //Get Release Notes
            XPathNavigator relNotesNav = manifestNav.SelectSingleNode("releaseNotes");
            if (relNotesNav != null)
            {
                string relNotesSrc = Util.ReadAttribute(relNotesNav, "src");
                if (string.IsNullOrEmpty(relNotesSrc))
                {
					//Load from element
                    Package.ReleaseNotes = relNotesNav.Value;
                }
                else
                {
                    Package.ReleaseNotes = ReadTextFromFile(relNotesSrc);
                }
            }
            if (string.IsNullOrEmpty(Package.ReleaseNotes))
            {
				//Legacy Packages have no Release Notes
				Package.ReleaseNotes = Util.PACKAGE_NoReleaseNotes;
            }
			
            //Parse the Dependencies
            IDependency dependency = null;
            foreach (XPathNavigator dependencyNav in manifestNav.CreateNavigator().Select("dependencies/dependency"))
            {
                dependency = DependencyFactory.GetDependency(dependencyNav);
                if (!dependency.IsValid)
                {
                    Log.AddFailure(dependency.ErrorMessage);
                    return;
                }
            }
			
            //Read Components
            ReadComponents(manifestNav);
        }
Ejemplo n.º 24
0
        /// -----------------------------------------------------------------------------
        /// <summary>
        /// This Constructor creates a new PackageInstaller instance
        /// </summary>
        /// <param name="info">An InstallerInfo instance</param>
        /// <param name="packageManifest">The manifest as a string</param>
        /// <history>
        /// 	[cnurse]	01/16/2008  created
        /// </history>
        /// -----------------------------------------------------------------------------
        public PackageInstaller(string packageManifest, InstallerInfo info)
        {
            IsValid = true;
            DeleteFiles = Null.NullBoolean;
            Package = new PackageInfo(info);
            Package.Manifest = packageManifest;

            if (!string.IsNullOrEmpty(packageManifest))
            {
				//Create an XPathDocument from the Xml
                var doc = new XPathDocument(new StringReader(packageManifest));
                XPathNavigator nav = doc.CreateNavigator().SelectSingleNode("package");
                ReadManifest(nav);
            }
        }
Ejemplo n.º 25
0
        /// -----------------------------------------------------------------------------
        /// <summary>
        /// This Constructor creates a new Installer instance from a PackageInfo object
        /// </summary>
        /// <param name="package">The PackageInfo instance</param>
        /// <param name="physicalSitePath">The physical path to the root of the site</param>
        /// -----------------------------------------------------------------------------
        public Installer(PackageInfo package, string physicalSitePath)
        {
            Packages = new SortedList<int, PackageInstaller>();
            InstallerInfo = new InstallerInfo(package, physicalSitePath);

            Packages.Add(Packages.Count, new PackageInstaller(package));
        }
Ejemplo n.º 26
0
        public static void ProcessLegacyModule(DesktopModuleInfo desktopModule)
        {
            //Get the Module folder
            string moduleFolder = Path.Combine(Globals.ApplicationMapPath, Path.Combine("DesktopModules", desktopModule.FolderName));

            //Find legacy manifest
            XPathNavigator rootNav = null;
            try
            {
                string hostModules = "Portals, SQL, HostSettings, Scheduler, SearchAdmin, Lists, SkinDesigner, Extensions";
                string[] files = Directory.GetFiles(moduleFolder, "*.dnn.config");
                if (files.Length > 0)
                {
                    //Create an XPathDocument from the Xml
                    var doc = new XPathDocument(new FileStream(files[0], FileMode.Open, FileAccess.Read));
                    rootNav = doc.CreateNavigator().SelectSingleNode("dotnetnuke");
                }

                //Module is not affiliated with a Package
                var package = new PackageInfo(new InstallerInfo());
                package.Name = desktopModule.ModuleName;

                package.FriendlyName = desktopModule.FriendlyName;
                package.Description = desktopModule.Description;
                package.Version = new Version(1, 0, 0);
                if (!string.IsNullOrEmpty(desktopModule.Version))
                {
                    package.Version = new Version(desktopModule.Version);
                }
                if (hostModules.Contains(desktopModule.ModuleName))
                {
                    //Host Module so make this a system package
                    package.IsSystemPackage = true;
                    desktopModule.IsAdmin = true;
                }
                else
                {
                    desktopModule.IsAdmin = false;
                }
                package.PackageType = "Module";

                //See if the Module is using a "Namespace" for its name
                ParsePackageName(package);

                if (files.Length > 0)
                {
                    var modulewriter = new ModulePackageWriter(desktopModule, rootNav, package);
                    package.Manifest = modulewriter.WriteManifest(true);
                }
                else
                {
                    package.Manifest = ""; //module has no manifest
                }

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

                //Update Desktop Module with new PackageID
                desktopModule.PackageID = package.PackageID;

                //Save DesktopModule
                DesktopModuleController.SaveDesktopModule(desktopModule, false, false);
            }
            catch (Exception exc)
            {
                Logger.Error(exc);

            }            
        }
Ejemplo n.º 27
0
        private static void UpgradeToVersion513()
        {
            //Ensure that default language is present (not neccessarily enabled)
            var defaultLanguage = LocaleController.Instance.GetLocale("en-US") ?? new Locale();
            defaultLanguage.Code = "en-US";
            defaultLanguage.Text = "English (United States)";
            Localization.Localization.SaveLanguage(defaultLanguage);

            //Ensure that there is a Default Authorization System
            var package = PackageController.Instance.GetExtensionPackage(Null.NullInteger, p => p.Name == "DefaultAuthentication");
            if (package == null)
            {
                package = new PackageInfo
                              {
                                  Name = "DefaultAuthentication",
                                  FriendlyName = "Default Authentication",
                                  Description = "The Default UserName/Password Authentication System for DotNetNuke.",
                                  PackageType = "Auth_System",
                                  Version = new Version(1, 0, 0),
                                  Owner = "DNN",
                                  License = Localization.Localization.GetString("License", Localization.Localization.GlobalResourceFile),
                                  Organization = "DNN Corp.",
                                  Url = "http://www.dnnsoftware.com",
                                  Email = "*****@*****.**",
                                  ReleaseNotes = "There are no release notes for this version.",
                                  IsSystemPackage = true
                              };
                PackageController.Instance.SaveExtensionPackage(package);

                //Add Authentication System
                var authSystem = AuthenticationController.GetAuthenticationServiceByType("DNN") ?? new AuthenticationInfo();
                authSystem.PackageID = package.PackageID;
                authSystem.AuthenticationType = "DNN";
                authSystem.SettingsControlSrc = "DesktopModules/AuthenticationServices/DNN/Settings.ascx";
                authSystem.LoginControlSrc = "DesktopModules/AuthenticationServices/DNN/Login.ascx";
                authSystem.IsEnabled = true;

                if (authSystem.AuthenticationID == Null.NullInteger)
                {
                    AuthenticationController.AddAuthentication(authSystem);
                }
                else
                {
                    AuthenticationController.UpdateAuthentication(authSystem);
                }
            }
        }
        private void BindGrid(string type, DataGrid grid, HtmlGenericControl noItemsControl)
        {
            var installPath = Globals.ApplicationMapPath + "\\Install\\" + type;
            var packages = new List<PackageInfo>();
            var invalidPackages = new List<string>();

            foreach (string file in Directory.GetFiles(installPath))
            {
                if (file.ToLower().EndsWith(".zip") || file.ToLower().EndsWith(".resources"))
                {
                    Stream inputStream = new FileStream(file, FileMode.Open, FileAccess.Read);
                    var unzip = new ZipInputStream(inputStream);

                    try
                    {
                        ZipEntry entry = unzip.GetNextEntry();

                        while (entry != null)
                        {
                            if (!entry.IsDirectory)
                            {
                                var fileName = entry.Name;
                                string extension = Path.GetExtension(fileName);
                                if (extension.ToLower() == ".dnn" || extension.ToLower() == ".dnn5")
                                {
                                    //Manifest
                                    var manifestReader = new StreamReader(unzip);
                                    var manifest = manifestReader.ReadToEnd();

                                    var package = new PackageInfo();
                                    package.Manifest = manifest;
                                    if (!string.IsNullOrEmpty(manifest))
                                    {
                                        var doc = new XPathDocument(new StringReader(manifest));
                                        XPathNavigator rootNav = doc.CreateNavigator().SelectSingleNode("dotnetnuke");
                                        string packageType = String.Empty;
                                        if (rootNav.Name == "dotnetnuke")
                                        {
                                            packageType = XmlUtils.GetAttributeValue(rootNav, "type");
                                        }
                                        else if (rootNav.Name.ToLower() == "languagepack")
                                        {
                                            packageType = "LanguagePack";
                                        }
                                        XPathNavigator nav = null;
                                        switch (packageType.ToLower())
                                        {
                                            case "package":
                                                nav = rootNav.SelectSingleNode("packages/package");
                                                break;

                                            case "languagepack":

                                                //nav = Installer.ConvertLegacyNavigator(rootNav, new InstallerInfo()).SelectSingleNode("packages/package");
                                                break;
                                        }

                                        if (nav != null)
                                        {
                                            package.Name = XmlUtils.GetAttributeValue(nav, "name");
                                            package.PackageType = XmlUtils.GetAttributeValue(nav, "type");
                                            package.IsSystemPackage = XmlUtils.GetAttributeValueAsBoolean(nav, "isSystem", false);
                                            package.Version = new Version(XmlUtils.GetAttributeValue(nav, "version"));
                                            package.FriendlyName = XmlUtils.GetNodeValue(nav, "friendlyName");
                                            if (String.IsNullOrEmpty(package.FriendlyName))
                                            {
                                                package.FriendlyName = package.Name;
                                            }

                                            package.Description = XmlUtils.GetNodeValue(nav, "description");
                                            package.FileName = file.Replace(installPath + "\\", "");

                                            packages.Add(package);
                                        }
                                    }

                                    break;
                                }
                            }
                            entry = unzip.GetNextEntry();
                        }
                    }
                    catch (Exception)
                    {
                        invalidPackages.Add(file);
                    }
                    finally
                    {
                        unzip.Close();
                        unzip.Dispose();
                    }
                }
            }

            if (invalidPackages.Count > 0)
            {
                var pkgErrorsMsg = invalidPackages.Aggregate(string.Empty, (current, pkg) => current + (pkg + "<br />"));
                Skin.AddModuleMessage(this, Localization.GetString("PackageErrors.Text", LocalResourceFile) + pkgErrorsMsg, ModuleMessage.ModuleMessageType.RedError);
            }

            if (packages.Count == 0)
            {
                noItemsControl.Visible = true;
                grid.Visible = false;    
            }
            else
            {
                noItemsControl.Visible = false;
                grid.DataSource = packages;
                grid.DataBind();
            }            
        }
Ejemplo n.º 29
0
        /// -----------------------------------------------------------------------------
        /// <summary>
        /// AddSkinControl adds a new Module Control to the system
        /// </summary>
        /// <remarks>
        /// </remarks>
        ///	<param name="controlKey">The key for this control in the Definition</param>
        /// <param name="packageName">Package Name.</param>
        ///	<param name="controlSrc">Te source of ths control</param>
        /// <history>
        /// 	[cnurse]	05/26/2008	created
        /// </history>
        /// -----------------------------------------------------------------------------
        private static void AddSkinControl(string controlKey, string packageName, string controlSrc)
        {
            DnnInstallLogger.InstallLogInfo(Localization.Localization.GetString("LogStart", Localization.Localization.GlobalResourceFile) + "AddSkinControl:" + controlKey);
            // check if skin control exists
            SkinControlInfo skinControl = SkinControlController.GetSkinControlByKey(controlKey);
            if (skinControl == null)
            {
                var package = new PackageInfo { Name = packageName, FriendlyName = string.Concat(controlKey, "SkinObject"), PackageType = "SkinObject", Version = new Version(1, 0, 0) };
                LegacyUtil.ParsePackageName(package);

                PackageController.Instance.SaveExtensionPackage(package);

                skinControl = new SkinControlInfo { PackageID = package.PackageID, ControlKey = controlKey, ControlSrc = controlSrc, SupportsPartialRendering = false };

                SkinControlController.SaveSkinControl(skinControl);
            }
        }
Ejemplo n.º 30
0
 public WidgetComponentWriter(string basePath, Dictionary<string, InstallFile> files, PackageInfo package) : base(basePath, files, package)
 {
 }