[ Index ] |
|
Code source de Phorum 5.1.25 |
1 <?php 2 3 //////////////////////////////////////////////////////////////////////////////// 4 // // 5 // Copyright (C) 2006 Phorum Development Team // 6 // http://www.phorum.org // 7 // // 8 // This program is free software. You can redistribute it and/or modify // 9 // it under the terms of either the current Phorum License (viewable at // 10 // phorum.org) or the Phorum License that was distributed with this file // 11 // // 12 // This program is distributed in the hope that it will be useful, // 13 // but WITHOUT ANY WARRANTY, without even the implied warranty of // 14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. // 15 // // 16 // You should have received a copy of the Phorum License // 17 // along with this program. // 18 //////////////////////////////////////////////////////////////////////////////// 19 20 if(!defined("PHORUM")) return; 21 22 //////////////////////////////////////////////////////////////////////// 23 // 24 // This function sorts $rows and fills $threads. It assumes that $rows 25 // is an array that is sorted by thread, then id. This is critical as 26 // it ensures that a child is not encountered before a parent. 27 // It could be made more complicated to implement the tree graphics 28 // as Phorum 3 did. However, this is much faster and less complicated 29 // If someone just has to have the tree graphics, it can be done. 30 // 31 32 function phorum_sort_threads($rows) 33 { 34 foreach($rows as $row){ 35 $rows[$row["parent_id"]]["children"][]=$row["message_id"]; 36 } 37 38 // rewriting the define to a var for the new style of indenting 39 $GLOBALS['PHORUM']['DATA']['marker']=$GLOBALS['PHORUM']['TMP']['marker']; 40 41 $sorted_rows=array(0=>array()); 42 43 _phorum_recursive_sort($rows, $sorted_rows); 44 45 unset($sorted_rows[0]); 46 47 return $sorted_rows; 48 } 49 50 51 // not to be called directly. Call phorum_sort_threads 52 53 function _phorum_recursive_sort($rows, &$threads, $seed=0, $indent=0) 54 { 55 global $PHORUM; 56 57 if($seed>0){ 58 $threads[$rows[$seed]["message_id"]]=$rows[$seed]; 59 // old style of indenting 60 $threads[$rows[$seed]["message_id"]]["indent"]=str_repeat($PHORUM['TMP']['indentstring'], $indent); 61 62 if(!empty($indent)){ 63 $threads[$rows[$seed]["message_id"]]["indent"].=$PHORUM['TMP']['marker']; 64 } 65 66 // new style of indenting by padding-left 67 $threads[$rows[$seed]["message_id"]]["indent_cnt"]=$indent*$PHORUM['TMP']['indentmultiplier']; 68 if($indent < 31) { 69 $wrapnum=80-($indent*2); 70 } else { 71 $wrapnum=20; 72 } 73 $threads[$rows[$seed]["message_id"]]["subject"]=wordwrap($rows[$seed]['subject'],$wrapnum," ",1); 74 75 $indent++; 76 77 } 78 if(isset($rows[$seed]["children"])){ 79 foreach($rows[$seed]["children"] as $child){ 80 _phorum_recursive_sort($rows, $threads, $child, $indent); 81 } 82 } 83 } 84 85 86 87 88 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Thu Nov 29 12:22:27 2007 | par Balluche grâce à PHPXref 0.7 |
![]() |