summaryrefslogtreecommitdiff
path: root/FisheyeGallery.php
diff options
context:
space:
mode:
authorChristian Fowler <spider@viovio.com>2008-06-20 13:17:58 +0000
committerChristian Fowler <spider@viovio.com>2008-06-20 13:17:58 +0000
commit9f5a71c0f85420105cac7c90b2bb88fa8a097dcf (patch)
tree547e04d0603bdf97e0dd65150379c62baff3f368 /FisheyeGallery.php
parent0f72e0b526ebef81e05fd9555d62bbb143adcf83 (diff)
downloadfisheye-9f5a71c0f85420105cac7c90b2bb88fa8a097dcf.tar.gz
fisheye-9f5a71c0f85420105cac7c90b2bb88fa8a097dcf.tar.bz2
fisheye-9f5a71c0f85420105cac7c90b2bb88fa8a097dcf.zip
add recursive generateList and generateMenu methods to build entire tree for a user using FisheyeGallery::getTree (which still only works for ADVANCED_POSTGRESQL due to its recursive nature
Diffstat (limited to 'FisheyeGallery.php')
-rw-r--r--FisheyeGallery.php67
1 files changed, 66 insertions, 1 deletions
diff --git a/FisheyeGallery.php b/FisheyeGallery.php
index 84436da..98e3579 100644
--- a/FisheyeGallery.php
+++ b/FisheyeGallery.php
@@ -1,6 +1,6 @@
<?php
/**
- * @version $Header: /cvsroot/bitweaver/_bit_fisheye/FisheyeGallery.php,v 1.73 2008/06/17 17:05:16 lsces Exp $
+ * @version $Header: /cvsroot/bitweaver/_bit_fisheye/FisheyeGallery.php,v 1.74 2008/06/20 13:17:58 spiderr Exp $
* @package fisheye
*/
@@ -609,6 +609,71 @@ class FisheyeGallery extends FisheyeBase {
}
}
+
+
+ // Generate a nested ul list of listed galleries
+ function generateList( $pListHash, $pOptions ) {
+ $ret = '';
+ if( $hash = FisheyeGallery::getTree( $pListHash ) ) {
+ $ret = "<ul ";
+ foreach( array( 'class', 'name', 'id', 'onchange' ) as $key ) {
+ if( !empty( $pOptions[$key] ) ) {
+ $ret .= " $key=\"$pOptions[$key]\" ";
+ }
+ }
+ $ret .= ">";
+ $ret .= FisheyeGallery::generateListItems( $hash, !empty( $pOptions['item_attributes'] ) ? $pOptions['item_attributes'] : array() );
+ $ret .= "</select>";
+ }
+ return $ret;
+ }
+
+ // Helper method for generateMenu. See that method. Is Recursive
+ function generateListItems( &$pHash, $pAttributes=array() ) {
+ $ret = '';
+ foreach( array_keys( $pHash ) as $conId ) {
+ $ret .= '<li gallery_id="'.$pHash[$conId]['content']['gallery_id'].'" ';
+ foreach( $pAttributes as $key=>$value ) {
+ $ret .= " $key=\"$value\" ";
+ }
+ $ret .= ' >'.$pHash[$conId]['content']['title'].'</li>';
+ if( !empty( $pHash[$conId]['children'] ) ) {
+ $ret .= '<ul>'.FisheyeGallery::generateListItems( $pHash[$conId]['children'], $pAttributes ).'</ul>';
+ }
+ }
+ return $ret;
+ }
+
+ // Generate a select drop menu of listed galleries
+ function generateMenu( $pListHash, $pOptions ) {
+ $ret = '';
+ if( $hash = FisheyeGallery::getTree( $pListHash ) ) {
+ $ret = "<select ";
+ foreach( array( 'class', 'name', 'id', 'onchange' ) as $key ) {
+ if( !empty( $pOptions[$key] ) ) {
+ $ret .= " $key=\"$pOptions[$key]\" ";
+ }
+ }
+ $ret .= ">";
+ $ret .= !empty( $pOptions['first_option'] ) ? $pOptions['first_option'] : '';
+ $ret .= FisheyeGallery::generateMenuOptions( $hash );
+ $ret .= "</select>";
+ }
+ return $ret;
+ }
+
+ // Helper method for generateMenu. See that method. Is Recursive
+ function generateMenuOptions( &$pHash, $pPrefix='' ) {
+ $ret = '';
+ foreach( array_keys( $pHash ) as $conId ) {
+ $ret .= '<option value="'.$pHash[$conId]['content']['gallery_id'].'">'.$pPrefix.' '.$pHash[$conId]['content']['title'].'</option>';
+ if( !empty( $pHash[$conId]['children'] ) ) {
+ $ret .= FisheyeGallery::generateMenuOptions( $pHash[$conId]['children'], $pPrefix.'&nbsp;&nbsp;&nbsp;' );
+ }
+ }
+ return $ret;
+ }
+
function getList( &$pListHash ) {
global $gBitUser,$gBitSystem, $gBitDbType;