mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-10-15 19:54:57 +08:00
Making MediaPicker controller an admin controller, fixes incorrect css loading.
--HG-- branch : dev
This commit is contained in:
@@ -1,27 +1,24 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Web;
|
||||
using System.Web.Mvc;
|
||||
using Orchard.Localization;
|
||||
using Orchard;
|
||||
using System.Collections.Generic;
|
||||
using Orchard.Media;
|
||||
using Orchard.Media.Models;
|
||||
using Orchard.Media.ViewModels;
|
||||
using Orchard.Media.Services;
|
||||
using Orchard.Media.ViewModels;
|
||||
using Orchard.Security;
|
||||
using Orchard.UI.Admin;
|
||||
using Orchard.Themes;
|
||||
using Orchard.UI.Notify;
|
||||
|
||||
namespace Orchard.MediaPicker.Controllers {
|
||||
[Themed(false)]
|
||||
public class HomeController : Controller {
|
||||
public class AdminController : Controller {
|
||||
private readonly IMediaService _mediaService;
|
||||
private readonly IAuthorizer _authorizer;
|
||||
|
||||
public IOrchardServices Services { get; set; }
|
||||
|
||||
public HomeController(IOrchardServices services, IMediaService mediaService, IAuthorizer authorizer) {
|
||||
public AdminController(IOrchardServices services, IMediaService mediaService, IAuthorizer authorizer) {
|
||||
_authorizer = authorizer;
|
||||
|
||||
Services = services;
|
||||
@@ -33,13 +30,6 @@ namespace Orchard.MediaPicker.Controllers {
|
||||
public Localizer T { get; set; }
|
||||
|
||||
public ActionResult Index(string name, string mediaPath) {
|
||||
// this controller should only be used from the admin panel.
|
||||
// it is not itself an admincontroller, however, because it needs to be 'unthemed',
|
||||
// which admincontrollers currently cannot be.
|
||||
if (!_authorizer.Authorize(StandardPermissions.AccessAdminPanel, T("Can't access the admin"))) {
|
||||
return new HttpUnauthorizedResult();
|
||||
}
|
||||
|
||||
IEnumerable<MediaFile> mediaFiles = _mediaService.GetMediaFiles(mediaPath);
|
||||
IEnumerable<MediaFolder> mediaFolders = _mediaService.GetMediaFolders(mediaPath);
|
||||
var model = new MediaFolderEditViewModel { FolderName = name, MediaFiles = mediaFiles, MediaFolders = mediaFolders, MediaPath = mediaPath };
|
||||
@@ -49,9 +39,6 @@ namespace Orchard.MediaPicker.Controllers {
|
||||
|
||||
[HttpPost]
|
||||
public JsonResult CreateFolder(string path, string folderName) {
|
||||
if (!_authorizer.Authorize(StandardPermissions.AccessAdminPanel)) {
|
||||
return Json(T("Can't access the admin").ToString());
|
||||
}
|
||||
if (!Services.Authorizer.Authorize(Permissions.ManageMedia)) {
|
||||
return Json(T("Couldn't create media folder").ToString());
|
||||
}
|
@@ -84,19 +84,19 @@
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="AdminFilter.cs" />
|
||||
<Compile Include="Controllers\HomeController.cs" />
|
||||
<Compile Include="Controllers\AdminController.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="Views\Index.cshtml" />
|
||||
<Content Include="Views\Admin\Index.cshtml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Folder Include="Models\" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="Views\Tab_Url.cshtml" />
|
||||
<Content Include="Views\Admin\Tab_Url.cshtml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="Views\Tab_Gallery.cshtml" />
|
||||
<Content Include="Views\Admin\Tab_Gallery.cshtml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="Content\Web.config" />
|
||||
|
@@ -57,7 +57,7 @@
|
||||
});
|
||||
|
||||
$("#createFolder").live("click", function () {
|
||||
$.post("MediaPicker/Home/CreateFolder", { path: query("mediaPath"), folderName: $("#folderName").val(), __RequestVerificationToken: $("#__requesttoken").val() },
|
||||
$.post("MediaPicker/Admin/CreateFolder", { path: query("mediaPath"), folderName: $("#folderName").val(), __RequestVerificationToken: $("#__requesttoken").val() },
|
||||
function (response) {
|
||||
if (typeof response === "string") {
|
||||
alert(response);
|
||||
|
@@ -16,7 +16,7 @@
|
||||
var adminIndex = location.href.toLowerCase().indexOf("/admin/");
|
||||
if (adminIndex === -1) return;
|
||||
var url = location.href.substr(0, adminIndex)
|
||||
+ "/MediaPicker?uploadpath=" + (data.uploadMediaPath || "")
|
||||
+ "/MediaPicker/Admin?uploadpath=" + (data.uploadMediaPath || "")
|
||||
+ "&callback=" + callbackName
|
||||
+ "&editmode=" + (!!(data.img && data.img.src))
|
||||
+ "&" + (new Date() - 0);
|
||||
|
@@ -5,9 +5,9 @@
|
||||
@using Orchard.Media.Models;
|
||||
@using Orchard.UI.Resources;
|
||||
@{
|
||||
Style.Include("~/themes/theadmin/styles/site.css"); // todo: and the IE conditional ones
|
||||
Style.Include("~/themes/theadmin/styles/ie.css").UseCondition("lte IE 8").Define(d => d.SetAttribute("media", "screen, projection"));
|
||||
Style.Include("~/themes/theadmin/styles/ie6.css").UseCondition("lte IE 6").Define(d => d.SetAttribute("media", "screen, projection"));
|
||||
Style.Include("~/themes/theadmin/styles/site.css");
|
||||
Style.Include("~/themes/theadmin/styles/ie.css").UseCondition("lte IE 8").SetAttribute("media", "screen, projection");
|
||||
Style.Include("~/themes/theadmin/styles/ie6.css").UseCondition("lte IE 6").SetAttribute("media", "screen, projection");
|
||||
Style.Include("mediapicker.css");
|
||||
|
||||
// these need to be in the head because MediaBrowser.js defines a callback that the thumbnail images call when they load,
|
Reference in New Issue
Block a user