diff --git a/plugins/example-settings-plugin.json b/plugins/example-settings-plugin.json index 4f4b272d..b951b113 100644 --- a/plugins/example-settings-plugin.json +++ b/plugins/example-settings-plugin.json @@ -7,6 +7,5 @@ "contact": "nobody@example.org", "require": { "myaac": "0.9.0" - }, - "settings": "plugins/example-settings-plugin/settings.php" + } } diff --git a/plugins/example-settings-plugin/settings.php b/plugins/example-settings-plugin/settings.php index 6ba9bd3c..6b7a2fe0 100644 --- a/plugins/example-settings-plugin/settings.php +++ b/plugins/example-settings-plugin/settings.php @@ -17,6 +17,10 @@ return [ you can use this outfit generator: http://sleqqus.idl.pl/tlg
Format: head,body,legs,feet", ], + 'section_1' => [ + 'type' => 'section', + 'title' => 'Section Test', + ], 'just_testing_boolean' => [ 'name' => 'Just Testing Boolean', 'type' => 'boolean', diff --git a/system/functions.php b/system/functions.php index 17a3253b..3e18f117 100644 --- a/system/functions.php +++ b/system/functions.php @@ -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'; diff --git a/system/libs/plugins.php b/system/libs/plugins.php index 77af4259..2c226d5b 100644 --- a/system/libs/plugins.php +++ b/system/libs/plugins.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)) { diff --git a/system/pages/admin/settings.php b/system/pages/admin/settings.php index c370c90a..ab9fae89 100644 --- a/system/pages/admin/settings.php +++ b/system/pages/admin/settings.php @@ -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.'); - return; - } + $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,22 +79,32 @@ if($query->rowCount() > 0) {
- - - - - - - - - ' . ($type ? 'Yes' : 'No') . ' '; }; + $i = 0; foreach($settingsFile as $key => $setting) { + if($setting['type'] === 'section') { + if($i++ !== 0) { + echo '
NameValueDescription
'; + } + ?> +

+ + + + + + + + + + diff --git a/system/settings.php b/system/settings.php index a6f6c10a..076043e6 100644 --- a/system/settings.php +++ b/system/settings.php @@ -1,6 +1,10 @@ [ + '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
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',
NameValueDescription