diff options
author | Phil Davis <phil.davis@inf.org> | 2016-01-22 22:42:28 +0545 |
---|---|---|
committer | Stephen Beaver <sbeaver@netgate.com> | 2016-01-22 12:21:45 -0500 |
commit | 3b3a95e5511ef5f60f8142480ddf5adcaed88cb1 (patch) | |
tree | c011d618e1b5d6123107f4c148d15fe0a6bb87d7 /src/usr/local/www/guiconfig.inc | |
parent | bea2dd6d5fd711653565ec212d0dd62a44b7f043 (diff) | |
download | pfsense-3b3a95e5511ef5f60f8142480ddf5adcaed88cb1.zip pfsense-3b3a95e5511ef5f60f8142480ddf5adcaed88cb1.tar.gz |
Fix #5794 remove print_info_box_np chackes for gettext("apply")
1) Get rid of the stristr() checks to "guess" if an apply button should
be used.
2) Change print_info_box() so it can take a button name of "close"
, "apply" or none to decide which button to show.
3) Delete function print_info_box_np_undo() - nothing calls it.
4) Add new function print_apply_box() to provide an easy wrapper for
print_info_box() with the parameters to be 'warning' level and 'apply'
button.
5) Change print_info_box_np() calls to just print_info_box() or
print_apply_box() as appropriate.
There is 1 direct call to print_info_box_np() from vpn_ipsec_mobile.php
remaining. That tries to make a "create" button. It was not working
before this change. It needs to be sorted out and fixed separately.
After this change there is no dependency on a string containing text
like "apply" to make the apply button appear.
Then we can work on re-engineering the internal code of
print_info_box_np() print_info_box() and print_apply_box() to fit
together however we like. It should be easy to preserving the current
API to print_info_box() and print_apply_box().
Diffstat (limited to 'src/usr/local/www/guiconfig.inc')
-rw-r--r-- | src/usr/local/www/guiconfig.inc | 83 |
1 files changed, 24 insertions, 59 deletions
diff --git a/src/usr/local/www/guiconfig.inc b/src/usr/local/www/guiconfig.inc index b86a0ba..af97879 100644 --- a/src/usr/local/www/guiconfig.inc +++ b/src/usr/local/www/guiconfig.inc @@ -91,11 +91,6 @@ $navlevelsep = ": "; /* navigation level separator string */ $mandfldhtml = ""; /* display this before mandatory input fields */ $mandfldhtmlspc = ""; /* same as above, but with spacing */ -if (!function_exists('set_language')) { - require_once("pfsense-utils.inc"); -} -set_language(); - /* Some ajax scripts still need access to GUI */ if (!$ignorefirmwarelock) { if (is_subsystem_dirty('firmwarelock')) { @@ -306,7 +301,7 @@ function verify_gzip_file($fname) { } } -function print_info_box_np($msg, $name="apply", $value="", $showapply=false, $class="alert-warning",$showbtn = true) { +function print_info_box_np($msg, $name="apply", $value="", $showapply=false, $class="alert-warning", $showclose = true) { global $g; if (strpos($class, "alert-") !== 0) { @@ -319,10 +314,7 @@ function print_info_box_np($msg, $name="apply", $value="", $showapply=false, $cl $msg = '<div class="pull-left">' . $msg . '</div>'; - // The $msg string might or might not have had a known translation into the target language. - // So check it against the keywords "apply", "save and "create" in both the target language and English. - if ((stristr($msg, gettext("apply")) != false) || (stristr($msg, gettext("save")) != false) || (stristr($msg, gettext("create")) != false) || - (stristr($msg, "apply") != false) || (stristr($msg, "save") != false) || (stristr($msg, "create") != false) || $showapply) { + if ($showapply) { $msg .= '<form method="post" class="pull-right"><button type="submit" class="btn btn-default" name="'. $name .'" value="' . $value . '">' . $name . '</button>'; if ($_POST['if']) { @@ -330,63 +322,36 @@ function print_info_box_np($msg, $name="apply", $value="", $showapply=false, $cl } $msg .= '</form>'; - } else if ($showbtn) { + } else if ($showclose) { $msg = '<button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span></button>' . $msg; } echo '<div class="alert ' . $class . ' clearfix" role="alert">' . $msg . '</div>'; } -function print_info_box_np_undo($msg, $name = "apply", $value = "Apply changes", $undo) { - global $g; - - if (stristr($msg, "apply") != false || stristr($msg, "save") != false || stristr($msg, "create") != false) { - $savebutton = "<td class=\"infoboxsave text-nowrap\">"; - $savebutton .= "<input type=\"button\" value=\"". gettext("Undo") . "\" onclick=\"document.location='{$undo}'\" />"; - $savebutton .= "<input name=\"{$name}\" type=\"submit\" class=\"formbtn\" id=\"${name}\" value=\"{$value}\" />"; - $savebutton .= "</td>"; - if ($_POST['if']) { - $savebutton .= "<input type=\"hidden\" name=\"if\" value=\"" . htmlspecialchars($_POST['if']) . "\" />"; - } - } - - $nifty_redbox = "#990000"; - $nifty_blackbox = "#000000"; - - if (!$savebutton) { - $savebutton = "<td class=\"infoboxsave\"><input value=\"" . gettext("Close") . "\" type=\"button\" onclick=\"$(this).parents('table[id=redboxtable]').hide();\" /></td>"; - } - - echo <<<EOFnp - <table class="infobox" id="redboxtable" summary="red box table"> - <tr> - <td> - <div class="infoboxnp" id="redbox"> - <table class="infoboxnptable2" summary="message"> - <tr> - <td class="infoboxnptd"> - <i class="fa fa-exclamation-circle"></i> - </td> - <td class="infoboxnptd2"> - <b>{$msg}</b> - </td> - {$savebutton} - {$undobutton} - </tr> - </table> - </div> - <div> - <p> </p> - </div> - </td> - </tr> - </table> -EOFnp; - +function print_info_box($msg, $class="alert-warning", $btntoshow = "close") { + switch ($btntoshow) { + case "close": + $showclose = true; + $showapply = false; + $name = ""; + break; + case "apply": + $showclose = false; + $showapply = true; + $name = "apply"; + break; + default: + $showclose = false; + $showapply = false; + $name = ""; + break; + } + print_info_box_np($msg, $name, null, $showapply, $class, $showclose); } -function print_info_box($msg, $class="alert-warning", $showbtn = true) { - print_info_box_np($msg, null, null, false, $class, $showbtn); +function print_apply_box($msg) { + print_info_box($msg, "warning", "apply"); } function get_std_save_message($ok) { |