mirror of
https://github.com/getgrav/grav-plugin-admin.git
synced 2026-05-07 06:16:56 +02:00
Make plugin enable/disable to work again
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
<table>
|
||||
{% for slug, package in admin.plugins %}
|
||||
{% set plugin = package.toArray() %}
|
||||
{% set data = admin.data('plugins/' ~ slug) %}
|
||||
|
||||
<tr data-gpm-plugin="{{ slug|url_encode }}">
|
||||
<td class="gpm-name">
|
||||
@@ -33,10 +34,10 @@
|
||||
{% endif %}
|
||||
</td>
|
||||
<td class="gpm-actions">
|
||||
<a class="{{ plugin.get('enabled') ? 'enabled' : 'disabled' }}" href="{{ base_url_relative }}/plugins/{{ slug }}/task:{{ plugin.get('enabled') ? 'disable' : 'enable' }}">
|
||||
<i class="fa fa-fw fa-toggle-{{ plugin.get('enabled') ? 'on' : 'off' }}"></i>
|
||||
<a class="{{ data.get('enabled') ? 'enabled' : 'disabled' }}" href="{{ base_url_relative }}/plugins/{{ slug }}/task:{{ data.get('enabled') ? 'disable' : 'enable' }}">
|
||||
<i class="fa fa-fw fa-toggle-{{ data.get('enabled') ? 'on' : 'off' }}"></i>
|
||||
</a>
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</table>
|
||||
</table>
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
<div class="themes card-row grid fixed-blocks pure-g">
|
||||
{% for slug, package in admin.themes %}
|
||||
{% set theme = package.toArray() %}
|
||||
|
||||
<div class="theme card-item pure-u-1-3" data-gpm-theme="{{ slug|url_encode }}">
|
||||
<div class="gpm-name">
|
||||
<i class="fa fa-fw fa-{{ theme.icon }}"></i>
|
||||
@@ -47,4 +48,4 @@
|
||||
{% endif %}
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user