Modules { get; set; }
}
}
\ No newline at end of file
diff --git a/src/Orchard.Web/Modules/Orchard.Modules/Views/Admin/Features.cshtml b/src/Orchard.Web/Modules/Orchard.Modules/Views/Admin/Features.cshtml
index 61f660f70..0b5ff95c8 100644
--- a/src/Orchard.Web/Modules/Orchard.Modules/Views/Admin/Features.cshtml
+++ b/src/Orchard.Web/Modules/Orchard.Modules/Views/Admin/Features.cshtml
@@ -23,7 +23,7 @@
if (featureGroup == featureGroups.Last()) {
categoryClassName += " last";
}
-
+
//temporarily "disable" actions on core features
var showActions = categoryName.ToString() != "Core";
@@ -96,5 +96,4 @@
}
}
}
-}}
-
+}}
\ No newline at end of file
diff --git a/src/Orchard.Web/Modules/Orchard.Modules/Views/Admin/Index.cshtml b/src/Orchard.Web/Modules/Orchard.Modules/Views/Admin/Index.cshtml
index 0456cc42c..0be57d5a4 100644
--- a/src/Orchard.Web/Modules/Orchard.Modules/Views/Admin/Index.cshtml
+++ b/src/Orchard.Web/Modules/Orchard.Modules/Views/Admin/Index.cshtml
@@ -8,7 +8,11 @@
}
@Html.TitleForPage(T("Installed Modules").ToString())
-@Html.ActionLink(T("Install a module").ToString(), "Add", null, new { @class = "button primaryAction" })
+
+@if (Model.InstallModules) {
+ @Html.ActionLink(T("Install a module").ToString(), "AddModule", "Gallery", new { area = "Orchard.Packaging", returnUrl = HttpContext.Current.Request.RawUrl }, new { @class = "button primaryAction" })
+}
+
@if (Model.Modules.Count() > 0) {
@foreach (var module in Model.Modules.OrderBy(m => m.Name)) {
diff --git a/src/Orchard.Web/Modules/Orchard.Packaging/Controllers/GalleryController.cs b/src/Orchard.Web/Modules/Orchard.Packaging/Controllers/GalleryController.cs
index 6400b0575..7ad804931 100644
--- a/src/Orchard.Web/Modules/Orchard.Packaging/Controllers/GalleryController.cs
+++ b/src/Orchard.Web/Modules/Orchard.Packaging/Controllers/GalleryController.cs
@@ -1,15 +1,20 @@
using System;
+using System.IO;
using System.Linq;
+using System.Web;
using System.Web.Hosting;
using System.Web.Mvc;
using System.Xml.Linq;
+using NuGet;
using Orchard.Environment.Extensions;
+using Orchard.FileSystems.AppData;
using Orchard.Localization;
using Orchard.Packaging.Services;
using Orchard.Packaging.ViewModels;
using Orchard.Themes;
using Orchard.UI.Admin;
using Orchard.UI.Notify;
+using IPackageManager = Orchard.Packaging.Services.IPackageManager;
namespace Orchard.Packaging.Controllers {
[OrchardFeature("Gallery")]
@@ -18,18 +23,19 @@ namespace Orchard.Packaging.Controllers {
private readonly IPackageManager _packageManager;
private readonly IPackagingSourceManager _packagingSourceManager;
- private readonly IExtensionManager _extensionManager;
+ private readonly IAppDataFolderRoot _appDataFolderRoot;
private readonly INotifier _notifier;
public GalleryController(
IPackageManager packageManager,
IPackagingSourceManager packagingSourceManager,
- IExtensionManager extensionManager,
- INotifier notifier) {
+ INotifier notifier,
+ IAppDataFolderRoot appDataFolderRoot) {
_packageManager = packageManager;
_packagingSourceManager = packagingSourceManager;
- _extensionManager = extensionManager;
_notifier = notifier;
+ _appDataFolderRoot = appDataFolderRoot;
+
T = NullLocalizer.Instance;
}
@@ -95,7 +101,6 @@ namespace Orchard.Packaging.Controllers {
}
}
-
public ActionResult Modules(int? sourceId) {
var selectedSource = _packagingSourceManager.GetSources().Where(s => s.Id == sourceId).FirstOrDefault();
@@ -137,5 +142,43 @@ namespace Orchard.Packaging.Controllers {
return RedirectToAction(redirectTo == "Themes" ? "Themes" : "Modules");
}
+
+ public ActionResult AddModule(string returnUrl) {
+ return View();
+ }
+
+ [HttpPost, ActionName("AddModule")]
+ public ActionResult AddModulePOST(string returnUrl) {
+ // module not used for anything o2ther than display (and that only to not have object in the view 'T')
+ try {
+ if (string.IsNullOrWhiteSpace(Request.Files[0].FileName)) {
+ ModelState.AddModelError("File", T("Select a file to upload.").ToString());
+ }
+
+ foreach (string fileName in Request.Files) {
+ HttpPostedFileBase file = Request.Files[fileName];
+ if (file != null) {
+ string fullFileName = Path.Combine(_appDataFolderRoot.RootFolder, fileName + ".nupkg").Replace(Path.DirectorySeparatorChar, '/');
+ file.SaveAs(fullFileName);
+ PackageInfo info = _packageManager.Install(new ZipPackage(fullFileName), _appDataFolderRoot.RootFolder, HostingEnvironment.MapPath("~/"));
+ System.IO.File.Delete(fullFileName);
+
+ _notifier.Information(T("Installed package \"{0}\", version {1} of type \"{2}\" at location \"{3}\"",
+ info.ExtensionName, info.ExtensionVersion, info.ExtensionType, info.ExtensionPath));
+ }
+ }
+
+ if (!string.IsNullOrEmpty(returnUrl))
+ return Redirect(returnUrl);
+
+ return RedirectToAction("Modules");
+ } catch (Exception exception) {
+ for (var scan = exception; scan != null; scan = scan.InnerException) {
+ _notifier.Error(T("Uploading module package failed: {0}", exception.Message));
+ }
+
+ return View("AddModule");
+ }
+ }
}
}
\ No newline at end of file
diff --git a/src/Orchard.Web/Modules/Orchard.Packaging/Module.txt b/src/Orchard.Web/Modules/Orchard.Packaging/Module.txt
index 64b039f9f..bec584f51 100644
--- a/src/Orchard.Web/Modules/Orchard.Packaging/Module.txt
+++ b/src/Orchard.Web/Modules/Orchard.Packaging/Module.txt
@@ -16,4 +16,4 @@ Features:
Gallery:
Description: Module gallery management.
Dependencies: PackagingServices, Orchard.Packaging
- Category: Packaging
+ Category: Packaging
\ No newline at end of file
diff --git a/src/Orchard.Web/Modules/Orchard.Packaging/Orchard.Packaging.csproj b/src/Orchard.Web/Modules/Orchard.Packaging/Orchard.Packaging.csproj
index 0a74fabfd..d0710b48b 100644
--- a/src/Orchard.Web/Modules/Orchard.Packaging/Orchard.Packaging.csproj
+++ b/src/Orchard.Web/Modules/Orchard.Packaging/Orchard.Packaging.csproj
@@ -35,7 +35,7 @@
-
+
False
..\..\..\..\lib\nuget\NuGet.Core.dll
@@ -93,7 +93,9 @@
-
+
+
+
{2D1D92BB-4555-4CBE-8D0E-63563D6CE4C6}
@@ -118,6 +120,7 @@
+