From 3b157a8c664d5b6d85a9bc52dde102cb716da1a4 Mon Sep 17 00:00:00 2001 From: "Michael Kaufmann (d00p)" Date: Mon, 12 Sep 2016 11:23:29 +0200 Subject: [PATCH] do not hide unavailable options, just disable them so people can see what is actually possible but just not available due to webserver-usage or other settings Signed-off-by: Michael Kaufmann (d00p) --- .../bool/function.getFormFieldOutputBool.php | 2 +- .../date/function.getFormFieldOutputDate.php | 4 ++-- .../file/function.getFormFieldOutputFile.php | 2 +- lib/functions/formfields/function.buildFormEx.php | 4 ++-- .../formfields/function.getFormFieldOutput.php | 12 +++++++++--- .../formfields/function.getFormGroupOutput.php | 8 +++++--- .../function.getFormFieldOutputString.php | 2 +- .../int/function.getFormFieldOutputInt.php | 4 ++-- .../option/function.getFormFieldOutputOption.php | 4 ++-- .../string/function.getFormFieldOutputString.php | 2 +- .../text/function.getFormFieldOutputText.php | 2 +- lng/english.lng.php | 2 ++ lng/german.lng.php | 2 ++ templates/Sparkle/formfields/bool.tpl | 2 +- templates/Sparkle/formfields/file.tpl | 2 +- templates/Sparkle/formfields/hiddenstring.tpl | 2 +- templates/Sparkle/formfields/option.tpl | 2 +- templates/Sparkle/formfields/string.tpl | 2 +- templates/Sparkle/formfields/text.tpl | 2 +- 19 files changed, 37 insertions(+), 25 deletions(-) diff --git a/lib/functions/formfields/bool/function.getFormFieldOutputBool.php b/lib/functions/formfields/bool/function.getFormFieldOutputBool.php index 1c33cbf8..d2e94f84 100644 --- a/lib/functions/formfields/bool/function.getFormFieldOutputBool.php +++ b/lib/functions/formfields/bool/function.getFormFieldOutputBool.php @@ -17,7 +17,7 @@ * */ -function getFormFieldOutputBool($fieldname, $fielddata) +function getFormFieldOutputBool($fieldname, $fielddata, $do_show = true) { $label = $fielddata['label']; $boolswitch = makeYesNo($fieldname, '1', '0', $fielddata['value']); diff --git a/lib/functions/formfields/date/function.getFormFieldOutputDate.php b/lib/functions/formfields/date/function.getFormFieldOutputDate.php index 7b757076..2c39a4b4 100644 --- a/lib/functions/formfields/date/function.getFormFieldOutputDate.php +++ b/lib/functions/formfields/date/function.getFormFieldOutputDate.php @@ -17,12 +17,12 @@ * */ -function getFormFieldOutputDate($fieldname, $fielddata) +function getFormFieldOutputDate($fieldname, $fielddata, $do_show = true) { if(isset($fielddata['date_timestamp']) && $fielddata['date_timestamp'] === true) { $fielddata['value'] = date('Y-m-d', $fielddata['value']); } - return getFormFieldOutputString($fieldname, $fielddata); + return getFormFieldOutputString($fieldname, $fielddata, $do_show); } diff --git a/lib/functions/formfields/file/function.getFormFieldOutputFile.php b/lib/functions/formfields/file/function.getFormFieldOutputFile.php index a8498440..7789ad4a 100644 --- a/lib/functions/formfields/file/function.getFormFieldOutputFile.php +++ b/lib/functions/formfields/file/function.getFormFieldOutputFile.php @@ -15,7 +15,7 @@ * */ -function getFormFieldOutputFile($fieldname, $fielddata) +function getFormFieldOutputFile($fieldname, $fielddata, $do_show = true) { $label = $fielddata['label']; $value = htmlentities($fielddata['value']); diff --git a/lib/functions/formfields/function.buildFormEx.php b/lib/functions/formfields/function.buildFormEx.php index 69162471..96048840 100644 --- a/lib/functions/formfields/function.buildFormEx.php +++ b/lib/functions/formfields/function.buildFormEx.php @@ -49,7 +49,7 @@ function buildFormEx($form, $part = '') { $do_show = $groupdetails['visible']; } - if ($do_show) { + //if ($do_show) { if (isset($groupdetails['title']) && $groupdetails['title'] != '') { $fields .= getFormGroupOutput($groupname, $groupdetails); } @@ -66,7 +66,7 @@ function buildFormEx($form, $part = '') { $fields .= getFormFieldOutput($fieldname, $fielddetails); } } - } + //} } } } diff --git a/lib/functions/formfields/function.getFormFieldOutput.php b/lib/functions/formfields/function.getFormFieldOutput.php index e610ee8f..c7e5b840 100644 --- a/lib/functions/formfields/function.getFormFieldOutput.php +++ b/lib/functions/formfields/function.getFormFieldOutput.php @@ -19,6 +19,8 @@ function getFormFieldOutput($fieldname, $fielddata) { + global $lng; + $returnvalue = ''; if (is_array($fielddata) && isset($fielddata['type']) @@ -51,6 +53,7 @@ function getFormFieldOutput($fieldname, $fielddata) { $websrv = Settings::Get('system.webserver'); if (!in_array($websrv, $fielddata['websrv_avail'])) { $do_show = false; + $fielddata['label'].= sprintf($lng['serversettings']['option_unavailable_websrv'], implode(", ", $fielddata['websrv_avail'])); } } @@ -59,11 +62,14 @@ function getFormFieldOutput($fieldname, $fielddata) { // be false due to websrv_avail if (isset($fielddata['visible']) && $do_show) { $do_show = $fielddata['visible']; + if (!$do_show) { + $fielddata['label'].= $lng['serversettings']['option_unavailable']; + } } - if ($do_show) { - $returnvalue = call_user_func('getFormFieldOutput' . ucfirst($fielddata['type']), $fieldname, $fielddata); - } + //if ($do_show) { + $returnvalue = call_user_func('getFormFieldOutput' . ucfirst($fielddata['type']), $fieldname, $fielddata, $do_show); + //} } return $returnvalue; } diff --git a/lib/functions/formfields/function.getFormGroupOutput.php b/lib/functions/formfields/function.getFormGroupOutput.php index 46bbe4fa..974cffac 100644 --- a/lib/functions/formfields/function.getFormGroupOutput.php +++ b/lib/functions/formfields/function.getFormGroupOutput.php @@ -81,11 +81,13 @@ function getFormOverviewGroupOutput($groupname, $groupdetails) { $websrv = Settings::Get('system.webserver'); if (!in_array($websrv, $groupdetails['websrv_avail'])) { $do_show = false; + $title .= sprintf($lng['serversettings']['option_unavailable_websrv'], implode(", ", $groupdetails['websrv_avail'])); + // hack disabled flag into select-box + $option = str_replace('checked="checked" /> + disabled="disabled" type="checkbox" name="{$fieldname}" value="1" checked="checked" /> diff --git a/templates/Sparkle/formfields/file.tpl b/templates/Sparkle/formfields/file.tpl index b7940962..c8b2aff0 100644 --- a/templates/Sparkle/formfields/file.tpl +++ b/templates/Sparkle/formfields/file.tpl @@ -1,4 +1,4 @@ {$label} - + disabled="disabled" type="file" class="file" name="{$fieldname}" /> diff --git a/templates/Sparkle/formfields/hiddenstring.tpl b/templates/Sparkle/formfields/hiddenstring.tpl index 4552c600..37b81de6 100644 --- a/templates/Sparkle/formfields/hiddenstring.tpl +++ b/templates/Sparkle/formfields/hiddenstring.tpl @@ -1,4 +1,4 @@ {$label} - + disabled="disabled" type="password" class="text" name="{$fieldname}" value="{$value}" /> \ No newline at end of file diff --git a/templates/Sparkle/formfields/option.tpl b/templates/Sparkle/formfields/option.tpl index 26f4ae3d..489ca542 100644 --- a/templates/Sparkle/formfields/option.tpl +++ b/templates/Sparkle/formfields/option.tpl @@ -1,4 +1,4 @@ {$label} - + diff --git a/templates/Sparkle/formfields/string.tpl b/templates/Sparkle/formfields/string.tpl index aa27675f..ae864af9 100644 --- a/templates/Sparkle/formfields/string.tpl +++ b/templates/Sparkle/formfields/string.tpl @@ -1,4 +1,4 @@ {$label} - + disabled="disabled" type="text" class="text" name="{$fieldname}" value="{$value}" /> diff --git a/templates/Sparkle/formfields/text.tpl b/templates/Sparkle/formfields/text.tpl index 68ba7396..d0a736f7 100644 --- a/templates/Sparkle/formfields/text.tpl +++ b/templates/Sparkle/formfields/text.tpl @@ -1,4 +1,4 @@ {$label} - +