diff options
| author | Max Kremmel <xing@synapse.plus.com> | 2006-09-08 06:58:46 +0000 |
|---|---|---|
| committer | Max Kremmel <xing@synapse.plus.com> | 2006-09-08 06:58:46 +0000 |
| commit | 807268c606c3b902f0322c9d07b37a674f9b1ae4 (patch) | |
| tree | 78a5dcfd259c595d6482f2f47a933e7a97e7fa74 /Pigeonholes.php | |
| parent | ce250666cbc3fc24fc3d519ba1b389a2b632da8a (diff) | |
| download | pigeonholes-807268c606c3b902f0322c9d07b37a674f9b1ae4.tar.gz pigeonholes-807268c606c3b902f0322c9d07b37a674f9b1ae4.tar.bz2 pigeonholes-807268c606c3b902f0322c9d07b37a674f9b1ae4.zip | |
only perform array related operations when there is one to work with
Diffstat (limited to 'Pigeonholes.php')
| -rw-r--r-- | Pigeonholes.php | 44 |
1 files changed, 23 insertions, 21 deletions
diff --git a/Pigeonholes.php b/Pigeonholes.php index e1e9a4a..e8f4b58 100644 --- a/Pigeonholes.php +++ b/Pigeonholes.php @@ -1,6 +1,6 @@ <?php /** - * @version $Header: /cvsroot/bitweaver/_bit_pigeonholes/Pigeonholes.php,v 1.66 2006/09/07 19:07:51 squareing Exp $ + * @version $Header: /cvsroot/bitweaver/_bit_pigeonholes/Pigeonholes.php,v 1.67 2006/09/08 06:58:46 squareing Exp $ * * +----------------------------------------------------------------------+ * | Copyright ( c ) 2004, bitweaver.org @@ -17,7 +17,7 @@ * Pigeonholes class * * @author xing <xing@synapse.plus.com> - * @version $Revision: 1.66 $ + * @version $Revision: 1.67 $ * @package pigeonholes */ @@ -250,30 +250,32 @@ class Pigeonholes extends LibertyContent { $ret[$pigeonhole['content_id']] = $this->getPigeonholePath( $pigeonhole['structure_id'] ); } - if( $pTruncate ) { - foreach( $ret as $cid => $path ) { - // count here to minimise speed loss - $count = count( $path ); - foreach( $path as $pos => $pig ) { - // calculate limit at which category is truncated - if( $count == 1 ) { - $limit = $pTruncate; - } elseif( $pos == $count - 1 ) { - $limit = ceil( $pTruncate / 2 ); - } else { - $limit = ceil( $pTruncate / 2 / $count ); + if( !empty( $ret ) ) { + if( $pTruncate ) { + foreach( $ret as $cid => $path ) { + // count here to minimise speed loss + $count = count( $path ); + foreach( $path as $pos => $pig ) { + // calculate limit at which category is truncated + if( $count == 1 ) { + $limit = $pTruncate; + } elseif( $pos == $count - 1 ) { + $limit = ceil( $pTruncate / 2 ); + } else { + $limit = ceil( $pTruncate / 2 / $count ); + } + $ret[$cid][$pos]['title'] = substr( $pig['title'], 0, $limit ).( ( strlen( $pig['title'] ) <= $limit ) ? '' : '...' ); } - $ret[$cid][$pos]['title'] = substr( $pig['title'], 0, $limit ).( ( strlen( $pig['title'] ) <= $limit ) ? '' : '...' ); } } - } - // sort the pathlist to make the display nicer - usort( $ret, 'pigeonholes_pathlist_sorter' ); + // sort the pathlist to make the display nicer + usort( $ret, 'pigeonholes_pathlist_sorter' ); - if( @BitBase::verifyId( $pContentId ) && $assigned = $this->getPigeonholesFromContentId( $pContentId ) ) { - foreach( $assigned as $a ) { - $ret[$a['content_id']][0]['selected'] = TRUE; + if( @BitBase::verifyId( $pContentId ) && $assigned = $this->getPigeonholesFromContentId( $pContentId ) ) { + foreach( $assigned as $a ) { + $ret[$a['content_id']][0]['selected'] = TRUE; + } } } |
