Add MQTT tab. Rework code that spits out options lines to be easier to read.
This commit is contained in:
parent
fb8db3b046
commit
2d8aa0801f
|
@ -45,6 +45,7 @@ $tabs['lowband'] = translate('LowBW');
|
||||||
$tabs['users'] = translate('Users');
|
$tabs['users'] = translate('Users');
|
||||||
$tabs['control'] = translate('Control');
|
$tabs['control'] = translate('Control');
|
||||||
$tabs['privacy'] = translate('Privacy');
|
$tabs['privacy'] = translate('Privacy');
|
||||||
|
$tabs['MQTT'] = translate('MQTT');
|
||||||
|
|
||||||
if (isset($_REQUEST['tab']))
|
if (isset($_REQUEST['tab']))
|
||||||
$tab = validHtmlStr($_REQUEST['tab']);
|
$tab = validHtmlStr($_REQUEST['tab']);
|
||||||
|
@ -398,19 +399,19 @@ foreach ( array_map('basename', glob('skins/'.$skin.'/css/*', GLOB_ONLYDIR)) as
|
||||||
} // $tab == API
|
} // $tab == API
|
||||||
else {
|
else {
|
||||||
$config = array();
|
$config = array();
|
||||||
$configCat = array();
|
|
||||||
$configCats = array();
|
$configCats = array();
|
||||||
|
|
||||||
$result = $dbConn->query('SELECT * FROM `Config` ORDER BY `Id` ASC');
|
$result = $dbConn->query('SELECT * FROM `Config` ORDER BY `Id` ASC');
|
||||||
if ( !$result )
|
if (!$result) {
|
||||||
echo mysql_error();
|
echo mysql_error();
|
||||||
|
} else {
|
||||||
while ($row = dbFetchNext($result)) {
|
while ($row = dbFetchNext($result)) {
|
||||||
$config[$row['Name']] = $row;
|
$config[$row['Name']] = $row;
|
||||||
if ( !($configCat = &$configCats[$row['Category']]) ) {
|
if ( !($configCat = &$configCats[$row['Category']]) ) {
|
||||||
$configCats[$row['Category']] = array();
|
$configCats[$row['Category']] = array();
|
||||||
$configCat = &$configCats[$row['Category']];
|
|
||||||
}
|
}
|
||||||
$configCat[$row['Name']] = $row;
|
$configCats[$row['Category']][$row['Name']] = &$config[$row['Name']];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($tab == 'system') {
|
if ($tab == 'system') {
|
||||||
|
@ -432,7 +433,6 @@ foreach ( array_map('basename', glob('skins/'.$skin.'/css/*', GLOB_ONLYDIR)) as
|
||||||
$offsets[] = $offset = $now->getOffset();
|
$offsets[] = $offset = $now->getOffset();
|
||||||
$timezones[$timezone] = '(' . format_GMT_offset($offset) . ') ' . format_timezone_name($timezone);
|
$timezones[$timezone] = '(' . format_GMT_offset($offset) . ') ' . format_timezone_name($timezone);
|
||||||
}
|
}
|
||||||
|
|
||||||
array_multisort($offsets, $timezones);
|
array_multisort($offsets, $timezones);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -454,13 +454,15 @@ foreach ( array_map('basename', glob('skins/'.$skin.'/css/*', GLOB_ONLYDIR)) as
|
||||||
$configCats[$tab]['ZM_TIMEZONE']['Hint'] = array(''=> translate('TZUnset')) + timezone_list();
|
$configCats[$tab]['ZM_TIMEZONE']['Hint'] = array(''=> translate('TZUnset')) + timezone_list();
|
||||||
} # end if tab == system
|
} # end if tab == system
|
||||||
?>
|
?>
|
||||||
<form name="optionsForm" class="" method="post" action="?">
|
<form name="optionsForm" method="post" action="?">
|
||||||
<input type="hidden" name="view" value="<?php echo $view ?>"/>
|
<input type="hidden" name="view" value="<?php echo $view ?>"/>
|
||||||
<input type="hidden" name="tab" value="<?php echo $tab ?>"/>
|
<input type="hidden" name="tab" value="<?php echo $tab ?>"/>
|
||||||
<input type="hidden" name="action" value="options"/>
|
<input type="hidden" name="action" value="options"/>
|
||||||
<?php
|
<?php
|
||||||
$configCat = $configCats[$tab];
|
if (!isset($configCats[$tab])) {
|
||||||
foreach ( $configCat as $name=>$value ) {
|
echo 'There are no config entries for category '.$tab.'.<br/>';
|
||||||
|
} else {
|
||||||
|
foreach ($configCats[$tab] as $name=>$value) {
|
||||||
$shortName = preg_replace( '/^ZM_/', '', $name );
|
$shortName = preg_replace( '/^ZM_/', '', $name );
|
||||||
$optionPromptText = !empty($OLANG[$shortName])?$OLANG[$shortName]['Prompt']:$value['Prompt'];
|
$optionPromptText = !empty($OLANG[$shortName])?$OLANG[$shortName]['Prompt']:$value['Prompt'];
|
||||||
?>
|
?>
|
||||||
|
@ -469,34 +471,22 @@ foreach ( array_map('basename', glob('skins/'.$skin.'/css/*', GLOB_ONLYDIR)) as
|
||||||
<div class="col-md">
|
<div class="col-md">
|
||||||
<?php
|
<?php
|
||||||
if ($value['Type'] == 'boolean') {
|
if ($value['Type'] == 'boolean') {
|
||||||
?>
|
echo '<input type="checkbox" id="'.$name.'" name="newConfig['.$name.']" value="1"'. ( $value['Value'] ? ' checked="checked"':'').( $canEdit?'':' disabled="disabled"' ).'/>'.PHP_EOL;
|
||||||
<input type="checkbox" id="<?php echo $name ?>" name="newConfig[<?php echo $name ?>]" value="1"<?php if ( $value['Value'] ) { ?> checked="checked"<?php } ?><?php echo $canEdit?'':' disabled="disabled"' ?>/>
|
|
||||||
<?php
|
|
||||||
} else if (is_array($value['Hint'])) {
|
} else if (is_array($value['Hint'])) {
|
||||||
echo htmlSelect("newConfig[$name]", $value['Hint'], $value['Value']);
|
echo htmlSelect("newConfig[$name]", $value['Hint'], $value['Value']);
|
||||||
} else if (preg_match('/\|/', $value['Hint'])) {
|
} else if (preg_match('/\|/', $value['Hint'])) {
|
||||||
?>
|
|
||||||
|
|
||||||
<?php
|
|
||||||
$options = explode('|', $value['Hint']);
|
$options = explode('|', $value['Hint']);
|
||||||
if (count($options) > 3) {
|
if (count($options) > 3) {
|
||||||
?>
|
$html_options = array();
|
||||||
<select class="form-control-sm" name="newConfig[<?php echo $name ?>]"<?php echo $canEdit?'':' disabled="disabled"' ?>>
|
|
||||||
<?php
|
|
||||||
foreach ($options as $option) {
|
foreach ($options as $option) {
|
||||||
if (preg_match('/^([^=]+)=(.+)$/', $option, $matches)) {
|
if (preg_match('/^([^=]+)=(.+)$/', $option, $matches)) {
|
||||||
$optionLabel = $matches[1];
|
$html_options[$matches[2]] = $matcahes[1];
|
||||||
$optionValue = $matches[2];
|
|
||||||
} else {
|
} else {
|
||||||
$optionLabel = $optionValue = $option;
|
$html_options[$option] = $option;
|
||||||
}
|
}
|
||||||
?>
|
|
||||||
<option value="<?php echo $optionValue ?>"<?php if ( $value['Value'] == $optionValue ) { echo ' selected="selected"'; } ?>><?php echo htmlspecialchars($optionLabel) ?></option>
|
|
||||||
<?php
|
|
||||||
}
|
}
|
||||||
?>
|
echo htmlSelect("newConfig[$name]", $html_options, $value['Value'],
|
||||||
</select>
|
$canEdit?array('class'=>'form-control-sm') : array('class'=>'form-control-sm', 'disabled'=>'disabled'));
|
||||||
<?php
|
|
||||||
} else {
|
} else {
|
||||||
foreach ( $options as $option ) {
|
foreach ( $options as $option ) {
|
||||||
if ( preg_match('/^([^=]+)=(.+)$/', $option) ) {
|
if ( preg_match('/^([^=]+)=(.+)$/', $option) ) {
|
||||||
|
@ -511,39 +501,29 @@ foreach ( array_map('basename', glob('skins/'.$skin.'/css/*', GLOB_ONLYDIR)) as
|
||||||
<?php echo htmlspecialchars($optionLabel) ?>
|
<?php echo htmlspecialchars($optionLabel) ?>
|
||||||
</label>
|
</label>
|
||||||
<?php
|
<?php
|
||||||
}
|
} # end foreach option
|
||||||
}
|
} # end if count options > 3
|
||||||
?>
|
|
||||||
<?php
|
|
||||||
} else if ( $value['Type'] == 'text' ) {
|
} else if ( $value['Type'] == 'text' ) {
|
||||||
?>
|
echo '<textarea class="form-control-sm" id="'.$name.'" name="newConfig['.$name.']" rows="5" cols="40"'.($canEdit?'':' disabled="disabled"').'>'.validHtmlStr($value['Value']).'</textarea>'.PHP_EOL;
|
||||||
<textarea class="form-control-sm" id="<?php echo $name ?>" name="newConfig[<?php echo $name ?>]" rows="5" cols="40"<?php echo $canEdit?'':' disabled="disabled"' ?>><?php echo validHtmlStr($value['Value']) ?></textarea>
|
|
||||||
<?php
|
|
||||||
} else if ( $value['Type'] == 'integer' ) {
|
} else if ( $value['Type'] == 'integer' ) {
|
||||||
?>
|
echo '<input type="number" class="form-control-sm" id="'.$name.'" name="newConfig['.$name.']" value="'.validHtmlStr($value['Value']).'" '.($canEdit?'':' disabled="disabled"' ).' step="1"/>'.PHP_EOL;
|
||||||
<input type="number" class="form-control-sm" id="<?php echo $name ?>" name="newConfig[<?php echo $name ?>]" value="<?php echo validHtmlStr($value['Value']) ?>" <?php echo $canEdit?'':' disabled="disabled"' ?>/>
|
|
||||||
<?php
|
|
||||||
} else if ( $value['Type'] == 'hexadecimal' ) {
|
} else if ( $value['Type'] == 'hexadecimal' ) {
|
||||||
?>
|
echo '<input type="text" class="form-control-sm" id="'.$name.'" name="newConfig['.$name.']" value="'.validHtmlStr($value['Value']).'" '.($canEdit?'':' disabled="disabled"' ).'/>'.PHP_EOL;
|
||||||
<input type="text" class="form-control-sm" id="<?php echo $name ?>" name="newConfig[<?php echo $name ?>]" value="<?php echo validHtmlStr($value['Value']) ?>" <?php echo $canEdit?'':' disabled="disabled"' ?>/>
|
|
||||||
<?php
|
|
||||||
} else if ( $value['Type'] == 'decimal' ) {
|
} else if ( $value['Type'] == 'decimal' ) {
|
||||||
?>
|
echo '<input type="text" class="form-control-sm" id="'.$name.'" name="newConfig['.$name.']" value="'.validHtmlStr($value['Value']).'" '.($canEdit?'':' disabled="disabled"' ).'/>'.PHP_EOL;
|
||||||
<input type="text" class="form-control-sm" id="<?php echo $name ?>" name="newConfig[<?php echo $name ?>]" value="<?php echo validHtmlStr($value['Value']) ?>" <?php echo $canEdit?'':' disabled="disabled"' ?>/>
|
} else if ( $value['Type'] == 'password' ) {
|
||||||
<?php
|
echo '<input type="password" class="form-control-sm" id="'.$name.'" name="newConfig['.$name.']" value="'.validHtmlStr($value['Value']).'" '.($canEdit?'':' disabled="disabled"' ).'/>'.PHP_EOL;
|
||||||
} else {
|
} else {
|
||||||
?>
|
echo '<input type="text" class="form-control-sm" id="'.$name.'" name="newConfig['.$name.']" value="'.validHtmlStr($value['Value']).'" '.($canEdit?'':' disabled="disabled"' ).'/>'.PHP_EOL;
|
||||||
<input type="text" class="form-control-sm" id="<?php echo $name ?>" name="newConfig[<?php echo $name ?>]" value="<?php echo validHtmlStr($value['Value']) ?>" <?php echo $canEdit?'':' disabled="disabled"' ?>/>
|
|
||||||
<?php
|
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
<span class="form-text form-control-sm"><?php echo validHtmlStr($optionPromptText); echo makeHelpLink($name) ?></span>
|
<span class="form-text form-control-sm"><?php echo validHtmlStr($optionPromptText); echo makeHelpLink($name) ?></span>
|
||||||
</div><!-- End .col-sm-9 -->
|
</div><!-- End .col-sm-9 -->
|
||||||
</div><!-- End .form-group -->
|
</div><!-- End .form-group -->
|
||||||
<?php
|
<?php
|
||||||
}
|
} # end foreach config entry in the category
|
||||||
|
} # end if category exists
|
||||||
?>
|
?>
|
||||||
|
|
||||||
<div id="contentButtons">
|
<div id="contentButtons">
|
||||||
<button type="submit" <?php echo $canEdit?'':' disabled="disabled"' ?>><?php echo translate('Save') ?></button>
|
<button type="submit" <?php echo $canEdit?'':' disabled="disabled"' ?>><?php echo translate('Save') ?></button>
|
||||||
</div>
|
</div>
|
||||||
|
@ -551,9 +531,6 @@ foreach ( array_map('basename', glob('skins/'.$skin.'/css/*', GLOB_ONLYDIR)) as
|
||||||
<?php
|
<?php
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</div><!-- end #options -->
|
</div><!-- end #options -->
|
||||||
</div>
|
</div>
|
||||||
</div> <!-- end row -->
|
</div> <!-- end row -->
|
||||||
|
|
Loading…
Reference in New Issue