mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-04-05 21:01:35 +08:00
Merge
--HG-- branch : dev
This commit is contained in:
commit
f288e3ec08
@ -3,9 +3,21 @@
|
||||
As a root Orchard system operator
|
||||
I want to install and enable modules and enable features
|
||||
|
||||
Scenario: Default modules are listed
|
||||
Scenario: Installed modules are listed
|
||||
Given I have installed Orchard
|
||||
When I go to "admin/modules"
|
||||
Then I should see "Installed Modules"
|
||||
Then I should see "<h2>Installed Modules</h2>"
|
||||
And I should see "<h3>Themes</h3>"
|
||||
And the status should be 200 OK
|
||||
|
||||
Scenario: Edit module shows its features
|
||||
Given I have installed Orchard
|
||||
When I go to "admin/modules/Edit/Orchard.Themes"
|
||||
Then I should see "<h1>Edit Module: Themes</h1>"
|
||||
And the status should be 200 OK
|
||||
|
||||
Scenario: Features of installed modules are listed
|
||||
Given I have installed Orchard
|
||||
When I go to "admin/modules/features"
|
||||
Then I should see "<h2>Available Features</h2>"
|
||||
And the status should be 200 OK
|
46
src/Orchard.Specs/Modules.feature.cs
generated
46
src/Orchard.Specs/Modules.feature.cs
generated
@ -51,10 +51,10 @@ namespace Orchard.Specs
|
||||
}
|
||||
|
||||
[NUnit.Framework.TestAttribute()]
|
||||
[NUnit.Framework.DescriptionAttribute("Default modules are listed")]
|
||||
public virtual void DefaultModulesAreListed()
|
||||
[NUnit.Framework.DescriptionAttribute("Installed modules are listed")]
|
||||
public virtual void InstalledModulesAreListed()
|
||||
{
|
||||
TechTalk.SpecFlow.ScenarioInfo scenarioInfo = new TechTalk.SpecFlow.ScenarioInfo("Default modules are listed", ((string[])(null)));
|
||||
TechTalk.SpecFlow.ScenarioInfo scenarioInfo = new TechTalk.SpecFlow.ScenarioInfo("Installed modules are listed", ((string[])(null)));
|
||||
#line 6
|
||||
this.ScenarioSetup(scenarioInfo);
|
||||
#line 7
|
||||
@ -62,11 +62,49 @@ this.ScenarioSetup(scenarioInfo);
|
||||
#line 8
|
||||
testRunner.When("I go to \"admin/modules\"");
|
||||
#line 9
|
||||
testRunner.Then("I should see \"Installed Modules\"");
|
||||
testRunner.Then("I should see \"<h2>Installed Modules</h2>\"");
|
||||
#line 10
|
||||
testRunner.And("I should see \"<h3>Themes</h3>\"");
|
||||
#line 11
|
||||
testRunner.And("the status should be 200 OK");
|
||||
#line hidden
|
||||
testRunner.CollectScenarioErrors();
|
||||
}
|
||||
|
||||
[NUnit.Framework.TestAttribute()]
|
||||
[NUnit.Framework.DescriptionAttribute("Edit module shows its features")]
|
||||
public virtual void EditModuleShowsItsFeatures()
|
||||
{
|
||||
TechTalk.SpecFlow.ScenarioInfo scenarioInfo = new TechTalk.SpecFlow.ScenarioInfo("Edit module shows its features", ((string[])(null)));
|
||||
#line 13
|
||||
this.ScenarioSetup(scenarioInfo);
|
||||
#line 14
|
||||
testRunner.Given("I have installed Orchard");
|
||||
#line 15
|
||||
testRunner.When("I go to \"admin/modules/Edit/Orchard.Themes\"");
|
||||
#line 16
|
||||
testRunner.Then("I should see \"<h1>Edit Module: Themes</h1>\"");
|
||||
#line 17
|
||||
testRunner.And("the status should be 200 OK");
|
||||
#line hidden
|
||||
testRunner.CollectScenarioErrors();
|
||||
}
|
||||
|
||||
[NUnit.Framework.TestAttribute()]
|
||||
[NUnit.Framework.DescriptionAttribute("Features of installed modules are listed")]
|
||||
public virtual void FeaturesOfInstalledModulesAreListed()
|
||||
{
|
||||
TechTalk.SpecFlow.ScenarioInfo scenarioInfo = new TechTalk.SpecFlow.ScenarioInfo("Features of installed modules are listed", ((string[])(null)));
|
||||
#line 19
|
||||
this.ScenarioSetup(scenarioInfo);
|
||||
#line 20
|
||||
testRunner.Given("I have installed Orchard");
|
||||
#line 21
|
||||
testRunner.When("I go to \"admin/modules/features\"");
|
||||
#line 22
|
||||
testRunner.Then("I should see \"<h2>Available Features</h2>\"");
|
||||
#line 23
|
||||
testRunner.And("the status should be 200 OK");
|
||||
#line hidden
|
||||
testRunner.CollectScenarioErrors();
|
||||
}
|
||||
|
@ -105,10 +105,6 @@ namespace Orchard.Tests.Environment {
|
||||
}
|
||||
}
|
||||
|
||||
public Feature LoadFeature(FeatureDescriptor featureDescriptor) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public IEnumerable<ExtensionEntry> ActiveExtensions_Obsolete() {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
@ -256,7 +256,7 @@ features:
|
||||
[Test]
|
||||
public void ExtensionManagerShouldThrowIfFeatureDoesNotExist() {
|
||||
var featureDescriptor = new FeatureDescriptor { Name = "NoSuchFeature" };
|
||||
Assert.Throws<ArgumentException>(() => _manager.LoadFeature(featureDescriptor));
|
||||
Assert.Throws<ArgumentException>(() => _manager.LoadFeatures(new [] { featureDescriptor }));
|
||||
}
|
||||
|
||||
[Test]
|
||||
@ -302,8 +302,10 @@ features:
|
||||
.SelectMany(x => x.Features)
|
||||
.Single(x => x.Name == "TestFeature");
|
||||
|
||||
foreach (var type in extensionManager.LoadFeature(testFeature).ExportedTypes) {
|
||||
Assert.That(type == typeof(Phi));
|
||||
foreach (var feature in extensionManager.LoadFeatures(new[] { testFeature })) {
|
||||
foreach (var type in feature.ExportedTypes) {
|
||||
Assert.That(type == typeof(Phi));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -328,9 +330,11 @@ features:
|
||||
.SelectMany(x => x.Features)
|
||||
.Single(x => x.Name == "TestModule");
|
||||
|
||||
foreach (var type in extensionManager.LoadFeature(testModule).ExportedTypes) {
|
||||
Assert.That(type != typeof(Phi));
|
||||
Assert.That((type == typeof(Alpha) || (type == typeof(Beta))));
|
||||
foreach (var feature in extensionManager.LoadFeatures(new [] { testModule })) {
|
||||
foreach (var type in feature.ExportedTypes) {
|
||||
Assert.That(type != typeof(Phi));
|
||||
Assert.That((type == typeof(Alpha) || (type == typeof(Beta))));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -68,10 +68,6 @@ namespace Orchard.Tests.Mvc.Routes {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public Feature LoadFeature(FeatureDescriptor featureDescriptor) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public IEnumerable<ExtensionEntry> ActiveExtensions_Obsolete() {
|
||||
yield return new ExtensionEntry {
|
||||
Descriptor = new ExtensionDescriptor {
|
||||
@ -87,11 +83,6 @@ namespace Orchard.Tests.Mvc.Routes {
|
||||
};
|
||||
}
|
||||
|
||||
public Feature LoadFeature(string featureName) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
|
||||
public void InstallExtension(string extensionType, HttpPostedFileBase extensionBundle) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
@ -8,7 +8,9 @@ namespace Orchard.Modules {
|
||||
builder.Add("Modules", "10",
|
||||
menu => menu
|
||||
.Add("Manage Modules", "1.0", item => item.Action("Index", "Admin", new { area = "Orchard.Modules" })
|
||||
.Permission(Permissions.ManageModules)));
|
||||
.Permission(Permissions.ManageModules))
|
||||
.Add("Manage Features", "2.0", item => item.Action("Features", "Admin", new { area = "Orchard.Modules" })
|
||||
.Permission(Permissions.ManageFeatures)));
|
||||
}
|
||||
}
|
||||
}
|
@ -1,17 +1,50 @@
|
||||
using System.Web.Mvc;
|
||||
using System;
|
||||
using System.Web.Mvc;
|
||||
using Orchard.Localization;
|
||||
using Orchard.Modules.ViewModels;
|
||||
using Orchard.Mvc.Results;
|
||||
|
||||
namespace Orchard.Modules.Controllers {
|
||||
public class AdminController : Controller {
|
||||
private readonly IModuleService _moduleService;
|
||||
|
||||
public AdminController(IModuleService moduleService) {
|
||||
public AdminController(IOrchardServices services, IModuleService moduleService) {
|
||||
Services = services;
|
||||
_moduleService = moduleService;
|
||||
T = NullLocalizer.Instance;
|
||||
}
|
||||
|
||||
private Localizer T { get; set; }
|
||||
public IOrchardServices Services { get; set; }
|
||||
|
||||
public ActionResult Index() {
|
||||
if (!Services.Authorizer.Authorize(Permissions.ManageModules, T("Not allowed to manage modules")))
|
||||
return new HttpUnauthorizedResult();
|
||||
|
||||
var modules = _moduleService.GetInstalledModules();
|
||||
return View(new ModulesIndexViewModel {Modules = modules});
|
||||
}
|
||||
|
||||
public ActionResult Edit(string moduleName) {
|
||||
if (!Services.Authorizer.Authorize(Permissions.ManageModules, T("Not allowed to edit module")))
|
||||
return new HttpUnauthorizedResult();
|
||||
|
||||
var module = _moduleService.GetModuleByName(moduleName);
|
||||
|
||||
if (module == null)
|
||||
return new NotFoundResult();
|
||||
|
||||
return View(new ModuleEditViewModel {
|
||||
Name = module.DisplayName
|
||||
});
|
||||
}
|
||||
|
||||
public ActionResult Features() {
|
||||
if (!Services.Authorizer.Authorize(Permissions.ManageFeatures, T("Not allowed to manage features")))
|
||||
return new HttpUnauthorizedResult();
|
||||
|
||||
var features = _moduleService.GetAvailableFeatures();
|
||||
return View(new FeatureListViewModel {Features = features});
|
||||
}
|
||||
}
|
||||
}
|
@ -63,10 +63,14 @@
|
||||
<ItemGroup>
|
||||
<Compile Include="AdminMenu.cs" />
|
||||
<Compile Include="Controllers\AdminController.cs" />
|
||||
<Compile Include="ViewModels\FeatureListViewModel.cs" />
|
||||
<Compile Include="Models\Module.cs" />
|
||||
<Compile Include="Permissions.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="Routes.cs" />
|
||||
<Compile Include="Routing\ModuleNameConstraint.cs" />
|
||||
<Compile Include="Services\ModuleService.cs" />
|
||||
<Compile Include="ViewModels\ModuleEditViewModel.cs" />
|
||||
<Compile Include="ViewModels\ModulesIndexViewModel.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
@ -81,8 +85,14 @@
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="Views\Admin\Features.ascx" />
|
||||
<Content Include="Views\Admin\Edit.ascx" />
|
||||
<Content Include="Views\Web.config" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Folder Include="Views\DisplayTemplates\Items\" />
|
||||
<Folder Include="Views\DisplayTemplates\Parts\" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
||||
<Import Project="$(MSBuildExtensionsPath)\Microsoft\VisualStudio\v9.0\WebApplications\Microsoft.WebApplication.targets" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
|
@ -4,13 +4,14 @@ using Orchard.Security.Permissions;
|
||||
namespace Orchard.Modules {
|
||||
public class Permissions : IPermissionProvider {
|
||||
public static readonly Permission ManageModules = new Permission { Description = "Manage Modules", Name = "ManageModules" };
|
||||
public static readonly Permission ManageFeatures = new Permission { Description = "Manage Features", Name = "ManageFeatures", ImpliedBy = new[] {ManageModules}};
|
||||
|
||||
public string ModuleName {
|
||||
get { return "Modules"; }
|
||||
}
|
||||
|
||||
public IEnumerable<Permission> GetPermissions() {
|
||||
return new[] {ManageModules};
|
||||
return new[] {ManageModules, ManageFeatures};
|
||||
}
|
||||
|
||||
public IEnumerable<PermissionStereotype> GetDefaultStereotypes() {
|
||||
|
41
src/Orchard.Web/Modules/Orchard.Modules/Routes.cs
Normal file
41
src/Orchard.Web/Modules/Orchard.Modules/Routes.cs
Normal file
@ -0,0 +1,41 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Web.Mvc;
|
||||
using System.Web.Routing;
|
||||
using Orchard.Modules.Routing;
|
||||
using Orchard.Mvc.Routes;
|
||||
|
||||
namespace Orchard.Modules {
|
||||
public class Routes : IRouteProvider {
|
||||
private readonly IModuleNameConstraint _moduleNameConstraint;
|
||||
|
||||
public Routes(IModuleNameConstraint moduleNameConstraint) {
|
||||
_moduleNameConstraint = moduleNameConstraint;
|
||||
}
|
||||
|
||||
public IEnumerable<RouteDescriptor> GetRoutes() {
|
||||
return new[] {
|
||||
new RouteDescriptor {
|
||||
Route = new Route(
|
||||
"Admin/Modules/Edit/{moduleName}",
|
||||
new RouteValueDictionary {
|
||||
{"area", "Orchard.Modules"},
|
||||
{"controller", "Admin"},
|
||||
{"action", "Edit"}
|
||||
},
|
||||
new RouteValueDictionary {
|
||||
{"moduleName", _moduleNameConstraint}
|
||||
},
|
||||
new RouteValueDictionary {
|
||||
{"area", "Orchard.Modules"}
|
||||
},
|
||||
new MvcRouteHandler())
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public void GetRoutes(ICollection<RouteDescriptor> routes) {
|
||||
foreach (var routeDescriptor in GetRoutes())
|
||||
routes.Add(routeDescriptor);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,27 @@
|
||||
using System;
|
||||
using System.Web;
|
||||
using System.Web.Routing;
|
||||
|
||||
namespace Orchard.Modules.Routing {
|
||||
public interface IModuleNameConstraint : IRouteConstraint, ISingletonDependency {
|
||||
}
|
||||
|
||||
public class ModuleNameConstraint : IModuleNameConstraint {
|
||||
private readonly IModuleService _moduleService;
|
||||
|
||||
public ModuleNameConstraint(IModuleService moduleService) {
|
||||
_moduleService = moduleService;
|
||||
}
|
||||
|
||||
public bool Match(HttpContextBase httpContext, Route route, string parameterName, RouteValueDictionary values, RouteDirection routeDirection) {
|
||||
if (routeDirection == RouteDirection.UrlGeneration)
|
||||
return true;
|
||||
|
||||
object value;
|
||||
if (values.TryGetValue(parameterName, out value))
|
||||
return _moduleService.GetModuleByName(Convert.ToString(value)) != null;
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
@ -3,10 +3,12 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
using Orchard.Environment.Extensions;
|
||||
using Orchard.Environment.Extensions.Models;
|
||||
using Orchard.Modules.Models;
|
||||
|
||||
namespace Orchard.Modules.Services {
|
||||
public class ModuleService : IModuleService {
|
||||
private const string ModuleExtensionType = "module";
|
||||
private readonly IExtensionManager _extensionManager;
|
||||
|
||||
public ModuleService(IExtensionManager extensionManager) {
|
||||
@ -14,28 +16,56 @@ namespace Orchard.Modules.Services {
|
||||
}
|
||||
|
||||
public IModule GetModuleByName(string moduleName) {
|
||||
return null;
|
||||
return _extensionManager.AvailableExtensions().Where(e => string.Equals(e.Name, moduleName, StringComparison.OrdinalIgnoreCase) && string.Equals(e.ExtensionType, "Module", StringComparison.OrdinalIgnoreCase)).Select(
|
||||
descriptor => AssembleModuleFromDescriptor(descriptor)).FirstOrDefault();
|
||||
}
|
||||
|
||||
public IEnumerable<IModule> GetInstalledModules() {
|
||||
return
|
||||
_extensionManager.AvailableExtensions().Where(
|
||||
e => String.Equals(e.ExtensionType, "Module", StringComparison.OrdinalIgnoreCase)).Select(
|
||||
descriptor => (new Module {
|
||||
ModuleName = descriptor.Name,
|
||||
DisplayName = descriptor.DisplayName,
|
||||
Description = descriptor.Description,
|
||||
Version = descriptor.Version,
|
||||
Author = descriptor.Author,
|
||||
HomePage = descriptor.WebSite,
|
||||
Tags = descriptor.Tags
|
||||
}) as IModule);
|
||||
e => String.Equals(e.ExtensionType, ModuleExtensionType, StringComparison.OrdinalIgnoreCase)).Select(
|
||||
descriptor => AssembleModuleFromDescriptor(descriptor));
|
||||
}
|
||||
|
||||
public void InstallModule(HttpPostedFileBase file) {
|
||||
_extensionManager.InstallExtension(ModuleExtensionType, file);
|
||||
}
|
||||
|
||||
public void UninstallModule(string moduleName) {
|
||||
_extensionManager.UninstallExtension(ModuleExtensionType, moduleName);
|
||||
}
|
||||
|
||||
public IEnumerable<Feature> GetAvailableFeatures() {
|
||||
return GetInstalledModules()
|
||||
.Where(m => m.Features != null)
|
||||
.SelectMany(m => _extensionManager.LoadFeatures(m.Features));
|
||||
}
|
||||
|
||||
public IEnumerable<Feature> GetAvailableFeaturesByModule(string moduleName) {
|
||||
var module = GetModuleByName(moduleName);
|
||||
if (module == null || module.Features == null)
|
||||
return null;
|
||||
|
||||
return _extensionManager.LoadFeatures(module.Features);
|
||||
}
|
||||
|
||||
public void EnableFeatures(IEnumerable<string> featureNames) {
|
||||
}
|
||||
|
||||
public void DisableFeatures(IEnumerable<string> featureNames) {
|
||||
}
|
||||
|
||||
private static IModule AssembleModuleFromDescriptor(ExtensionDescriptor extensionDescriptor) {
|
||||
return new Module {
|
||||
ModuleName = extensionDescriptor.Name,
|
||||
DisplayName = extensionDescriptor.DisplayName,
|
||||
Description = extensionDescriptor.Description,
|
||||
Version = extensionDescriptor.Version,
|
||||
Author = extensionDescriptor.Author,
|
||||
HomePage = extensionDescriptor.WebSite,
|
||||
Tags = extensionDescriptor.Tags,
|
||||
Features = extensionDescriptor.Features
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,9 @@
|
||||
using System.Collections.Generic;
|
||||
using Orchard.Environment.Extensions.Models;
|
||||
using Orchard.Mvc.ViewModels;
|
||||
|
||||
namespace Orchard.Modules.ViewModels {
|
||||
public class FeatureListViewModel : BaseViewModel {
|
||||
public IEnumerable<Feature> Features { get; set; }
|
||||
}
|
||||
}
|
@ -0,0 +1,7 @@
|
||||
using Orchard.Mvc.ViewModels;
|
||||
|
||||
namespace Orchard.Modules.ViewModels {
|
||||
public class ModuleEditViewModel : BaseViewModel {
|
||||
public string Name { get; set; }
|
||||
}
|
||||
}
|
@ -0,0 +1,5 @@
|
||||
<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl<ModuleEditViewModel>" %>
|
||||
<%@ Import Namespace="Orchard.Mvc.Html"%>
|
||||
<%@ Import Namespace="Orchard.Modules.ViewModels"%>
|
||||
<h1><%=Html.TitleForPage(T("Edit Module: {0}", Model.Name).ToString()) %></h1>
|
||||
<p><%=_Encoded("Edit the module. Maybe show module's features.") %></p>
|
@ -0,0 +1,33 @@
|
||||
<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl<FeatureListViewModel>" %>
|
||||
<%@ Import Namespace="Orchard.Mvc.Html"%>
|
||||
<%@ Import Namespace="Orchard.Modules.ViewModels"%>
|
||||
<h1><%=Html.TitleForPage(T("Manage Features").ToString()) %></h1>
|
||||
<h2><%=T("Available Features") %></h2>
|
||||
<% if (Model.Features.Count() > 0) { %>
|
||||
<ul class="contentItems blogs"><%
|
||||
foreach (var featureGroup in Model.Features.OrderBy(f => f.Descriptor.Name).GroupBy(f => f.Descriptor.Category)) { %>
|
||||
<li>
|
||||
<h3><%=Html.Encode(featureGroup.First().Descriptor.Category ?? T("General")) %></h3>
|
||||
<ul><%
|
||||
foreach (var feature in featureGroup.Select(f => f.Descriptor)) {%>
|
||||
<li>
|
||||
<h4><%=Html.Encode(feature.Name) %></h4>
|
||||
<p><%=T("From: {0}", Html.Encode(feature.Extension.DisplayName)) %></p><%
|
||||
if (!string.IsNullOrEmpty(feature.Description)) { %>
|
||||
<p><%=Html.Encode(feature.Description) %></p><%
|
||||
}
|
||||
if (feature.Dependencies.Count() > 0) {%>
|
||||
<h5><%=_Encoded("Depends on:")%></h5>
|
||||
<ul><%
|
||||
foreach (var dependency in feature.Dependencies) { %>
|
||||
<li><%=Html.Encode(dependency) %></li><%
|
||||
} %>
|
||||
</ul><%
|
||||
}%>
|
||||
</li><%
|
||||
} %>
|
||||
</ul>
|
||||
</li><%
|
||||
} %>
|
||||
</ul><%
|
||||
} %>
|
@ -4,11 +4,21 @@
|
||||
<h1><%=Html.TitleForPage(T("Manage Modules").ToString()) %></h1>
|
||||
<h2><%=T("Installed Modules") %></h2>
|
||||
<% if (Model.Modules.Count() > 0) { %>
|
||||
<ul><%
|
||||
<ul class="contentItems blogs"><%
|
||||
foreach (var module in Model.Modules.OrderBy(m => m.DisplayName)) { %>
|
||||
<li>
|
||||
<h3><%=Html.Encode(module.DisplayName) %></h3>
|
||||
<p><%=module.Description != null ? Html.Encode(module.Description) : T("<em>no description</em>") %></p>
|
||||
<div class="summary">
|
||||
<div class="properties">
|
||||
<h3><%=Html.Encode(module.DisplayName) %></h3>
|
||||
<div class="related">
|
||||
<%=Html.ActionLink(T("Edit").ToString(), "edit", new {moduleName = module.ModuleName, area = "Orchard.Modules"}) %><%=_Encoded(" | ")%>
|
||||
<a href="#">Delete</a>
|
||||
</div>
|
||||
</div>
|
||||
</div><%
|
||||
if (!string.IsNullOrEmpty(module.Description)) { %>
|
||||
<p><%=Html.Encode(module.Description) %></p><%
|
||||
} %>
|
||||
</li><%
|
||||
} %>
|
||||
</ul><%
|
||||
|
@ -84,7 +84,7 @@ namespace Orchard.Setup.Controllers {
|
||||
DataTablePrefix = model.DatabaseTablePrefix,
|
||||
};
|
||||
|
||||
// The vanilla Orchard distibution has the following modules enabled.
|
||||
// The vanilla Orchard distibution has the following features enabled.
|
||||
const string hardcoded =
|
||||
@"Orchard.Framework,
|
||||
Common,Dashboard,Feeds,HomePage,Navigation,Scheduling,Settings,XmlRpc,
|
||||
|
@ -17,7 +17,6 @@ namespace Orchard.Environment.Extensions {
|
||||
private readonly IEnumerable<IExtensionFolders> _folders;
|
||||
private readonly IEnumerable<IExtensionLoader> _loaders;
|
||||
private IEnumerable<ExtensionEntry> _activeExtensions;
|
||||
//private readonly IRepository<ExtensionRecord> _extensionRepository;
|
||||
|
||||
public Localizer T { get; set; }
|
||||
public ILogger Logger { get; set; }
|
||||
@ -25,11 +24,9 @@ namespace Orchard.Environment.Extensions {
|
||||
public ExtensionManager(
|
||||
IEnumerable<IExtensionFolders> folders,
|
||||
IEnumerable<IExtensionLoader> loaders
|
||||
//IRepository<ExtensionRecord> extensionRepository
|
||||
) {
|
||||
_folders = folders;
|
||||
_loaders = loaders.OrderBy(x => x.Order);
|
||||
//_extensionRepository = extensionRepository;
|
||||
T = NullLocalizer.Instance;
|
||||
Logger = NullLogger.Instance;
|
||||
}
|
||||
@ -119,7 +116,7 @@ namespace Orchard.Environment.Extensions {
|
||||
return featureDescriptors;
|
||||
}
|
||||
|
||||
public Feature LoadFeature(FeatureDescriptor featureDescriptor) {
|
||||
private Feature LoadFeature(FeatureDescriptor featureDescriptor) {
|
||||
var featureName = featureDescriptor.Name;
|
||||
string extensionName = GetExtensionForFeature(featureName);
|
||||
if (extensionName == null) throw new ArgumentException(T("Feature ") + featureName + T(" was not found in any of the installed extensions"));
|
||||
@ -224,7 +221,6 @@ namespace Orchard.Environment.Extensions {
|
||||
|
||||
private IEnumerable<ExtensionEntry> BuildActiveExtensions() {
|
||||
foreach (var descriptor in AvailableExtensions()) {
|
||||
//_extensionRepository.Create(new ExtensionRecord { Name = descriptor.Name });
|
||||
// Extensions that are Themes don't have buildable components.
|
||||
if (String.Equals(descriptor.ExtensionType, "Module", StringComparison.OrdinalIgnoreCase)) {
|
||||
yield return BuildEntry(descriptor);
|
||||
@ -232,15 +228,7 @@ namespace Orchard.Environment.Extensions {
|
||||
}
|
||||
}
|
||||
|
||||
private bool IsExtensionEnabled(string name) {
|
||||
//ExtensionRecord extensionRecord = _extensionRepository.Get(x => x.Name == name);
|
||||
//if (extensionRecord.Enabled) return true;
|
||||
//return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
private ExtensionEntry BuildEntry(ExtensionDescriptor descriptor) {
|
||||
if (!IsExtensionEnabled(descriptor.Name)) return null;
|
||||
foreach (var loader in _loaders) {
|
||||
var entry = loader.Load(descriptor);
|
||||
if (entry != null)
|
||||
|
@ -6,10 +6,10 @@ namespace Orchard.Environment.Extensions {
|
||||
public interface IExtensionManager {
|
||||
IEnumerable<ExtensionDescriptor> AvailableExtensions();
|
||||
IEnumerable<Feature> LoadFeatures(IEnumerable<FeatureDescriptor> featureDescriptors);
|
||||
Feature LoadFeature(FeatureDescriptor featureDescriptor);
|
||||
|
||||
IEnumerable<ExtensionEntry> ActiveExtensions_Obsolete();
|
||||
void InstallExtension(string extensionType, HttpPostedFileBase extensionBundle);
|
||||
void UninstallExtension(string extensionType, string extensionName);
|
||||
|
||||
// Used by the HackInstallationGenerator and will be removed along with it.
|
||||
IEnumerable<ExtensionEntry> ActiveExtensions_Obsolete();
|
||||
}
|
||||
}
|
@ -1,5 +1,6 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Web;
|
||||
using Orchard.Environment.Extensions.Models;
|
||||
|
||||
namespace Orchard.Modules {
|
||||
public interface IModuleService : IDependency {
|
||||
@ -7,5 +8,8 @@ namespace Orchard.Modules {
|
||||
IEnumerable<IModule> GetInstalledModules();
|
||||
void InstallModule(HttpPostedFileBase file);
|
||||
void UninstallModule(string moduleName);
|
||||
IEnumerable<Feature> GetAvailableFeatures();
|
||||
void EnableFeatures(IEnumerable<string> featureNames);
|
||||
void DisableFeatures(IEnumerable<string> featureNames);
|
||||
}
|
||||
}
|
@ -52,10 +52,10 @@ namespace Orchard.Mvc.ViewEngines {
|
||||
}
|
||||
|
||||
|
||||
var modules = _extensionManager.ActiveExtensions_Obsolete()
|
||||
.Where(x => x.Descriptor.ExtensionType == "Module");
|
||||
var modules = _extensionManager.AvailableExtensions()
|
||||
.Where(x => x.ExtensionType == "Module");
|
||||
|
||||
var moduleLocations = modules.Select(x => Path.Combine(x.Descriptor.Location, x.Descriptor.Name));
|
||||
var moduleLocations = modules.Select(x => Path.Combine(x.Location, x.Name));
|
||||
var moduleViewEngines = _viewEngineProviders
|
||||
.Select(x => x.CreateModulesViewEngine(new CreateModulesViewEngineParams { VirtualPaths = moduleLocations }));
|
||||
Logger.Debug("Module locations:\r\n\t-{0}", string.Join("\r\n\t-", moduleLocations.ToArray()));
|
||||
|
Loading…
Reference in New Issue
Block a user