fix rename media file reload issue
References #370 and allow better umlaut conversion This is a plain javascript event, therefore the message and reload stuff had to move into the JS caller.
This commit is contained in:
@@ -1,6 +1,11 @@
|
|||||||
Version 2.1 ()
|
Version 2.1 ()
|
||||||
------------------------------------------------------------------------
|
------------------------------------------------------------------------
|
||||||
|
|
||||||
|
* Fixed media item rename handler (#370)
|
||||||
|
|
||||||
|
* Fixed and enhanced multiple media redirects and path / name
|
||||||
|
related issues, as well as some better umlaut conversions
|
||||||
|
|
||||||
* Allow strict media directory selection by toggle filter
|
* Allow strict media directory selection by toggle filter
|
||||||
|
|
||||||
* Allow a better auto char conversion to media upload item names
|
* Allow a better auto char conversion to media upload item names
|
||||||
|
|||||||
@@ -173,18 +173,22 @@ switch ($serendipity['GET']['adminAction']) {
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case 'rename':
|
case 'rename':
|
||||||
$data['case_rename'] = true;
|
|
||||||
$serendipity['GET']['fid'] = (int)$serendipity['GET']['fid'];
|
$serendipity['GET']['fid'] = (int)$serendipity['GET']['fid'];
|
||||||
$file = serendipity_fetchImageFromDatabase($serendipity['GET']['fid']);
|
$file = serendipity_fetchImageFromDatabase($serendipity['GET']['fid']);
|
||||||
$serendipity['GET']['newname'] = serendipity_uploadSecure($serendipity['GET']['newname'], true);
|
|
||||||
|
if (LANG_CHARSET == 'UTF-8') {
|
||||||
|
// yeah, turn on content to be a real utf-8 string, which it isn't at this point! Else serendipity_makeFilename() can not work!
|
||||||
|
$serendipity['GET']['newname'] = utf8_encode($serendipity['GET']['newname']);
|
||||||
|
}
|
||||||
|
$serendipity['GET']['newname'] = str_replace(' ', '_', $serendipity['GET']['newname']); // keep serendipity_uploadSecure(URL) whitespace convert behaviour, when using serendipity_makeFilename()
|
||||||
|
$serendipity['GET']['newname'] = serendipity_uploadSecure(serendipity_makeFilename($serendipity['GET']['newname']), true);
|
||||||
|
|
||||||
if (!is_array($file) || !serendipity_checkFormToken() || !serendipity_checkPermission('adminImagesDelete') ||
|
if (!is_array($file) || !serendipity_checkFormToken() || !serendipity_checkPermission('adminImagesDelete') ||
|
||||||
(!serendipity_checkPermission('adminImagesMaintainOthers') && $file['authorid'] != '0' && $file['authorid'] != $serendipity['authorid'])) {
|
(!serendipity_checkPermission('adminImagesMaintainOthers') && $file['authorid'] != '0' && $file['authorid'] != $serendipity['authorid'])) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!serendipity_moveMediaDirectory(null, $serendipity['GET']['newname'], 'file', $serendipity['GET']['fid'], $file)) {
|
// since this is a javascript action only, all event success/error action messages have moved into js
|
||||||
$data['go_back'] = true;
|
serendipity_moveMediaDirectory(null, $serendipity['GET']['newname'], 'file', $serendipity['GET']['fid'], $file);
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'properties':
|
case 'properties':
|
||||||
@@ -218,7 +222,7 @@ switch ($serendipity['GET']['adminAction']) {
|
|||||||
|
|
||||||
$serendipity['POST']['imageurl'] = serendipity_specialchars($serendipity['POST']['imageurl']);
|
$serendipity['POST']['imageurl'] = serendipity_specialchars($serendipity['POST']['imageurl']);
|
||||||
|
|
||||||
// First find out whether to fetch a file or accept an upload
|
// First find out whether to fetch a hotlink file or accept an upload
|
||||||
if ($serendipity['POST']['imageurl'] != '' && $serendipity['POST']['imageurl'] != 'http://') {
|
if ($serendipity['POST']['imageurl'] != '' && $serendipity['POST']['imageurl'] != 'http://') {
|
||||||
if (!empty($serendipity['POST']['target_filename'][2])) {
|
if (!empty($serendipity['POST']['target_filename'][2])) {
|
||||||
// Faked hidden form 2 when submitting with JavaScript
|
// Faked hidden form 2 when submitting with JavaScript
|
||||||
@@ -233,7 +237,7 @@ switch ($serendipity['GET']['adminAction']) {
|
|||||||
$tindex = 1;
|
$tindex = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
$tfile = str_replace(' ', '_', basename($tfile)); // keep serendipity_uploadSecure(URL) whitespace convert behaviour
|
$tfile = str_replace(' ', '_', basename($tfile)); // keep serendipity_uploadSecure(URL) whitespace convert behaviour, when using serendipity_makeFilename()
|
||||||
$tfile = serendipity_uploadSecure(serendipity_makeFilename($tfile));
|
$tfile = serendipity_uploadSecure(serendipity_makeFilename($tfile));
|
||||||
|
|
||||||
if (serendipity_isActiveFile($tfile)) {
|
if (serendipity_isActiveFile($tfile)) {
|
||||||
@@ -336,7 +340,7 @@ switch ($serendipity['GET']['adminAction']) {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
$tfile = str_replace(' ', '_', basename($tfile)); // keep serendipity_uploadSecure(URL) whitespace convert behaviour
|
$tfile = str_replace(' ', '_', basename($tfile)); // keep serendipity_uploadSecure(URL) whitespace convert behaviour, when using serendipity_makeFilename()
|
||||||
$tfile = serendipity_uploadSecure(serendipity_makeFilename($tfile));
|
$tfile = serendipity_uploadSecure(serendipity_makeFilename($tfile));
|
||||||
|
|
||||||
if (serendipity_isActiveFile($tfile)) {
|
if (serendipity_isActiveFile($tfile)) {
|
||||||
@@ -689,7 +693,7 @@ switch ($serendipity['GET']['adminAction']) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$data['extraParems'] = serendipity_generateImageSelectorParems("form");
|
$data['extraParems'] = serendipity_generateImageSelectorParems('form');
|
||||||
$data['case_scaleSelect'] = true;
|
$data['case_scaleSelect'] = true;
|
||||||
$s = getimagesize($serendipity['serendipityPath'] . $serendipity['uploadPath'] . $file['path'] . $file['name'] . ($file['extension'] ? '.'. $file['extension'] : ""));
|
$s = getimagesize($serendipity['serendipityPath'] . $serendipity['uploadPath'] . $file['path'] . $file['name'] . ($file['extension'] ? '.'. $file['extension'] : ""));
|
||||||
$data['img_width'] = $s[0];
|
$data['img_width'] = $s[0];
|
||||||
@@ -731,6 +735,7 @@ switch ($serendipity['GET']['adminAction']) {
|
|||||||
$data['case_default'] = true;
|
$data['case_default'] = true;
|
||||||
$data['showML'] = showMediaLibrary();
|
$data['showML'] = showMediaLibrary();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! isset($data['showML'])) {
|
if (! isset($data['showML'])) {
|
||||||
|
|||||||
@@ -40,18 +40,11 @@
|
|||||||
</form>
|
</form>
|
||||||
{/if}
|
{/if}
|
||||||
{if $case_do_multidelete || $case_do_delete}
|
{if $case_do_multidelete || $case_do_delete}
|
||||||
{if $showML}{$showML}{/if}
|
{if isset($showML)}{$showML}{/if}
|
||||||
{/if}
|
|
||||||
{if $case_rename}
|
|
||||||
{if $go_back}
|
|
||||||
<input class="go_back" type="button" value="{$CONST.BACK}">
|
|
||||||
{else}
|
|
||||||
<script>location.href="?serendipity[adminModule]=images&serendipity[adminAction]=default";</script>
|
|
||||||
<noscript><a class="button_link icon_link standalone" href="?serendipity[adminModule]=images&serendipity[adminAction]=default">{$CONST.DONE}</a></noscript>
|
|
||||||
{/if}
|
|
||||||
{/if}
|
{/if}
|
||||||
|
{* A $case_rename can not respond to reload page while in JS - serendipity.rename() ajax will reload and set message events by script *}
|
||||||
{if $case_add}
|
{if $case_add}
|
||||||
{$showML}
|
{if isset($showML)}{$showML}{/if}
|
||||||
{/if}
|
{/if}
|
||||||
{if $case_directoryDoDelete}
|
{if $case_directoryDoDelete}
|
||||||
{if $print_DIRECTORY_WRITE_ERROR}<span class="msg_error"><span class="icon-attention-circled"></span> {$print_DIRECTORY_WRITE_ERROR}</span>{/if}
|
{if $print_DIRECTORY_WRITE_ERROR}<span class="msg_error"><span class="icon-attention-circled"></span> {$print_DIRECTORY_WRITE_ERROR}</span>{/if}
|
||||||
|
|||||||
@@ -497,7 +497,61 @@
|
|||||||
var media_rename = '{$CONST.ENTER_NEW_NAME}';
|
var media_rename = '{$CONST.ENTER_NEW_NAME}';
|
||||||
if (newname = prompt(media_rename + fname, fname)) {
|
if (newname = prompt(media_rename + fname, fname)) {
|
||||||
var media_token_url = $('input[name*="serendipity[token]"]').val();
|
var media_token_url = $('input[name*="serendipity[token]"]').val();
|
||||||
$.post('?serendipity[adminModule]=images&serendipity[adminAction]=rename&serendipity[fid]='+ escape(id) +'&serendipity[newname]='+ escape(newname) +'&serendipity[token]='+ media_token_url);
|
$.ajax({
|
||||||
|
type: 'POST',
|
||||||
|
url: '?serendipity[adminModule]=images&serendipity[adminAction]=rename&serendipity[fid]='+ escape(id) +'&serendipity[newname]='+ escape(newname) +'&serendipity[token]='+ media_token_url,
|
||||||
|
async: true,
|
||||||
|
cache: false,
|
||||||
|
success: function(response) {
|
||||||
|
$response = (response.trim() == '')
|
||||||
|
? '<p>{$CONST.DONE}!</p>\
|
||||||
|
<button id="rename_ok" class="button_link state_submit" type="button" >{$CONST.GO}</button>\
|
||||||
|
'
|
||||||
|
: response + '\
|
||||||
|
<input class="go_back" type="button" onClick="$.magnificPopup.close();" value="{$CONST.BACK}">\
|
||||||
|
';
|
||||||
|
$.magnificPopup.open({
|
||||||
|
items: {
|
||||||
|
type: 'inline',
|
||||||
|
src: $('<div id="rename_msg">\
|
||||||
|
<h4>{$CONST.MEDIA_RENAME}</h4>\
|
||||||
|
'+ $response +'\
|
||||||
|
</div>')
|
||||||
|
},
|
||||||
|
type: 'inline',
|
||||||
|
midClick: true,
|
||||||
|
callbacks: {
|
||||||
|
open: function() {
|
||||||
|
this.content.on('click', '#rename_ok', function() {
|
||||||
|
window.parent.parent.location.href= '?serendipity[adminModule]=images&serendipity[adminAction]=default';
|
||||||
|
});
|
||||||
|
},
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
error: function(XMLHttpRequest, textStatus, errorThrown) {
|
||||||
|
$.magnificPopup.open({
|
||||||
|
items: {
|
||||||
|
type: 'inline',
|
||||||
|
src: $('<div id="rename_msg">\
|
||||||
|
<h4>{$CONST.MEDIA_RENAME}</h4>\
|
||||||
|
<p>"Status: " + textStatus</p>\
|
||||||
|
'+ errorThrown +'\
|
||||||
|
<button id="rename_error" class="button_link state_submit" type="button" >{$CONST.GO}</button>\
|
||||||
|
</div>')
|
||||||
|
},
|
||||||
|
type: 'inline',
|
||||||
|
midClick: true,
|
||||||
|
callbacks: {
|
||||||
|
open: function() {
|
||||||
|
this.content.on('click', '#rename_error', function() {
|
||||||
|
window.parent.parent.location.href= '?serendipity[adminModule]=images&serendipity[adminAction]=default';
|
||||||
|
});
|
||||||
|
},
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1859,6 +1859,25 @@ form > .button_link:first-of-type,
|
|||||||
padding-bottom: .583335em;
|
padding-bottom: .583335em;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.mfp-content #rename_msg {
|
||||||
|
width: 40em;
|
||||||
|
background-color: #FFF;
|
||||||
|
text-align: center;
|
||||||
|
margin: auto;
|
||||||
|
border: 2px double #00FFDB;
|
||||||
|
padding: 0.5em;
|
||||||
|
}
|
||||||
|
.mfp-content #rename_ok {
|
||||||
|
margin-bottom: 1em;
|
||||||
|
color: #FFF;
|
||||||
|
text-shadow: inherit;
|
||||||
|
}
|
||||||
|
.mfp-content #rename_msg button.mfp-close {
|
||||||
|
display: none;
|
||||||
|
visibility: hidden;
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
|
||||||
.taxonomy h3:hover,
|
.taxonomy h3:hover,
|
||||||
.taxonomy li:hover {
|
.taxonomy li:hover {
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
|
|||||||
Reference in New Issue
Block a user