mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-09-22 20:13:50 +08:00
Converting module and themes entries to shapes on module and theme projects. Adding recently updated notifications. Fixing small issue in Layout.Title.
--HG-- branch : dev rename : src/Orchard.Web/Modules/Orchard.Modules/ViewModels/Module.cs => src/Orchard.Web/Modules/Orchard.Modules/Models/ModuleEntry.cs rename : src/Orchard.Web/Modules/Orchard.Modules/ViewModels/ModuleFeature.cs => src/Orchard.Web/Modules/Orchard.Modules/Models/ModuleFeature.cs
This commit is contained in:
@@ -1,6 +1,9 @@
|
||||
@using Orchard.Utility.Extensions;
|
||||
@{
|
||||
Layout.Title = Model.Title;
|
||||
if (Model.Title != null) {
|
||||
Layout.Title = Model.Title;
|
||||
}
|
||||
|
||||
var contentTypeClassName = ((string)Model.ContentItem.ContentType).HtmlClassify();
|
||||
}
|
||||
<article class="content-item @contentTypeClassName">
|
||||
|
@@ -9,6 +9,8 @@ using Orchard.Environment.Extensions.Models;
|
||||
using Orchard.Environment.Features;
|
||||
using Orchard.Localization;
|
||||
using Orchard.Logging;
|
||||
using Orchard.Modules.Events;
|
||||
using Orchard.Modules.Models;
|
||||
using Orchard.Modules.Services;
|
||||
using Orchard.Modules.ViewModels;
|
||||
using Orchard.Reports.Services;
|
||||
@@ -18,6 +20,7 @@ using Orchard.Utility.Extensions;
|
||||
|
||||
namespace Orchard.Modules.Controllers {
|
||||
public class AdminController : Controller {
|
||||
private readonly IExtensionDisplayEventHandler _extensionDisplayEventHandler;
|
||||
private readonly IModuleService _moduleService;
|
||||
private readonly IDataMigrationManager _dataMigrationManager;
|
||||
private readonly IReportsCoordinator _reportsCoordinator;
|
||||
@@ -25,7 +28,9 @@ namespace Orchard.Modules.Controllers {
|
||||
private readonly IFeatureManager _featureManager;
|
||||
private readonly ShellDescriptor _shellDescriptor;
|
||||
|
||||
public AdminController(IOrchardServices services,
|
||||
public AdminController(
|
||||
IEnumerable<IExtensionDisplayEventHandler> extensionDisplayEventHandlers,
|
||||
IOrchardServices services,
|
||||
IModuleService moduleService,
|
||||
IDataMigrationManager dataMigrationManager,
|
||||
IReportsCoordinator reportsCoordinator,
|
||||
@@ -34,6 +39,7 @@ namespace Orchard.Modules.Controllers {
|
||||
ShellDescriptor shellDescriptor)
|
||||
{
|
||||
Services = services;
|
||||
_extensionDisplayEventHandler = extensionDisplayEventHandlers.FirstOrDefault();
|
||||
_moduleService = moduleService;
|
||||
_dataMigrationManager = dataMigrationManager;
|
||||
_reportsCoordinator = reportsCoordinator;
|
||||
@@ -53,11 +59,22 @@ namespace Orchard.Modules.Controllers {
|
||||
if (!Services.Authorizer.Authorize(StandardPermissions.SiteOwner, T("Not allowed to manage modules")))
|
||||
return new HttpUnauthorizedResult();
|
||||
|
||||
IEnumerable<Module> modules = _extensionManager.AvailableExtensions()
|
||||
IEnumerable<ModuleEntry> modules = _extensionManager.AvailableExtensions()
|
||||
.Where(x => DefaultExtensionTypes.IsModule(x.ExtensionType))
|
||||
.Select(extensionDescriptor => new Module(extensionDescriptor) {
|
||||
.Select(extensionDescriptor => {
|
||||
ModuleEntry moduleEntry = new ModuleEntry {
|
||||
Descriptor = extensionDescriptor,
|
||||
IsRecentlyInstalled = _moduleService.IsRecentlyInstalled(extensionDescriptor)
|
||||
});
|
||||
};
|
||||
|
||||
if (_extensionDisplayEventHandler != null) {
|
||||
foreach (string notification in _extensionDisplayEventHandler.Displaying(moduleEntry.Descriptor)) {
|
||||
moduleEntry.Notifications.Add(notification);
|
||||
}
|
||||
}
|
||||
|
||||
return moduleEntry;
|
||||
});
|
||||
|
||||
return View(new ModulesIndexViewModel {
|
||||
Modules = modules,
|
||||
|
@@ -0,0 +1,12 @@
|
||||
using System.Collections.Generic;
|
||||
using Orchard.Environment.Extensions.Models;
|
||||
using Orchard.Events;
|
||||
|
||||
namespace Orchard.Modules.Events {
|
||||
public interface IExtensionDisplayEventHandler : IEventHandler {
|
||||
/// <summary>
|
||||
/// Called before an extension is displayed
|
||||
/// </summary>
|
||||
IEnumerable<string> Displaying(ExtensionDescriptor extensionDescriptor);
|
||||
}
|
||||
}
|
@@ -1,21 +1,16 @@
|
||||
using Orchard.Environment.Extensions.Models;
|
||||
using System.Collections.Generic;
|
||||
using Orchard.Environment.Extensions.Models;
|
||||
|
||||
namespace Orchard.Modules.ViewModels {
|
||||
namespace Orchard.Modules.Models {
|
||||
/// <summary>
|
||||
/// Represents a module.
|
||||
/// </summary>
|
||||
public class Module {
|
||||
public class ModuleEntry {
|
||||
/// <summary>
|
||||
/// Default constructor.
|
||||
/// </summary>
|
||||
public Module() {}
|
||||
|
||||
/// <summary>
|
||||
/// Instantiates a module based on an extension descriptor.
|
||||
/// </summary>
|
||||
/// <param name="extensionDescriptor">The extension descriptor.</param>
|
||||
public Module(ExtensionDescriptor extensionDescriptor) {
|
||||
Descriptor = extensionDescriptor;
|
||||
public ModuleEntry() {
|
||||
Notifications = new List<string>();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -32,5 +27,10 @@ namespace Orchard.Modules.ViewModels {
|
||||
/// Boolean value indicating if the feature was recently installed.
|
||||
/// </summary>
|
||||
public bool IsRecentlyInstalled { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// List of module notifications.
|
||||
/// </summary>
|
||||
public List<string> Notifications { get; set; }
|
||||
}
|
||||
}
|
@@ -1,6 +1,6 @@
|
||||
using Orchard.Environment.Extensions.Models;
|
||||
|
||||
namespace Orchard.Modules.ViewModels {
|
||||
namespace Orchard.Modules.Models {
|
||||
/// <summary>
|
||||
/// Represents a module's feature.
|
||||
/// </summary>
|
@@ -43,6 +43,7 @@
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\..\..\..\lib\autofac\Autofac.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Web" />
|
||||
<Reference Include="System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
@@ -52,14 +53,15 @@
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="AdminMenu.cs" />
|
||||
<Compile Include="Events\IExtensionDisplayEventHandler.cs" />
|
||||
<Compile Include="ResourceManifest.cs" />
|
||||
<Compile Include="Commands\FeatureCommands.cs" />
|
||||
<Compile Include="Controllers\AdminController.cs" />
|
||||
<Compile Include="Extensions\StringExtensions.cs" />
|
||||
<Compile Include="Models\DoghouseComparer.cs" />
|
||||
<Compile Include="Services\IModuleService.cs" />
|
||||
<Compile Include="ViewModels\Module.cs" />
|
||||
<Compile Include="ViewModels\ModuleFeature.cs" />
|
||||
<Compile Include="Models\ModuleEntry.cs" />
|
||||
<Compile Include="Models\ModuleFeature.cs" />
|
||||
<Compile Include="ViewModels\FeaturesViewModel.cs" />
|
||||
<Compile Include="Permissions.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
@@ -96,6 +98,9 @@
|
||||
<ItemGroup>
|
||||
<Content Include="web.config" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="Views\ModuleEntry.cshtml" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
||||
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v10.0\WebApplications\Microsoft.WebApplication.targets" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
|
@@ -7,7 +7,7 @@ using Orchard.Environment.Descriptor;
|
||||
using Orchard.Environment.Descriptor.Models;
|
||||
using Orchard.FileSystems.VirtualPath;
|
||||
using Orchard.Localization;
|
||||
using Orchard.Modules.ViewModels;
|
||||
using Orchard.Modules.Models;
|
||||
using Orchard.UI.Notify;
|
||||
|
||||
namespace Orchard.Modules.Services {
|
||||
|
@@ -1,4 +1,5 @@
|
||||
using System.Collections.Generic;
|
||||
using Orchard.Modules.Models;
|
||||
|
||||
namespace Orchard.Modules.ViewModels {
|
||||
public class FeaturesViewModel {
|
||||
|
@@ -1,8 +1,9 @@
|
||||
using System.Collections.Generic;
|
||||
using Orchard.Modules.Models;
|
||||
|
||||
namespace Orchard.Modules.ViewModels {
|
||||
public class ModulesIndexViewModel {
|
||||
public bool InstallModules { get; set; }
|
||||
public IEnumerable<Module> Modules { get; set; }
|
||||
public IEnumerable<ModuleEntry> Modules { get; set; }
|
||||
}
|
||||
}
|
@@ -4,6 +4,7 @@
|
||||
@using Orchard.Modules.ViewModels;
|
||||
@using Orchard.Utility.Extensions;
|
||||
@using Orchard.Modules.Models;
|
||||
|
||||
@{
|
||||
Style.Require("ModulesAdmin");
|
||||
Style.Require("Switchable");
|
||||
|
@@ -1,7 +1,9 @@
|
||||
@model ModulesIndexViewModel
|
||||
@model Orchard.Modules.ViewModels.ModulesIndexViewModel
|
||||
@using Orchard.Localization;
|
||||
@using Orchard.Modules.Models;
|
||||
@using Orchard.Modules.Extensions;
|
||||
@using Orchard.Mvc.Html;
|
||||
@using Orchard.Modules.ViewModels;
|
||||
@using Orchard.Utility.Extensions;
|
||||
|
||||
@{
|
||||
Style.Require("ModulesAdmin");
|
||||
@@ -15,26 +17,8 @@
|
||||
|
||||
@if (Model.Modules.Count() > 0) {
|
||||
<ul class="contentItems">
|
||||
@foreach (var module in Model.Modules.OrderBy(m => m.Descriptor.Name)) {
|
||||
string moduleClasses = module.IsRecentlyInstalled ? "recentlyInstalledModule" : string.Empty;
|
||||
|
||||
<li class="@moduleClasses">
|
||||
<div class="summary">
|
||||
<div class="properties">
|
||||
<h2>@module.Descriptor.Name<span> - @T("Version: {0}", !string.IsNullOrEmpty(module.Descriptor.Version) ? module.Descriptor.Version : T("1.0").ToString())</span></h2>
|
||||
@if (!string.IsNullOrEmpty(module.Descriptor.Description)) {
|
||||
<p>@module.Descriptor.Description</p>}
|
||||
<ul class="pageStatus" style="color:#666; margin:.6em 0 0 0;">
|
||||
<li>@T("Features: {0}", MvcHtmlString.Create(string.Join(", ", module.Descriptor.Features.Select(f => Html.Link(string.IsNullOrEmpty(f.Name) ? f.Id : f.Name, string.Format("{0}#{1}", Url.Action("features", new { area = "Orchard.Modules" }), f.Id.AsFeatureId(n => T(n)))).ToString()).OrderBy(s => s).ToArray())))</li>
|
||||
<li> | @T("Author: {0}", !string.IsNullOrEmpty(module.Descriptor.Author) ? module.Descriptor.Author : T("Unknown").ToString())</li>
|
||||
<li> | @T("Website: ")
|
||||
@if (!string.IsNullOrEmpty(module.Descriptor.WebSite)) { <a href="@module.Descriptor.WebSite">@module.Descriptor.WebSite</a> }
|
||||
else { @T("Unknown").ToString() }
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
@foreach (ModuleEntry module in Model.Modules.OrderBy(m => m.Descriptor.Name)) {
|
||||
<li>@Display.ModuleEntry(ContentPart: module)</li>
|
||||
}
|
||||
</ul>
|
||||
}
|
@@ -0,0 +1,32 @@
|
||||
@using Orchard.Modules.Extensions;
|
||||
@using Orchard.Mvc.Html;
|
||||
@using Orchard.Modules.ViewModels;
|
||||
@using Orchard.Environment.Extensions.Models;
|
||||
|
||||
@{ string moduleClasses = Model.ContentPart.IsRecentlyInstalled ? "recentlyInstalledModule" : string.Empty; }
|
||||
|
||||
<div class="summary @moduleClasses">
|
||||
<div class="properties">
|
||||
<h2>@Model.ContentPart.Descriptor.Name<span> - @T("Version: {0}", !string.IsNullOrEmpty(Model.ContentPart.Descriptor.Version) ? Model.ContentPart.Descriptor.Version : T("1.0").ToString())</span></h2>
|
||||
@if (!string.IsNullOrEmpty(Model.ContentPart.Descriptor.Description)) {
|
||||
<p>@Model.ContentPart.Descriptor.Description</p>}
|
||||
|
||||
@if (Model.ContentPart.Notifications != null && Model.ContentPart.Notifications.Count > 0) {
|
||||
<ul class="notifications">
|
||||
@foreach (string notification in Model.ContentPart.Notifications) {
|
||||
<li>@notification</li>
|
||||
}
|
||||
</ul>
|
||||
}
|
||||
|
||||
<ul class="pageStatus" style="color:#666; margin:.6em 0 0 0;">
|
||||
@{ IEnumerable<FeatureDescriptor> features = Model.ContentPart.Descriptor.Features; }
|
||||
<li>@T("Features: {0}", MvcHtmlString.Create(string.Join(", ", features.Select(f => Html.Link(string.IsNullOrEmpty(f.Name) ? f.Id : f.Name, string.Format("{0}#{1}", Url.Action("features", new { area = "Orchard.Modules" }), f.Id.AsFeatureId(n => T(n)))).ToString()).OrderBy(s => s).ToArray())))</li>
|
||||
<li> | @T("Author: {0}", !string.IsNullOrEmpty(Model.ContentPart.Descriptor.Author) ? Model.ContentPart.Descriptor.Author : T("Unknown").ToString())</li>
|
||||
<li> | @T("Website: ")
|
||||
@if (!string.IsNullOrEmpty(Model.ContentPart.Descriptor.WebSite)) { <a href="@Model.ContentPart.Descriptor.WebSite">@Model.ContentPart.Descriptor.WebSite</a> }
|
||||
else { @T("Unknown").ToString() }
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
@@ -4,6 +4,9 @@
|
||||
#main .features h3 {
|
||||
padding:0 3em 0 0;
|
||||
}
|
||||
.pageStatus {
|
||||
clear: both;
|
||||
}
|
||||
.features.detail-view .category > ul {
|
||||
border:1px solid #EAEAEA;
|
||||
margin-bottom:2em;
|
||||
|
@@ -51,7 +51,7 @@ namespace Orchard.PackageManager.Controllers {
|
||||
}
|
||||
|
||||
public ActionResult ModulesUpdates(int? reportId) {
|
||||
return PackageUpdate("ModulesUpdate", DefaultExtensionTypes.Theme, reportId);
|
||||
return PackageUpdate("ModulesUpdate", DefaultExtensionTypes.Module, reportId);
|
||||
}
|
||||
|
||||
private ActionResult PackageUpdate(string view, string extensionType, int? reportId) {
|
||||
|
@@ -0,0 +1,43 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Orchard.Environment.Extensions.Models;
|
||||
using Orchard.Localization;
|
||||
using Orchard.PackageManager.Services;
|
||||
using Orchard.Packaging.Services;
|
||||
|
||||
namespace Orchard.PackageManager.Events {
|
||||
public class ExtensionDisplayEventHandler : IExtensionDisplayEventHandler {
|
||||
private readonly IBackgroundPackageUpdateStatus _backgroundPackageUpdateStatus;
|
||||
private readonly IPackagingSourceManager _packagingSourceManager;
|
||||
private readonly IPackageUpdateService _packageUpdateService;
|
||||
|
||||
public ExtensionDisplayEventHandler(IBackgroundPackageUpdateStatus backgroundPackageUpdateStatus,
|
||||
IPackagingSourceManager packagingSourceManager,
|
||||
IPackageUpdateService packageUpdateService) {
|
||||
|
||||
_backgroundPackageUpdateStatus = backgroundPackageUpdateStatus;
|
||||
_packagingSourceManager = packagingSourceManager;
|
||||
_packageUpdateService = packageUpdateService;
|
||||
|
||||
T = NullLocalizer.Instance;
|
||||
}
|
||||
|
||||
public Localizer T { get; set; }
|
||||
|
||||
public IEnumerable<string> Displaying(ExtensionDescriptor extensionDescriptor) {
|
||||
// Get status from background task state or directly
|
||||
_backgroundPackageUpdateStatus.Value =
|
||||
_backgroundPackageUpdateStatus.Value ??
|
||||
_packageUpdateService.GetPackagesStatus(_packagingSourceManager.GetSources());
|
||||
|
||||
UpdatePackageEntry updatePackageEntry = _backgroundPackageUpdateStatus.Value.Entries
|
||||
.Where(package => package.ExtensionsDescriptor.Id.Equals(extensionDescriptor.Id)).FirstOrDefault();
|
||||
|
||||
if (updatePackageEntry != null) {
|
||||
if (updatePackageEntry.NewVersionToInstall != null) {
|
||||
yield return T("New version available: {0}", updatePackageEntry.NewVersionToInstall.Version).ToString();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,12 @@
|
||||
using System.Collections.Generic;
|
||||
using Orchard.Environment.Extensions.Models;
|
||||
using Orchard.Events;
|
||||
|
||||
namespace Orchard.PackageManager.Events {
|
||||
public interface IExtensionDisplayEventHandler : IEventHandler {
|
||||
/// <summary>
|
||||
/// Called before an extension is displayed
|
||||
/// </summary>
|
||||
IEnumerable<string> Displaying(ExtensionDescriptor extensionDescriptor);
|
||||
}
|
||||
}
|
@@ -81,6 +81,8 @@
|
||||
<ItemGroup>
|
||||
<Compile Include="AdminMenu.cs" />
|
||||
<Compile Include="Controllers\AdminController.cs" />
|
||||
<Compile Include="Events\ExtensionDisplayEventHandler.cs" />
|
||||
<Compile Include="Events\IExtensionDisplayEventHandler.cs" />
|
||||
<Compile Include="Services\BackgroundPackageUpdateStatus.cs" />
|
||||
<Compile Include="Services\BackgroundPackageUpdateTask.cs" />
|
||||
<Compile Include="Services\FolderUpdater.cs" />
|
||||
|
@@ -71,6 +71,7 @@
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</li>}
|
||||
</li>
|
||||
}
|
||||
</ul>
|
||||
}
|
@@ -71,6 +71,7 @@
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</li>}
|
||||
</li>
|
||||
}
|
||||
</ul>
|
||||
}
|
@@ -66,7 +66,7 @@ namespace Orchard.Themes.Commands {
|
||||
Context.Output.WriteLine(T("--------------------------"));
|
||||
themes.Where(t => t.Name.Trim().Equals(currentTheme.Name.Trim(), StringComparison.OrdinalIgnoreCase) == false)
|
||||
.ToList()
|
||||
.ForEach(t => WriteThemeLines(t));
|
||||
.ForEach(WriteThemeLines);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -13,6 +13,7 @@ using Orchard.Logging;
|
||||
using Orchard.Mvc.Extensions;
|
||||
using Orchard.Reports.Services;
|
||||
using Orchard.Security;
|
||||
using Orchard.Themes.Events;
|
||||
using Orchard.Themes.Models;
|
||||
using Orchard.Themes.Preview;
|
||||
using Orchard.Themes.Services;
|
||||
@@ -23,6 +24,7 @@ using Orchard.Utility.Extensions;
|
||||
namespace Orchard.Themes.Controllers {
|
||||
[ValidateInput(false)]
|
||||
public class AdminController : Controller {
|
||||
private readonly IExtensionDisplayEventHandler _extensionDisplayEventHandler;
|
||||
private readonly IDataMigrationManager _dataMigrationManager;
|
||||
private readonly IFeatureManager _featureManager;
|
||||
private readonly ISiteThemeService _siteThemeService;
|
||||
@@ -33,6 +35,7 @@ namespace Orchard.Themes.Controllers {
|
||||
private readonly IReportsCoordinator _reportsCoordinator;
|
||||
|
||||
public AdminController(
|
||||
IEnumerable<IExtensionDisplayEventHandler> extensionDisplayEventHandlers,
|
||||
IOrchardServices services,
|
||||
IDataMigrationManager dataMigraitonManager,
|
||||
IFeatureManager featureManager,
|
||||
@@ -44,6 +47,7 @@ namespace Orchard.Themes.Controllers {
|
||||
IReportsCoordinator reportsCoordinator) {
|
||||
Services = services;
|
||||
|
||||
_extensionDisplayEventHandler = extensionDisplayEventHandlers.FirstOrDefault();
|
||||
_dataMigrationManager = dataMigraitonManager;
|
||||
_siteThemeService = siteThemeService;
|
||||
_extensionManager = extensionManager;
|
||||
@@ -63,32 +67,44 @@ namespace Orchard.Themes.Controllers {
|
||||
|
||||
public ActionResult Index() {
|
||||
try {
|
||||
var featuresThatNeedUpdate = _dataMigrationManager.GetFeaturesThatNeedUpdate();
|
||||
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));
|
||||
}
|
||||
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 => new ThemeEntry(extensionDescriptor) {
|
||||
NeedsUpdate = featuresThatNeedUpdate.Contains(extensionDescriptor.Id),
|
||||
IsRecentlyInstalled = _themeService.IsRecentlyInstalled(extensionDescriptor),
|
||||
Enabled = _shellDescriptor.Features.Any(sf => sf.Name == extensionDescriptor.Id)
|
||||
})
|
||||
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)) {
|
||||
themeEntry.Notifications.Add(notification);
|
||||
}
|
||||
}
|
||||
|
||||
return themeEntry;
|
||||
})
|
||||
.ToArray();
|
||||
|
||||
return View(new ThemesIndexViewModel {
|
||||
CurrentTheme = currentTheme,
|
||||
Themes = themes,
|
||||
InstallThemes = _featureManager.GetEnabledFeatures().FirstOrDefault(f => f.Id == "PackagingServices") != null
|
||||
InstallThemes = installThemes
|
||||
});
|
||||
} catch (Exception exception) {
|
||||
this.Error(exception, T("Listing themes failed: {0}", exception.Message), Logger, Services.Notifier);
|
||||
@@ -102,7 +118,10 @@ namespace Orchard.Themes.Controllers {
|
||||
try {
|
||||
if (!Services.Authorizer.Authorize(Permissions.ApplyTheme, T("Couldn't preview the current theme")))
|
||||
return new HttpUnauthorizedResult();
|
||||
|
||||
_themeService.EnableThemeFeatures(themeName);
|
||||
_previewTheme.SetPreviewTheme(themeName);
|
||||
|
||||
return this.RedirectLocal(returnUrl, "~/");
|
||||
} catch (Exception exception) {
|
||||
this.Error(exception, T("Previewing theme failed: {0}", exception.Message), Logger, Services.Notifier);
|
||||
|
@@ -0,0 +1,12 @@
|
||||
using System.Collections.Generic;
|
||||
using Orchard.Environment.Extensions.Models;
|
||||
using Orchard.Events;
|
||||
|
||||
namespace Orchard.Themes.Events {
|
||||
public interface IExtensionDisplayEventHandler : IEventHandler {
|
||||
/// <summary>
|
||||
/// Called before an extension is displayed
|
||||
/// </summary>
|
||||
IEnumerable<string> Displaying(ExtensionDescriptor extensionDescriptor);
|
||||
}
|
||||
}
|
@@ -1,3 +1,4 @@
|
||||
using System.Collections.Generic;
|
||||
using Orchard.Environment.Extensions.Models;
|
||||
|
||||
namespace Orchard.Themes.Models {
|
||||
@@ -43,6 +44,16 @@ namespace Orchard.Themes.Models {
|
||||
/// </summary>
|
||||
public bool IsRecentlyInstalled { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Boolean value indicating if the theme can be uninstalled.
|
||||
/// </summary>
|
||||
public bool CanUninstall { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// List of theme notifications.
|
||||
/// </summary>
|
||||
public List<string> Notifications { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The theme's name.
|
||||
/// </summary>
|
||||
|
@@ -49,11 +49,11 @@
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="AdminMenu.cs" />
|
||||
<Compile Include="Models\ThemeEntry.cs" />
|
||||
<Compile Include="Commands\ThemeCommands.cs" />
|
||||
<Compile Include="Events\IExtensionDisplayEventHandler.cs" />
|
||||
<Compile Include="Models\ThemeEntry.cs" />
|
||||
<Compile Include="ResourceManifest.cs" />
|
||||
<Compile Include="Controllers\AdminController.cs" />
|
||||
<Compile Include="Migrations.cs" />
|
||||
<Compile Include="Handlers\ThemeSiteSettingsPartHandler.cs" />
|
||||
<Compile Include="Models\ThemeSiteSettingsPart.cs" />
|
||||
<Compile Include="Models\ThemeSiteSettingsPartRecord.cs" />
|
||||
@@ -101,6 +101,12 @@
|
||||
<ItemGroup>
|
||||
<Content Include="web.config" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="Views\ThemeEntry.cshtml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="Views\ThemeEntry.Current.cshtml" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
||||
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v10.0\WebApplications\Microsoft.WebApplication.targets" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
|
@@ -15,20 +15,7 @@
|
||||
} else {
|
||||
<h3 id="currentThemeTitle">@T("Current Theme")</h3>
|
||||
|
||||
<div id="currentTheme">
|
||||
@Html.Image(Href(Html.ThemePath(Model.CurrentTheme.Descriptor, "/Theme.png")), Html.Encode(Model.CurrentTheme.Name), new { @class = "themePreviewImage" })
|
||||
|
||||
<div class="details">
|
||||
@Model.CurrentTheme.Name<br />
|
||||
@T("By") @Model.CurrentTheme.Descriptor.Author<br />
|
||||
@T("Version:") @Model.CurrentTheme.Descriptor.Version<br />
|
||||
@if (Model.CurrentTheme.Descriptor.WebSite != null) {
|
||||
<a href="@Model.CurrentTheme.Descriptor.WebSite">@Model.CurrentTheme.Descriptor.WebSite</a><br />
|
||||
}
|
||||
<br />
|
||||
<p>@Model.CurrentTheme.Descriptor.Description</p>
|
||||
</div>
|
||||
</div>
|
||||
@Display.ThemeEntry_Current(ContentPart: Model.CurrentTheme)
|
||||
}
|
||||
|
||||
<div id="installedBar">
|
||||
@@ -43,54 +30,8 @@
|
||||
<p>@T("There are no additional themes installed.")</p>
|
||||
} else {
|
||||
<ul class="templates">
|
||||
@foreach (ThemeEntry theme in Model.Themes) {
|
||||
string themeClasses = theme.IsRecentlyInstalled ? "recentlyInstalledTheme" : string.Empty;
|
||||
|
||||
<li class="@themeClasses">
|
||||
<div>
|
||||
<h3>@theme.Name</h3>
|
||||
@Html.Image(Href(Html.ThemePath(Model.CurrentTheme.Descriptor, "/Theme.png")), Html.Encode(Model.CurrentTheme.Name), null)
|
||||
|
||||
@using (Html.BeginFormAntiForgeryPost(Url.Action("Activate"), FormMethod.Post, new { @class = "inline" })) {
|
||||
@Html.Hidden("themeName", theme.Descriptor.Id)
|
||||
<button type="submit" title="@T("Activate")">@T("Set Current")</button>
|
||||
}
|
||||
|
||||
@using (Html.BeginFormAntiForgeryPost(Url.Action("Preview"), FormMethod.Post, new { @class = "inline" })) {
|
||||
@Html.Hidden("themeName", theme.Descriptor.Id)
|
||||
<button type="submit" title="@T("Preview")">@T("Preview")</button>
|
||||
}
|
||||
|
||||
<h5>@T("By") @theme.Descriptor.Author</h5>
|
||||
<p>
|
||||
@T("Version:") @theme.Descriptor.Version<br />
|
||||
@theme.Descriptor.Description<br />
|
||||
@if (theme.Descriptor.WebSite != null) {
|
||||
<a href="@theme.Descriptor.WebSite">@theme.Descriptor.WebSite</a><br />
|
||||
}
|
||||
</p>
|
||||
|
||||
@if (theme.Enabled) {
|
||||
using (Html.BeginFormAntiForgeryPost(Url.Action("Disable"), FormMethod.Post, new { @class = "inline link" })) {
|
||||
@Html.Hidden("themeName", theme.Descriptor.Id)
|
||||
<button type="submit" title="Disable">@T("Disable")</button>
|
||||
}
|
||||
}
|
||||
|
||||
@if (theme.NeedsUpdate) {
|
||||
using (Html.BeginFormAntiForgeryPost(Url.Action("Update"), FormMethod.Post, new { @class = "inline link" })) {
|
||||
@Html.Hidden("themeName", theme.Descriptor.Id)
|
||||
<button type="submit" class="update">@T("Update")</button> <br/>
|
||||
}
|
||||
}
|
||||
|
||||
@if (Model.InstallThemes) {
|
||||
using (Html.BeginFormAntiForgeryPost(Url.Action("RemoveTheme", "PackagingServices", new { area = "Orchard.Packaging", returnUrl = HttpContext.Current.Request.RawUrl, retryUrl = HttpContext.Current.Request.RawUrl, themeId = theme.Descriptor.Id }), FormMethod.Post, new { @class = "inline link" })) {
|
||||
<button type="submit" class="uninstall" title="@T("Uninstall")">@T("Uninstall")</button>
|
||||
}
|
||||
}
|
||||
</div>
|
||||
</li>
|
||||
@foreach (ThemeEntry themeEntry in Model.Themes) {
|
||||
<li>@Display.ThemeEntry(ContentPart: themeEntry)</li>
|
||||
}
|
||||
</ul>
|
||||
}
|
@@ -0,0 +1,18 @@
|
||||
@using Orchard.Themes.Models
|
||||
@using Orchard.Mvc.Html
|
||||
@using Orchard.Environment.Extensions.Models
|
||||
|
||||
<div id="currentTheme">
|
||||
@Html.Image(Href(Html.ThemePath((ExtensionDescriptor)Model.ContentPart.Descriptor, "/Theme.png")), Html.Encode((string)Model.ContentPart.Name), new { @class = "themePreviewImage" })
|
||||
|
||||
<div class="details">
|
||||
@Model.ContentPart.Name<br />
|
||||
@T("By") @Model.ContentPart.Descriptor.Author<br />
|
||||
@T("Version:") @Model.ContentPart.Descriptor.Version<br />
|
||||
@if (Model.ContentPart.Descriptor.WebSite != null) {
|
||||
<a href="@Model.ContentPart.Descriptor.WebSite">@Model.ContentPart.Descriptor.WebSite</a><br />
|
||||
}
|
||||
<br />
|
||||
<p>@Model.ContentPart.Descriptor.Description</p>
|
||||
</div>
|
||||
</div>
|
@@ -0,0 +1,58 @@
|
||||
@using Orchard.Themes.Models
|
||||
@using Orchard.Mvc.Html
|
||||
@using Orchard.Environment.Extensions.Models
|
||||
|
||||
@{ string themeClasses = Model.ContentPart.IsRecentlyInstalled ? "recentlyInstalledTheme" : string.Empty; }
|
||||
|
||||
<div class="@themeClasses">
|
||||
|
||||
<h3>@Model.ContentPart.Name</h3>
|
||||
|
||||
@Html.Image(Href(Html.ThemePath((ExtensionDescriptor) Model.ContentPart.Descriptor, "/Theme.png")), Html.Encode((string)Model.ContentPart.Name), null)
|
||||
@using (Html.BeginFormAntiForgeryPost(Url.Action("Activate"), FormMethod.Post, new { @class = "inline" })) {
|
||||
@Html.Hidden("themeName", (string)Model.ContentPart.Descriptor.Id)
|
||||
<button type="submit" title="@T("Activate")">@T("Set Current")</button>
|
||||
}
|
||||
|
||||
@using (Html.BeginFormAntiForgeryPost(Url.Action("Preview"), FormMethod.Post, new { @class = "inline" })) {
|
||||
@Html.Hidden("themeName", (string)Model.ContentPart.Descriptor.Id)
|
||||
<button type="submit" title="@T("Preview")">@T("Preview")</button>
|
||||
}
|
||||
|
||||
<h5>@T("By") @Model.ContentPart.Descriptor.Author</h5>
|
||||
<p>
|
||||
@T("Version:") @Model.ContentPart.Descriptor.Version<br />
|
||||
@Model.ContentPart.Descriptor.Description<br />
|
||||
@if (Model.ContentPart.Descriptor.WebSite != null) {
|
||||
<a href="@Model.ContentPart.Descriptor.WebSite">@Model.ContentPart.Descriptor.WebSite</a><br />
|
||||
}
|
||||
</p>
|
||||
|
||||
@if (Model.ContentPart.Notifications != null && Model.ContentPart.Notifications.Count > 0) {
|
||||
<ul class="notifications">
|
||||
@foreach (string notification in Model.ContentPart.Notifications) {
|
||||
<li>@notification</li>
|
||||
}
|
||||
</ul>
|
||||
}
|
||||
|
||||
@if (Model.ContentPart.Enabled) {
|
||||
using (Html.BeginFormAntiForgeryPost(Url.Action("Disable"), FormMethod.Post, new { @class = "inline link" })) {
|
||||
@Html.Hidden("themeName", (string)Model.ContentPart.Descriptor.Id)
|
||||
<button type="submit" title="Disable">@T("Disable")</button>
|
||||
}
|
||||
}
|
||||
|
||||
@if (Model.ContentPart.NeedsUpdate) {
|
||||
using (Html.BeginFormAntiForgeryPost(Url.Action("Update"), FormMethod.Post, new { @class = "inline link" })) {
|
||||
@Html.Hidden("themeName", (string)Model.ContentPart.Descriptor.Id)
|
||||
<button type="submit" class="update">@T("Update")</button> <br/>
|
||||
}
|
||||
}
|
||||
|
||||
@if (Model.ContentPart.CanUninstall) {
|
||||
using (Html.BeginFormAntiForgeryPost(Url.Action("RemoveTheme", "PackagingServices", new { area = "Orchard.Packaging", returnUrl = HttpContext.Current.Request.RawUrl, retryUrl = HttpContext.Current.Request.RawUrl, themeId = Model.ContentPart.Descriptor.Id }), FormMethod.Post, new { @class = "inline link" })) {
|
||||
<button type="submit" class="uninstall" title="@T("Uninstall")">@T("Uninstall")</button>
|
||||
}
|
||||
}
|
||||
</div>
|
@@ -67,5 +67,4 @@ html.dyn #themepreview button.preview { display:none; }
|
||||
<button type="submit" class="cancel" title="@T("Cancel")" name="submit.Cancel" value="@T("Cancel")">@T("Cancel")</button>
|
||||
</fieldset>
|
||||
}
|
||||
</div>
|
||||
|
||||
</div>
|
Reference in New Issue
Block a user