diff options
Diffstat (limited to 'modules/mod_images.php')
| -rw-r--r-- | modules/mod_images.php | 88 |
1 files changed, 71 insertions, 17 deletions
diff --git a/modules/mod_images.php b/modules/mod_images.php index 05ffb14..b937bb1 100644 --- a/modules/mod_images.php +++ b/modules/mod_images.php @@ -1,28 +1,82 @@ <?php -// $Header: /cvsroot/bitweaver/_bit_fisheye/modules/mod_images.php,v 1.2 2005/06/21 18:17:51 squareing Exp $ -global $gQueryUserId, $module_rows, $module_params; +/** + * @version $Header: /cvsroot/bitweaver/_bit_fisheye/modules/mod_images.php,v 1.3 2005/06/28 07:45:43 spiderr Exp $ + * @package fisheye + * @subpackage modules + */ +global $gQueryUserId, $module_rows, $module_params, $gContent; + +/** + * required setup + */ require_once( FISHEYE_PKG_PATH.'FisheyeImage.php' ); $image = new FisheyeImage(); -$listHash = $module_params; -$listHash['max_records'] = $module_rows; -$listHash['user_id'] = $gQueryUserId; +$display = TRUE; -// this is needed to avoid wrong sort_modes entered resulting in db errors -$sort_options = array( 'hits', 'created' ); -if( !empty( $module_params['sort_mode'] ) && in_array( $module_params['sort_mode'], $sort_options ) ) { - $sort_mode = $module_params['sort_mode'].'_asc'; -} else { - $sort_mode = 'random'; +$listHash = $module_params; +if( !empty( $gContent ) && $gContent->mInfo['content_type_guid'] == FISHEYEGALLERY_CONTENT_TYPE_GUID ) { + $displayCount = empty( $gContent->mItems ) ? 0 : count( $gContent->mItems ); + $thumbCount = $gContent->mInfo['rows_per_page'] * $gContent->mInfo["cols_per_page"]; + $listHash['gallery_id'] = $_REQUEST['gallery_id']; + $display = $displayCount >= $thumbCount; } -$listHash['sort_mode'] = $sort_mode; -$images = $image->getList( $listHash ); +if( $display ) { + + $listHash['max_records'] = $module_rows; + if( $gQueryUserId ) { + $listHash['user_id'] = $gQueryUserId; + } elseif( !empty( $_REQUEST['user_id'] ) ) { + $listHash['user_id'] = $_REQUEST['user_id']; + } elseif( !empty( $module_params['recent_users'] ) ) { + $listHash['recent_users'] = TRUE; + } + + // this is needed to avoid wrong sort_modes entered resulting in db errors + $sort_options = array( 'hits', 'created' ); + if( !empty( $module_params['sort_mode'] ) && in_array( $module_params['sort_mode'], $sort_options ) ) { + $sort_mode = $module_params['sort_mode'].'_desc'; + } else { + $sort_mode = 'random'; + } + $listHash['sort_mode'] = $sort_mode; -$smarty->assign( 'modImages', $images ); -$smarty->assign( 'module_params', $module_params ); -$smarty->assign( 'maxlen', isset( $module_params["maxlen"] ) ? $module_params["maxlen"] : 0 ); -$smarty->assign( 'maxlendesc', isset( $module_params["maxlendesc"] ) ? $module_params["maxlendesc"] : 0 ); + $images = $image->getList( $listHash ); + + if( empty( $module_title ) && $images ) { + $moduleTitle = ''; + if( !empty( $module_params['sort_mode'] ) ) { + if( $module_params['sort_mode'] == 'random' ) { + $moduleTitle = 'Random'; + } elseif( $module_params['sort_mode'] == 'created' ) { + $moduleTitle = 'Recent'; + } elseif( $module_params['sort_mode'] == 'hits' ) { + $moduleTitle = 'Popular'; + } + } else { + $moduleTitle = 'Recent'; + } + + $moduleTitle .= ' Images'; + $moduleTitle = tra( $moduleTitle ); + + if( !empty( $listHash['user_id'] ) ) { + $moduleTitle .= ' '.tra('by').' '.BitUser::getDisplayName( TRUE, current( $images ) ); + } elseif( !empty( $listHash['recent_users'] ) ) { + $moduleTitle .= ' '.tra( 'by' ).' <a href="'.USERS_PKG_URL.'">'.tra( 'New Users' ).'</a>'; + } + + $listHash['sort_mode'] = $sort_mode; + $smarty->assign( 'moduleTitle', $moduleTitle ); + } + + $smarty->assign( 'imageSort', $sort_mode ); + $smarty->assign( 'modImages', $images ); + $smarty->assign( 'module_params', $module_params ); + $smarty->assign( 'maxlen', isset( $module_params["maxlen"] ) ? $module_params["maxlen"] : 0 ); + $smarty->assign( 'maxlendesc', isset( $module_params["maxlendesc"] ) ? $module_params["maxlendesc"] : 0 ); +} ?> |
