mirror of
https://github.com/getgrav/grav-plugin-admin.git
synced 2025-11-01 19:06:16 +01:00
Handle removing a media also if it's not a json request
Was not working after https://github.com/getgrav/grav-plugin-admin/commit/6b343365996ce838759d 80fa3917d4d994f1aeb4
This commit is contained in:
@@ -876,6 +876,9 @@ class AdminBaseController
|
||||
}
|
||||
|
||||
$filename = base64_decode($this->grav['uri']->param('route'));
|
||||
if (!$filename) {
|
||||
$filename = base64_decode($this->route);
|
||||
}
|
||||
|
||||
$file = File::instance($filename);
|
||||
$resultRemoveMedia = false;
|
||||
@@ -895,17 +898,27 @@ class AdminBaseController
|
||||
}
|
||||
|
||||
if ($resultRemoveMedia && $resultRemoveMediaMeta) {
|
||||
$this->admin->json_response = [
|
||||
'status' => 'success',
|
||||
'message' => $this->admin->translate('PLUGIN_ADMIN.REMOVE_SUCCESSFUL')
|
||||
];
|
||||
if ($this->grav['uri']->extension() === 'json') {
|
||||
$this->admin->json_response = [
|
||||
'status' => 'success',
|
||||
'message' => $this->admin->translate('PLUGIN_ADMIN.REMOVE_SUCCESSFUL')
|
||||
];
|
||||
} else {
|
||||
$this->admin->setMessage($this->admin->translate('PLUGIN_ADMIN.REMOVE_SUCCESSFUL'), 'info');
|
||||
$this->clearMediaCache();
|
||||
$this->setRedirect('/media-manager');
|
||||
}
|
||||
|
||||
return true;
|
||||
} else {
|
||||
$this->admin->json_response = [
|
||||
'status' => 'success',
|
||||
'message' => $this->admin->translate('PLUGIN_ADMIN.REMOVE_FAILED')
|
||||
];
|
||||
if ($this->grav['uri']->extension() === 'json') {
|
||||
$this->admin->json_response = [
|
||||
'status' => 'success',
|
||||
'message' => $this->admin->translate('PLUGIN_ADMIN.REMOVE_FAILED')
|
||||
];
|
||||
} else {
|
||||
$this->admin->setMessage($this->admin->translate('PLUGIN_ADMIN.REMOVE_FAILED'), 'error');
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user