Esempio n. 1
0
        public ActionResult Index() {
            bool installThemes = 
                _featureManager.GetEnabledFeatures().FirstOrDefault(f => f.Id == "PackagingServices") != null 
                && Services.Authorizer.Authorize(StandardPermissions.SiteOwner) // only site owners
                && _shellSettings.Name == ShellSettings.DefaultName; // of the default tenant

            var featuresThatNeedUpdate = _dataMigrationManager.GetFeaturesThatNeedUpdate();

            ThemeEntry currentTheme = null;
            ExtensionDescriptor currentThemeDescriptor = _siteThemeService.GetSiteTheme();
            if (currentThemeDescriptor != null) {
                currentTheme = new ThemeEntry(currentThemeDescriptor);
            }

            IEnumerable<ThemeEntry> themes = _extensionManager.AvailableExtensions()
                .Where(extensionDescriptor => {
                        bool hidden = false;
                        string tags = extensionDescriptor.Tags;
                        if (tags != null) {
                            hidden = tags.Split(',').Any(t => t.Trim().Equals("hidden", StringComparison.OrdinalIgnoreCase));
                        }

                        // is the theme allowed for this tenant ?
                        bool allowed = _shellSettings.Themes.Length == 0 || _shellSettings.Themes.Contains(extensionDescriptor.Id);

                        return !hidden && allowed &&
                                DefaultExtensionTypes.IsTheme(extensionDescriptor.ExtensionType) &&
                                (currentTheme == null ||
                                !currentTheme.Descriptor.Id.Equals(extensionDescriptor.Id));
                    })
                .Select(extensionDescriptor => {
                        ThemeEntry themeEntry = new ThemeEntry(extensionDescriptor) {
                            NeedsUpdate = featuresThatNeedUpdate.Contains(extensionDescriptor.Id),
                            IsRecentlyInstalled = _themeService.IsRecentlyInstalled(extensionDescriptor),
                            Enabled = _shellDescriptor.Features.Any(sf => sf.Name == extensionDescriptor.Id),
                            CanUninstall = installThemes
                        };

                        if (_extensionDisplayEventHandler != null) {
                            foreach (string notification in _extensionDisplayEventHandler.Displaying(themeEntry.Descriptor, ControllerContext.RequestContext))
                            {
                                themeEntry.Notifications.Add(notification);
                            }
                        }

                        return themeEntry;
                    })
                .ToArray();

            return View(new ThemesIndexViewModel {
                CurrentTheme = currentTheme,
                InstallThemes = installThemes,
                Themes = themes
            });
        }
Esempio n. 2
0
 private void WriteThemeLines(ThemeEntry theme) {
     Context.Output.WriteLine(T("  Name: {0}", theme.Name));
     Context.Output.WriteLine(T("    State:         {0}", theme.Enabled ? T("Enabled") : T("Disabled")));
     Context.Output.WriteLine(T("    NeedsUpdate:   {0}", theme.NeedsUpdate ? T("Yes") : T("No")));
     Context.Output.WriteLine(T("    Author:        {0}", theme.Descriptor.Author));
     Context.Output.WriteLine(T("    Version:       {0}", theme.Descriptor.Version));
     Context.Output.WriteLine(T("    Description:   {0}", theme.Descriptor.Description));
     Context.Output.WriteLine(T("    Website:       {0}", theme.Descriptor.WebSite));
     Context.Output.WriteLine(T("    Zones:         {0}", string.Join(", ", theme.Descriptor.Zones)));
     Context.Output.WriteLine();
 }
Esempio n. 3
0
        public ActionResult Index()
        {
            try {
                bool installThemes = _featureManager.GetEnabledFeatures().FirstOrDefault(f => f.Id == "PackagingServices") != null;

                var featuresThatNeedUpdate = _dataMigrationManager.GetFeaturesThatNeedUpdate();
                ThemeEntry currentTheme = new ThemeEntry(_siteThemeService.GetSiteTheme());
                IEnumerable<ThemeEntry> themes = _extensionManager.AvailableExtensions()
                    .Where(extensionDescriptor => {
                            bool hidden = false;
                            string tags = extensionDescriptor.Tags;
                            if (tags != null) {
                                hidden = tags.Split(',').Any(t => t.Trim().Equals("hidden", StringComparison.OrdinalIgnoreCase));
                            }

                            return !hidden &&
                                    DefaultExtensionTypes.IsTheme(extensionDescriptor.ExtensionType) &&
                                    !currentTheme.Descriptor.Id.Equals(extensionDescriptor.Id);
                        })
                    .Select(extensionDescriptor => {
                            ThemeEntry themeEntry = new ThemeEntry(extensionDescriptor) {
                                NeedsUpdate = featuresThatNeedUpdate.Contains(extensionDescriptor.Id),
                                IsRecentlyInstalled = _themeService.IsRecentlyInstalled(extensionDescriptor),
                                Enabled = _shellDescriptor.Features.Any(sf => sf.Name == extensionDescriptor.Id),
                                CanUninstall = installThemes
                            };

                            if (_extensionDisplayEventHandler != null) {
                                foreach (string notification in _extensionDisplayEventHandler.Displaying(themeEntry.Descriptor, ControllerContext.RequestContext))
                                {
                                    themeEntry.Notifications.Add(notification);
                                }
                            }

                            return themeEntry;
                        })
                    .ToArray();

                return View(new ThemesIndexViewModel {
                    CurrentTheme = currentTheme,
                    InstallThemes = installThemes,
                    Themes = themes
                });
            } catch (Exception exception) {
                this.Error(exception, T("Listing themes failed: {0}", exception.Message), Logger, Services.Notifier);

                return View(new ThemesIndexViewModel());
            }
        }