[pLog-svn] r6557 - plog/trunk/class/gallery/dao
mark at devel.lifetype.net
mark at devel.lifetype.net
Mon Jun 16 06:25:43 EDT 2008
Author: mark
Date: 2008-06-16 06:25:43 -0400 (Mon, 16 Jun 2008)
New Revision: 6557
Modified:
plog/trunk/class/gallery/dao/galleryalbum.class.php
Log:
Implement getParents() in galleryalbum, it is easier for us to implement bread crumbs of galleryalbums in template.
Modified: plog/trunk/class/gallery/dao/galleryalbum.class.php
===================================================================
--- plog/trunk/class/gallery/dao/galleryalbum.class.php 2008-06-16 09:45:48 UTC (rev 6556)
+++ plog/trunk/class/gallery/dao/galleryalbum.class.php 2008-06-16 10:25:43 UTC (rev 6557)
@@ -20,6 +20,7 @@
var $_flags;
var $_parentId;
var $_parent;
+ var $_parents;
var $_date;
var $_id;
var $_numResources;
@@ -174,6 +175,34 @@
}
/**
+ * Returns the parent albums, or empty array if there is no parent albums (from root to itself)
+ *
+ * @return A GalleryAlbum object or null if there is no parent
+ */
+ function getParents()
+ {
+ if( $this->_parents == null )
+ {
+ $albums = new GalleryAlbums();
+ $parentIds = $albums->getAllParentAlbumIds( $this );
+
+ $parentAlbums = array();
+ foreach( $parentIds as $parentId )
+ {
+ $album = $albums->getAlbum( $parentId, $this->_ownerId, false, true );
+ if( $album )
+ array_push( $this->_parents, $album );
+ }
+
+ if( $this->_parents && is_array( $this->_parents ) ) {
+ $this->_parents = array_reverse( $this->_parents );
+ }
+ }
+
+ return $this->_parents;
+ }
+
+ /**
* Sets the parent id of the album. It is important that it is a valid
* parent id, otherwise reading this album will generate unexpected errors
* since it won't be possible to find its parent id!
@@ -447,4 +476,4 @@
$this->_normalizedDescription = $normalizedDescription;
}
}
-?>
\ No newline at end of file
+?>
More information about the pLog-svn
mailing list