/[webpac]/trunk2/lib/WebPAC/Tree.pm
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /trunk2/lib/WebPAC/Tree.pm

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 572 by dpavlin, Mon Nov 1 14:55:16 2004 UTC revision 573 by dpavlin, Mon Nov 1 15:29:17 2004 UTC
# Line 128  Create new tree object Line 128  Create new tree object
128   my $tree = new WebPAC::Tree(   my $tree = new WebPAC::Tree(
129          tree => \@tree,          tree => \@tree,
130          log => 'log4perl.conf',          log => 'log4perl.conf',
131            detail_url => sub {
132                    my $mfn = shift;
133                    my $path = "./out/thes/${mfn}.html";
134                    return $path if (-e $path);
135            },
136   );   );
137    
138  C<tree> is tree array with levels of tree described above.  C<tree> is tree array with levels of tree described above.
# Line 135  C<tree> is tree array with levels of tre Line 140  C<tree> is tree array with levels of tre
140  C<log> is optional parametar which specify filename of L<Log::Log4Perl>  C<log> is optional parametar which specify filename of L<Log::Log4Perl>
141  config file. Default is C<log.conf>.  config file. Default is C<log.conf>.
142    
143    C<detail_url> code ref to check if detail html exists (and return URL if
144    it does).
145    
146  =cut  =cut
147    
148  sub new {  sub new {
# Line 263  Generate tree recursively. Line 271  Generate tree recursively.
271  sub unroll {  sub unroll {
272          my $self = shift;          my $self = shift;
273    
274          my ($level,$data_arr) = @_;          my ($level,$data_arr, $base_path) = @_;
275    
276            $base_path ||= '';
277    
278          my $log = $self->_get_logger();          my $log = $self->_get_logger();
279    
# Line 318  sub unroll { Line 328  sub unroll {
328    
329                          ($link_start,$link_end) = (qq{<a href="#mfn$mfn" onClick="return toggle_display('id$mfn');">},qq{</a>}) if ($have_children);                          ($link_start,$link_end) = (qq{<a href="#mfn$mfn" onClick="return toggle_display('id$mfn');">},qq{</a>}) if ($have_children);
330    
331                          my $mfn_link = "thes/$mfn.html";                          my $mfn_link;
332                          if (-e "out/$mfn_link") {                          $mfn_link = $self->{'detail_url'}->($mfn) if ($self->{'detail_url'});
333                                  $term =~ s# *\* *# <img src="img/crovoc.png" border="0">#;  
334                            if ($mfn_link) {
335                                    $term =~ s, *#C# *, <img src="${base_path}img/crovoc.png" border="0">,;
336                                  $html .= " " x $level .                                  $html .= " " x $level .
337                                          qq{<li>${link_start}<span id="o$mfn">${term}</span>${link_end}}.                                          qq{<li>${link_start}<span id="o$mfn">${term}</span>${link_end}}.
338                                          qq{&nbsp;<a href="$mfn_link" onClick="javascript:return popup(this);"><img src="img/listic.png" border="0"></a></li>\n};                                          qq{&nbsp;<a href="${base_path}${mfn_link}" onClick="javascript:return popup(this);"><img src="${base_path}img/listic.png" border="0"></a></li>\n};
339                                    $log->debug("linked details to $mfn_link");
340                          } else {                          } else {
341                                  $log->warn("file 'out/$mfn_link' doesn't exist, skipping");                                  $log->warn("file 'out/$mfn_link' doesn't exist, skipping");
342                          }                          }
# Line 351  sub unroll { Line 364  sub unroll {
364    
365                          if ($tree->[$level]->{'iframe'}) {                          if ($tree->[$level]->{'iframe'}) {
366                                  # unroll to separate file                                  # unroll to separate file
367                                  $self->{'node_html'}->{$mfn} = $self->unroll($next_level, $have_children);                                  $self->{'node_html'}->{$mfn} = $self->unroll($next_level, $have_children, '../');
368    
369                          } else {                          } else {
370                                  # unroll at base HTML                                  # unroll at base HTML
371                                  $html .= $self->unroll($next_level, $have_children);                                  $html .= $self->unroll($next_level, $have_children, $base_path);
372                          }                          }
373    
374                          $html .= " " x $level . qq{</ul>\n};                          $html .= " " x $level . qq{</ul>\n};

Legend:
Removed from v.572  
changed lines
  Added in v.573

  ViewVC Help
Powered by ViewVC 1.1.26