mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-10-15 11:44:58 +08:00
#1694: Moving module / theme install from gallery to packaging services and changing themes / module modules dependencies.
--HG-- branch : dev
This commit is contained in:
@@ -50,8 +50,9 @@ namespace Orchard.Modules.Controllers {
|
||||
var modules = _extensionManager.AvailableExtensions().Where(x => DefaultExtensionTypes.IsModule(x.ExtensionType));
|
||||
|
||||
return View(new ModulesIndexViewModel {
|
||||
Modules = modules,
|
||||
InstallModules = _featureManager.GetEnabledFeatures().FirstOrDefault(f => f.Id == "Gallery") != null });
|
||||
Modules = modules,
|
||||
InstallModules = _featureManager.GetEnabledFeatures().FirstOrDefault(f => f.Id == "PackagingServices") != null
|
||||
});
|
||||
}
|
||||
|
||||
public ActionResult Features() {
|
||||
|
@@ -10,7 +10,7 @@
|
||||
<h1>@Html.TitleForPage(T("Installed Modules").ToString())</h1>
|
||||
|
||||
@if (Model.InstallModules) {
|
||||
<div class="manage">@Html.ActionLink(T("Install a module").ToString(), "AddModule", "Gallery", new { area = "Orchard.Packaging", returnUrl = HttpContext.Current.Request.RawUrl }, new { @class = "button primaryAction" })</div>
|
||||
<div class="manage">@Html.ActionLink(T("Install a module").ToString(), "AddModule", "PackagingServices", new { area = "Orchard.Packaging", returnUrl = HttpContext.Current.Request.RawUrl }, new { @class = "button primaryAction" })</div>
|
||||
}
|
||||
|
||||
@if (Model.Modules.Count() > 0) {
|
||||
|
@@ -1,14 +1,9 @@
|
||||
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;
|
||||
using Orchard.Environment.Extensions;
|
||||
using Orchard.FileSystems.AppData;
|
||||
using Orchard.Localization;
|
||||
using Orchard.Packaging.Services;
|
||||
using Orchard.Packaging.ViewModels;
|
||||
@@ -24,21 +19,15 @@ namespace Orchard.Packaging.Controllers {
|
||||
|
||||
private readonly IPackageManager _packageManager;
|
||||
private readonly IPackagingSourceManager _packagingSourceManager;
|
||||
private readonly IAppDataFolderRoot _appDataFolderRoot;
|
||||
private readonly INotifier _notifier;
|
||||
private readonly IHostEnvironment _hostEnvironment;
|
||||
|
||||
public GalleryController(
|
||||
IPackageManager packageManager,
|
||||
IPackagingSourceManager packagingSourceManager,
|
||||
INotifier notifier,
|
||||
IAppDataFolderRoot appDataFolderRoot,
|
||||
IHostEnvironment hostEnvironment) {
|
||||
INotifier notifier) {
|
||||
_packageManager = packageManager;
|
||||
_packagingSourceManager = packagingSourceManager;
|
||||
_notifier = notifier;
|
||||
_appDataFolderRoot = appDataFolderRoot;
|
||||
_hostEnvironment = hostEnvironment;
|
||||
|
||||
T = NullLocalizer.Instance;
|
||||
}
|
||||
@@ -143,75 +132,5 @@ namespace Orchard.Packaging.Controllers {
|
||||
|
||||
return RedirectToAction(redirectTo == "Themes" ? "Themes" : "Modules");
|
||||
}
|
||||
|
||||
public ActionResult AddTheme(string returnUrl) {
|
||||
return View();
|
||||
}
|
||||
|
||||
[HttpPost, ActionName("AddTheme")]
|
||||
public ActionResult AddThemePOST(string returnUrl) {
|
||||
return InstallPackage(returnUrl, Request.RawUrl);
|
||||
}
|
||||
|
||||
[HttpPost, ActionName("RemoveTheme")]
|
||||
public ActionResult RemoveThemePOST(string themeId, string returnUrl, string retryUrl) {
|
||||
return UninstallPackage(PackagingSourceManager.ThemesFilter + themeId, returnUrl, retryUrl);
|
||||
}
|
||||
|
||||
public ActionResult AddModule(string returnUrl) {
|
||||
return View();
|
||||
}
|
||||
|
||||
[HttpPost, ActionName("AddModule")]
|
||||
public ActionResult AddModulePOST(string returnUrl) {
|
||||
return InstallPackage(returnUrl, Request.RawUrl);
|
||||
}
|
||||
|
||||
public ActionResult InstallPackage(string returnUrl, string retryUrl) {
|
||||
try {
|
||||
if (Request.Files != null &&
|
||||
Request.Files.Count > 0 &&
|
||||
!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));
|
||||
}
|
||||
}
|
||||
|
||||
return Redirect(returnUrl);
|
||||
} catch (Exception exception) {
|
||||
for (Exception scan = exception; scan != null; scan = scan.InnerException) {
|
||||
_notifier.Error(T("Uploading module package failed: {0}", exception.Message));
|
||||
}
|
||||
|
||||
return Redirect(retryUrl);
|
||||
}
|
||||
}
|
||||
|
||||
public ActionResult UninstallPackage(string id, string returnUrl, string retryUrl) {
|
||||
try {
|
||||
_packageManager.Uninstall(id, HostingEnvironment.MapPath("~/"));
|
||||
|
||||
_notifier.Information(T("Uninstalled package \"{0}\"", id));
|
||||
|
||||
return Redirect(returnUrl);
|
||||
} catch (Exception exception) {
|
||||
for (Exception scan = exception; scan != null; scan = scan.InnerException) {
|
||||
_notifier.Error(T("Uninstall failed: {0}", exception.Message));
|
||||
}
|
||||
|
||||
return Redirect(retryUrl);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,108 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Web;
|
||||
using System.Web.Hosting;
|
||||
using System.Web.Mvc;
|
||||
using NuGet;
|
||||
using Orchard.Environment.Extensions;
|
||||
using Orchard.FileSystems.AppData;
|
||||
using Orchard.Localization;
|
||||
using Orchard.Packaging.Services;
|
||||
using Orchard.Themes;
|
||||
using Orchard.UI.Admin;
|
||||
using Orchard.UI.Notify;
|
||||
using IPackageManager = Orchard.Packaging.Services.IPackageManager;
|
||||
|
||||
namespace Orchard.Packaging.Controllers {
|
||||
[OrchardFeature("PackagingServices")]
|
||||
[Themed, Admin]
|
||||
public class PackagingServicesController : Controller {
|
||||
|
||||
private readonly IPackageManager _packageManager;
|
||||
private readonly IAppDataFolderRoot _appDataFolderRoot;
|
||||
private readonly INotifier _notifier;
|
||||
|
||||
public PackagingServicesController(
|
||||
IPackageManager packageManager,
|
||||
INotifier notifier,
|
||||
IAppDataFolderRoot appDataFolderRoot) {
|
||||
_packageManager = packageManager;
|
||||
_notifier = notifier;
|
||||
_appDataFolderRoot = appDataFolderRoot;
|
||||
|
||||
T = NullLocalizer.Instance;
|
||||
}
|
||||
|
||||
public Localizer T { get; set; }
|
||||
|
||||
public ActionResult AddTheme(string returnUrl) {
|
||||
return View();
|
||||
}
|
||||
|
||||
[HttpPost, ActionName("AddTheme")]
|
||||
public ActionResult AddThemePOST(string returnUrl) {
|
||||
return InstallPackage(returnUrl, Request.RawUrl);
|
||||
}
|
||||
|
||||
[HttpPost, ActionName("RemoveTheme")]
|
||||
public ActionResult RemoveThemePOST(string themeId, string returnUrl, string retryUrl) {
|
||||
return UninstallPackage(PackagingSourceManager.ThemesFilter + themeId, returnUrl, retryUrl);
|
||||
}
|
||||
|
||||
public ActionResult AddModule(string returnUrl) {
|
||||
return View();
|
||||
}
|
||||
|
||||
[HttpPost, ActionName("AddModule")]
|
||||
public ActionResult AddModulePOST(string returnUrl) {
|
||||
return InstallPackage(returnUrl, Request.RawUrl);
|
||||
}
|
||||
|
||||
public ActionResult InstallPackage(string returnUrl, string retryUrl) {
|
||||
try {
|
||||
if (Request.Files != null &&
|
||||
Request.Files.Count > 0 &&
|
||||
!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));
|
||||
}
|
||||
}
|
||||
|
||||
return Redirect(returnUrl);
|
||||
} catch (Exception exception) {
|
||||
for (Exception scan = exception; scan != null; scan = scan.InnerException) {
|
||||
_notifier.Error(T("Uploading module package failed: {0}", exception.Message));
|
||||
}
|
||||
|
||||
return Redirect(retryUrl);
|
||||
}
|
||||
}
|
||||
|
||||
public ActionResult UninstallPackage(string id, string returnUrl, string retryUrl) {
|
||||
try {
|
||||
_packageManager.Uninstall(id, HostingEnvironment.MapPath("~/"));
|
||||
|
||||
_notifier.Information(T("Uninstalled package \"{0}\"", id));
|
||||
|
||||
return Redirect(returnUrl);
|
||||
} catch (Exception exception) {
|
||||
for (Exception scan = exception; scan != null; scan = scan.InnerException) {
|
||||
_notifier.Error(T("Uninstall failed: {0}", exception.Message));
|
||||
}
|
||||
|
||||
return Redirect(retryUrl);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -59,6 +59,7 @@
|
||||
<ItemGroup>
|
||||
<Compile Include="AdminMenu.cs" />
|
||||
<Compile Include="Commands\PackagingCommands.cs" />
|
||||
<Compile Include="Controllers\PackagingServicesController.cs" />
|
||||
<Compile Include="Controllers\DownloadStreamResult.cs" />
|
||||
<Compile Include="Controllers\GalleryController.cs" />
|
||||
<Compile Include="DefaultPackagingUpdater.cs" />
|
||||
@@ -94,7 +95,7 @@
|
||||
<Content Include="Views\Web.config" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="Views\Gallery\AddModule.cshtml" />
|
||||
<Content Include="Views\PackagingServices\AddModule.cshtml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\..\Orchard\Orchard.Framework.csproj">
|
||||
@@ -121,7 +122,7 @@
|
||||
<Content Include="Views\Gallery\Themes.cshtml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="Views\Gallery\AddTheme.cshtml" />
|
||||
<Content Include="Views\PackagingServices\AddTheme.cshtml" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
||||
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v10.0\WebApplications\Microsoft.WebApplication.targets" />
|
||||
|
@@ -1,6 +1,6 @@
|
||||
@{
|
||||
<h1>@Html.TitleForPage(T("Install a Module").ToString())</h1>
|
||||
using (Html.BeginFormAntiForgeryPost(Url.Action("AddModule", new { area = "Orchard.Gallery" }), FormMethod.Post, new { enctype = "multipart/form-data" })) {
|
||||
using (Html.BeginFormAntiForgeryPost(Url.Action("AddModule", new { area = "Orchard.Packaging", returnUrl = HttpContext.Current.Request["returnUrl"] }), FormMethod.Post, new { enctype = "multipart/form-data" })) {
|
||||
Html.ValidationSummary();
|
||||
<fieldset>
|
||||
<label for="ModulePackage">@T("Module Package")</label>
|
@@ -1,6 +1,6 @@
|
||||
@{
|
||||
<h1>@Html.TitleForPage(T("Install a Theme").ToString())</h1>
|
||||
using (Html.BeginFormAntiForgeryPost(Url.Action("AddTheme", new { area = "Orchard.Gallery" }), FormMethod.Post, new { enctype = "multipart/form-data" })) {
|
||||
using (Html.BeginFormAntiForgeryPost(Url.Action("AddTheme", new { area = "Orchard.Packaging", returnUrl = HttpContext.Current.Request["returnUrl"] }), FormMethod.Post, new { enctype = "multipart/form-data" })) {
|
||||
Html.ValidationSummary();
|
||||
<fieldset>
|
||||
<label for="ModulePackage">@T("Theme Package")</label>
|
@@ -69,7 +69,8 @@ namespace Orchard.Themes.Controllers {
|
||||
|
||||
return View(new ThemesIndexViewModel {
|
||||
CurrentTheme = currentTheme, Themes = themes,
|
||||
InstallThemes = _featureManager.GetEnabledFeatures().FirstOrDefault(f => f.Id == "Gallery") != null });
|
||||
InstallThemes = _featureManager.GetEnabledFeatures().FirstOrDefault(f => f.Id == "PackagingServices") != null
|
||||
});
|
||||
}
|
||||
catch (Exception exception) {
|
||||
Services.Notifier.Error(T("Listing themes failed: " + exception.Message));
|
||||
|
@@ -19,7 +19,7 @@
|
||||
</p>
|
||||
|
||||
if (Model.InstallThemes) {
|
||||
@Html.ActionLink(T("Install a new Theme").ToString(), "AddTheme", "Gallery", new { area = "Orchard.Packaging", returnUrl = HttpContext.Current.Request.RawUrl }, new { @class = "button primaryAction" })
|
||||
@Html.ActionLink(T("Install a new Theme").ToString(), "AddTheme", "PackagingServices", new { area = "Orchard.Packaging", returnUrl = HttpContext.Current.Request.RawUrl }, new { @class = "button primaryAction" })
|
||||
}
|
||||
}
|
||||
|
||||
@@ -57,7 +57,7 @@
|
||||
}
|
||||
|
||||
@if (Model.InstallThemes) {
|
||||
using (Html.BeginFormAntiForgeryPost(Url.Action("RemoveTheme", "Gallery", new { area = "Orchard.Packaging", returnUrl = HttpContext.Current.Request.RawUrl, retryUrl = HttpContext.Current.Request.RawUrl, themeId = theme.Id }), FormMethod.Post, new { @class = "inline link" })) {
|
||||
using (Html.BeginFormAntiForgeryPost(Url.Action("RemoveTheme", "PackagingServices", new { area = "Orchard.Packaging", returnUrl = HttpContext.Current.Request.RawUrl, retryUrl = HttpContext.Current.Request.RawUrl, themeId = theme.Id }), FormMethod.Post, new { @class = "inline link" })) {
|
||||
<button type="submit" class="uninstall" title="@T("Uninstall")">@T("Uninstall")</button>
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user