Move template logic to includes + code cleanup

This commit is contained in:
billz 2023-03-20 20:14:01 +01:00
parent 24abe9c53c
commit 7b3a7dba1d
4 changed files with 33 additions and 36 deletions

View File

@ -800,7 +800,6 @@ function getTooltip($msg, $id, $visible = true, $data_html = false)
{
($visible) ? $opt1 = 'visible' : $opt1 = 'invisible';
($data_html) ? $opt2 = 'data-html="true"' : $opt2 = 'data-html="false"';
$tooltip = '<i class="fas fa-question-circle text-muted ' .$opt1.'" id="' .$id. '" data-toggle="tooltip" ' .$opt2. ' data-placement="auto" title="' . _($msg). '"></i>';
return $tooltip;
echo '<i class="fas fa-question-circle text-muted ' .$opt1.'" id="' .$id. '" data-toggle="tooltip" ' .$opt2. ' data-placement="auto" title="' . _($msg). '"></i>';
}

View File

@ -109,6 +109,30 @@ function DisplayHostAPDConfig()
$txpower = $_POST['txpower'];
}
$countries_5Ghz_max48ch = RASPI_5GHZ_ISO_ALPHA2;
$selectedHwMode = $arrConfig['hw_mode'];
if (isset($arrConfig['ieee80211n'])) {
if (strval($arrConfig['ieee80211n']) === '1') {
$selectedHwMode = 'n';
}
}
if (isset($arrConfig['ieee80211ac'])) {
if (strval($arrConfig['ieee80211ac']) === '1') {
$selectedHwMode = 'ac';
}
}
if (isset($arrConfig['ieee80211w'])) {
if (strval($arrConfig['ieee80211w']) === '2') {
$selectedHwMode = 'w';
}
}
if (!in_array($arrConfig['country_code'], $countries_5Ghz_max48ch)) {
$hwModeDisabled = 'ac';
if ($selectedHwMode === $hwModeDisabled) {
unset($selectedHwMode);
}
}
echo renderTemplate(
"hostapd", compact(
"status",
@ -124,7 +148,9 @@ function DisplayHostAPDConfig()
"arrTxPower",
"txpower",
"arrHostapdConf",
"operatingSystem"
"operatingSystem",
"selectedHwMode",
"hwModeDisabled"
)
);
}

View File

@ -56,10 +56,8 @@
<div class="row">
<div class="form-group col-md-6">
<label for="cbxtxpower"><?php echo _("Transmit power (dBm)") ?></label>
<?php echo getTooltip('dBm is a unit of level used to indicate that a power ratio is expressed in decibels (dB) with reference to one milliwatt (mW). 30 dBm is equal to 1000 mW, while 0 dBm equals 1.25 mW.', 'tiptxpower'); ?>
<?php
SelectorOptions('txpower', $arrTxPower, $txpower, 'cbxtxpower');
?>
<?php getTooltip('dBm is a unit of level used to indicate that a power ratio is expressed in decibels (dB) with reference to one milliwatt (mW). 30 dBm is equal to 1000 mW, while 0 dBm equals 1.25 mW.', 'tiptxpower'); ?>
<?php SelectorOptions('txpower', $arrTxPower, $txpower, 'cbxtxpower'); ?>
<small id="txpower_help" class="text-muted"><?php echo _("Sets the <code>txpower</code> option for the AP interface and the configured country."); ?></small>
</div>
</div>

View File

@ -3,9 +3,7 @@
<div class="row">
<div class="form-group col-md-6">
<label for="cbxinterface"><?php echo _("Interface") ;?></label>
<?php
SelectorOptions('interface', $interfaces, $arrConfig['interface'], 'cbxinterface', 'setHardwareModeTooltip');
?>
<?php SelectorOptions('interface', $interfaces, $arrConfig['interface'], 'cbxinterface', 'setHardwareModeTooltip'); ?>
</div>
</div>
<div class="row">
@ -17,32 +15,8 @@
<div class="row">
<div class="form-group col-md-6">
<label for="cbxhwmode"><?php echo _("Wireless Mode") ;?></label>
<?php echo getTooltip(null, 'tiphwmode', true); ?>
<?php
$countries_5Ghz_max48ch = RASPI_5GHZ_ISO_ALPHA2;
$selectedHwMode = $arrConfig['hw_mode'];
if (isset($arrConfig['ieee80211n'])) {
if (strval($arrConfig['ieee80211n']) === '1') {
$selectedHwMode = 'n';
}
}
if (isset($arrConfig['ieee80211ac'])) {
if (strval($arrConfig['ieee80211ac']) === '1') {
$selectedHwMode = 'ac';
}
}
if (isset($arrConfig['ieee80211w'])) {
if (strval($arrConfig['ieee80211w']) === '2') {
$selectedHwMode = 'w';
}
}
if (!in_array($arrConfig['country_code'], $countries_5Ghz_max48ch)) {
$hwModeDisabled = 'ac';
if ($selectedHwMode === $hwModeDisabled) {
unset($selectedHwMode);
}
}
SelectorOptions('hw_mode', $arr80211Standard, $selectedHwMode, 'cbxhwmode', 'loadChannelSelect', $hwModeDisabled); ?>
<?php getTooltip(null, 'tiphwmode', true); ?>
<?php SelectorOptions('hw_mode', $arr80211Standard, $selectedHwMode, 'cbxhwmode', 'loadChannelSelect', $hwModeDisabled); ?>
<div id="hwmode" data-tooltip="<?php echo _("The 802.11ac 5 GHz option is disabled until a compatible wireless regulatory domain is set."); ?>"></div>
</div>
</div>