Location: PHPKode > projects > L-Forum > l-forum/inc/list_thr.inc
<?echo $design['listhead']?>
<tr>
<td class=head>&nbsp;<?echo $lang['subject']?></td>
<td class=head><?echo $lang['from']?></td>
<td class=head><?echo $lang['date']?></td></tr>
<?

include $pre."lib/date_trans.inc";

// Setting image dir from relative path and theme dir

if(ereg("admin/remove.php", $PHP_SELF))
   $imgdir="../themes/".$theme."/img";
else
   $imgdir="themes/".$theme."/img";

// Setting path - it's needed because this list is used on administration page

$link=(ereg("admin/remove.php", $PHP_SELF)? "remove.php" : "read.php");

// Standard query

$sort = $s=='d'?'desc':'';

if($db_type=='mysql'){
   $timestamp = "UNIX_TIMESTAMP(time) as time";
}
else if($db_type=='postgres'){
   $timestamp = "date_part('epoch', time) as time";
}

$q=new Query("select id, $timestamp, author, subject, email, parent, is_parent, subs, level, views, attach, moderation_state from articles where forum = $f and moderation_state != 1 order by time $sort");

$count_query = new Query("select count(*) as c from articles where forum = $f and level = 0");

$count = $count_query->get(0, 'c');

for($x=0; $x<$q->nr(); $x++){
   $row=$q->row();
   $array[$row['id']]=$row;
}

$level_stat = $level = Array();

if(!empty($cookie_read))
   $ca=unserialize($cookie_read);

function make_list_recursive($mess_id){
   global $array, $out_array, $level, $type, $f, $open_thr, $forum_array;
   global $true, $false;
   
   @$level[$array[$mess_id]['level']]++;

   $out_array[]=$mess_id;
   if(($array[$mess_id]['level']>0||@$open_thr[$f][$mess_id]==1||$type==1)){
      $subs = unserialize($array[$mess_id]['subs']);
      $parent = $false;
      $newsubs = Array();
      $count = count($subs);
      for($i=0; $i<$count; $i++){
         if($forum_array[$f]['moderation']){
            if($array[$subs[$i]]['moderation_state']!=1 &&
                  isset($array[$subs[$i]]['moderation_state'])){
               make_list_recursive($subs[$i]);
               $newsubs[] = $subs[$i];
               $parent = $true;
            }
         }
         else
            make_list_recursive($subs[$i]);
      }
      if($forum_array[$f]['moderation']){
         $array[$mess_id]['is_parent'] = $parent;
         $array[$mess_id]['subs'] = serialize($newsubs);
      }
   }
}

$tempcount = $forum_array[$f]['tpp'];
$otemp = $o;
if(!empty($mess_id))
   make_list_recursive($mess_id);
else if($q->nr()>0){
   while(list($k, $v) = each($array)){
     if($array[$k]['level']==0&&$tempcount>0){
	if($otemp>0){
	   $otemp--;
	}
	else{
	   $tempcount--;           
	   make_list_recursive($array[$k]['id']);
	}
     }
   }
}

if(!isset($href))
   $href=true;

$countout = @count($out_array);
for($x=0; $x<$countout; $x++){
   $bgcolor=( ($x+1)%2==0 ? $design['evencolor'] : $design['oddcolor'] );
   $curr_id = $out_array[$x];
   $date_arr = getdate($array[$curr_id]['time']);
   $date = $lang[$dow[$date_arr['wday']].($long_names?"_l":"_s")];
   $date .= ", ".$date_arr['mday']." ".$lang[$mth[$date_arr['mon']].($long_names?"_l":"_s")]." ";
   $date .= $date_arr['year']." ";
   $date .= ($date_arr['hours']<10?"0".$date_arr['hours']:$date_arr['hours']).":";
   $date .= ($date_arr['minutes']<10?"0".$date_arr['minutes']:$date_arr['minutes']).":";
   $date .= ($date_arr['seconds']<10?"0".$date_arr['seconds']:$date_arr['seconds']);

   if($array[$curr_id]['parent']!=''){
      $child = true;
      $parent_id = $array[$curr_id]['parent'];
      @$parent_subs = unserialize($array[$parent_id]['subs']);
      $countsubs = count($parent_subs);
      for($z=0; $z<$countsubs; $z++){
	 if($parent_subs[$z]==$curr_id){
	    $child_location = $z+1;
	    $child_loc_arr[$array[$curr_id]['level']] = $child_location;
	 }
      }
   }
   @$level_stat[$array[$curr_id]['level']]+=1;
   $level_curr[$array[$curr_id]['level']]=$curr_id;
   echo "<tr><td class=list bgcolor=\"$bgcolor\">";
   for($i=0; $i<=$array[$curr_id]['level']; $i++){
      if(empty($child_loc_arr[$i])) $child_loc_arr[$i]=0;
      if($array[$curr_id]['level']==0&&$array[$curr_id]['is_parent']==$true){
	 if(@$open_thr[$f][$curr_id]==1||$type==1){
	    if($href)
	       echo "<a href=\"".$PHP_SELF."?f=$f&lng=$lng&t=$t&c=$curr_id\">";
	    echo "<img width=20 height=20 src=\"$imgdir/tree4".
	       ".png\" border=0 vspace=0 hspace=0 align=absmiddle>";
	    if($href)
	       echo "</a>";
	 }
	 else{
	    if($href)
	       echo "<a href=\"".$PHP_SELF."?f=$f&lng=$lng&t=$t&uc=$curr_id\">";
	    echo "<img width=20 height=20 src=\"".$imgdir.
	       "/tree5.png\" border=0 vspace=0 hspace=0 align=absmiddle>";
	    if($href)
	       echo "</a>";
	 }
      }
      else if($array[$curr_id]['level']==0&&$array[$curr_id]['is_parent']==$false){
	 echo "<img width=20 height=20 src=\"$imgdir/tree3.png\" border=0 vspace=0 hspace=0 align=absmiddle>";
      }
      else if($array[$curr_id]['level']>$i+1 && $child &&
	    $child_loc_arr[$i+1] < count(unserialize($array[$level_curr[$i]]['subs'])) ){
	 echo "<img width=20 height=20 src=\"$imgdir/tree1.png\" border=0 vspace=0 hspace=0 align=absmiddle>";
      }
      else if($i == $array[$curr_id]['level']&&$array[$curr_id]['is_parent']==$false){
	 echo "<img width=20 height=20 src=\"$imgdir/tree8.png\" border=0 vspace=0 hspace=0 align=absmiddle>";
      }
      else if($i == $array[$curr_id]['level']&&$array[$curr_id]['is_parent']==$true){
	 echo "<img width=20 height=20 src=\"$imgdir/tree7.png\" border=0 vspace=0 hspace=0 align=absmiddle>";
      }
      else if($i+1==$array[$curr_id]['level']&&
	    $child_location == count($parent_subs)
	    ){
	 echo "<img width=20 height=20 src=\"$imgdir/tree2.png\" border=0 vspace=0 hspace=0 align=absmiddle>";
      }
      else if($level[$i+1]>$level_stat[$i+1] && 
	    $child &&
	    $child_loc_arr[$i+1] < count(unserialize($array[$level_curr[$i]]['subs'])) ) {
	 echo "<img width=20 height=20 src=\"$imgdir/tree6.png\" border=0 vspace=0 hspace=0 align=absmiddle>";
      }
      else{
	 echo "<img width=20 height=20 src=\"$imgdir/tree0.png\" border=0 vspace=0 hspace=0 align=absmiddle>";
      }
   }
   if(isset($r)){
      if($curr_id==$r['id'])
         echo "<b>";
      else
         echo "<a class=list href=\"$link?f=$f&i=$curr_id\">";
   }
   else
      echo "<a class=list href=\"$link?f=$f&i=$curr_id\">";
   if($array[$curr_id]['level']>0)
      echo dots($array[$curr_id]['subject'], 50-$array[$curr_id]['level']*5);
   else
      echo $array[$curr_id]['subject'];
   if(isset($r)){
      if($curr_id==$r['id'])
         echo "</b>&nbsp;";
      else
         echo "</a>&nbsp;";
   }
   else
      echo "</a>&nbsp;";
   if($array[$curr_id]['attach'])
      echo "<img src=\"$imgdir/clip.png\" hspace=0 vspace=0 align=absmiddle>";
   if($count_view)
      echo "&nbsp;(".$array[$curr_id]['views']." ".$lang['views'].")";
   if(@$ca[$curr_id]!=1&&@$r['id']!=$curr_id)
      echo "&nbsp;<img src=\"$imgdir/unread.png\">";
   echo "</td><td width=20% class=list bgcolor=\"$bgcolor\">";
   if(!empty($array[$curr_id]['email']))
      echo "<a class=list href=\"mailto:".hide_addr($array[$curr_id]['email'])."\">";
   echo $array[$curr_id]['author'];
   if(!empty($array[$curr_id]['email']))
      echo "</a>";
   echo "</td><td width=250 class=date bgcolor=\"$bgcolor\">";
   echo $date;
   echo "</td>";
   echo "</tr>\n";
}
echo $design['listfoot'];
?>
Return current item: L-Forum