Auto lint

This commit is contained in:
Flavio Copes
2017-02-26 19:36:01 +01:00
parent ec2821183a
commit 47beb2d5a6
6 changed files with 115 additions and 96 deletions

View File

@@ -77,7 +77,7 @@ class AdminBaseController
8 => "A PHP extension stopped the file upload"
];
/** @var array */
/** @var array */
public $blacklist_views = [];
/**
@@ -105,7 +105,8 @@ class AdminBaseController
$this->admin->setMessage($e->getMessage(), 'error');
}
} else {
$success = $this->grav->fireEvent('onAdminTaskExecute', new Event(['controller' => $this, 'method' => $method]));
$success = $this->grav->fireEvent('onAdminTaskExecute',
new Event(['controller' => $this, 'method' => $method]));
}
// Grab redirect parameter.
@@ -182,6 +183,7 @@ class AdminBaseController
}
}
}
return true;
}
@@ -213,16 +215,13 @@ class AdminBaseController
$config = $this->grav['config'];
$data = $this->view == 'pages' ? $this->admin->page(true) : $this->prepareData([]);
$settings = $data->blueprints()->schema()->getProperty($this->post['name']);
$settings = (object)array_merge(
['avoid_overwriting' => false,
'random_name' => false,
'accept' => ['image/*'],
'limit' => 10,
'filesize' => $config->get('system.media.upload_limit', 5242880) // 5MB
],
(array)$settings,
['name' => $this->post['name']]
);
$settings = (object)array_merge([
'avoid_overwriting' => false,
'random_name' => false,
'accept' => ['image/*'],
'limit' => 10,
'filesize' => $config->get('system.media.upload_limit', 5242880) // 5MB
], (array)$settings, ['name' => $this->post['name']]);
$upload = $this->normalizeFiles($_FILES['data'], $settings->name);
@@ -239,7 +238,8 @@ class AdminBaseController
if ($this->view != 'pages' && in_array($settings->destination, ['@self', 'self@'])) {
$this->admin->json_response = [
'status' => 'error',
'message' => sprintf($this->admin->translate('PLUGIN_ADMIN.FILEUPLOAD_PREVENT_SELF', null), $settings->destination)
'message' => sprintf($this->admin->translate('PLUGIN_ADMIN.FILEUPLOAD_PREVENT_SELF', null),
$settings->destination)
];
return false;
@@ -249,8 +249,8 @@ class AdminBaseController
if ($upload->file->error != UPLOAD_ERR_OK) {
$this->admin->json_response = [
'status' => 'error',
'message' => sprintf($this->admin->translate('PLUGIN_ADMIN.FILEUPLOAD_UNABLE_TO_UPLOAD', null), $upload->file->name,
$this->upload_errors[$upload->file->error])
'message' => sprintf($this->admin->translate('PLUGIN_ADMIN.FILEUPLOAD_UNABLE_TO_UPLOAD', null),
$upload->file->name, $this->upload_errors[$upload->file->error])
];
return false;
@@ -269,7 +269,8 @@ class AdminBaseController
if (!move_uploaded_file($tmp_file, $tmp)) {
$this->admin->json_response = [
'status' => 'error',
'message' => sprintf($this->admin->translate('PLUGIN_ADMIN.FILEUPLOAD_UNABLE_TO_MOVE', null), '', $tmp)
'message' => sprintf($this->admin->translate('PLUGIN_ADMIN.FILEUPLOAD_UNABLE_TO_MOVE', null), '',
$tmp)
];
return false;
@@ -539,6 +540,7 @@ class AdminBaseController
}
$this->admin->json_response = ['status' => 'success'];
return true;
}
@@ -565,8 +567,7 @@ class AdminBaseController
// now the first 4 chars of base contain the lang code.
// if redirect path already contains the lang code, and is != than the base lang code, then use redirect path as-is
if (Utils::pathPrefixedByLangCode($base) && Utils::pathPrefixedByLangCode($this->redirect)
&& substr($base,
if (Utils::pathPrefixedByLangCode($base) && Utils::pathPrefixedByLangCode($this->redirect) && substr($base,
0, 4) != substr($this->redirect, 0, 4)
) {
$redirect = $this->redirect;
@@ -674,8 +675,8 @@ class AdminBaseController
foreach ($queue as $key => $files) {
foreach ($files as $destination => $file) {
if (!rename($file['tmp_name'], $destination)) {
throw new \RuntimeException(sprintf($this->admin->translate('PLUGIN_ADMIN.FILEUPLOAD_UNABLE_TO_MOVE', null),
'"' . $file['tmp_name'] . '"', $destination));
throw new \RuntimeException(sprintf($this->admin->translate('PLUGIN_ADMIN.FILEUPLOAD_UNABLE_TO_MOVE',
null), '"' . $file['tmp_name'] . '"', $destination));
}
unset($files[$destination]['tmp_name']);
@@ -691,7 +692,8 @@ class AdminBaseController
$new_data = $files;
}
if (isset($data['header'][$init_key])) {
$obj->modifyHeader($init_key, array_replace_recursive([], $data['header'][$init_key], $new_data));
$obj->modifyHeader($init_key,
array_replace_recursive([], $data['header'][$init_key], $new_data));
} else {
$obj->modifyHeader($init_key, $new_data);
}
@@ -730,6 +732,7 @@ class AdminBaseController
'status' => 'error',
'message' => sprintf($this->admin->translate('PLUGIN_ADMIN.FILEUPLOAD_PREVENT_SELF', null), $folder)
];
return false;
}
@@ -931,7 +934,7 @@ class AdminBaseController
*/
protected function clearMediaCache()
{
$key = 'media-manager-files';
$key = 'media-manager-files';
$cache = $this->grav['cache'];
$cache->delete(md5($key));