diff --git a/admin.php b/admin.php index c48baf37..b26f0cf1 100644 --- a/admin.php +++ b/admin.php @@ -71,10 +71,12 @@ class AdminPlugin extends Plugin return [ 'onPluginsInitialized' => [['setup', 100000], ['onPluginsInitialized', 1000]], 'onShutdown' => ['onShutdown', 1000], - 'onFormProcessed' => ['onFormProcessed', 0] + 'onFormProcessed' => ['onFormProcessed', 0], + 'onAdminDashboard' => ['onAdminDashboard', 0], ]; } + return []; } @@ -423,6 +425,10 @@ class AdminPlugin extends Plugin switch ($this->template) { case 'dashboard': $twig->twig_vars['popularity'] = $this->popularity; + + // Gather Plugin-hooked dashboard items + $this->grav->fireEvent('onAdminDashboard'); + break; case 'pages': $page = $this->admin->page(true); @@ -622,4 +628,10 @@ class AdminPlugin extends Plugin return false; } + public function onAdminDashboard() + { + $this->grav['twig']->plugins_hooked_dashboard_widgets[] = ['template' => 'dashboard-maintenance']; + $this->grav['twig']->plugins_hooked_dashboard_widgets[] = ['template' => 'dashboard-statistics']; + } + } diff --git a/themes/grav/templates/dashboard.html.twig b/themes/grav/templates/dashboard.html.twig index 2a590f1f..04e6753a 100644 --- a/themes/grav/templates/dashboard.html.twig +++ b/themes/grav/templates/dashboard.html.twig @@ -27,106 +27,11 @@ {% block messages %}{% endblock %} {% block content_top %} - - {% set gpm = admin.gpm() %} - {% set updatable = gpm.getUpdatablePlugins() %} - {% set backup = admin.lastBackup() %} -
- {% if authorize(['admin.maintenance', 'admin.super']) %} -
-
-

{{ "PLUGIN_ADMIN.MAINTENANCE"|tu }}

-
-
-
-
- -
-

 

-
-
-
-
- - {{ backup.days }}{{ "PLUGIN_ADMIN.DAYS"|tu|lower }} -
-

{{ "PLUGIN_ADMIN.LAST_BACKUP"|tu }}

-
-
-
- - -
-
-
- {% endif %} - {% if authorize(['admin.statistics', 'admin.super']) %} -
-
-

{{ "PLUGIN_ADMIN.STATISTICS"|tu }}

-
- -
- - {{ popularity.getDailyTotal }} - {{ "PLUGIN_ADMIN.TODAY"|tu }} - - - {{ popularity.getWeeklyTotal }} - {{ "PLUGIN_ADMIN.WEEK"|tu }} - - - {{ popularity.getMonthlyTotal }} - {{ "PLUGIN_ADMIN.MONTH"|tu }} - -
-
-
+ {% if grav.twig.plugins_hooked_dashboard_widgets %} + {% for widget in grav.twig.plugins_hooked_dashboard_widgets %} + {% include 'partials/' ~ widget.template ~ '.html.twig' %} + {% endfor %} {% endif %}
{% endblock %} diff --git a/themes/grav/templates/partials/dashboard-maintenance.html.twig b/themes/grav/templates/partials/dashboard-maintenance.html.twig new file mode 100644 index 00000000..4c040ece --- /dev/null +++ b/themes/grav/templates/partials/dashboard-maintenance.html.twig @@ -0,0 +1,44 @@ +{% set backup = admin.lastBackup() %} + +{% if authorize(['admin.maintenance', 'admin.super']) %} +
+
+

{{ "PLUGIN_ADMIN.MAINTENANCE"|tu }}

+
+
+
+
+ +
+

 

+
+
+
+
+ + {{ backup.days }}{{ "PLUGIN_ADMIN.DAYS"|tu|lower }} +
+

{{ "PLUGIN_ADMIN.LAST_BACKUP"|tu }}

+
+
+
+ + +
+
+
+{% endif %} \ No newline at end of file diff --git a/themes/grav/templates/partials/dashboard-statistics.html.twig b/themes/grav/templates/partials/dashboard-statistics.html.twig new file mode 100644 index 00000000..db3402fa --- /dev/null +++ b/themes/grav/templates/partials/dashboard-statistics.html.twig @@ -0,0 +1,53 @@ +{% if authorize(['admin.statistics', 'admin.super']) %} +
+
+

{{ "PLUGIN_ADMIN.STATISTICS"|tu }}

+
+ +
+ + {{ popularity.getDailyTotal }} + {{ "PLUGIN_ADMIN.TODAY"|tu }} + + + {{ popularity.getWeeklyTotal }} + {{ "PLUGIN_ADMIN.WEEK"|tu }} + + + {{ popularity.getMonthlyTotal }} + {{ "PLUGIN_ADMIN.MONTH"|tu }} + +
+
+
+{% endif %} \ No newline at end of file