From: Bernhard Bitsch <bbitsch@ipfire.org>
To: development@lists.ipfire.org
Subject: Re: [PATCH] menu: Fix warnings, clean code
Date: Wed, 20 Apr 2022 15:42:36 +0200 [thread overview]
Message-ID: <54cde0da-e27a-a051-e4f6-cea56398bea4@ipfire.org> (raw)
In-Reply-To: <20220420133234.1588-1-hofmann@leo-andres.de>
[-- Attachment #1: Type: text/plain, Size: 5873 bytes --]
Reviewed-by: Bernhard Bitsch <bbitsch(a)ipfire.org>
Am 20.04.2022 um 15:32 schrieb Leo-Andres Hofmann:
> This patch adds default values and removes a missing translation
> to fix "uninitialized value" and "odd number of elements" warnings.
>
> Removes function calls from functions.pl that have already been
> handled by the header before it is loaded by eval().
>
> Signed-off-by: Leo-Andres Hofmann <hofmann(a)leo-andres.de>
> ---
> config/cfgroot/header.pl | 4 +++-
> config/menu/20-status.menu | 4 ++--
> config/menu/30-network.menu | 2 +-
> html/html/themes/ipfire/include/functions.pl | 16 +++++-----------
> langs/de/cgi-bin/de.pl | 1 -
> langs/fr/cgi-bin/fr.pl | 1 -
> 6 files changed, 11 insertions(+), 17 deletions(-)
>
> diff --git a/config/cfgroot/header.pl b/config/cfgroot/header.pl
> index 5ddea348e..65459cc92 100644
> --- a/config/cfgroot/header.pl
> +++ b/config/cfgroot/header.pl
> @@ -46,7 +46,7 @@ my $menu = \%menuhash;
> %settings = ();
> %ethsettings = ();
> %pppsettings = ();
> -(a)URI = ();
> +my @URI = split('\?', $ENV{'REQUEST_URI'});
>
> ### Make sure this is an SSL request
> if ($ENV{'SERVER_ADDR'} && $ENV{'HTTPS'} ne 'on') {
> @@ -573,3 +573,5 @@ sub get_manualpage_url() {
> # No manual page configured, return nothing
> return;
> }
> +
> +1; # End of package "Header"
> diff --git a/config/menu/20-status.menu b/config/menu/20-status.menu
> index 2bcf0d5e8..f969a3b0b 100644
> --- a/config/menu/20-status.menu
> +++ b/config/menu/20-status.menu
> @@ -49,7 +49,7 @@
> $substatus->{'54.networkovpnsrv'} = {
> 'caption' => "$Lang::tr{'vpn statistic n2n'}",
> 'uri' => '/cgi-bin/netovpnsrv.cgi',
> - 'title' => "$Lang::tr{'vpn statistics n2n'}",
> + 'title' => "$Lang::tr{'vpn statistic n2n'}",
> 'enabled' => 1,
> };
> $substatus->{'60.hardwaregraphs'} = {
> @@ -90,7 +90,7 @@
> $substatus->{'75.atm-status'} = {'caption' => 'Atm-status',
> 'uri' => '/cgi-bin/atm-status.cgi',
> 'title' => 'Atm-status',
> - 'enabled' => `find /sys/class/atm/*/device 2>/dev/null`,
> + 'enabled' => (`find /sys/class/atm/*/device 2>/dev/null` ? 1 : 0),
> };
> $substatus->{'76.mdstat'} = {'caption' => 'Mdstat',
> 'uri' => '/cgi-bin/mdstat.cgi',
> diff --git a/config/menu/30-network.menu b/config/menu/30-network.menu
> index 19571a870..4ef537ed4 100644
> --- a/config/menu/30-network.menu
> +++ b/config/menu/30-network.menu
> @@ -67,7 +67,7 @@
> 'caption' => $Lang::tr{'aliases'},
> 'uri' => '/cgi-bin/aliases.cgi',
> 'title' => "$Lang::tr{'aliases'}",
> - 'enabled' => `grep "RED_TYPE=STATIC" /var/ipfire/ethernet/settings`,
> + 'enabled' => (`grep "RED_TYPE=STATIC" /var/ipfire/ethernet/settings` ? 1 : 0),
> };
> $subnetwork->{'80.macadressmenu'} = {
> 'caption' => $Lang::tr{'mac address menu'},
> diff --git a/html/html/themes/ipfire/include/functions.pl b/html/html/themes/ipfire/include/functions.pl
> index d74c962e4..f2b8e9925 100644
> --- a/html/html/themes/ipfire/include/functions.pl
> +++ b/html/html/themes/ipfire/include/functions.pl
> @@ -31,8 +31,6 @@
> # IPFire default theme. #
> ###############################################################################
>
> -require "${General::swroot}/lang.pl";
> -
> ###############################################################################
> #
> # print menu html elements for submenu entries
> @@ -101,20 +99,15 @@ sub openpage {
> my $title = shift;
> my $boh = shift;
> my $extrahead = shift;
> - my $suppressMenu = shift;
> + my $suppressMenu = shift // 0;
> my @tmp = split(/\./, basename($0));
> my $scriptName = @tmp[0];
>
> - @URI=split ('\?', $ENV{'REQUEST_URI'} );
> - &General::readhash("${swroot}/main/settings", \%settings);
> - &genmenu();
> -
> my $headline = "IPFire";
> if (($settings{'WINDOWWITHHOSTNAME'} eq 'on') || ($settings{'WINDOWWITHHOSTNAME'} eq '')) {
> $headline = "$settings{'HOSTNAME'}.$settings{'DOMAINNAME'}";
> }
>
> -
> print <<END;
> <!DOCTYPE html>
> <html>
> @@ -165,7 +158,10 @@ print <<END
> END
> ;
>
> -&showmenu() if ($suppressMenu != 1);
> +unless($suppressMenu) {
> + &genmenu();
> + &showmenu();
> +}
>
> print <<END
> <div class="bigbox fixed">
> @@ -270,5 +266,3 @@ sub openbox {
> sub closebox {
> print "</div>";
> }
> -
> -1;
> diff --git a/langs/de/cgi-bin/de.pl b/langs/de/cgi-bin/de.pl
> index 6094c191a..1145745e0 100644
> --- a/langs/de/cgi-bin/de.pl
> +++ b/langs/de/cgi-bin/de.pl
> @@ -2874,7 +2874,6 @@
> 'vpn start action start' => 'Immer An',
> 'vpn statistic n2n' => 'OpenVPN: Netz-zu-Netz-Statistik',
> 'vpn statistic rw' => 'OpenVPN: Roadwarrior-Statistik',
> -'vpn statistics n2n' => 'OpenVPN: Netz-zu-Netz-Statistiken',
> 'vpn subjectaltname' => 'SubjectAlternativeName',
> 'vpn subjectaltname missing' => 'SubjectAlternativeName darf nicht leer bleiben.',
> 'vpn wait' => 'WARTE',
> diff --git a/langs/fr/cgi-bin/fr.pl b/langs/fr/cgi-bin/fr.pl
> index 03fc754df..23c01ddb8 100644
> --- a/langs/fr/cgi-bin/fr.pl
> +++ b/langs/fr/cgi-bin/fr.pl
> @@ -2949,7 +2949,6 @@
> 'vpn start action start' => 'Toujours démarré',
> 'vpn statistic n2n' => 'OpenVPN (site-à-site)',
> 'vpn statistic rw' => 'OpenVPN (client nomade)',
> -'vpn statistics n2n' => 'OpenVPN (site-à-site)',
> 'vpn subjectaltname' => 'Nom de l\'objet',
> 'vpn subjectaltname missing' => 'Le nom de l\'objet ne peut être vide.',
> 'vpn wait' => 'ATTENTE',
prev parent reply other threads:[~2022-04-20 13:42 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-04-20 13:32 Leo-Andres Hofmann
2022-04-20 13:42 ` Bernhard Bitsch [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=54cde0da-e27a-a051-e4f6-cea56398bea4@ipfire.org \
--to=bbitsch@ipfire.org \
--cc=development@lists.ipfire.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox