2
use Embperl::Recipe::XSLT ;
3
use Embperl::Recipe::Embperl ;
4
use Embperl::Recipe::EmbperlXSLT ;
5
use Embperl::Recipe::EmbperlPODXSLT ;
6
use Embperl::Constant ;
14
my ($config, $item, $baseuri, $root, $parent) = @_ ;
18
$m -> {parent} ||= $parent ;
19
$m -> {relurl} ||= "$baseuri$m->{uri}" ;
22
foreach my $k (keys %{$m -> {path}})
24
if (($m -> {path}{$k} =~ /^\%(.*?)\%/))
28
my $val = $config -> {$1} ;
29
$m -> {path}{$k} =~ s/^\%.*?\%/$val/ ;
33
$m -> {path}{$k} = '' ;
40
if (($m -> {path} =~ /^\%(.*?)\%/))
42
#warn "path=$m->{path}, 1=$1 c1=$config->{$1}" ;
45
my $val = $config -> {$1} ;
46
$m -> {path} =~ s/^\%.*?\%/$val/ ;
54
elsif (!$m -> {file} && !exists $m -> {path})
56
$m -> {path} = $root . $config -> {basepath} . $m -> {relurl} ;
57
$m -> {path} .= 'index.htm' if ($m -> {path} =~ m#/$#) ;
59
elsif (ref $m -> {file})
61
$m -> {path} = { map { $_ => $root . $m->{file}{$_} } keys %{$m->{file}} } ;
63
elsif (!exists $m -> {path})
65
$m -> {path} = $root . $m->{file} ;
66
$m -> {path} .= 'index.htm' if ($m -> {path} =~ m#/$#) ;
70
$config -> {map1}{$m -> {relurl}} = $m ;
71
$config -> {map2}{$1} = $m if ($m -> {relurl} =~ /^(.*)\./ );
75
if ($m -> {relurl} !~ m#/$#)
77
$m -> {relurl} =~ /^(.*)\./ ;
82
$subbase = $m -> {relurl} ;
85
fill_menu ($config, $m -> {sub}, $subbase, $root, $m) if ($m -> {sub}) ;
86
fill_menu ($config, $m -> {same}, $baseuri, $root, $parent) if ($m -> {same}) ;
96
my ($self, $r, $uri, $lang) = @_ ;
98
my $buri = $r->{config}{baseuri} ;
99
$lang ||= $r -> {selected_language} ;
100
$prefix = $r->{baseuri} . ($r -> {selected_language}?'../':'') ;
101
if ($lang && ($uri =~ /$buri(.*?)$/))
103
return "$prefix$lang/$1" ;
114
my $config = $r -> {config} ;
116
# check if we have anything under this uri in our configuration
117
# if it's a directory, try to append index.*
120
if (!($m = $config -> {map1}{$uri} || $config -> {map2}{$1}))
122
$m = $config -> {map1}{$1} if ($uri =~ m#^(.*?/)index\..*$#) ;
125
# if we found something, setup $r -> {menuitem} to hold the menu
126
# tree we need to display for this page
127
if ($m && $m -> {path})
129
my @menuitems = ($m) ;
131
while ($item = $item -> {parent})
133
unshift @menuitems, $item ;
135
$r -> {menuitems} = \@menuitems ;
138
while (my ($k, $v) = each %{$m -> {fdat}})
144
$r -> {curritem} = $m ;
145
my $path = $m -> {path} ;
148
return $path -> {$r -> param -> language} || $path -> {'en'} ;
154
# nothing found, so return a general error page
155
return "$r->{config}{root}$r->{config}{basepath}notfound.htm" ;
164
my $config = Execute ({object => 'config.pl', syntax => 'Perl'}) ;
166
$config -> new ($r) ;
168
$r -> {config} = $config ;
170
my $uri = $r -> param -> uri ;
172
# we embed some parameters in the uri itself, to allow making a
173
# static copy, so see if there is anything here
174
while ($uri =~ s/\.-(.*?)-(.*?)-\././g)
180
# figure out necessary prefixes, so we can use relativ urls
181
my @uri = split (/\//, $uri) ;
182
push @uri, '' if ($uri =~ m#/$#) ;
183
my $basedepth = $config->{basedepth} + 1 ;
184
shift @uri while ($basedepth--) ;
185
my $depth = $r -> {depth} = $#uri ;
187
$r -> {imageuri} = ('../' x $depth) . $config -> {imageuri} ;
188
$r -> {baseuri} = ('../' x $depth) ;
189
# this is when creating static pages, to let actions point to the correct URL of the dynamic site
190
$r -> {action_prefix} = $ENV{ACTION_PREFIX} || '' ;
192
my $langs = $config -> {supported_languages} ;
193
# serach the url, if there is a language embeded,
195
$r -> {selected_language} = '' ;
196
my $accept_lang = $r -> param -> language ;
202
$r -> param -> language($_) ;
203
$r -> {selected_language} = $_ ;
206
$r -> {baseuri} = ('../' x ($depth - 1)) ; # we want to stay in the same language tree
210
elsif ($accept_lang && $_ eq $accept_lang)
216
$r -> param -> uri ($uri) ;
217
$r -> param -> language($langs -> [0]) if (!$r -> param -> language || !$lang_ok) ;
220
#warn "2 d = $r->{depth} bd = $config->{basedepth} #uri=$#uri uri = @uri new uri = $uri" ;
222
# get the menu data and create a tree structure out of it if not already done
223
$r -> {menu} = $config -> get_menu ($r) ;
224
fill_menu ($config, $r -> {menu}, '', $config -> {root}) ; ##if (!$config -> {map1}) ;
227
# map the request uri to the real filename
228
$pf = map_file ($r, join ('/', @uri)) ;
229
$r -> param -> filename ($pf) ; # tell Embperl the filename
230
$r -> apache_req -> filename ($pf) ; # tell Apache the filename
233
#warn Dumper ($r -> {config}, $r -> param -> uri, $pf, \%fdat, $r -> config -> path) ;
235
# read in the multi language messages
236
Execute ({inputfile => 'messages.pl', syntax => 'Perl'}) ;
244
my ($class, $r, $config, $param) = @_ ;
246
$config -> xsltstylesheet('pod.xsl') ;
247
$r -> param -> uri =~ /^.*\/(.*)\.(.*?)$/ ;
248
$param -> xsltparam({
249
page => $fdat{page} || 0,
252
imageuri => "'$r->{imageuri}'",
253
baseuri => "'$r->{baseuri}'",
254
language => "'" . $r -> param -> language . "'" ,
263
my ($class, $r, $recipe) = @_ ;
266
my $param = $r -> component -> param ;
267
my $config = $r -> component -> config ;
268
my ($src) = $param -> inputfile =~ /^.*\.(.*?)$/ ;
269
my ($dest) = $r -> param -> uri =~ /^.*\.(.*?)$/ ;
275
$config -> syntax('Perl') ;
276
return Embperl::Recipe::Embperl -> get_recipe ($r, $recipe) ;
279
if ($src eq 'pod' || $src eq 'pm')
281
$config -> escmode(0) ;
284
$config -> syntax('Text') ;
285
return Embperl::Recipe::Embperl -> get_recipe ($r, $recipe) ;
288
$config -> syntax('POD') ;
291
return Embperl::Recipe::Embperl -> get_recipe ($r, $recipe) ;
294
$class -> set_xslt_param ($r, $config, $param) ;
295
return Embperl::Recipe::EmbperlXSLT -> get_recipe ($r, $recipe) ;
300
$class -> set_xslt_param ($r, $config, $param) ;
301
return Embperl::Recipe::EmbperlXSLT -> get_recipe ($r, $recipe) ;
306
$config -> escmode(0) ;
307
$config -> options($config -> options | &Embperl::Constant::optKeepSpaces) ;
311
$config -> syntax('EmbperlBlocks') ;
312
return Embperl::Recipe::Embperl -> get_recipe ($r, $recipe) ;
316
$class -> set_xslt_param ($r, $config, $param) ;
317
return Embperl::Recipe::EmbperlPODXSLT -> get_recipe ($r, $recipe) ;
320
if ($src eq 'epl' || $src eq 'htm')
322
$config -> syntax('Embperl') ;
323
return Embperl::Recipe::Embperl -> get_recipe ($r, $recipe) ;
328
$config -> syntax('EmbperlBlocks') ;
329
return Embperl::Recipe::Embperl -> get_recipe ($r, $recipe) ;
333
$config -> syntax('Text') ;
334
return Embperl::Recipe::Embperl -> get_recipe ($r, $recipe) ;