]> git.p6c8.net - selfforum.git/blobdiff - selfforum-cgi/shared/Template/_thread.pm
modified version check
[selfforum.git] / selfforum-cgi / shared / Template / _thread.pm
index 74ae404329955092804e6e98894dde8f0d7da1a8..f4ee5b28086f81ddfda4728233ebf04681277a1d 100644 (file)
@@ -1,38 +1,53 @@
-# Template/_thread.pm
+package Template::_thread;
 
 
-# ====================================================
-# Autor: n.d.p. / 2001-01-11
-# lm   : n.d.p. / 2001-01-11
-# ====================================================
-# Funktion:
-#      HTML-Darstellung eines Threads
-# ====================================================
+################################################################################
+#                                                                              #
+# File:        shared/Template/_thread.pm                                      #
+#                                                                              #
+# Authors:     AndrĂ© Malo <nd@o3media.de>                                      #
+#                                                                              #
+# Description: convert parsed thread to HTML                                   #
+#                                                                              #
+################################################################################
 
 use strict;
 
 use strict;
-
-package Template::_thread;
-
-use vars qw(@ISA @EXPORT);
+use vars qw(
+  @EXPORT
+);
 
 use Encode::Plain; $Encode::Plain::utf8 = 1;
 use Posting::_lib qw(short_hr_time);
 use Template;
 use Template::_query;
 
 
 use Encode::Plain; $Encode::Plain::utf8 = 1;
 use Posting::_lib qw(short_hr_time);
 use Template;
 use Template::_query;
 
-# ====================================================
-# Funktionsexport
-# ====================================================
+################################################################################
+#
+# Version check
+#
+# last modified:
+#    $Date$ (GMT)
+# by $Author$
+#
+sub VERSION {(q$Revision$ =~ /([\d.]+)\s*$/)[0] or '0.0'}
 
 
-require Exporter;
-@ISA    = qw(Exporter);
+################################################################################
+#
+# Export
+#
+use base qw(Exporter);
 @EXPORT = qw(html_thread);
 
 @EXPORT = qw(html_thread);
 
-################################
-# sub html_thread
+### html_thread () #############################################################
+#
+# create HTML string
+#
+# Params: $msg      - Reference of Message-Array
+#                     (Output of parse_single_thread in Posting::_lib)
+#         $template - Template object
+#         $par      - Hash Reference (see doc for details)
+#
+# Return: Reference of HTML String
 #
 #
-# Thread erzeugen
-################################
-
 sub html_thread ($$$) {
   my ($msg, $template, $par) = @_;
 
 sub html_thread ($$$) {
   my ($msg, $template, $par) = @_;
 
@@ -49,45 +64,73 @@ sub html_thread ($$$) {
   my $oldlevel=0;
   my @indexes;
 
   my $oldlevel=0;
   my @indexes;
 
-  # ganzer Thread
+  # whole thread
   if ($par -> {start} == -1) {
     $_ = $msg -> [0];
     @indexes = (1..$_ -> {answers});
 
     if ($_ -> {answers}) {
   if ($par -> {start} == -1) {
     $_ = $msg -> [0];
     @indexes = (1..$_ -> {answers});
 
     if ($_ -> {answers}) {
-      $html = '<dd><dl><dt>'
-              .${$template -> scrap ($temp -> {(length $_ -> {cat})?'start':'startNC'},
-                                    {$temp -> {name}    => $_ -> {name},
-                                     $temp -> {subject} => $_ -> {subject},
-                                     $temp -> {cat}     => $_ -> {cat},
-                                     $temp -> {time}    => plain(short_hr_time ($_ -> {time})),
-                                     $temp -> {link}    => query_string({$t => $tid, $p => $_ -> {mid}})},
-                                     $par -> {addParam})}
-              .'</dt>';}
+      $html =
+        '<dd><dl><dt>'.
+
+        ${$template -> scrap (
+           $temp -> {
+             length $_ -> {cat}
+               ? 'start'
+               : 'startNC'
+           },
+           { $temp -> {name}    => $_ -> {name},
+             $temp -> {subject} => $_ -> {subject},
+             $temp -> {cat}     => $_ -> {cat},
+             $temp -> {time}    => plain(short_hr_time ($_ -> {time})),
+             $temp -> {link}    => query_string({$t => $tid, $p => $_ -> {mid}}),
+             $temp -> {tid}     => $tid,
+             $temp -> {mid}     => $_ -> {mid},
+           },
+           $par -> {addParam}
+          )} .
+        '</dt>';
+    }
 
     else {
 
     else {
-      $html = '<dd>'
-              .${$template -> scrap ($temp -> {(length $_ -> {cat})?'start':'startNC'},
-                                    {$temp -> {name}    => $_ -> {name},
-                                     $temp -> {subject} => $_ -> {subject},
-                                     $temp -> {cat}     => $_ -> {cat},
-                                     $temp -> {time}    => plain(short_hr_time ($_ -> {time})),
-                                     $temp -> {link}    => query_string({$t => $tid, $p => $_ -> {mid}})},
-                                     $par -> {addParam})}
-              .'</dd>';
-
-      return \$html;}}
-
-  # Teilthread
+      $html =
+        '<dd>'.
+        ${$template -> scrap (
+           $temp -> {
+             length $_ -> {cat}
+             ? 'start'
+             : 'startNC'
+           },
+           { $temp -> {name}    => $_ -> {name},
+             $temp -> {subject} => $_ -> {subject},
+             $temp -> {cat}     => $_ -> {cat},
+             $temp -> {time}    => plain(short_hr_time ($_ -> {time})),
+             $temp -> {link}    => query_string({$t => $tid, $p => $_ -> {mid}}),
+             $temp -> {tid}     => $tid,
+             $temp -> {mid}     => $_ -> {mid},
+           },
+           $par -> {addParam}
+          )}.
+        '</dd>';
+
+      return \$html;
+    }
+  }
+
+  # only subthread
+  #
   else {
     my $start=-1;
     for (@$msg) {$start++; last if ($_ -> {mid} == $par -> {start});}
     my $end   = $start + $msg -> [$start] -> {answers};
     $start++;
     @indexes = ($start..$end);
   else {
     my $start=-1;
     for (@$msg) {$start++; last if ($_ -> {mid} == $par -> {start});}
     my $end   = $start + $msg -> [$start] -> {answers};
     $start++;
     @indexes = ($start..$end);
-    $oldlevel = $startlevel = $msg -> [$start] -> {level};}
+    $oldlevel = $startlevel = $msg -> [$start] -> {level}
+      if (defined $msg -> [$start] -> {level});
+  }
 
 
-  # HTML erzeugen
+  # create HTML
+  #
   for (@$msg[@indexes]) {
 
     if ($_ -> {level} < $oldlevel) {
   for (@$msg[@indexes]) {
 
     if ($_ -> {level} < $oldlevel) {
@@ -96,41 +139,56 @@ sub html_thread ($$$) {
     $oldlevel = $_ -> {level};
 
     if ($_ -> {answers}) {
     $oldlevel = $_ -> {level};
 
     if ($_ -> {answers}) {
-      $html.='<dd><dl><dt>'
-             .${$template -> scrap ($temp -> {(length $_ -> {cat})?'line':'lineNC'},
-                                   {$temp -> {name}    => $_ -> {name},
-                                   $temp -> {subject} => $_ -> {subject},
-                                   $temp -> {cat}     => $_ -> {cat},
-                                   $temp -> {time}    => plain(short_hr_time ($_ -> {time})),
-                                   $temp -> {link}    => query_string({$t => $tid, $p => $_ -> {mid}})},
-                                   $par -> {addParam})}
-             .'</dt>';
+      $html.=
+        '<dd><dl><dt>'.
+        ${$template -> scrap (
+           $temp -> {
+             length $_ -> {cat}
+             ? 'line'
+             : 'lineNC'
+           },
+           { $temp -> {name}    => $_ -> {name},
+             $temp -> {subject} => $_ -> {subject},
+             $temp -> {cat}     => $_ -> {cat},
+             $temp -> {time}    => plain(short_hr_time ($_ -> {time})),
+             $temp -> {link}    => query_string({$t => $tid, $p => $_ -> {mid}}),
+             $temp -> {tid}     => $tid,
+             $temp -> {mid}     => $_ -> {mid},
+           },
+           $par -> {addParam}
+          )}.
+        '</dt>';
     }
     else {
     }
     else {
-      $html.='<dd>'
-             .${$template -> scrap ($temp -> {(length $_ -> {cat})?'line':'lineNC'},
-                                   {$temp -> {name}    => $_ -> {name},
-                                   $temp -> {subject} => $_ -> {subject},
-                                   $temp -> {cat}     => $_ -> {cat},
-                                   $temp -> {time}    => plain(short_hr_time ($_ -> {time})),
-                                   $temp -> {link}    => query_string({$t => $tid, $p => $_ -> {mid}})},
-                                   $par -> {addParam})}
-             .'</dd>';
+      $html.=
+        '<dd>'.
+        ${$template -> scrap (
+           $temp -> {
+             length $_ -> {cat}
+             ? 'line'
+             : 'lineNC'
+           },
+           { $temp -> {name}    => $_ -> {name},
+             $temp -> {subject} => $_ -> {subject},
+             $temp -> {cat}     => $_ -> {cat},
+             $temp -> {time}    => plain(short_hr_time ($_ -> {time})),
+             $temp -> {link}    => query_string({$t => $tid, $p => $_ -> {mid}}),
+             $temp -> {tid}     => $tid,
+             $temp -> {mid}     => $_ -> {mid},
+           },
+           $par -> {addParam}
+          )}.
+        '</dd>';
     }
   }
     }
   }
-
   $html.='</dl></dd>' x ($oldlevel - $startlevel);
 
   \$html;
 }
 
   $html.='</dl></dd>' x ($oldlevel - $startlevel);
 
   \$html;
 }
 
-# ====================================================
-# Modulinitialisierung
-# ====================================================
-
-# making require happy
+# keep 'require' happy
 1;
 
 1;
 
-# ====================================================
-# end of Template::_thread
-# ====================================================
\ No newline at end of file
+#
+#
+### end of Template::_thread ###################################################
\ No newline at end of file

patrick-canterino.de