| [ Index ] |
|
Code source de LifeType 1.2.4 |
1 <?php 2 3 4 lt_include( PLOG_CLASS_PATH."class/data/stringutils.class.php" ); 5 lt_include( PLOG_CLASS_PATH."class/gallery/dao/galleryalbums.class.php" ); 6 7 /** 8 * \ingroup Gallery 9 * 10 * some extra useful functions, which shouldn't be used by developers anyway... 11 */ 12 class GalleryTemplateTools 13 { 14 15 /** 16 * returns a nicely formated string with <option>...</option> tags that can be 17 * used in a <select> list. It will nest the album names in order to graphically 18 * describe hierarchies, for easier understanding of how our album structure 19 * is built 20 * 21 * @param userId 22 * @return A string 23 */ 24 function getNestedDropDownListContents( $userId ) 25 { 26 // fetch the list of albums properly arranged 27 $albums = new GalleryAlbums(); 28 $userAlbums = $albums->getUserAlbumsGroupedByParentId( $userId ); 29 30 // printing format 31 $format = '<option value="{id}">{name}</option>'; 32 33 // call the method and return the results 34 $result = GalleryTemplateTools::_printNested( $userAlbums, $format, " " ); 35 36 return $result; 37 } 38 39 /** 40 * @static 41 * @private 42 */ 43 function _printNested( $albums, $format, $spacing = " ", $start = 0, $level = -1 ) 44 { 45 $level++; 46 if( $albums["$start"] == "" ) 47 return ""; 48 49 foreach( $albums["$start"] as $album ) { 50 // do the replacing 51 $line = str_replace( '{id}', $album->getId(), $format); 52 $albumName = StringUtils::pad( $level, $spacing).$album->getName(); 53 $line = str_replace( '{name}', $albumName, $line ); 54 $results .= $line; 55 56 // make a recursive call 57 $results .= GalleryTemplateTools::_printNested( $albums, $format, $spacing, $album->getId(), $level); 58 } 59 60 return $results; 61 } 62 } 63 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
| Généré le : Mon Nov 26 21:04:15 2007 | par Balluche grâce à PHPXref 0.7 |
|