mirror of
https://github.com/getgrav/grav-plugin-admin.git
synced 2026-04-04 19:58:49 +02:00
Move Scheduler to Tools
This commit is contained in:
15
admin.php
15
admin.php
@@ -607,6 +607,7 @@ class AdminPlugin extends Plugin
|
||||
'onAdminRegisterPermissions' => ['onAdminRegisterPermissions', 0],
|
||||
'onOutputGenerated' => ['onOutputGenerated', 0],
|
||||
'onAdminAfterSave' => ['onAdminAfterSave', 0],
|
||||
'onAdminData' => ['onAdminData', 0],
|
||||
]);
|
||||
|
||||
// Autoload classes
|
||||
@@ -838,10 +839,22 @@ class AdminPlugin extends Plugin
|
||||
*/
|
||||
public function onAdminTools(Event $event)
|
||||
{
|
||||
$event['tools'] = array_merge($event['tools'], [$this->grav['language']->translate('PLUGIN_ADMIN.DIRECT_INSTALL')]);
|
||||
$event['tools'] = array_merge($event['tools'], [
|
||||
$this->grav['language']->translate('PLUGIN_ADMIN.DIRECT_INSTALL'),
|
||||
$this->grav['language']->translate('PLUGIN_ADMIN.SCHEDULER')
|
||||
]);
|
||||
|
||||
return $event;
|
||||
}
|
||||
|
||||
public function onAdminData(Event $e)
|
||||
{
|
||||
$type = $e['type'] ?? null;
|
||||
if ($type === 'tools/scheduler') {
|
||||
$e['data_type'] = 'config/scheduler';
|
||||
}
|
||||
}
|
||||
|
||||
public function onAdminDashboard()
|
||||
{
|
||||
$this->grav['twig']->plugins_hooked_dashboard_widgets_top[] = ['template' => 'dashboard-maintenance'];
|
||||
|
||||
@@ -601,7 +601,11 @@ class Admin
|
||||
// Check to see if a data type is plugin-provided, before looking into core ones
|
||||
$event = $this->grav->fireEvent('onAdminData', new Event(['type' => &$type]));
|
||||
if ($event && isset($event['data_type'])) {
|
||||
return $event['data_type'];
|
||||
if (is_string($event['data_type'])) {
|
||||
$type = $event['data_type'];
|
||||
} else {
|
||||
return $event['data_type'];
|
||||
}
|
||||
}
|
||||
|
||||
/** @var UniformResourceLocator $locator */
|
||||
|
||||
@@ -724,7 +724,8 @@ PLUGIN_ADMIN:
|
||||
STRICT_YAML_COMPAT_HELP: "Falls back to Symfony 2.4 YAML parser if Native or 3.4 parser fails"
|
||||
STRICT_TWIG_COMPAT: "Twig Compatibility"
|
||||
STRICT_TWIG_COMPAT_HELP: "Enables deprecated Twig autoescape setting. When disabled, |raw filter is required to output HTML as Twig will autoescape output"
|
||||
SCHEDULER_SETUP: Scheduler Setup
|
||||
SCHEDULER: "Scheduler"
|
||||
SCHEDULER_SETUP: "Scheduler Setup"
|
||||
SCHEDULER_INSTRUCTIONS: "The <b>Grav Scheduler</b> allow you to create and schedule custom jobs. It also provides a method for Grav plugins to integrate programatically and dynamically add jobs to be run periodically."
|
||||
SCHEDULER_POST_INSTRUCTIONS: "To enable the Scheduler's functionality, you must add the <b>Grav Scheduler</b> to your system's crontab file. Run the command above from the terminal to add it automatically. Once saved, refresh this page to see the status Ready."
|
||||
SCHEDULER_JOBS: "Custom Scheduler Jobs"
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
<div class="button-bar">
|
||||
<a class="button" href="{{ base_url }}"><i class="fa fa-reply"></i> {{ "PLUGIN_ADMIN.BACK"|tu }}</a>
|
||||
<button class="button" type="submit" name="task" value="save" form="blueprints"><i class="fa fa-check"></i> {{ "PLUGIN_ADMIN.SAVE"|tu }}</button>
|
||||
</div>
|
||||
<h1><i class="fa fa-fw fa-clock-o"></i> {{ "PLUGIN_ADMIN.SCHEDULER"|tu }}</h1>
|
||||
|
||||
13
themes/grav/templates/partials/tools-scheduler.html.twig
Normal file
13
themes/grav/templates/partials/tools-scheduler.html.twig
Normal file
@@ -0,0 +1,13 @@
|
||||
<div class="scheduler-content">
|
||||
|
||||
{% set data = admin.data('config/scheduler') %}
|
||||
|
||||
{% if authorize(['admin.configuration_scheduler', 'admin.super']) %}
|
||||
|
||||
{% include 'partials/blueprints.html.twig' with { blueprints: data.blueprints, data: data } %}
|
||||
|
||||
{% include 'partials/modal-changes-detected.html.twig' %}
|
||||
{% endif %}
|
||||
|
||||
|
||||
</div>
|
||||
@@ -4,8 +4,19 @@
|
||||
{% if tools_slug == 'tools' %}{% set tools_slug = 'direct-install' %}{% endif %}
|
||||
{% set title = "PLUGIN_ADMIN.TOOLS"|tu ~ ": " ~ ("PLUGIN_ADMIN." ~ tools_slug|underscorize|upper)|tu %}
|
||||
|
||||
{% set titlebar -%}
|
||||
{% include 'partials/tools-' ~ tools_slug ~ '-titlebar.html.twig' ignore missing %}
|
||||
{%- endset %}
|
||||
|
||||
{% block titlebar %}
|
||||
{% if titlebar %}
|
||||
{{ titlebar }}
|
||||
{% else %}
|
||||
<div class="button-bar">
|
||||
<a class="button" href="{{ base_url }}"><i class="fa fa-reply"></i> {{ "PLUGIN_ADMIN.BACK"|tu }}</a>
|
||||
</div>
|
||||
<h1><i class="fa fa-fw fa-briefcase"></i> {{ "PLUGIN_ADMIN.TOOLS"|tu }} - {{ ("PLUGIN_ADMIN." ~ tools_slug|underscorize|upper)|tu }}</h1>
|
||||
{% endif %}
|
||||
{% endblock %}
|
||||
|
||||
{% block content_top %}
|
||||
|
||||
Reference in New Issue
Block a user