private void RemovePages(string assemblyName, IEnumerable <string> resourceNames)
        {
            var xml          = new XmlDocument();
            var contentPages = Pages(assemblyName, resourceNames);

            foreach (var theme in Themes.List(ThemeTypes.Group))
            {
                var supportedTheme = SupportedThemes.Get(theme.Id);
                if (supportedTheme == null)
                {
                    continue;
                }

                var themeName = supportedTheme.Name;
                foreach (var contentPage in contentPages.Where(p => p.Theme == themeName).ToList())
                {
                    xml.LoadXml(EmbeddedResources.GetString(contentPage.Path));
                    foreach (XmlNode xmlPage in xml.SelectNodes("//contentFragmentPage"))
                    {
                        var pageName = xmlPage.Attributes["pageName"].Value;
                        if (theme.IsConfigurationBased)
                        {
                            ThemePages.DeleteFactoryDefault(theme, pageName, false);
                        }
                        ThemePages.DeleteDefault(theme, pageName, false);
                        ThemePages.Delete(theme, pageName, false);
                    }
                }
            }
        }
Exemplo n.º 2
0
        public void Uninstall()
        {
            if (!Diagnostics.IsDebug(GetType().Assembly))
            {
                #region Delete custom pages from theme (factory defaults, configured defaults, and contextual pages)

                string basePath = BaseResourcePath + "Themes.";

                EmbeddedResources.EnumerateReosurces(basePath, ".xml", resourceName =>
                {
                    XmlDocument xml = new XmlDocument();

                    try
                    {
                        xml.LoadXml(EmbeddedResources.GetString(resourceName));
                        XmlNode node = xml.SelectSingleNode("/theme/contentFragmentPages/contentFragmentPage");

                        if (node == null || node.Attributes == null)
                        {
                            return;
                        }

                        string pageName  = node.Attributes["pageName"].Value;
                        string themeType = node.Attributes["themeType"].Value;

                        if (string.IsNullOrEmpty(pageName) || string.IsNullOrEmpty(themeType))
                        {
                            return;
                        }

                        foreach (Theme theme in Themes.List(Guid.Parse(themeType)))
                        {
                            if (theme != null)
                            {
                                if (theme.IsConfigurationBased)
                                {
                                    ThemePages.DeleteFactoryDefault(theme, pageName, true);
                                }

                                ThemePages.DeleteDefault(theme, pageName, true);
                                ThemePages.Delete(theme, pageName, true);
                            }
                        }
                    }
                    catch (Exception exception)
                    {
                        new CSException(CSExceptionType.UnknownError,
                                        string.Format("Couldn't delete page from '{0}' embedded resource.", resourceName), exception)
                        .Log();
                    }
                });

                #endregion
            }
        }
        void IInstallablePlugin.Install(Version lastInstalledVersion)
        {
            base.Install(lastInstalledVersion);

            foreach (var theme in Themes.List(ThemeTypes.Weblog))
            {
                if (ThemePages.FactoryDefaultExists(theme, "post", false))
                {
                    var fragments = ThemePageContentFragments.ListFactoryDefault(theme, "post", false);

                    var findFrag = GetScriptedFragmentName("66335d7ac5c841429709a730aec55ac9");

                    if (!fragments.Any(f => f.ContentFragmentType == findFrag))
                    {
                        ThemePageContentFragments.InsertInFactoryDefault(theme, "post", false, GetScriptedFragmentName("aa55795b63a949718dea4032197f3507"), ContentFragmentPlacement.After, findFrag, "fragmentHeader=%24%7Bresource%3AContentDiscuss_Header%7D&amp;textAreaSelector=.blog-post%20.post-content.user-defined-markup", "full-border with-header");
                    }
                }
            }
        }
        private void InstallPages(string assemblyName, IEnumerable <string> resourceNames)
        {
            var xml          = new XmlDocument();
            var contentPages = Pages(assemblyName, resourceNames);

            foreach (var theme in Themes.List(ThemeTypes.Group))
            {
                var supportedTheme = SupportedThemes.Get(theme.Id);
                if (supportedTheme == null)
                {
                    continue;
                }

                var themeName = supportedTheme.Name;
                foreach (var contentPage in contentPages.Where(p => p.Theme == themeName).ToList())
                {
                    xml.LoadXml(EmbeddedResources.GetString(contentPage.Path));
                    foreach (XmlNode xmlPage in xml.SelectNodes("//contentFragmentPage"))
                    {
                        var pageName = xmlPage.Attributes["pageName"].Value;
#if DEBUG
                        Telligent.Evolution.Extensibility.Api.Version1.PublicApi.Eventlogs.Write(string.Format("Adding Page \"{0}\"", pageName), new Telligent.Evolution.Extensibility.Api.Version1.EventLogEntryWriteOptions {
                            Category = "SharePoint", EventId = 1000, EventType = "Information"
                        });
#endif
                        if (theme.IsConfigurationBased)
                        {
                            ThemePages.AddUpdateFactoryDefault(theme, xmlPage);
                        }
                        if (!ThemePages.DefaultExists(theme, pageName, false))
                        {
                            ThemePages.AddUpdateDefault(theme, xmlPage);
                        }
                        ThemePages.AddUpdate(theme, ThemeTypes.Site, xmlPage);
                    }
                }
            }
        }
Exemplo n.º 5
0
        public void Install(Version lastInstalledVersion)
        {
            if (lastInstalledVersion < Version)
            {
                Uninstall();

                #region Install custom theme

                string basePath = BaseResourcePath + "Themes.";

                EmbeddedResources.EnumerateReosurces(basePath, ".xml", resourceName =>
                {
                    // Get widget identifier
                    XmlDocument xmlDocument = new XmlDocument();

                    try
                    {
                        xmlDocument.LoadXml(EmbeddedResources.GetString(resourceName));
                        XmlNode node = xmlDocument.SelectSingleNode("/theme/themeImplementation");

                        if (node != null)
                        {
                            ThemeConfigurations.DeserializeTheme(node, true, false);
                        }
                    }
                    catch (Exception exception)
                    {
                        new CSException(CSExceptionType.UnknownError,
                                        string.Format("Couldn't load theme from '{0}' embedded resource.", resourceName), exception).Log();
                    }
                });


                #endregion

                #region Install custom pages into theme (and revert any configured defaults or contextual versions of these pages)

                basePath = BaseResourcePath + "Pages.";

                EmbeddedResources.EnumerateReosurces(basePath, ".xml", resourceName =>
                {
                    XmlDocument xml = new XmlDocument();

                    try
                    {
                        xml.LoadXml(EmbeddedResources.GetString(resourceName));
                        XmlNode node = xml.SelectSingleNode("/theme/contentFragmentPages/contentFragmentPage");

                        if (node == null || node.Attributes == null)
                        {
                            return;
                        }

                        string pageName  = node.Attributes["pageName"].Value;
                        string themeType = node.Attributes["themeType"].Value;

                        if (string.IsNullOrEmpty(pageName) || string.IsNullOrEmpty(themeType))
                        {
                            return;
                        }

                        foreach (Theme theme in Themes.List(Guid.Parse(themeType)))
                        {
                            if (theme != null)
                            {
                                if (theme.IsConfigurationBased)
                                {
                                    ThemePages.AddUpdateFactoryDefault(theme, node);
                                    ThemePages.DeleteDefault(theme, pageName, true);
                                }
                                else
                                {
                                    ThemePages.AddUpdateDefault(theme, node);
                                }

                                ThemePages.Delete(theme, pageName, true);
                            }
                        }
                    }
                    catch (Exception exception)
                    {
                        new CSException(CSExceptionType.UnknownError, string.Format("Couldn't load page from '{0}' embedded resource.", resourceName), exception).Log();
                    }
                });

                #endregion
            }
        }