summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorwn_ <[email protected]>2023-02-05 16:40:42 +0000
committerwn_ <[email protected]>2023-02-05 16:40:42 +0000
commitcc4e851bf0e0c302017c91c03bb384607e159c68 (patch)
tree75a23bc804b50a4c6af6835fc9808a3fe87b9601
parent9d0bfb31df8b29abda3bcccd8d103b39e35d1164 (diff)
Spaces to tabs
-rw-r--r--init.php228
1 files changed, 120 insertions, 108 deletions
diff --git a/init.php b/init.php
index 97882cf..2b9fa4b 100644
--- a/init.php
+++ b/init.php
@@ -1,55 +1,64 @@
<?php
-class Prefs_Effective_Config extends Plugin {
- private const CONFIG_KEYS_TO_MASK = ['DB_PASS'];
- private const PARAM_TYPE_TO_NAME = [
- Config::T_BOOL => 'boolean',
- Config::T_STRING => 'string',
- Config::T_INT => 'integer',
- ];
-
- /** @return array<null|float|string|bool> */
- function about() {
- return [
- null, // version
- 'Shows your effective tt-rss config @ Preferences --> System', // description
- 'wn', // author
- false, // is system
- 'https://dev.tt-rss.org/fox/ttrss-prefs-effective-config', // more info URL
- ];
- }
-
- /** @return int */
- function api_version() {
- return 2;
- }
-
- /**
- * @param PluginHost $host
- *
- * @return void
- * */
- function init($host) {
- $host->add_hook($host::HOOK_PREFS_TAB, $this);
- }
-
- /**
- * @param string $tab
- * @return void
- */
- function hook_prefs_tab($tab) {
- if ($tab != 'prefSystem' || !self::is_admin()) {
- return;
- }
+class Prefs_Effective_Config extends Plugin
+{
+ private const CONFIG_KEYS_TO_MASK = ['DB_PASS'];
+ private const PARAM_TYPE_TO_NAME = [
+ Config::T_BOOL => 'boolean',
+ Config::T_STRING => 'string',
+ Config::T_INT => 'integer',
+ ];
+
+ /** @return array<null|float|string|bool> */
+ function about()
+ {
+ return [
+ null, // version
+ 'Shows your effective tt-rss config @ Preferences --> System', // description
+ 'wn', // author
+ false, // is system
+ 'https://dev.tt-rss.org/fox/ttrss-prefs-effective-config', // more info URL
+ ];
+ }
+
+ /** @return int */
+ function api_version()
+ {
+ return 2;
+ }
+
+ /**
+ * @param PluginHost $host
+ *
+ * @return void
+ * */
+ function init($host)
+ {
+ $host->add_hook($host::HOOK_PREFS_TAB, $this);
+ }
+
+ /**
+ * @param string $tab
+ * @return void
+ */
+ function hook_prefs_tab($tab)
+ {
+ if ($tab != 'prefSystem' || !self::is_admin()) {
+ return;
+ }
?>
- <div dojoType='dijit.layout.AccordionPane' title='<i class="material-icons">subject</i> <?= __('Effective Config') ?>'>
- <script type='dojo/method' event='onSelected' args='evt'>
- if (!this.domNode.querySelector('.loading')) {
- return;
- }
-
- window.setTimeout(() => {
- xhr.json('backend.php', {op: 'pluginhandler', plugin: 'prefs_effective_config', method: 'get_effective_config'}, (reply) => {
- this.attr('content', `
+ <div dojoType='dijit.layout.AccordionPane' title='<i class="material-icons">subject</i> <?= __('Effective Config') ?>'>
+ <script type='dojo/method' event='onSelected' args='evt'>
+ if (!this.domNode.querySelector('.loading')) {
+ return;
+ }
+
+ window.setTimeout(() => {
+ xhr.json('backend.php', {
+ op: 'pluginhandler',
+ plugin: 'prefs_effective_config',
+ method: 'get_effective_config'
+ }, (reply) => {
+ this.attr('content', `
<style type='text/css'>
#config-items-list { text-align: left; border-spacing: 0; }
@@ -103,63 +112,66 @@ class Prefs_Effective_Config extends Plugin {
</tbody>
</table>
`);
- });
- }, 200);
- </script>
- <span class='loading'><?= __('Loading, please wait...') ?></span>
- </div>
+ });
+ }, 200);
+ </script>
+ <span class='loading'><?= __('Loading, please wait...') ?></span>
+ </div>
<?php
- }
-
- function get_effective_config(): void {
- if (!self::is_admin()) {
- print Errors::to_json(Errors::E_UNAUTHORIZED);
- return;
- }
-
- $cfg_instance = new Config();
- $cfg_rc = new ReflectionClass($cfg_instance);
-
- $envvar_prefix = $cfg_rc->getConstant('_ENVVAR_PREFIX');
- $defaults = $cfg_rc->getConstant('_DEFAULTS');
-
- $params_rc = $cfg_rc->getProperty('params');
- $params_rc->setAccessible(true);
-
- $params = [];
-
- foreach ($params_rc->getValue($cfg_instance) as $p => $v) {
- list ($pval, $ptype) = $v;
- $env_val = getenv($envvar_prefix . $p);
- list ($defval, $deftype) = $defaults[$cfg_rc->getConstant($p)];
- $should_redact = in_array($p, self::CONFIG_KEYS_TO_MASK);
-
- $params[] = [
- 'name' => $p,
- 'should_redact' => $should_redact,
- 'effective_val' => $should_redact ? 'redacted' : strval(self::maybe_bool_to_str($pval)),
- 'env_val' => $env_val ? ($should_redact ? 'redacted' : $env_val) : '',
- 'default_val' => strval($defval),
- 'type_hint' => self::PARAM_TYPE_TO_NAME[$ptype],
- ];
- }
-
- print json_encode([
- 'envvar_prefix' => $envvar_prefix,
- 'params' => $params,
- ]);
- }
-
- private static function is_admin(): bool {
- return ($_SESSION['access_level'] ?? UserHelper::ACCESS_LEVEL_DISABLED) >= UserHelper::ACCESS_LEVEL_ADMIN;
- }
-
- /**
- * @param bool|int|string $val
- *
- * @return int|string
- */
- private static function maybe_bool_to_str($val) {
- return $val === true ? 'true' : ($val === false ? 'false' : $val);
- }
+ }
+
+ function get_effective_config(): void
+ {
+ if (!self::is_admin()) {
+ print Errors::to_json(Errors::E_UNAUTHORIZED);
+ return;
+ }
+
+ $cfg_instance = new Config();
+ $cfg_rc = new ReflectionClass($cfg_instance);
+
+ $envvar_prefix = $cfg_rc->getConstant('_ENVVAR_PREFIX');
+ $defaults = $cfg_rc->getConstant('_DEFAULTS');
+
+ $params_rc = $cfg_rc->getProperty('params');
+ $params_rc->setAccessible(true);
+
+ $params = [];
+
+ foreach ($params_rc->getValue($cfg_instance) as $p => $v) {
+ list($pval, $ptype) = $v;
+ $env_val = getenv($envvar_prefix . $p);
+ list($defval, $deftype) = $defaults[$cfg_rc->getConstant($p)];
+ $should_redact = in_array($p, self::CONFIG_KEYS_TO_MASK);
+
+ $params[] = [
+ 'name' => $p,
+ 'should_redact' => $should_redact,
+ 'effective_val' => $should_redact ? 'redacted' : strval(self::maybe_bool_to_str($pval)),
+ 'env_val' => $env_val ? ($should_redact ? 'redacted' : $env_val) : '',
+ 'default_val' => strval($defval),
+ 'type_hint' => self::PARAM_TYPE_TO_NAME[$ptype],
+ ];
+ }
+
+ print json_encode([
+ 'envvar_prefix' => $envvar_prefix,
+ 'params' => $params,
+ ]);
+ }
+
+ private static function is_admin(): bool
+ {
+ return ($_SESSION['access_level'] ?? UserHelper::ACCESS_LEVEL_DISABLED) >= UserHelper::ACCESS_LEVEL_ADMIN;
+ }
+
+ /**
+ * @param bool|int|string $val
+ *
+ * @return int|string
+ */
+ private static function maybe_bool_to_str($val)
+ {
+ return $val === true ? 'true' : ($val === false ? 'false' : $val);
+ }
}