--- trunk2/lib/WebPAC/Tree.pm 2004/11/01 14:55:16 572 +++ trunk2/lib/WebPAC/Tree.pm 2004/11/01 15:29:17 573 @@ -128,6 +128,11 @@ my $tree = new WebPAC::Tree( tree => \@tree, log => 'log4perl.conf', + detail_url => sub { + my $mfn = shift; + my $path = "./out/thes/${mfn}.html"; + return $path if (-e $path); + }, ); C is tree array with levels of tree described above. @@ -135,6 +140,9 @@ C is optional parametar which specify filename of L config file. Default is C. +C code ref to check if detail html exists (and return URL if +it does). + =cut sub new { @@ -263,7 +271,9 @@ sub unroll { my $self = shift; - my ($level,$data_arr) = @_; + my ($level,$data_arr, $base_path) = @_; + + $base_path ||= ''; my $log = $self->_get_logger(); @@ -318,12 +328,15 @@ ($link_start,$link_end) = (qq{},qq{}) if ($have_children); - my $mfn_link = "thes/$mfn.html"; - if (-e "out/$mfn_link") { - $term =~ s# *\* *# #; + my $mfn_link; + $mfn_link = $self->{'detail_url'}->($mfn) if ($self->{'detail_url'}); + + if ($mfn_link) { + $term =~ s, *#C# *, ,; $html .= " " x $level . qq{
  • ${link_start}${term}${link_end}}. - qq{ 
  • \n}; + qq{ \n}; + $log->debug("linked details to $mfn_link"); } else { $log->warn("file 'out/$mfn_link' doesn't exist, skipping"); } @@ -351,11 +364,11 @@ if ($tree->[$level]->{'iframe'}) { # unroll to separate file - $self->{'node_html'}->{$mfn} = $self->unroll($next_level, $have_children); + $self->{'node_html'}->{$mfn} = $self->unroll($next_level, $have_children, '../'); } else { # unroll at base HTML - $html .= $self->unroll($next_level, $have_children); + $html .= $self->unroll($next_level, $have_children, $base_path); } $html .= " " x $level . qq{\n};