mirror of
https://github.com/slawkens/myaac.git
synced 2025-05-07 14:49:21 +02:00
Add Sections + Add setting($key) function
Reorganisation
This commit is contained in:
parent
96068d003b
commit
084e191b28
@ -7,6 +7,5 @@
|
||||
"contact": "nobody@example.org",
|
||||
"require": {
|
||||
"myaac": "0.9.0"
|
||||
},
|
||||
"settings": "plugins/example-settings-plugin/settings.php"
|
||||
}
|
||||
}
|
||||
|
@ -17,6 +17,10 @@ return [
|
||||
you can use this outfit generator: http://sleqqus.idl.pl/tlg<br/>
|
||||
Format: head,body,legs,feet",
|
||||
],
|
||||
'section_1' => [
|
||||
'type' => 'section',
|
||||
'title' => 'Section Test',
|
||||
],
|
||||
'just_testing_boolean' => [
|
||||
'name' => 'Just Testing Boolean',
|
||||
'type' => 'boolean',
|
||||
|
@ -1100,6 +1100,12 @@ function configLua($key) {
|
||||
return @$config['lua'][$key];
|
||||
}
|
||||
|
||||
function setting($key)
|
||||
{
|
||||
$settings = Settings::getInstance();
|
||||
return $settings[$key];
|
||||
}
|
||||
|
||||
function clearCache()
|
||||
{
|
||||
require_once LIBS . 'news.php';
|
||||
|
@ -102,20 +102,6 @@ class Plugins {
|
||||
return $hooks;
|
||||
}
|
||||
|
||||
public static function getPluginSettings($pluginName)
|
||||
{
|
||||
$plugin_json = self::getPluginJson($pluginName);
|
||||
if (!$plugin_json) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!isset($plugin_json['settings']) || !file_exists(BASE . $plugin_json['settings'])) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return $plugin_json['settings'];
|
||||
}
|
||||
|
||||
public static function getPluginJson($name = null)
|
||||
{
|
||||
if(!isset($name)) {
|
||||
|
@ -19,18 +19,22 @@ if (!isset($_GET['plugin']) || empty($_GET['plugin'])) {
|
||||
$plugin = $_GET['plugin'];
|
||||
|
||||
if($plugin != 'core') {
|
||||
$pluginSettings = Plugins::getPluginSettings($plugin);
|
||||
if (!$pluginSettings) {
|
||||
error('This plugin does not exist or does not have options defined.');
|
||||
$settingsFilePath = PLUGINS . $plugin . '/settings.php';
|
||||
}
|
||||
else {
|
||||
$settingsFilePath = SYSTEM . 'settings.php';
|
||||
}
|
||||
|
||||
if (!file_exists($settingsFilePath)) {
|
||||
error('This plugin does not exist or does not have settings defined.');
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if($plugin === 'core') {
|
||||
$settingsFile = require SYSTEM . 'settings.php';
|
||||
$settingsFile = require $settingsFilePath;
|
||||
}
|
||||
else {
|
||||
$settingsFile = require BASE . $pluginSettings;
|
||||
$settingsFile = require $settingsFilePath;
|
||||
}
|
||||
|
||||
if (!is_array($settingsFile)) {
|
||||
@ -75,6 +79,20 @@ if($query->rowCount() > 0) {
|
||||
<div class="box-body">
|
||||
<button name="save" type="submit" class="btn btn-primary">Save</button>
|
||||
</div>
|
||||
<?php
|
||||
|
||||
$checkbox = function ($key, $type, $value) {
|
||||
echo '<label><input type="radio" id="' . $key . '" name="settings[' . $key . ']" value="' . ($type ? 'true' : 'false') . '" ' . ($value === $type ? 'checked' : '') . '/>' . ($type ? 'Yes' : 'No') . '</label> ';
|
||||
};
|
||||
|
||||
$i = 0;
|
||||
foreach($settingsFile as $key => $setting) {
|
||||
if($setting['type'] === 'section') {
|
||||
if($i++ !== 0) {
|
||||
echo '</tbody></table>';
|
||||
}
|
||||
?>
|
||||
<h2 style="text-align: center"><strong><?= $setting['title']; ?></strong></h2>
|
||||
<table class="table table-bordered table-striped">
|
||||
<thead>
|
||||
<tr>
|
||||
@ -85,12 +103,8 @@ if($query->rowCount() > 0) {
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php
|
||||
|
||||
$checkbox = function ($key, $type, $value) {
|
||||
echo '<label><input type="radio" id="' . $key . '" name="settings[' . $key . ']" value="' . ($type ? 'true' : 'false') . '" ' . ($value === $type ? 'checked' : '') . '/>' . ($type ? 'Yes' : 'No') . '</label> ';
|
||||
};
|
||||
|
||||
foreach($settingsFile as $key => $setting) {
|
||||
continue;
|
||||
}
|
||||
?>
|
||||
<tr>
|
||||
<td><label for="<?= $key ?>" class="control-label"><?= $setting['name'] ?></label></td>
|
||||
|
@ -1,6 +1,10 @@
|
||||
<?php
|
||||
|
||||
return [
|
||||
'section_1' => [
|
||||
'type' => 'section',
|
||||
'title' => 'Template'
|
||||
],
|
||||
'template' => [
|
||||
'name' => 'Template Name',
|
||||
'type' => 'options',
|
||||
@ -14,6 +18,10 @@ return [
|
||||
'desc' => 'Allow changing template of the website by showing a special select in the part of website',
|
||||
'default' => true,
|
||||
],
|
||||
'section_2' => [
|
||||
'type' => 'section',
|
||||
'title' => 'Misc'
|
||||
],
|
||||
'vocations_amount' => [
|
||||
'name' => 'Amount of Vocations',
|
||||
'type' => 'number',
|
||||
@ -48,6 +56,10 @@ allows using gesior templates and pages with myaac<br/>
|
||||
might bring some performance when disabled',
|
||||
'default' => true,
|
||||
],
|
||||
'section_3' => [
|
||||
'type' => 'section',
|
||||
'title' => 'Meta Site Settings'
|
||||
],
|
||||
'charset' => [
|
||||
'name' => 'Meta Charset',
|
||||
'type' => 'text',
|
||||
@ -85,6 +97,10 @@ might bring some performance when disabled',
|
||||
'default' => false,
|
||||
'desc' => 'default language (currently only English available)'
|
||||
],*/
|
||||
'section_4' => [
|
||||
'type' => 'section',
|
||||
'title' => 'Visitors Counter & Views Counter'
|
||||
],
|
||||
'visitors_counter' => [
|
||||
'name' => 'Visitors Counter',
|
||||
'type' => 'boolean',
|
||||
@ -103,6 +119,10 @@ might bring some performance when disabled',
|
||||
'desc' => 'Enable Views Counter? It will show how many times the website has been viewed by users',
|
||||
'default' => true,
|
||||
],
|
||||
'section_5' => [
|
||||
'type' => 'section',
|
||||
'title' => 'Images URL'
|
||||
],
|
||||
'outfit_images_url' => [
|
||||
'name' => 'Outfit Images URL',
|
||||
'type' => 'text',
|
||||
|
Loading…
x
Reference in New Issue
Block a user