matts 2003/02/07 08:07:37
Modified: lib/Apache/AxKit Tag: AxKit-1_6_1 ConfigReader.pm lib/Apache/AxKit/MediaChooser Tag: AxKit-1_6_1 WAPCheck.pm lib/Apache/AxKit/Plugin Tag: AxKit-1_6_1 Fragment.pm Log: Fix ENV stuff (no longer works with fast_handler) Documented WAPCheck Revision Changes Path No revision No revision 1.12.2.1 +2 -2 xml-axkit/lib/Apache/AxKit/ConfigReader.pm Index: ConfigReader.pm =================================================================== RCS file: /home/cvs/xml-axkit/lib/Apache/AxKit/ConfigReader.pm,v retrieving revision 1.12 retrieving revision 1.12.2.1 diff -u -r1.12 -r1.12.2.1 --- ConfigReader.pm 29 Jan 2003 12:35:34 -0000 1.12 +++ ConfigReader.pm 7 Feb 2003 16:07:37 -0000 1.12.2.1 @@ -230,7 +230,7 @@ # warn "Checking Accept-Charset\n"; # check HTTP_ACCEPT_CHARSET - if (my $ok_charsets = $ENV{HTTP_ACCEPT_CHARSET}) { + if (my $ok_charsets = $self->{apache}->header_in('Accept-Charset')) { my @charsets = split(/,\s*/, $ok_charsets); my $retcharset; my $retscore = 0; No revision No revision 1.2.2.1 +30 -6 xml-axkit/lib/Apache/AxKit/MediaChooser/WAPCheck.pm Index: WAPCheck.pm =================================================================== RCS file: /home/cvs/xml-axkit/lib/Apache/AxKit/MediaChooser/WAPCheck.pm,v retrieving revision 1.2 retrieving revision 1.2.2.1 diff -u -r1.2 -r1.2.2.1 --- WAPCheck.pm 1 Feb 2002 14:47:21 -0000 1.2 +++ WAPCheck.pm 7 Feb 2003 16:07:37 -0000 1.2.2.1 @@ -9,15 +9,16 @@ my $r = shift; my $type; -# warn "WAP Check on $ENV{HTTP_ACCEPT}\n"; -# warn " and $ENV{HTTP_USER_AGENT}\n"; + my $accept = $r->header_in('Accept') || ''; + my $ua = $r->header_in('User-Agent') || ''; + AxKit::Debug(3, "WAP Check on '$accept' and '$ua'"); local $^W; - if ($ENV{HTTP_ACCEPT} =~ /vnd.wap.wml/i) { + if ($accept =~ /vnd.wap.wml/i) { $r->notes('preferred_media', 'handheld'); } - elsif (substr($ENV{HTTP_USER_AGENT},0,4) =~ + elsif (substr($ua,0,4) =~ /( Noki | Eric @@ -41,7 +42,7 @@ | ALAV | Wapa )/x) { -# warn "set media to handheld!\n"; + AxKit::Debug(3, "set media to handheld!"); $r->notes('preferred_media', 'handheld'); } @@ -49,3 +50,26 @@ } 1; + +__END__ + +=head1 NAME + +Apache::AxKit::MediaChooser::WAPCheck - WAP device media chooser + +=head1 SYNOPSIS + + AxAddPlugin Apache::AxKit::MediaChooser::WAPCheck + +=head1 DESCRIPTION + +This module sets the preferred media type in AxKit to B<handheld> if +it detects that a WAP device made the request. This way you can specify +different stylesheets for WAP devices automatically. + +The selection is performed either based on the C<Accept> header being +sent, or based on the C<User-Agent> header (see the source code for +a list of the supported user agent strings). + +=cut + No revision No revision 1.3.2.1 +2 -2 xml-axkit/lib/Apache/AxKit/Plugin/Fragment.pm Index: Fragment.pm =================================================================== RCS file: /home/cvs/xml-axkit/lib/Apache/AxKit/Plugin/Fragment.pm,v retrieving revision 1.3 retrieving revision 1.3.2.1 diff -u -r1.3 -r1.3.2.1 --- Fragment.pm 11 Mar 2002 13:37:21 -0000 1.3 +++ Fragment.pm 7 Feb 2003 16:07:37 -0000 1.3.2.1 @@ -18,7 +18,7 @@ my $mtime = -M $r->finfo; my $xmlfile = $r->filename; - my $qs = $ENV{QUERY_STRING}; + my $qs = $r->args(); return DECLINED unless $qs; return DECLINED if ($qs =~ /^\w+=/);