<:{
# create a hash and maintain order of keys
my %navigation;
my @keys;
while (@navigation) {
my $key = shift @navigation;
my $val = shift @navigation;
push @keys, $key;
$navigation{$key} = $val;
}
my $page = $WML_SRC_BASENAME;
my $lang = "$(LANG)";
for my $key (@keys) {
my ($dir, $base) = $key =~ m,^(?:(.*)/)?(.*?)$,;
# in directory of active link, set class active. This rule should be improved with proper structuring of the links.
my $class;
if ((index($page, 'contact') ne -1) and (index($base, 'overview') ne -1)) {
$class = '';
} elsif ((defined $dir) and ($WML_SRC_DIRNAME =~/$dir/) and (index($key, 'contact') eq -1) or ($WML_SRC_BASENAME eq $base)) {
$class = 'class="active '.$base.' '.$page.'"';
} else {
$class = '';
}
$dir = '.' unless defined $dir;
# translated version
if (-e "$(DOCROOT)/$dir/$lang/$base.wml") {
printf '
'."\n", $key, $navigation{$key};
} else {
warn "$WML_SRC_FILENAME has a [page $key] (parses to
docdir: $(DOCROOT)/; dir: $dir; base: $base -> $(DOCROOT)/$dir/$lang/$base.wml), but that doesn't exist.";
}
}
}:>
# end navigation generation
<:{
my %calltoaction;
my @keys;
while (@calltoaction) {
my $key = shift @calltoaction;
my $val = shift @calltoaction;
push @keys, $key;
$calltoaction{$key} = $val;
}
my $page = $WML_SRC_BASENAME;
my $lang = "$(LANG)";
for my $key (@keys) {
my ($dir, $base) = $key =~ m,^(?:(.*)/)?(.*?)$,;
# in directory, set active
my $class;
if ((defined $dir) and ($WML_SRC_DIRNAME =~/$dir/) or ($WML_SRC_BASENAME eq $base)) {
#if ($WML_SRC_BASENAME eq $base) {
$class = 'class="active"';
} else {
$class = '';
}
$dir = '.' unless defined $dir;
# try to use a translated version
if (-e "$(DOCROOT)/$dir/$lang/$base.wml") {
printf '
'."\n",
stripDotSlashs("$(DOCROOT)/$dir/$base.html.$(LANG)"),$calltoaction{$key};
}
# default to english version
elsif (-e "$(DOCROOT)/$dir/en/$base.wml") {
printf '