]> git.sesse.net Git - wloh/blobdiff - common.pm
Make the display frontend filter out only the data relevant for the current locale.
[wloh] / common.pm
index 7ec01a06e4eee50bb8975329ff0e47f9779bc2b2..832a61173f0f85932e164d0f828742ac78862df6 100644 (file)
--- a/common.pm
+++ b/common.pm
@@ -5,8 +5,9 @@ use POSIX;
 package wloh_common;
 
 sub get_max_season {
-       my $dbh = shift;
-       my $ref = $dbh->selectrow_hashref('SELECT MAX(sesong) AS max_sesong FROM fotballserier');
+       my ($dbh, $locale) = @_;
+       my $ref = $dbh->selectrow_hashref('SELECT MAX(sesong) AS max_sesong FROM fotballserier se JOIN fotballspraak sp ON se.spraak=sp.id WHERE kultur=?',
+               undef, $locale);
        return $ref->{'max_sesong'};
 }
 
@@ -21,4 +22,11 @@ sub output_last_sync {
        }
 }
 
+sub get_locale {
+       my $cgi = shift;
+       my $url = $cgi->url(-absolute => 1);
+       $url =~ m#^/([a-z][a-z]-[A-Z][A-Z])/# or die "Invalid locale!";
+       return $1;
+}
+
 1;