Location: PHPKode > projects > L-Forum > l-forum/inc/list_mod.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>
<td class=head>IP</td>
<td class=head>State</td>
<td class=head>Action</td>
</tr>
<?

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

// Setting image dir from relative path and theme dir

$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, ip, moderation_state from articles where forum = $f 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;
   
   $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']);
      $count = count($subs);
      for($i=0; $i<$count; $i++){
	 make_list_recursive($subs[$i]);
      }
   }
}

$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']);
      $count = count($parent_subs);
      for($z=0; $z<$count; $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>";
      }
   }
   echo ($curr_id!=$r['id'] ? "<a class=list href=\"$link?f=$f&i=$curr_id\">" : "<b>");
   if($array[$curr_id]['level']>0)
      echo dots($array[$curr_id]['subject'], 50-$array[$curr_id]['level']*5);
   else
      echo $array[$curr_id]['subject'];
   echo ($curr_id!=$r['id'] ? "</a>&nbsp;" : "</b>&nbsp;");
   if($array[$curr_id]['attach'])
      echo "<img src=\"$imgdir/clip.png\" hspace=0 vspace=0 align=absmiddle>";
   echo "</td><td 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 class=date bgcolor=\"$bgcolor\">";
   echo $date;
   echo "</td>";
   echo "<td bgcolor=\"$bgcolor\">".$array[$curr_id]['ip']."</td>";
   echo "<td bgcolor=\"$bgcolor\">";
   switch($array[$curr_id]['moderation_state']){
      case 0:
         echo "Approved";
         break;
      case 1:
         echo "Waiting";
         break;
      case 2:
         echo "Locked";
         break;
      case 3:
         echo "Thread locked";
         break;
   }
   echo "</td>";
   echo "<td bgcolor=\"$bgcolor\" style=\"font-size : 12px\">";
   if($array[$curr_id]['moderation_state']==0){
      echo "<a href=lock.php?f=$f&msg=$curr_id>Lock</a> ";
      if($array[$curr_id]['level']==0)
         echo "<a href=lock_thr.php?f=$f&thr=$curr_id>Lock&nbsp;thread</a> ";
   }
   if($array[$curr_id]['moderation_state']==1){
      echo "<a href=approve.php?f=$f&msg=$curr_id>Approve</a> ";
   }
   if($array[$curr_id]['moderation_state']==2){
      echo "<a href=unlock.php?f=$f&msg=$curr_id>Unlock</a> ";
   }
   if($array[$curr_id]['moderation_state']==3&&$array[$curr_id]['level']==0){
      echo "<a href=unlock_thr.php?f=$f&thr=$curr_id>Unlock&nbsp;thread</a> ";
   }
   echo "<a href=remove.php?f=$f&i=$curr_id>Remove</a>";
   echo "</td>";
   echo "</tr>\n";
}
echo $design['listfoot'];
?>
Return current item: L-Forum