matts 2003/07/11 09:03:54
Modified: lib/Apache/AxKit ConfigReader.pm
Log:
Fixed bug where requesting a non-existing style would mean only global
styles get applied, rather than global + #default.
Revision Changes Path
1.17 +42 -11 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.16
retrieving revision 1.17
diff -u -r1.16 -r1.17
--- ConfigReader.pm 7 Jul 2003 22:29:50 -0000 1.16
+++ ConfigReader.pm 11 Jul 2003 16:03:54 -0000 1.17
@@ -340,22 +340,20 @@
return $can_gzip;
}
-sub GetMatchingProcessors {
+sub _extract_dir_config_processors {
my $self = shift;
- my ($media, $style, $doctype, $dtd, $root, $styles, $provider) = @_;
- return @$styles if @$styles;
-
- $style ||= '#default';
-
- my $list = $self->{cfg}{Processors}{$media}{'#global'} || [];
- push @$list, @{ $self->{cfg}{Processors}{$media}{$style} || [] };
+ my ($style, $media) = @_;
+ my @list;
+
my $processors = $self->{apache}->dir_config('AxProcessors');
+ my $found_non_global_style = 0;
if( $processors ) {
foreach my $processor (split(/\s*,\s*/, $processors) ) {
my ($pmedia, $pstyle, @processor) = split(/\s+/, $processor);
next unless ($pmedia eq $media and ($pstyle eq $style or $pstyle eq
'#global'));
- push (@$list, [ 'NORMAL', @processor ] );
+ $found_non_global_style++ if $pstyle ne '#global';
+ push (@list, [ 'NORMAL', @processor ] );
}
}
@@ -363,8 +361,41 @@
foreach my $processor (@processors) {
my ($pmedia, $pstyle, @processor) = split(/\s+/, $processor);
next unless ($pmedia eq $media and ($pstyle eq $style or $pstyle eq
'#global'));
- push (@$list, [ @processor ] );
+ $found_non_global_style++ if $pstyle ne '#global';
+ push (@list, [ 'NORMAL', @processor ] );
+ }
+
+ return @list if $style eq '#default';
+
+ if ($found_non_global_style) {
+ return @list;
+ }
+ else {
+ return $self->_extract_dir_config_processors('#default', $media);
+ }
+}
+
+
+sub GetMatchingProcessors {
+ my $self = shift;
+ my ($media, $style, $doctype, $dtd, $root, $styles, $provider) = @_;
+ return @$styles if @$styles;
+
+ $style ||= '#default';
+
+ # Add global styles
+ my $list = $self->{cfg}{Processors}{$media}{'#global'} || [];
+
+ # Add styles matching this style
+ if (exists($self->{cfg}{Processors}{$media}{$style})) {
+ push @$list, @{ $self->{cfg}{Processors}{$media}{$style} || [] };
+ }
+ else {
+ # if the style didn't exist, push the #default styles
+ push @$list, @{ $self->{cfg}{Processors}{$media}{'#default'} || [] };
}
+
+ push @$list, $self->_extract_dir_config_processors($style, $media);
my @results;