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); } } } }
private void PagePreRender(object sender, EventArgs e) { HttpContext context = HttpContext.Current; if (IsValid(context.Request)) { Page page = HttpContext.Current.Handler as Page; if (page == null) { return; } // TODO: Get Javascript and CSS from plugin properties string js = EmbeddedResources.GetString(string.Format("{0}console.js", EmbeddedResources.BasePath)); string css = EmbeddedResources.GetString(string.Format("{0}console.css", EmbeddedResources.BasePath)); string url = string.Format( "/ControlPanel/Utility/RevertTheme.aspx?ThemeTypeID={0}&ThemeContextID={1}&ThemeName={2}", SiteThemeContext.Instance().ThemeTypeID, Guid.Empty, CSContext.Current.SiteTheme); js += string.Format(@" $(function () {{ $.fourroads.plugins.themeConsole.register({{ urls: {{ modal: '{0}' }} }}); }})", url); Head.AddRawContent(string.Format(@"<style type=""text/css"">{0}</style>", css), HttpContext.Current); page.ClientScript.RegisterStartupScript(GetType(), "cacheconsole", js, true); } }
private static string LoadPageXml(string pageName) { var xml = new XmlDocument(); xml.LoadXml(EmbeddedResources.GetString("Telligent.Services.SamlAuthenticationPlugin.Resources.Pages." + pageName + ".xml")); var xmlNode = xml.SelectSingleNode("theme/contentFragmentPages/contentFragmentPage"); return(xmlNode != null ? xmlNode.OuterXml : String.Empty); }
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 } }
public void Uninstall() { if (!Diagnostics.IsDebug(GetType().Assembly)) { EmbeddedResources.EnumerateReosurces(BaseResourcePath + "Sql.", ".uninstall.sql", resourceName => { using (var connection = GetSqlConnection()) { connection.Open(); foreach (string statement in GetStatementsFromSqlBatch(EmbeddedResources.GetString(resourceName))) { using (var command = new SqlCommand(statement, connection)) { command.ExecuteNonQuery(); } } connection.Close(); } }); } }
public void Install(Version lastInstalledVersion) { if (lastInstalledVersion < Version) { Uninstall(); EmbeddedResources.EnumerateReosurces(BaseResourcePath + "Sql.", ".install.sql", resourceName => { using (var connection = GetSqlConnection()) { connection.Open(); foreach (string statement in GetStatementsFromSqlBatch(EmbeddedResources.GetString(resourceName))) { using (var command = new SqlCommand(statement, connection)) { command.ExecuteNonQuery(); } } connection.Close(); } }); } }
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); } } } }
public virtual void Install(Version lastInstalledVersion) { if (lastInstalledVersion < Version) { Uninstall(); string basePath = BaseResourcePath + "Widgets."; EmbeddedResources.EnumerateReosurces(basePath, ".xml", resourceName => { try { string widgetName = resourceName.Substring(basePath.Length); using (var stream = EmbeddedResources.GetStream(resourceName)) { FactoryDefaultScriptedContentFragmentProviderFiles.AddUpdateDefinitionFile(this, widgetName, stream); } // Get widget identifier XDocument xdoc = XDocument.Parse(EmbeddedResources.GetString(resourceName)); XElement root = xdoc.Root; if (root == null) { return; } XElement element = root.Element("scriptedContentFragment"); if (element == null) { return; } XAttribute attribute = element.Attribute("instanceIdentifier"); if (attribute == null) { return; } Guid instanceId = new Guid(attribute.Value); string widgetBasePath = string.Concat(basePath, char.IsNumber(attribute.Value[0]) ? "_" : "", instanceId.ToString("N"), "."); IEnumerable <string> supplementaryResources = GetType().Assembly.GetManifestResourceNames().Where(r => r.StartsWith(widgetBasePath)).ToArray(); if (!supplementaryResources.Any()) { return; } foreach (string supplementPath in supplementaryResources) { string supplementName = supplementPath.Substring(widgetBasePath.Length); using (var stream = EmbeddedResources.GetStream(supplementPath)) { FactoryDefaultScriptedContentFragmentProviderFiles .AddUpdateSupplementaryFile(this, instanceId, supplementName, stream); } } } catch (Exception exception) { new CSException(CSExceptionType.UnknownError, string.Format("Couldn't load widget from '{0}' embedded resource.", resourceName), exception).Log(); } }); } }
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 } }
public string loadFile(string name) { var f = "BubbleEngine." + name + ".lua"; return(EmbeddedResources.GetString(f)); }