diff --git a/classes/controller.php b/classes/controller.php index c5c32d79..96a7d846 100644 --- a/classes/controller.php +++ b/classes/controller.php @@ -73,10 +73,6 @@ class AdminController */ public function execute() { - // Grab redirect parameter. - $redirect = isset($this->post['_redirect']) ? $this->post['_redirect'] : null; - unset($this->post['_redirect']); - $success = false; $method = 'task' . ucfirst($this->task); if (method_exists($this, $method)) { @@ -86,6 +82,11 @@ class AdminController $success = true; $this->admin->setMessage($e->getMessage()); } + + // Grab redirect parameter. + $redirect = isset($this->post['_redirect']) ? $this->post['_redirect'] : null; + unset($this->post['_redirect']); + // Redirect if requested. if ($redirect) { $this->setRedirect($redirect); @@ -255,10 +256,30 @@ class AdminController } // Filter value and save it. - $this->post = array('enabled' => !empty($this->post['enabled'])); + $this->post = array('enabled' => 1, '_redirect' => 'plugins'); $obj = $this->prepareData(); $obj->save(); - $this->admin->setMessage('Successfully saved'); + $this->admin->setMessage('Successfully enabled plugin'); + + return true; + } + + /** + * Enable plugin. + * + * @return bool True if the action was performed. + */ + public function taskDisable() + { + if ($this->view != 'plugins') { + return false; + } + + // Filter value and save it. + $this->post = array('enabled' => 0, '_redirect' => 'plugins'); + $obj = $this->prepareData(); + $obj->save(); + $this->admin->setMessage('Successfully disabled plugin'); return true; } diff --git a/themes/grav/templates/partials/plugins-list.html.twig b/themes/grav/templates/partials/plugins-list.html.twig index 379506aa..0883eba7 100644 --- a/themes/grav/templates/partials/plugins-list.html.twig +++ b/themes/grav/templates/partials/plugins-list.html.twig @@ -17,6 +17,7 @@ {% for slug, package in admin.plugins %} {% set plugin = package.toArray() %} + {% set data = admin.data('plugins/' ~ slug) %} {% endfor %} -
@@ -33,10 +34,10 @@ {% endif %} - - + +
\ No newline at end of file + diff --git a/themes/grav/templates/partials/themes-list.html.twig b/themes/grav/templates/partials/themes-list.html.twig index b9b2d4d8..c6030001 100644 --- a/themes/grav/templates/partials/themes-list.html.twig +++ b/themes/grav/templates/partials/themes-list.html.twig @@ -17,6 +17,7 @@
{% for slug, package in admin.themes %} {% set theme = package.toArray() %} +
@@ -47,4 +48,4 @@ {% endif %}
{% endfor %} -
\ No newline at end of file +