mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2026-01-19 17:51:45 +08:00
#18100 : Various MediaPicker alert screens showing garbage (3 different failures)
--HG-- branch : 1.x extra : transplant_source : k%A3%B7q%D0%3B%C4%F6%DCr%F02%8D%C2p%20K%C6J%AC
This commit is contained in:
@@ -37,15 +37,15 @@ namespace Orchard.MediaPicker.Controllers {
|
||||
[HttpPost]
|
||||
public JsonResult CreateFolder(string path, string folderName) {
|
||||
if (!Services.Authorizer.Authorize(Permissions.ManageMedia)) {
|
||||
return Json(T("Couldn't create media folder").ToString());
|
||||
return Json(new { Success = false, Message = T("Couldn't create media folder").ToString() });
|
||||
}
|
||||
|
||||
try {
|
||||
_mediaService.CreateFolder(HttpUtility.UrlDecode(path), folderName);
|
||||
return Json(true);
|
||||
return Json(new { Success = true, Message = "" });
|
||||
}
|
||||
catch (Exception exception) {
|
||||
return Json(T("Creating Folder failed: {0}", exception.Message).ToString());
|
||||
return Json(new { Success = false, Message = T("Creating Folder failed: {0}", exception.Message).ToString()} );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -45,17 +45,26 @@
|
||||
});
|
||||
|
||||
$("#createFolder").live("click", function () {
|
||||
if ($(this).hasClass("disabled")) return;
|
||||
$.post("MediaPicker/CreateFolder", { path: query("mediaPath") || "", folderName: $("#folderName").val(), __RequestVerificationToken: $("#__requesttoken").val() },
|
||||
function (response) {
|
||||
if (typeof response === "string") {
|
||||
alert(response);
|
||||
}
|
||||
else {
|
||||
if (response.Success == true) {
|
||||
location.reload(true);
|
||||
} else if (response.Success == false) {
|
||||
alert(response.Message);
|
||||
} else {
|
||||
// Most likely a redirection due to expired authorisation
|
||||
alert($("#AccessDeniedMsg").val());
|
||||
var loginWindow = window.open($("#LoginUrl").val(), "AccessDenied", 'toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=yes,copyhistory=no,resizable=yes');
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
$("#folderName").live("propertychange keyup input paste", function () {
|
||||
var empty = ($("#folderName").val() == "");
|
||||
$("#createFolder").attr("disabled", empty).toggleClass("disabled", empty);
|
||||
});
|
||||
|
||||
$(function () {
|
||||
$("#tabs").tabs({
|
||||
selected: parseInt(query("tab", location.hash)) || 0,
|
||||
@@ -101,8 +110,15 @@
|
||||
});
|
||||
}
|
||||
|
||||
var data = window.opener.jQuery[query("callback")].data,
|
||||
try {
|
||||
var data = window.opener.jQuery[query("callback")].data,
|
||||
img = data ? data.img : null;
|
||||
}
|
||||
catch (ex) {
|
||||
alert($("#LostCallbackMsg").val());
|
||||
window.close();
|
||||
}
|
||||
|
||||
if (img) {
|
||||
for (var name in img) {
|
||||
$("#img-" + name).val(img[name]);
|
||||
@@ -140,7 +156,12 @@
|
||||
height: $(prefix + "height").val()
|
||||
};
|
||||
img.html = getImageHtml(img);
|
||||
window.opener.jQuery[query("callback")]({ img: img });
|
||||
try {
|
||||
window.opener.jQuery[query("callback")]({ img: img });
|
||||
}
|
||||
catch (ex) {
|
||||
alert($("#LostCallbackMsg").val());
|
||||
}
|
||||
window.close();
|
||||
}
|
||||
|
||||
@@ -274,6 +295,10 @@
|
||||
else if (result && result.error) {
|
||||
alert(result.error);
|
||||
}
|
||||
else if (frame.location.pathname.match("AccessDenied")) {
|
||||
alert($("#AccessDeniedMsg").val());
|
||||
window.open($("#LoginUrl").val(), "AccessDenied", 'toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=yes,copyhistory=no,resizable=yes');
|
||||
}
|
||||
else {
|
||||
var somethingPotentiallyHorrible = "";
|
||||
try {
|
||||
|
||||
@@ -29,6 +29,11 @@
|
||||
</head>
|
||||
<body id="orchardmediapicker">
|
||||
|
||||
<form id="ErrorHandlingValues">
|
||||
<input type="hidden" id="LostCallbackMsg" value="@T("Cannot perform requested operation")" />
|
||||
<input type="hidden" id="AccessDeniedMsg" value="@T("Authentification timed-out: please log-on again")" />
|
||||
<input type="hidden" id="LoginUrl" value="@Url.Action("LogIn", new { Controller = "Account", Area = "Orchard.Users" })" />
|
||||
</form>
|
||||
<div id="tabs" class="group">
|
||||
<ul>
|
||||
<li><a href="#tab-url" data-edittext="@T("Update/Upload Image")" data-edittext-content="true">@T("Insert/Upload Image")</a></li>
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
<fieldset>
|
||||
<input id="__requesttoken" type="hidden" value="@Html.AntiForgeryTokenValueOrchard()" />
|
||||
<input class="text-box" id="folderName" type="text" />
|
||||
<input class="button" type="button" id="createFolder" value="@T("Create Folder")" />
|
||||
<input class="button disabled" type="button" id="createFolder" value="@T("Create Folder")" />
|
||||
</fieldset>
|
||||
</div>
|
||||
<fieldset>
|
||||
|
||||
Reference in New Issue
Block a user