Esempio n. 1
0
        /// -----------------------------------------------------------------------------
        /// <summary>
        /// Exports the selected portal
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        /// <remarks>
        /// Template will be saved in Portals\_default folder.
        /// An extension of .template will be added to filename if not entered
        /// </remarks>
        /// <history>
        ///     [VMasanas]	23/09/2004	Created
        ///     [cnurse]	11/08/2004	Addition of files to template
        ///     [aprasad]	1/17/2011	New setting AutoAddPortalAlias
        /// </history>
        /// -----------------------------------------------------------------------------
        private void cmdExport_Click(Object sender, EventArgs e)
        {
            try
            {
                ZipOutputStream resourcesFile;
                var             sb       = new StringBuilder();
                var             settings = new XmlWriterSettings();
                settings.ConformanceLevel   = ConformanceLevel.Fragment;
                settings.OmitXmlDeclaration = true;
                settings.Indent             = true;

                if (!Page.IsValid)
                {
                    return;
                }
                string filename;
                filename = Globals.HostMapPath + txtTemplateName.Text;
                if (!filename.EndsWith(".template"))
                {
                    filename += ".template";
                }
                XmlWriter writer = XmlWriter.Create(filename, settings);

                writer.WriteStartElement("portal");
                writer.WriteAttributeString("version", "5.0");

                //Add template description
                writer.WriteElementString("description", Server.HtmlEncode(txtDescription.Text));

                //Serialize portal settings
                PortalInfo objportal;
                var        objportals = new PortalController();
                objportal = objportals.GetPortal(Convert.ToInt32(cboPortals.SelectedValue));

                writer.WriteStartElement("settings");

                writer.WriteElementString("logofile", objportal.LogoFile);
                writer.WriteElementString("footertext", objportal.FooterText);
                writer.WriteElementString("userregistration", objportal.UserRegistration.ToString());
                writer.WriteElementString("banneradvertising", objportal.BannerAdvertising.ToString());
                writer.WriteElementString("defaultlanguage", objportal.DefaultLanguage);

                Dictionary <string, string> settingsDictionary = PortalController.GetPortalSettingsDictionary(objportal.PortalID);

                string setting = "";
                settingsDictionary.TryGetValue("DefaultPortalSkin", out setting);
                if (!string.IsNullOrEmpty(setting))
                {
                    writer.WriteElementString("skinsrc", setting);
                }
                settingsDictionary.TryGetValue("DefaultAdminSkin", out setting);
                if (!string.IsNullOrEmpty(setting))
                {
                    writer.WriteElementString("skinsrcadmin", setting);
                }
                settingsDictionary.TryGetValue("DefaultPortalContainer", out setting);
                if (!string.IsNullOrEmpty(setting))
                {
                    writer.WriteElementString("containersrc", setting);
                }
                settingsDictionary.TryGetValue("DefaultAdminContainer", out setting);
                if (!string.IsNullOrEmpty(setting))
                {
                    writer.WriteElementString("containersrcadmin", setting);
                }
                settingsDictionary.TryGetValue("EnableSkinWidgets", out setting);
                if (!string.IsNullOrEmpty(setting))
                {
                    writer.WriteElementString("enableskinwidgets", setting);
                }
                settingsDictionary.TryGetValue("portalaliasmapping", out setting);
                if (!String.IsNullOrEmpty(setting))
                {
                    writer.WriteElementString("portalaliasmapping", setting);
                }
                settingsDictionary.TryGetValue("ContentLocalizationEnabled", out setting);
                if (!String.IsNullOrEmpty(setting))
                {
                    writer.WriteElementString("contentlocalizationenabled", setting);
                }
                settingsDictionary.TryGetValue("TimeZone", out setting);
                if (!string.IsNullOrEmpty(setting))
                {
                    writer.WriteElementString("timezone", setting);
                }

                writer.WriteElementString("hostspace", objportal.HostSpace.ToString());
                writer.WriteElementString("userquota", objportal.UserQuota.ToString());
                writer.WriteElementString("pagequota", objportal.PageQuota.ToString());

                //End Portal Settings
                writer.WriteEndElement();

                //Serialize Profile Definitions
                SerializeProfileDefinitions(writer, objportal);

                //Serialize Portal Desktop Modules
                DesktopModuleController.SerializePortalDesktopModules(writer, objportal.PortalID);

                //Serialize Roles
                RoleController.SerializeRoleGroups(writer, objportal.PortalID);

                //Serialize tabs
                SerializeTabs(writer, objportal);

                if (chkContent.Checked)
                {
                    //Create Zip File to hold files
                    resourcesFile = new ZipOutputStream(File.Create(filename + ".resources"));
                    resourcesFile.SetLevel(6);

                    //Serialize folders (while adding files to zip file)
                    SerializeFolders(writer, objportal, ref resourcesFile);

                    //Finish and Close Zip file
                    resourcesFile.Finish();
                    resourcesFile.Close();
                }
                writer.WriteEndElement();

                writer.Close();

                DotNetNuke.UI.Skins.Skin.AddModuleMessage(this, "", string.Format(Localization.GetString("ExportedMessage", LocalResourceFile), filename), ModuleMessage.ModuleMessageType.GreenSuccess);
            }
            catch (Exception exc)
            {
                Exceptions.ProcessModuleLoadException(this, exc);
            }
        }
Esempio n. 2
0
        /// -----------------------------------------------------------------------------
        /// <summary>
        /// Exports the selected portal
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        /// <remarks>
        /// Template will be saved in Portals\_default folder.
        /// An extension of .template will be added to filename if not entered
        /// </remarks>
        /// <history>
        ///     [VMasanas]	23/09/2004	Created
        ///     [cnurse]	11/08/2004	Addition of files to template
        ///     [aprasad]	1/17/2011	New setting AutoAddPortalAlias
        /// </history>
        /// -----------------------------------------------------------------------------
        private void cmdExport_Click(Object sender, EventArgs e)
        {
            try
            {
                // Validations
                bool isValid = true;

                // Verify all ancestor pages are selected
                foreach (RadTreeNode page in ctlPages.CheckedNodes)
                {
                    if (page.ParentNode != null && page.ParentNode.Value != "-1" && !page.ParentNode.Checked)
                    {
                        isValid = false;
                    }
                }
                if (!isValid)
                {
                    DotNetNuke.UI.Skins.Skin.AddModuleMessage(this, LocalizeString("ErrorAncestorPages"), ModuleMessage.ModuleMessageType.RedError);
                }

                if (ctlPages.CheckedNodes.Count == 0)
                {
                    isValid = false;
                    DotNetNuke.UI.Skins.Skin.AddModuleMessage(this, LocalizeString("ErrorPages"), ModuleMessage.ModuleMessageType.RedError);
                }

                if (!Page.IsValid || !isValid)
                {
                    return;
                }

                ZipOutputStream resourcesFile;
                var             sb       = new StringBuilder();
                var             settings = new XmlWriterSettings();
                settings.ConformanceLevel   = ConformanceLevel.Fragment;
                settings.OmitXmlDeclaration = true;
                settings.Indent             = true;

                string filename;
                filename = Globals.HostMapPath + txtTemplateName.Text;
                if (!filename.EndsWith(".template"))
                {
                    filename += ".template";
                }
                XmlWriter writer = XmlWriter.Create(filename, settings);

                writer.WriteStartElement("portal");
                writer.WriteAttributeString("version", "5.0");

                //Add template description
                writer.WriteElementString("description", Server.HtmlEncode(txtDescription.Text));

                //Serialize portal settings
                var portal = PortalController.Instance.GetPortal(Convert.ToInt32(cboPortals.SelectedValue));

                this.SerializePortalSettings(writer, portal);
                this.SerializeEnabledLocales(writer, portal);
                SerializeExtensionUrlProviders(writer, portal.PortalID);

                if (chkProfile.Checked)
                {
                    //Serialize Profile Definitions
                    SerializeProfileDefinitions(writer, portal);
                }

                if (chkModules.Checked)
                {
                    //Serialize Portal Desktop Modules
                    DesktopModuleController.SerializePortalDesktopModules(writer, portal.PortalID);
                }

                if (chkRoles.Checked)
                {
                    //Serialize Roles
                    RoleController.SerializeRoleGroups(writer, portal.PortalID);
                }

                //Serialize tabs
                SerializeTabs(writer, portal);

                if (chkFiles.Checked)
                {
                    //Create Zip File to hold files
                    resourcesFile = new ZipOutputStream(File.Create(filename + ".resources"));
                    resourcesFile.SetLevel(6);

                    //Serialize folders (while adding files to zip file)
                    SerializeFolders(writer, portal, ref resourcesFile);

                    //Finish and Close Zip file
                    resourcesFile.Finish();
                    resourcesFile.Close();
                }
                writer.WriteEndElement();

                writer.Close();

                DotNetNuke.UI.Skins.Skin.AddModuleMessage(this, "", string.Format(Localization.GetString("ExportedMessage", LocalResourceFile), filename), ModuleMessage.ModuleMessageType.GreenSuccess);
            }
            catch (Exception exc)
            {
                Exceptions.ProcessModuleLoadException(this, exc);
            }
        }