mirror of
https://github.com/flextype/flextype.git
synced 2025-08-19 03:11:21 +02:00
- Admin Panel: Plugins issues #151
This commit is contained in:
@@ -62,11 +62,12 @@ class PluginsController extends Controller
|
||||
public function pluginStatusProcess(Request $request, Response $response) : Response
|
||||
{
|
||||
$data = $request->getParsedBody();
|
||||
$plugin_settings = JsonParser::decode(Filesystem::read(PATH['plugins'] . '/' . $data['plugin'] . '/' . 'settings.json'));
|
||||
Arr::set($plugin_settings, 'enabled', ($data['status'] == 'true' ? true : false));
|
||||
Filesystem::write(PATH['plugins'] . '/' . $data['plugin'] . '/' . 'settings.json', JsonParser::encode($plugin_settings));
|
||||
|
||||
$plugin_settings = JsonParser::decode(Filesystem::read(PATH['plugins'] . '/' . $data['plugin-key'] . '/' . 'settings.json'));
|
||||
Arr::set($plugin_settings, 'enabled', ($data['plugin-status'] == 'true' ? true : false));
|
||||
Filesystem::write(PATH['plugins'] . '/' . $data['plugin-key'] . '/' . 'settings.json', JsonParser::encode($plugin_settings));
|
||||
$this->cache->clear();
|
||||
|
||||
return $response;
|
||||
return $response->withRedirect($this->router->pathFor('admin.plugins.index'));
|
||||
}
|
||||
}
|
||||
|
@@ -45,8 +45,8 @@ $app->group('/' . $admin_route, function () use ($flextype, $app) {
|
||||
$app->post('/settings/clear-cache', 'SettingsController:clearCacheProcess')->setName('admin.settings.clear-cache');
|
||||
|
||||
// Plugins Controller
|
||||
$app->get('/admin/plugins', 'PluginsController:index')->setName('admin.plugins.index');
|
||||
$app->post('/admin/plugins/update-status', 'PluginsController:pluginStatusProcess')->setName('admin.plugins.update-status');
|
||||
$app->get('/plugins', 'PluginsController:index')->setName('admin.plugins.index');
|
||||
$app->post('/plugins/update-status', 'PluginsController:pluginStatusProcess')->setName('admin.plugins.update-status');
|
||||
|
||||
// FieldsetsController
|
||||
$app->get('/fieldsets', 'FieldsetsController:index')->setName('admin.fieldsets.index');
|
||||
|
@@ -273,30 +273,6 @@
|
||||
|
||||
if (typeof $.flextype == 'undefined') $.flextype = {};
|
||||
|
||||
$.flextype.plugins = {
|
||||
|
||||
init: function() {
|
||||
this.changeStatusProcess();
|
||||
},
|
||||
|
||||
changeStatus: function(plugin, status, token) {
|
||||
$.ajax({
|
||||
type: "post",
|
||||
data: "plugin_change_status=1&plugin="+plugin+"&status="+status+"&csrf_name="+$('form input[name="csrf_name"]').val()+"&csrf_value="+$('form input[name="csrf_value"]').val(),
|
||||
url: $('form input[name="url"]').val()
|
||||
});
|
||||
},
|
||||
|
||||
changeStatusProcess: function() {
|
||||
$(".js-switch").click(function() {
|
||||
if ($(this).is(':checked')) {
|
||||
$.flextype.plugins.changeStatus($(this).data("plugin"), "true", $(this).data("token"));
|
||||
} else {
|
||||
$.flextype.plugins.changeStatus($(this).data("plugin"), "false", $(this).data("token"));
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
$(document).ready(function() {
|
||||
|
||||
@@ -326,8 +302,6 @@
|
||||
removeformatPasted: true
|
||||
});
|
||||
|
||||
$.flextype.plugins.init();
|
||||
|
||||
$('.js-save-form-submit').click(function() {
|
||||
$("#form" ).submit();
|
||||
});
|
||||
|
@@ -5,17 +5,17 @@
|
||||
<div class="col-md-6">
|
||||
<form method="post" id="form">
|
||||
{{ csrf() }}
|
||||
<input type="hidden" name="entry_name" value="{{entry_name}}">
|
||||
<input type="hidden" name="id" value="{{ id }}">
|
||||
<div class="form-group">
|
||||
<label for="title">{{ tr('admin_type') }}</label>
|
||||
<select class="form-control" name="fieldset">
|
||||
{% for key, value in fieldsets %}
|
||||
<option value="{{ key }}-{{fieldset}}" {% if key == fieldset %}selected{% endif %}>{{ value }}</option>
|
||||
<option value="{{ key }}" {% if key == fieldset %}selected{% endif %}>{{ value }}</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<input type="submit" id="typeEntry" name="type_entry" value="{{ tr('admin_save') }}" class="btn btn-black btn-fill btn-wd">
|
||||
<input type="submit" id="saveEntry" name="save_entry" value="{{ tr('admin_save') }}" class="btn btn-black btn-fill btn-wd">
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
|
@@ -1,10 +1,6 @@
|
||||
{% extends "plugins/admin/views/partials/base.html" %}
|
||||
|
||||
{% block content %}
|
||||
<form>
|
||||
<input type="hidden" name="url" value="{{ base_url() }}/admin/plugins/update-status">
|
||||
{{ csrf() }}
|
||||
</form>
|
||||
<table class="table no-margin">
|
||||
<thead>
|
||||
<tr>
|
||||
@@ -33,11 +29,19 @@
|
||||
<td class="text-right">
|
||||
<div class="form-group no-margin">
|
||||
<span class="switch switch-sm">
|
||||
<input id="switch-sm-{{ plugin.name }}" type="checkbox" class="switch js-switch" data-plugin="{{ key }}"
|
||||
<input id="switch-sm-{{ key }}"
|
||||
onclick="event.preventDefault();
|
||||
document.getElementById('update-status-{{ key }}').submit();"
|
||||
type="checkbox" class="switch js-switch" data-plugin="{{ key }}"
|
||||
{% if plugin.enabled %}checked{% endif %}
|
||||
{% if key == 'admin' or key == 'site' or key == '' %}disabled{% endif %}>
|
||||
<label for="switch-sm-{{ plugin.name }}"></label>
|
||||
<label for="switch-sm-{{ key }}"></label>
|
||||
</span>
|
||||
<form id="update-status-{{ key }}" action="{{ path_for('admin.plugins.update-status') }}" method="POST" style="display: none;">
|
||||
{{ csrf() }}
|
||||
<input type="hidden" name="plugin-key" value="{{ key }}">
|
||||
<input type="hidden" name="plugin-status" value="{% if plugin.enabled %}false{% else %}true{% endif %}">
|
||||
</form>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
|
Reference in New Issue
Block a user