mirror of
https://github.com/getgrav/grav-plugin-admin.git
synced 2025-11-03 11:55:52 +01:00
Auto lint
This commit is contained in:
@@ -193,6 +193,7 @@ class Admin
|
|||||||
{
|
{
|
||||||
$tools = [];
|
$tools = [];
|
||||||
$event = Grav::instance()->fireEvent('onAdminTools', new Event(['tools' => &$tools]));
|
$event = Grav::instance()->fireEvent('onAdminTools', new Event(['tools' => &$tools]));
|
||||||
|
|
||||||
return $tools;
|
return $tools;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -273,6 +274,7 @@ class Admin
|
|||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
$tmp_dir = Grav::instance()['locator']->findResource('cache://', true, true) . '/tmp';
|
$tmp_dir = Grav::instance()['locator']->findResource('cache://', true, true) . '/tmp';
|
||||||
}
|
}
|
||||||
|
|
||||||
return $tmp_dir;
|
return $tmp_dir;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -349,6 +351,7 @@ class Admin
|
|||||||
|
|
||||||
$this->setMessage($this->translate('PLUGIN_ADMIN.LOGIN_LOGGED_IN'), 'info');
|
$this->setMessage($this->translate('PLUGIN_ADMIN.LOGIN_LOGGED_IN'), 'info');
|
||||||
$grav->redirect($post['redirect']);
|
$grav->redirect($post['redirect']);
|
||||||
|
|
||||||
return true; //never reached
|
return true; //never reached
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1149,7 +1152,8 @@ class Admin
|
|||||||
require_once(__DIR__ . '/../twig/AdminTwigExtension.php');
|
require_once(__DIR__ . '/../twig/AdminTwigExtension.php');
|
||||||
$adminTwigExtension = new AdminTwigExtension();
|
$adminTwigExtension = new AdminTwigExtension();
|
||||||
|
|
||||||
$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);
|
||||||
$read_notifications = CompiledYamlFile::instance($filename)->content();
|
$read_notifications = CompiledYamlFile::instance($filename)->content();
|
||||||
|
|
||||||
$notifications_processed = [];
|
$notifications_processed = [];
|
||||||
@@ -1196,6 +1200,7 @@ class Admin
|
|||||||
// Process notifications
|
// Process notifications
|
||||||
$notifications_processed = array_map(function ($notification) use ($adminTwigExtension) {
|
$notifications_processed = array_map(function ($notification) use ($adminTwigExtension) {
|
||||||
$notification->date = $adminTwigExtension->adminNicetimeFilter($notification->date);
|
$notification->date = $adminTwigExtension->adminNicetimeFilter($notification->date);
|
||||||
|
|
||||||
return $notification;
|
return $notification;
|
||||||
}, $notifications_processed);
|
}, $notifications_processed);
|
||||||
|
|
||||||
@@ -1373,8 +1378,7 @@ class Admin
|
|||||||
$type = $parent->childType()
|
$type = $parent->childType()
|
||||||
? $parent->childType()
|
? $parent->childType()
|
||||||
: $parent->blueprints()->get('child_type',
|
: $parent->blueprints()->get('child_type',
|
||||||
'default')
|
'default');
|
||||||
;
|
|
||||||
$page->name($type . CONTENT_EXT);
|
$page->name($type . CONTENT_EXT);
|
||||||
$page->header();
|
$page->header();
|
||||||
}
|
}
|
||||||
@@ -1409,6 +1413,7 @@ class Admin
|
|||||||
$string = strip_tags($content);
|
$string = strip_tags($content);
|
||||||
$string = htmlspecialchars_decode($string, ENT_QUOTES);
|
$string = htmlspecialchars_decode($string, ENT_QUOTES);
|
||||||
$string = str_replace("\n", ' ', $string);
|
$string = str_replace("\n", ' ', $string);
|
||||||
|
|
||||||
return trim($string);
|
return trim($string);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -105,7 +105,8 @@ class AdminBaseController
|
|||||||
$this->admin->setMessage($e->getMessage(), 'error');
|
$this->admin->setMessage($e->getMessage(), 'error');
|
||||||
}
|
}
|
||||||
} else {
|
} 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.
|
// Grab redirect parameter.
|
||||||
@@ -182,6 +183,7 @@ class AdminBaseController
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -213,16 +215,13 @@ class AdminBaseController
|
|||||||
$config = $this->grav['config'];
|
$config = $this->grav['config'];
|
||||||
$data = $this->view == 'pages' ? $this->admin->page(true) : $this->prepareData([]);
|
$data = $this->view == 'pages' ? $this->admin->page(true) : $this->prepareData([]);
|
||||||
$settings = $data->blueprints()->schema()->getProperty($this->post['name']);
|
$settings = $data->blueprints()->schema()->getProperty($this->post['name']);
|
||||||
$settings = (object)array_merge(
|
$settings = (object)array_merge([
|
||||||
['avoid_overwriting' => false,
|
'avoid_overwriting' => false,
|
||||||
'random_name' => false,
|
'random_name' => false,
|
||||||
'accept' => ['image/*'],
|
'accept' => ['image/*'],
|
||||||
'limit' => 10,
|
'limit' => 10,
|
||||||
'filesize' => $config->get('system.media.upload_limit', 5242880) // 5MB
|
'filesize' => $config->get('system.media.upload_limit', 5242880) // 5MB
|
||||||
],
|
], (array)$settings, ['name' => $this->post['name']]);
|
||||||
(array)$settings,
|
|
||||||
['name' => $this->post['name']]
|
|
||||||
);
|
|
||||||
|
|
||||||
$upload = $this->normalizeFiles($_FILES['data'], $settings->name);
|
$upload = $this->normalizeFiles($_FILES['data'], $settings->name);
|
||||||
|
|
||||||
@@ -239,7 +238,8 @@ class AdminBaseController
|
|||||||
if ($this->view != 'pages' && in_array($settings->destination, ['@self', 'self@'])) {
|
if ($this->view != 'pages' && in_array($settings->destination, ['@self', 'self@'])) {
|
||||||
$this->admin->json_response = [
|
$this->admin->json_response = [
|
||||||
'status' => 'error',
|
'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;
|
return false;
|
||||||
@@ -249,8 +249,8 @@ class AdminBaseController
|
|||||||
if ($upload->file->error != UPLOAD_ERR_OK) {
|
if ($upload->file->error != UPLOAD_ERR_OK) {
|
||||||
$this->admin->json_response = [
|
$this->admin->json_response = [
|
||||||
'status' => 'error',
|
'status' => 'error',
|
||||||
'message' => sprintf($this->admin->translate('PLUGIN_ADMIN.FILEUPLOAD_UNABLE_TO_UPLOAD', null), $upload->file->name,
|
'message' => sprintf($this->admin->translate('PLUGIN_ADMIN.FILEUPLOAD_UNABLE_TO_UPLOAD', null),
|
||||||
$this->upload_errors[$upload->file->error])
|
$upload->file->name, $this->upload_errors[$upload->file->error])
|
||||||
];
|
];
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
@@ -269,7 +269,8 @@ class AdminBaseController
|
|||||||
if (!move_uploaded_file($tmp_file, $tmp)) {
|
if (!move_uploaded_file($tmp_file, $tmp)) {
|
||||||
$this->admin->json_response = [
|
$this->admin->json_response = [
|
||||||
'status' => 'error',
|
'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;
|
return false;
|
||||||
@@ -539,6 +540,7 @@ class AdminBaseController
|
|||||||
}
|
}
|
||||||
|
|
||||||
$this->admin->json_response = ['status' => 'success'];
|
$this->admin->json_response = ['status' => 'success'];
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -565,8 +567,7 @@ class AdminBaseController
|
|||||||
|
|
||||||
// now the first 4 chars of base contain the lang code.
|
// 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 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)
|
if (Utils::pathPrefixedByLangCode($base) && Utils::pathPrefixedByLangCode($this->redirect) && substr($base,
|
||||||
&& substr($base,
|
|
||||||
0, 4) != substr($this->redirect, 0, 4)
|
0, 4) != substr($this->redirect, 0, 4)
|
||||||
) {
|
) {
|
||||||
$redirect = $this->redirect;
|
$redirect = $this->redirect;
|
||||||
@@ -674,8 +675,8 @@ class AdminBaseController
|
|||||||
foreach ($queue as $key => $files) {
|
foreach ($queue as $key => $files) {
|
||||||
foreach ($files as $destination => $file) {
|
foreach ($files as $destination => $file) {
|
||||||
if (!rename($file['tmp_name'], $destination)) {
|
if (!rename($file['tmp_name'], $destination)) {
|
||||||
throw new \RuntimeException(sprintf($this->admin->translate('PLUGIN_ADMIN.FILEUPLOAD_UNABLE_TO_MOVE', null),
|
throw new \RuntimeException(sprintf($this->admin->translate('PLUGIN_ADMIN.FILEUPLOAD_UNABLE_TO_MOVE',
|
||||||
'"' . $file['tmp_name'] . '"', $destination));
|
null), '"' . $file['tmp_name'] . '"', $destination));
|
||||||
}
|
}
|
||||||
|
|
||||||
unset($files[$destination]['tmp_name']);
|
unset($files[$destination]['tmp_name']);
|
||||||
@@ -691,7 +692,8 @@ class AdminBaseController
|
|||||||
$new_data = $files;
|
$new_data = $files;
|
||||||
}
|
}
|
||||||
if (isset($data['header'][$init_key])) {
|
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 {
|
} else {
|
||||||
$obj->modifyHeader($init_key, $new_data);
|
$obj->modifyHeader($init_key, $new_data);
|
||||||
}
|
}
|
||||||
@@ -730,6 +732,7 @@ class AdminBaseController
|
|||||||
'status' => 'error',
|
'status' => 'error',
|
||||||
'message' => sprintf($this->admin->translate('PLUGIN_ADMIN.FILEUPLOAD_PREVENT_SELF', null), $folder)
|
'message' => sprintf($this->admin->translate('PLUGIN_ADMIN.FILEUPLOAD_PREVENT_SELF', null), $folder)
|
||||||
];
|
];
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -13,8 +13,6 @@ use Grav\Common\Page\Media;
|
|||||||
use Grav\Common\Page\Page;
|
use Grav\Common\Page\Page;
|
||||||
use Grav\Common\Page\Pages;
|
use Grav\Common\Page\Pages;
|
||||||
use Grav\Common\Page\Collection;
|
use Grav\Common\Page\Collection;
|
||||||
use Grav\Common\Plugin;
|
|
||||||
use Grav\Common\Theme;
|
|
||||||
use Grav\Common\User\User;
|
use Grav\Common\User\User;
|
||||||
use Grav\Common\Utils;
|
use Grav\Common\Utils;
|
||||||
use Grav\Common\Backup\ZipBackup;
|
use Grav\Common\Backup\ZipBackup;
|
||||||
@@ -446,6 +444,7 @@ class AdminController extends AdminBaseController
|
|||||||
if ($this->prepareData($data)->username !== $this->grav['user']->username) {
|
if ($this->prepareData($data)->username !== $this->grav['user']->username) {
|
||||||
$this->admin->setMessage($this->admin->translate('PLUGIN_ADMIN.INSUFFICIENT_PERMISSIONS_FOR_TASK') . ' save.',
|
$this->admin->setMessage($this->admin->translate('PLUGIN_ADMIN.INSUFFICIENT_PERMISSIONS_FOR_TASK') . ' save.',
|
||||||
'error');
|
'error');
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -587,7 +586,9 @@ class AdminController extends AdminBaseController
|
|||||||
$topParent = $obj->topParent();
|
$topParent = $obj->topParent();
|
||||||
if (isset($topParent)) {
|
if (isset($topParent)) {
|
||||||
$top_parent_route = (string)$topParent->route();
|
$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;
|
$route = $top_parent_route . $route;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -776,9 +777,8 @@ class AdminController extends AdminBaseController
|
|||||||
|
|
||||||
foreach ($feed_items as $item) {
|
foreach ($feed_items as $item) {
|
||||||
$datetime = $adminTwigExtension->adminNicetimeFilter($item->getDate()->getTimestamp());
|
$datetime = $adminTwigExtension->adminNicetimeFilter($item->getDate()->getTimestamp());
|
||||||
$feed_data[] =
|
$feed_data[] = '<li><span class="date">' . $datetime . '</span> <a href="' . $item->getUrl() . '" target="_blank" title="' . str_replace('"',
|
||||||
'<li><span class="date">' . $datetime . '</span> <a href="' . $item->getUrl() . '" target="_blank" title="' . str_replace('"', '″',
|
'″', $item->getTitle()) . '">' . $item->getTitle() . '</a></li>';
|
||||||
$item->getTitle()) . '">' . $item->getTitle() . '</a></li>';
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -787,6 +787,7 @@ class AdminController extends AdminBaseController
|
|||||||
|
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
$this->admin->json_response = ['status' => 'error', 'message' => $e->getMessage()];
|
$this->admin->json_response = ['status' => 'error', 'message' => $e->getMessage()];
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -849,6 +850,7 @@ class AdminController extends AdminBaseController
|
|||||||
if (!(bool)$this->grav['config']->get('system.cache.enabled') || !$notifications = $cache->fetch('notifications')) {
|
if (!(bool)$this->grav['config']->get('system.cache.enabled') || !$notifications = $cache->fetch('notifications')) {
|
||||||
//No notifications cache (first time)
|
//No notifications cache (first time)
|
||||||
$this->admin->json_response = ['status' => 'success', 'notifications' => [], 'need_update' => true];
|
$this->admin->json_response = ['status' => 'success', 'notifications' => [], 'need_update' => true];
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -865,10 +867,15 @@ class AdminController extends AdminBaseController
|
|||||||
$notifications = $this->admin->processNotifications($notifications);
|
$notifications = $this->admin->processNotifications($notifications);
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
$this->admin->json_response = ['status' => 'error', 'message' => $e->getMessage()];
|
$this->admin->json_response = ['status' => 'error', 'message' => $e->getMessage()];
|
||||||
|
|
||||||
return;
|
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);
|
$notifications = $this->admin->processNotifications($notifications);
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
$this->admin->json_response = ['status' => 'error', 'message' => $e->getMessage()];
|
$this->admin->json_response = ['status' => 'error', 'message' => $e->getMessage()];
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -898,7 +906,12 @@ class AdminController extends AdminBaseController
|
|||||||
$cache->save('notifications', $notifications);
|
$cache->save('notifications', $notifications);
|
||||||
$cache->save('notifications_last_checked', time());
|
$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;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -992,18 +1005,13 @@ class AdminController extends AdminBaseController
|
|||||||
if ($result) {
|
if ($result) {
|
||||||
$this->admin->json_response = [
|
$this->admin->json_response = [
|
||||||
'status' => 'success',
|
'status' => 'success',
|
||||||
'message' => $this->admin->translate(is_string($result)
|
'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',
|
||||||
? $result
|
null), $package))
|
||||||
: sprintf($this->admin->translate(
|
|
||||||
$reinstall ? 'PLUGIN_ADMIN.PACKAGE_X_REINSTALLED_SUCCESSFULLY' : 'PLUGIN_ADMIN.PACKAGE_X_INSTALLED_SUCCESSFULLY'
|
|
||||||
, null), $package))
|
|
||||||
];
|
];
|
||||||
} else {
|
} else {
|
||||||
$this->admin->json_response = [
|
$this->admin->json_response = [
|
||||||
'status' => 'error',
|
'status' => 'error',
|
||||||
'message' => $this->admin->translate(
|
'message' => $this->admin->translate($reinstall ? 'PLUGIN_ADMIN.REINSTALLATION_FAILED' : 'PLUGIN_ADMIN.INSTALLATION_FAILED')
|
||||||
$reinstall ? 'PLUGIN_ADMIN.REINSTALLATION_FAILED' : 'PLUGIN_ADMIN.INSTALLATION_FAILED'
|
|
||||||
)
|
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1026,7 +1034,8 @@ class AdminController extends AdminBaseController
|
|||||||
'status' => 'error',
|
'status' => 'error',
|
||||||
'message' => $this->admin->translate('PLUGIN_ADMIN.INSUFFICIENT_PERMISSIONS_FOR_TASK')
|
'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
|
//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];
|
$json_response = ['status' => 'error', 'message' => $message];
|
||||||
echo json_encode($json_response);exit;
|
echo json_encode($json_response);
|
||||||
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@@ -1049,7 +1059,8 @@ class AdminController extends AdminBaseController
|
|||||||
$result = Gpm::uninstall($package, []);
|
$result = Gpm::uninstall($package, []);
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
$json_response = ['status' => 'error', 'message' => $e->getMessage()];
|
$json_response = ['status' => 'error', 'message' => $e->getMessage()];
|
||||||
echo json_encode($json_response);exit;
|
echo json_encode($json_response);
|
||||||
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($result) {
|
if ($result) {
|
||||||
@@ -1058,13 +1069,15 @@ class AdminController extends AdminBaseController
|
|||||||
'dependencies' => $dependencies,
|
'dependencies' => $dependencies,
|
||||||
'message' => $this->admin->translate(is_string($result) ? $result : 'PLUGIN_ADMIN.UNINSTALL_SUCCESSFUL')
|
'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 {
|
} else {
|
||||||
$json_response = [
|
$json_response = [
|
||||||
'status' => 'error',
|
'status' => 'error',
|
||||||
'message' => $this->admin->translate('PLUGIN_ADMIN.UNINSTALL_FAILED')
|
'message' => $this->admin->translate('PLUGIN_ADMIN.UNINSTALL_FAILED')
|
||||||
];
|
];
|
||||||
echo json_encode($json_response);exit;
|
echo json_encode($json_response);
|
||||||
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@@ -1127,8 +1140,7 @@ class AdminController extends AdminBaseController
|
|||||||
$author = $this->grav['config']->get('site.author.name', '');
|
$author = $this->grav['config']->get('site.author.name', '');
|
||||||
$fullname = $user->fullname ?: $username;
|
$fullname = $user->fullname ?: $username;
|
||||||
$reset_link = rtrim($this->grav['uri']->rootUrl(true), '/') . '/' . trim($this->admin->base,
|
$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
|
'/') . '/reset/task' . $param_sep . 'reset/user' . $param_sep . $username . '/token' . $param_sep . $token . '/admin-nonce' . $param_sep . Utils::getNonce('admin-form');
|
||||||
. Utils::getNonce('admin-form');
|
|
||||||
|
|
||||||
$sitename = $this->grav['config']->get('site.title', 'Website');
|
$sitename = $this->grav['config']->get('site.title', 'Website');
|
||||||
$from = $this->grav['config']->get('plugins.email.from');
|
$from = $this->grav['config']->get('plugins.email.from');
|
||||||
@@ -1193,8 +1205,7 @@ class AdminController extends AdminBaseController
|
|||||||
if (count($results) > 0) {
|
if (count($results) > 0) {
|
||||||
$this->admin->json_response = [
|
$this->admin->json_response = [
|
||||||
'status' => 'success',
|
'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 {
|
} else {
|
||||||
$this->admin->json_response = [
|
$this->admin->json_response = [
|
||||||
@@ -1223,10 +1234,12 @@ class AdminController extends AdminBaseController
|
|||||||
$this->admin->json_response = [
|
$this->admin->json_response = [
|
||||||
'status' => 'error'
|
'status' => 'error'
|
||||||
];
|
];
|
||||||
|
|
||||||
return false;
|
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);
|
$file = CompiledYamlFile::instance($filename);
|
||||||
$data = $file->content();
|
$data = $file->content();
|
||||||
$data[] = $notification_id;
|
$data[] = $notification_id;
|
||||||
@@ -1290,8 +1303,7 @@ class AdminController extends AdminBaseController
|
|||||||
|
|
||||||
$this->admin->json_response = [
|
$this->admin->json_response = [
|
||||||
'status' => 'success',
|
'status' => 'success',
|
||||||
'message' => $this->admin->translate('PLUGIN_ADMIN.YOUR_BACKUP_IS_READY_FOR_DOWNLOAD') . '. <a href="' . $url . '" class="button">'
|
'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>',
|
||||||
. $this->admin->translate('PLUGIN_ADMIN.DOWNLOAD_BACKUP') . '</a>',
|
|
||||||
'toastr' => [
|
'toastr' => [
|
||||||
'timeOut' => 0,
|
'timeOut' => 0,
|
||||||
'extendedTimeOut' => 0,
|
'extendedTimeOut' => 0,
|
||||||
@@ -1399,8 +1411,7 @@ class AdminController extends AdminBaseController
|
|||||||
foreach ($collection as $page) {
|
foreach ($collection as $page) {
|
||||||
foreach ($queries as $query) {
|
foreach ($queries as $query) {
|
||||||
$query = trim($query);
|
$query = trim($query);
|
||||||
if (stripos($page->getRawContent(), $query) === false
|
if (stripos($page->getRawContent(), $query) === false && stripos($page->title(),
|
||||||
&& stripos($page->title(),
|
|
||||||
$query) === false
|
$query) === false
|
||||||
) {
|
) {
|
||||||
$collection->remove($page);
|
$collection->remove($page);
|
||||||
@@ -1710,7 +1721,8 @@ class AdminController extends AdminBaseController
|
|||||||
$input = (array)$this->data;
|
$input = (array)$this->data;
|
||||||
|
|
||||||
if (isset($input['order'])) {
|
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) : '';
|
$ordering = $order ? sprintf('%02d.', $order) : '';
|
||||||
$slug = empty($input['folder']) ? $page->value('folder') : (string)$input['folder'];
|
$slug = empty($input['folder']) ? $page->value('folder') : (string)$input['folder'];
|
||||||
$page->folder($ordering . $slug);
|
$page->folder($ordering . $slug);
|
||||||
@@ -2097,12 +2109,10 @@ class AdminController extends AdminBaseController
|
|||||||
*/
|
*/
|
||||||
protected function taskDirectInstall()
|
protected function taskDirectInstall()
|
||||||
{
|
{
|
||||||
$file_path = '';
|
$file_path = $this->data['file_path'];
|
||||||
|
|
||||||
if (isset($_FILES['uploaded_file'])) {
|
if (isset($_FILES['uploaded_file'])) {
|
||||||
$file_path = $_FILES['uploaded_file']['tmp_name'];
|
$file_path = $_FILES['uploaded_file']['tmp_name'];
|
||||||
} else {
|
|
||||||
$file_path = $this->data['file_path'];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$result = Gpm::directInstall($file_path);
|
$result = Gpm::directInstall($file_path);
|
||||||
@@ -2110,7 +2120,8 @@ class AdminController extends AdminBaseController
|
|||||||
if ($result === true) {
|
if ($result === true) {
|
||||||
$this->admin->setMessage($this->admin->translate('PLUGIN_ADMIN.INSTALLATION_SUCCESSFUL'), 'info');
|
$this->admin->setMessage($this->admin->translate('PLUGIN_ADMIN.INSTALLATION_SUCCESSFUL'), 'info');
|
||||||
} else {
|
} 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');
|
$this->setRedirect('/tools');
|
||||||
|
|||||||
Reference in New Issue
Block a user