]> git.sesse.net Git - wloh/commitdiff
Add a language navbar at the top.
authorSteinar H. Gunderson <sgunderson@bigfoot.com>
Wed, 30 May 2012 20:02:34 +0000 (22:02 +0200)
committerSteinar H. Gunderson <sgunderson@bigfoot.com>
Wed, 30 May 2012 20:02:34 +0000 (22:02 +0200)
common.pm
www/index.pl
www/rating.pl

index a5c730b806f3d0bda20e511bda9e77be7e8d2cf8..60cc243d608e275714f60edb17c65eef1e1b5dda 100644 (file)
--- a/common.pm
+++ b/common.pm
@@ -42,4 +42,29 @@ sub get_auxillary_parameters {
        return $aux_parms;
 }
 
+sub print_navbar {
+       my ($cgi, $dbh, $locale) = @_;
+       my $url = $cgi->url(-relative => 1);
+
+       print "<p style=\"font-size: smaller;\">";
+
+       my $q = $dbh->prepare('SELECT spraak, kultur FROM fotballspraak WHERE nyestesesong <> -1 ORDER BY id');
+       $q->execute;
+
+       my $first = 1;
+       while (my $ref = $q->fetchrow_hashref) {
+               if (!$first) {
+                       print " :: ";
+               }
+               $first = 0;
+
+               if ($ref->{'kultur'} eq $locale) {
+                       printf "%s ", $ref->{'spraak'};
+               } else {
+                       printf "<a href=\"/%s/%s\">%s</a> ", $ref->{'kultur'}, $url, $ref->{'spraak'};
+               }
+       }
+       print "</p>\n";
+}
+
 1;
index 7546d658ac8a4b5bf14bf8a30b8e46d408c4092b..23dbe6c0494005cb762df45c286e32b684ae05bc 100755 (executable)
@@ -359,6 +359,7 @@ get_players_and_ratings($dbh, $locale, $season, $division, $subdivision);
 my $cov = get_covariance_matrix($dbh, keys %players);
 
 print_header($cgi, 'WLoH-plasseringsannsynlighetsberegning');
+wloh_common::print_navbar($cgi, $dbh, $locale);
 
 if (defined($match_player) && defined($match_position)) {
        my $tmpnam = write_parms_to_file($aux_parms, $match_stddev, \%ratings, $cov);
index 2118f40e4e3d9108709dca813987fdb09927ec00..38768d4673ca281eec5062f8808859be04e52666 100755 (executable)
@@ -29,7 +29,7 @@ my $match_stddev = $aux_parms->{'score_stddev'} * sqrt(2.0);
 print CGI->header(-type=>'text/html; charset=utf-8', -expires=>'+5m');
 POSIX::setlocale(&POSIX::LC_ALL, 'nb_NO.UTF-8');
 
-printf <<"EOF", $aux_parms->{'rating_prior_stddev'}, $match_stddev;
+print <<"EOF";
 <?xml version="1.0" encoding="UTF-8" ?>
 <!DOCTYPE
   html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
@@ -40,6 +40,11 @@ printf <<"EOF", $aux_parms->{'rating_prior_stddev'}, $match_stddev;
     <link rel="stylesheet" href="style" type="text/css" />
   </head>
   <body>
+EOF
+
+wloh_common::print_navbar($cgi, $dbh, $locale);
+
+printf <<"EOF", $aux_parms->{'rating_prior_stddev'}, $match_stddev;
     <h1>WLoH-rating</h1>
 
     <p><em>Dette er et hobbyprosjekt fra tredjepart, og ikke en offisiell del av