mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-10-15 19:54:57 +08:00
#17179: Fixing YSOD, centralizing duplicate code and renaming css class to a more appropriate name.
--HG-- branch : 1.x
This commit is contained in:
@@ -6,8 +6,10 @@ using System.Web.Hosting;
|
|||||||
using System.Web.Mvc;
|
using System.Web.Mvc;
|
||||||
using System.Xml.Linq;
|
using System.Xml.Linq;
|
||||||
using Orchard.Environment.Extensions;
|
using Orchard.Environment.Extensions;
|
||||||
|
using Orchard.Environment.Extensions.Models;
|
||||||
using Orchard.Localization;
|
using Orchard.Localization;
|
||||||
using Orchard.Logging;
|
using Orchard.Logging;
|
||||||
|
using Orchard.Packaging.Models;
|
||||||
using Orchard.Packaging.Services;
|
using Orchard.Packaging.Services;
|
||||||
using Orchard.Packaging.ViewModels;
|
using Orchard.Packaging.ViewModels;
|
||||||
using Orchard.Security;
|
using Orchard.Security;
|
||||||
@@ -113,7 +115,15 @@ namespace Orchard.Packaging.Controllers {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public ActionResult Modules(int? sourceId) {
|
public ActionResult Modules(int? sourceId) {
|
||||||
if (!Services.Authorizer.Authorize(StandardPermissions.SiteOwner, T("Not authorized to list modules")))
|
return ListExtensions(sourceId, DefaultExtensionTypes.Module, "Modules", source => _packagingSourceManager.GetModuleList(source).ToArray());
|
||||||
|
}
|
||||||
|
|
||||||
|
public ActionResult Themes(int? sourceId) {
|
||||||
|
return ListExtensions(sourceId, DefaultExtensionTypes.Theme, "Themes", source => _packagingSourceManager.GetThemeList(source).ToArray());
|
||||||
|
}
|
||||||
|
|
||||||
|
protected ActionResult ListExtensions(int? sourceId, string extensionType, string returnView, Func<PackagingSource, PackagingEntry[]> getList) {
|
||||||
|
if (!Services.Authorizer.Authorize(StandardPermissions.SiteOwner, T("Not authorized to list {0}", extensionType)))
|
||||||
return new HttpUnauthorizedResult();
|
return new HttpUnauthorizedResult();
|
||||||
|
|
||||||
var selectedSource = _packagingSourceManager.GetSources().Where(s => s.Id == sourceId).FirstOrDefault();
|
var selectedSource = _packagingSourceManager.GetSources().Where(s => s.Id == sourceId).FirstOrDefault();
|
||||||
@@ -126,40 +136,21 @@ namespace Orchard.Packaging.Controllers {
|
|||||||
IEnumerable<PackagingEntry> extensions = null;
|
IEnumerable<PackagingEntry> extensions = null;
|
||||||
foreach (var source in sources) {
|
foreach (var source in sources) {
|
||||||
try {
|
try {
|
||||||
var sourceExtensions = _packagingSourceManager.GetModuleList(source).ToArray();
|
var sourceExtensions = getList(source);
|
||||||
extensions = extensions == null ? sourceExtensions : extensions.Concat(sourceExtensions);
|
extensions = extensions == null ? sourceExtensions : extensions.Concat(sourceExtensions);
|
||||||
}
|
} catch (Exception ex) {
|
||||||
catch (Exception ex) {
|
|
||||||
Logger.Error(ex, "Error loading extensions from gallery source '{0}'. {1}.", source.FeedTitle, ex.Message);
|
Logger.Error(ex, "Error loading extensions from gallery source '{0}'. {1}.", source.FeedTitle, ex.Message);
|
||||||
_notifier.Error(T("Error loading extensions from gallery source '{0}'. {1}.", source.FeedTitle, ex.Message));
|
_notifier.Error(T("Error loading extensions from gallery source '{0}'. {1}.", source.FeedTitle, ex.Message));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return View("Modules", new PackagingExtensionsViewModel {
|
return View(returnView, new PackagingExtensionsViewModel {
|
||||||
Extensions = extensions ?? new PackagingEntry[] { },
|
Extensions = extensions ?? new PackagingEntry[] { },
|
||||||
Sources = _packagingSourceManager.GetSources().OrderBy(s => s.FeedTitle),
|
Sources = _packagingSourceManager.GetSources().OrderBy(s => s.FeedTitle),
|
||||||
SelectedSource = selectedSource
|
SelectedSource = selectedSource
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public ActionResult Themes(int? sourceId) {
|
|
||||||
if (!Services.Authorizer.Authorize(StandardPermissions.SiteOwner, T("Not authorized to list themes")))
|
|
||||||
return new HttpUnauthorizedResult();
|
|
||||||
|
|
||||||
var selectedSource = _packagingSourceManager.GetSources().Where(s => s.Id == sourceId).FirstOrDefault();
|
|
||||||
|
|
||||||
var sources = selectedSource != null
|
|
||||||
? new[] { selectedSource }
|
|
||||||
: _packagingSourceManager.GetSources()
|
|
||||||
;
|
|
||||||
|
|
||||||
return View("Themes", new PackagingExtensionsViewModel {
|
|
||||||
Extensions = sources.SelectMany(source => _packagingSourceManager.GetThemeList(source)),
|
|
||||||
Sources = _packagingSourceManager.GetSources().OrderBy(s => s.FeedTitle),
|
|
||||||
SelectedSource = selectedSource
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
public ActionResult Install(string packageId, string version, int sourceId, string redirectTo) {
|
public ActionResult Install(string packageId, string version, int sourceId, string redirectTo) {
|
||||||
if (!Services.Authorizer.Authorize(StandardPermissions.SiteOwner, T("Not authorized to install packages")))
|
if (!Services.Authorizer.Authorize(StandardPermissions.SiteOwner, T("Not authorized to install packages")))
|
||||||
return new HttpUnauthorizedResult();
|
return new HttpUnauthorizedResult();
|
||||||
|
@@ -1,16 +1,13 @@
|
|||||||
.moduleName {
|
.extensionName {
|
||||||
float:left;
|
float:left;
|
||||||
}
|
}
|
||||||
|
|
||||||
.contentItems .related {
|
.contentItems .related {
|
||||||
padding:1.2em 0.4em 0.5em
|
padding:1.2em 0.4em 0.5em
|
||||||
}
|
}
|
||||||
|
|
||||||
.contentItems .properties {
|
.contentItems .properties {
|
||||||
float:none;
|
float:none;
|
||||||
clear:both;
|
clear:both;
|
||||||
}
|
}
|
||||||
|
|
||||||
.contentItems .pageStatus {
|
.contentItems .pageStatus {
|
||||||
margin:.8em 0;
|
margin:.8em 0;
|
||||||
color:#666;
|
color:#666;
|
||||||
|
@@ -22,7 +22,7 @@
|
|||||||
<ul class="contentItems">
|
<ul class="contentItems">
|
||||||
@foreach (var item in Model.Extensions) {
|
@foreach (var item in Model.Extensions) {
|
||||||
<li>
|
<li>
|
||||||
<div class="moduleName">
|
<div class="extensionName">
|
||||||
<h2>@item.Title<span> - @T("Version: {0}", item.Version)</span></h2>
|
<h2>@item.Title<span> - @T("Version: {0}", item.Version)</span></h2>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
@@ -22,7 +22,7 @@
|
|||||||
<ul class="contentItems">
|
<ul class="contentItems">
|
||||||
@foreach (var item in Model.Extensions) {
|
@foreach (var item in Model.Extensions) {
|
||||||
<li>
|
<li>
|
||||||
<div class="moduleName">
|
<div class="extensionName">
|
||||||
<h2>@item.Title<span> - @T("Version: {0}", item.Version)</span></h2>
|
<h2>@item.Title<span> - @T("Version: {0}", item.Version)</span></h2>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user