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

@@ -13,8 +13,6 @@ use Grav\Common\Page\Media;
use Grav\Common\Page\Page;
use Grav\Common\Page\Pages;
use Grav\Common\Page\Collection;
use Grav\Common\Plugin;
use Grav\Common\Theme;
use Grav\Common\User\User;
use Grav\Common\Utils;
use Grav\Common\Backup\ZipBackup;
@@ -371,7 +369,7 @@ class AdminController extends AdminBaseController
}
$orderOfNewFolder = $this->getNextOrderInFolder($path);
$new_path = $path . '/' . $orderOfNewFolder . '.' . $data['folder'];
$new_path = $path . '/' . $orderOfNewFolder . '.' . $data['folder'];
Folder::create($new_path);
Cache::clearCache('standard');
@@ -445,7 +443,8 @@ class AdminController extends AdminBaseController
//not admin.super or admin.users
if ($this->prepareData($data)->username !== $this->grav['user']->username) {
$this->admin->setMessage($this->admin->translate('PLUGIN_ADMIN.INSUFFICIENT_PERMISSIONS_FOR_TASK') . ' save.',
'error');
'error');
return false;
}
}
@@ -587,7 +586,9 @@ class AdminController extends AdminBaseController
$topParent = $obj->topParent();
if (isset($topParent)) {
$top_parent_route = (string)$topParent->route();
if ($top_parent_route == $home_route && substr($route, 0, strlen($top_parent_route) + 1) != ($top_parent_route . '/')) {
if ($top_parent_route == $home_route && substr($route, 0,
strlen($top_parent_route) + 1) != ($top_parent_route . '/')
) {
$route = $top_parent_route . $route;
}
}
@@ -776,9 +777,8 @@ class AdminController extends AdminBaseController
foreach ($feed_items as $item) {
$datetime = $adminTwigExtension->adminNicetimeFilter($item->getDate()->getTimestamp());
$feed_data[] =
'<li><span class="date">' . $datetime . '</span> <a href="' . $item->getUrl() . '" target="_blank" title="' . str_replace('"', '″',
$item->getTitle()) . '">' . $item->getTitle() . '</a></li>';
$feed_data[] = '<li><span class="date">' . $datetime . '</span> <a href="' . $item->getUrl() . '" target="_blank" title="' . str_replace('"',
'″', $item->getTitle()) . '">' . $item->getTitle() . '</a></li>';
}
}
@@ -787,6 +787,7 @@ class AdminController extends AdminBaseController
} catch (\Exception $e) {
$this->admin->json_response = ['status' => 'error', 'message' => $e->getMessage()];
return;
}
}
@@ -799,7 +800,7 @@ class AdminController extends AdminBaseController
*/
protected function taskGetUpdates()
{
$data = $this->post;
$data = $this->post;
$flush = isset($data['flush']) && $data['flush'] == true ? true : false;
if (isset($this->grav['session'])) {
@@ -849,6 +850,7 @@ class AdminController extends AdminBaseController
if (!(bool)$this->grav['config']->get('system.cache.enabled') || !$notifications = $cache->fetch('notifications')) {
//No notifications cache (first time)
$this->admin->json_response = ['status' => 'success', 'notifications' => [], 'need_update' => true];
return;
}
@@ -865,10 +867,15 @@ class AdminController extends AdminBaseController
$notifications = $this->admin->processNotifications($notifications);
} catch (\Exception $e) {
$this->admin->json_response = ['status' => 'error', 'message' => $e->getMessage()];
return;
}
$this->admin->json_response = ['status' => 'success', 'notifications' => $notifications, 'need_update' => $need_update];
$this->admin->json_response = [
'status' => 'success',
'notifications' => $notifications,
'need_update' => $need_update
];
}
/**
@@ -887,6 +894,7 @@ class AdminController extends AdminBaseController
$notifications = $this->admin->processNotifications($notifications);
} catch (\Exception $e) {
$this->admin->json_response = ['status' => 'error', 'message' => $e->getMessage()];
return false;
}
@@ -898,7 +906,12 @@ class AdminController extends AdminBaseController
$cache->save('notifications', $notifications);
$cache->save('notifications_last_checked', time());
$this->admin->json_response = ['status' => 'success', 'notifications' => $notifications, 'show_immediately' => $show_immediately];
$this->admin->json_response = [
'status' => 'success',
'notifications' => $notifications,
'show_immediately' => $show_immediately
];
return true;
}
@@ -992,18 +1005,13 @@ class AdminController extends AdminBaseController
if ($result) {
$this->admin->json_response = [
'status' => 'success',
'message' => $this->admin->translate(is_string($result)
? $result
: sprintf($this->admin->translate(
$reinstall ? 'PLUGIN_ADMIN.PACKAGE_X_REINSTALLED_SUCCESSFULLY' : 'PLUGIN_ADMIN.PACKAGE_X_INSTALLED_SUCCESSFULLY'
, null), $package))
'message' => $this->admin->translate(is_string($result) ? $result : sprintf($this->admin->translate($reinstall ? 'PLUGIN_ADMIN.PACKAGE_X_REINSTALLED_SUCCESSFULLY' : 'PLUGIN_ADMIN.PACKAGE_X_INSTALLED_SUCCESSFULLY',
null), $package))
];
} else {
$this->admin->json_response = [
'status' => 'error',
'message' => $this->admin->translate(
$reinstall ? 'PLUGIN_ADMIN.REINSTALLATION_FAILED' : 'PLUGIN_ADMIN.INSTALLATION_FAILED'
)
'message' => $this->admin->translate($reinstall ? 'PLUGIN_ADMIN.REINSTALLATION_FAILED' : 'PLUGIN_ADMIN.INSTALLATION_FAILED')
];
}
@@ -1026,7 +1034,8 @@ class AdminController extends AdminBaseController
'status' => 'error',
'message' => $this->admin->translate('PLUGIN_ADMIN.INSUFFICIENT_PERMISSIONS_FOR_TASK')
];
echo json_encode($json_response);exit;
echo json_encode($json_response);
exit;
}
//check if there are packages that have this as a dependency. Abort and show which ones
@@ -1041,7 +1050,8 @@ class AdminController extends AdminBaseController
}
$json_response = ['status' => 'error', 'message' => $message];
echo json_encode($json_response);exit;
echo json_encode($json_response);
exit;
}
try {
@@ -1049,7 +1059,8 @@ class AdminController extends AdminBaseController
$result = Gpm::uninstall($package, []);
} catch (\Exception $e) {
$json_response = ['status' => 'error', 'message' => $e->getMessage()];
echo json_encode($json_response);exit;
echo json_encode($json_response);
exit;
}
if ($result) {
@@ -1058,13 +1069,15 @@ class AdminController extends AdminBaseController
'dependencies' => $dependencies,
'message' => $this->admin->translate(is_string($result) ? $result : 'PLUGIN_ADMIN.UNINSTALL_SUCCESSFUL')
];
echo json_encode($json_response);exit;
echo json_encode($json_response);
exit;
} else {
$json_response = [
'status' => 'error',
'message' => $this->admin->translate('PLUGIN_ADMIN.UNINSTALL_FAILED')
];
echo json_encode($json_response);exit;
echo json_encode($json_response);
exit;
}
return true;
@@ -1127,8 +1140,7 @@ class AdminController extends AdminBaseController
$author = $this->grav['config']->get('site.author.name', '');
$fullname = $user->fullname ?: $username;
$reset_link = rtrim($this->grav['uri']->rootUrl(true), '/') . '/' . trim($this->admin->base,
'/') . '/reset/task' . $param_sep . 'reset/user' . $param_sep . $username . '/token' . $param_sep . $token . '/admin-nonce' . $param_sep
. Utils::getNonce('admin-form');
'/') . '/reset/task' . $param_sep . 'reset/user' . $param_sep . $username . '/token' . $param_sep . $token . '/admin-nonce' . $param_sep . Utils::getNonce('admin-form');
$sitename = $this->grav['config']->get('site.title', 'Website');
$from = $this->grav['config']->get('plugins.email.from');
@@ -1193,8 +1205,7 @@ class AdminController extends AdminBaseController
if (count($results) > 0) {
$this->admin->json_response = [
'status' => 'success',
'message' => $this->admin->translate('PLUGIN_ADMIN.CACHE_CLEARED') . ' <br />' . $this->admin->translate('PLUGIN_ADMIN.METHOD') . ': ' . $clear
. ''
'message' => $this->admin->translate('PLUGIN_ADMIN.CACHE_CLEARED') . ' <br />' . $this->admin->translate('PLUGIN_ADMIN.METHOD') . ': ' . $clear . ''
];
} else {
$this->admin->json_response = [
@@ -1223,10 +1234,12 @@ class AdminController extends AdminBaseController
$this->admin->json_response = [
'status' => 'error'
];
return false;
}
$filename = $this->grav['locator']->findResource('user://data/notifications/' . $this->grav['user']->username . YAML_EXT, true, true);
$filename = $this->grav['locator']->findResource('user://data/notifications/' . $this->grav['user']->username . YAML_EXT,
true, true);
$file = CompiledYamlFile::instance($filename);
$data = $file->content();
$data[] = $notification_id;
@@ -1290,8 +1303,7 @@ class AdminController extends AdminBaseController
$this->admin->json_response = [
'status' => 'success',
'message' => $this->admin->translate('PLUGIN_ADMIN.YOUR_BACKUP_IS_READY_FOR_DOWNLOAD') . '. <a href="' . $url . '" class="button">'
. $this->admin->translate('PLUGIN_ADMIN.DOWNLOAD_BACKUP') . '</a>',
'message' => $this->admin->translate('PLUGIN_ADMIN.YOUR_BACKUP_IS_READY_FOR_DOWNLOAD') . '. <a href="' . $url . '" class="button">' . $this->admin->translate('PLUGIN_ADMIN.DOWNLOAD_BACKUP') . '</a>',
'toastr' => [
'timeOut' => 0,
'extendedTimeOut' => 0,
@@ -1399,8 +1411,7 @@ class AdminController extends AdminBaseController
foreach ($collection as $page) {
foreach ($queries as $query) {
$query = trim($query);
if (stripos($page->getRawContent(), $query) === false
&& stripos($page->title(),
if (stripos($page->getRawContent(), $query) === false && stripos($page->title(),
$query) === false
) {
$collection->remove($page);
@@ -1601,12 +1612,12 @@ class AdminController extends AdminBaseController
}
$targetPath = $page->path() . '/' . $filename;
$fileParts = pathinfo($filename);
$fileParts = pathinfo($filename);
$found = false;
if (file_exists($targetPath)) {
$found = true;
$found = true;
$result = unlink($targetPath);
if (!$result) {
@@ -1710,7 +1721,8 @@ class AdminController extends AdminBaseController
$input = (array)$this->data;
if (isset($input['order'])) {
$order = max(0, ((int)isset($input['order']) && $input['order']) ? $input['order'] : $page->value('order'));
$order = max(0,
((int)isset($input['order']) && $input['order']) ? $input['order'] : $page->value('order'));
$ordering = $order ? sprintf('%02d.', $order) : '';
$slug = empty($input['folder']) ? $page->value('folder') : (string)$input['folder'];
$page->folder($ordering . $slug);
@@ -2097,12 +2109,10 @@ class AdminController extends AdminBaseController
*/
protected function taskDirectInstall()
{
$file_path = '';
$file_path = $this->data['file_path'];
if (isset($_FILES['uploaded_file'])) {
$file_path = $_FILES['uploaded_file']['tmp_name'];
} else {
$file_path = $this->data['file_path'];
}
$result = Gpm::directInstall($file_path);
@@ -2110,7 +2120,8 @@ class AdminController extends AdminBaseController
if ($result === true) {
$this->admin->setMessage($this->admin->translate('PLUGIN_ADMIN.INSTALLATION_SUCCESSFUL'), 'info');
} else {
$this->admin->setMessage($this->admin->translate('PLUGIN_ADMIN.INSTALLATION_FAILED') . ': ' . $result, 'error');
$this->admin->setMessage($this->admin->translate('PLUGIN_ADMIN.INSTALLATION_FAILED') . ': ' . $result,
'error');
}
$this->setRedirect('/tools');