From 2d8aa0801f4d70e6fea471ed6cc76beca0417058 Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Wed, 29 Dec 2021 13:15:20 -0500 Subject: [PATCH] Add MQTT tab. Rework code that spits out options lines to be easier to read. --- web/skins/classic/views/options.php | 131 ++++++++++++---------------- 1 file changed, 54 insertions(+), 77 deletions(-) diff --git a/web/skins/classic/views/options.php b/web/skins/classic/views/options.php index 25cad40cc..fb26cef5d 100644 --- a/web/skins/classic/views/options.php +++ b/web/skins/classic/views/options.php @@ -45,6 +45,7 @@ $tabs['lowband'] = translate('LowBW'); $tabs['users'] = translate('Users'); $tabs['control'] = translate('Control'); $tabs['privacy'] = translate('Privacy'); +$tabs['MQTT'] = translate('MQTT'); if (isset($_REQUEST['tab'])) $tab = validHtmlStr($_REQUEST['tab']); @@ -398,22 +399,22 @@ foreach ( array_map('basename', glob('skins/'.$skin.'/css/*', GLOB_ONLYDIR)) as } // $tab == API else { $config = array(); - $configCat = array(); $configCats = array(); $result = $dbConn->query('SELECT * FROM `Config` ORDER BY `Id` ASC'); - if ( !$result ) + if (!$result) { echo mysql_error(); - while ( $row = dbFetchNext($result) ) { - $config[$row['Name']] = $row; - if ( !($configCat = &$configCats[$row['Category']]) ) { - $configCats[$row['Category']] = array(); - $configCat = &$configCats[$row['Category']]; + } else { + while ($row = dbFetchNext($result)) { + $config[$row['Name']] = $row; + if ( !($configCat = &$configCats[$row['Category']]) ) { + $configCats[$row['Category']] = array(); + } + $configCats[$row['Category']][$row['Name']] = &$config[$row['Name']]; } - $configCat[$row['Name']] = $row; } - if ( $tab == 'system' ) { + if ($tab == 'system') { $configCats[$tab]['ZM_LANG_DEFAULT']['Hint'] = join('|', getLanguages()); $configCats[$tab]['ZM_SKIN_DEFAULT']['Hint'] = join('|', array_map('basename', glob('skins/*',GLOB_ONLYDIR))); $configCats[$tab]['ZM_CSS_DEFAULT']['Hint'] = join('|', array_map ( 'basename', glob('skins/'.ZM_SKIN_DEFAULT.'/css/*',GLOB_ONLYDIR) )); @@ -422,17 +423,16 @@ foreach ( array_map('basename', glob('skins/'.$skin.'/css/*', GLOB_ONLYDIR)) as function timezone_list() { static $timezones = null; - if ( $timezones === null ) { + if ($timezones === null) { $timezones = []; $offsets = []; $now = new DateTime('now', new DateTimeZone('UTC')); - foreach ( DateTimeZone::listIdentifiers() as $timezone ) { + foreach (DateTimeZone::listIdentifiers() as $timezone) { $now->setTimezone(new DateTimeZone($timezone)); $offsets[] = $offset = $now->getOffset(); $timezones[$timezone] = '(' . format_GMT_offset($offset) . ') ' . format_timezone_name($timezone); } - array_multisort($offsets, $timezones); } @@ -454,50 +454,40 @@ foreach ( array_map('basename', glob('skins/'.$skin.'/css/*', GLOB_ONLYDIR)) as $configCats[$tab]['ZM_TIMEZONE']['Hint'] = array(''=> translate('TZUnset')) + timezone_list(); } # end if tab == system ?> -
+ $value ) { - $shortName = preg_replace( '/^ZM_/', '', $name ); - $optionPromptText = !empty($OLANG[$shortName])?$OLANG[$shortName]['Prompt']:$value['Prompt']; + if (!isset($configCats[$tab])) { + echo 'There are no config entries for category '.$tab.'.
'; + } else { + foreach ($configCats[$tab] as $name=>$value) { + $shortName = preg_replace( '/^ZM_/', '', $name ); + $optionPromptText = !empty($OLANG[$shortName])?$OLANG[$shortName]['Prompt']:$value['Prompt']; ?>
- checked="checked"/> - - - 3 ) { -?> - -'form-control-sm') : array('class'=>'form-control-sm', 'disabled'=>'disabled')); + } else { foreach ( $options as $option ) { if ( preg_match('/^([^=]+)=(.+)$/', $option) ) { $optionLabel = $matches[1]; @@ -506,44 +496,34 @@ foreach ( array_map('basename', glob('skins/'.$skin.'/css/*', GLOB_ONLYDIR)) as $optionLabel = $optionValue = $option; } ?> -
+
- - - /> - - /> - - /> - - /> - - - - - -
@@ -551,9 +531,6 @@ foreach ( array_map('basename', glob('skins/'.$skin.'/css/*', GLOB_ONLYDIR)) as - - -