fisheye
[ class tree: fisheye ] [ index: fisheye ] [ all elements ]

Source for file mod_images.php

Documentation is available at mod_images.php

  1. <?php
  2. /**
  3.  * @version $Header$
  4.  * @package fisheye
  5.  * @subpackage modules
  6.  */
  7.  
  8. global $gQueryUserId, $gContent, $moduleParams;
  9.  
  10. // makes things in older modules easier
  11. extract( $moduleParams );
  12.  
  13. /**
  14.  * required setup
  15.  */
  16. require_once( FISHEYE_PKG_PATH.'FisheyeGallery.php' );
  17.  
  18. $image = new FisheyeImage();
  19.  
  20. $display = TRUE;
  21.  
  22. $listHash = $module_params;
  23.  
  24. if( !empty( $gContent ) && $gContent->getField( 'content_type_guid' ) == FISHEYEGALLERY_CONTENT_TYPE_GUID ) {
  25.     $displayCount = empty( $gContent->mItems ) ? 0 : count( $gContent->mItems );
  26.     $thumbCount = $gContent->mInfo['rows_per_page'] * $gContent->mInfo["cols_per_page"];
  27.     $listHash['gallery_id'] = $gContent->mGalleryId;
  28.     $display = $displayCount >= $thumbCount;
  29. }
  30.  
  31.  
  32. if( $display ) {
  33.     $listHash['max_records'] = $module_rows;
  34.     if( $gQueryUserId ) {
  35.         $listHash['user_id'] = $gQueryUserId;
  36.     } elseif( !empty( $_REQUEST['user_id'] ) ) {
  37.         $_template->tpl_vars['userGallery'] = new Smarty_variable( $_REQUEST['user_id'] );
  38.         $listHash['user_id'] = $_REQUEST['user_id'];
  39.     } elseif( !empty( $module_params['recent_users'] ) ) {
  40.         $listHash['recent_users'] = TRUE;
  41.     }
  42.  
  43.     // this is needed to avoid wrong sort_modes entered resulting in db errors
  44.     $sort_options = array( 'hits', 'created' );
  45.     if( !empty( $module_params['sort_mode'] ) && in_array( $module_params['sort_mode'], $sort_options ) ) {
  46.         $sort_mode = $module_params['sort_mode'].'_desc';
  47.     } else {
  48.         $sort_mode = 'random';
  49.     }
  50.     $listHash['sort_mode'] = $sort_mode;
  51.  
  52.     $images = $image->getList( $listHash );
  53.  
  54.     if( empty( $title ) && $images ) {
  55.         $moduleTitle = '';
  56.         if( !empty( $module_params['sort_mode'] ) ) {
  57.             if( $module_params['sort_mode'] == 'random' ) {
  58.                 $moduleTitle = 'Random';
  59.             } elseif( $module_params['sort_mode'] == 'created' ) {
  60.                 $moduleTitle = 'Recent';
  61.             } elseif( $module_params['sort_mode'] == 'hits' ) {
  62.                 $moduleTitle = 'Popular';
  63.             }
  64.         } else {
  65.             $moduleTitle = 'Random';
  66.         }
  67.  
  68.         $moduleTitle .= ' Images';
  69.         $moduleTitle = tra( $moduleTitle );
  70.  
  71.         if( !empty( $listHash['user_id'] ) ) {
  72.             $moduleTitle .= ' '.tra('by').' '.BitUser::getDisplayNameFromHash( TRUE, current( $images ) );
  73.         } elseif( !empty( $listHash['recent_users'] ) ) {
  74.             $moduleTitle .= ' '.tra( 'by' ).' <a href="'.USERS_PKG_URL.'">'.tra( 'New Users' ).'</a>';
  75.         }
  76.  
  77.         $listHash['sort_mode'] = $sort_mode;
  78.         $_template->tpl_vars['moduleTitle'] = new Smarty_variable( $moduleTitle );
  79.     } else {
  80.         $_template->tpl_vars['moduleTitle'] = new Smarty_variable( $title );
  81.     }
  82.  
  83.     $_template->tpl_vars['imageSort'] = new Smarty_variable( $sort_mode );
  84.     $_template->tpl_vars['modImages'] = new Smarty_variable( $images );
  85.     $_template->tpl_vars['module_params'] = new Smarty_variable( $module_params );
  86.     $_template->tpl_vars['maxlen'] = new Smarty_variable( isset( $module_params["maxlen"] ) );
  87.     $_template->tpl_vars['maxlendesc'] = new Smarty_variable( isset( $module_params["maxlendesc"] ) );
  88. }
  89. ?>

Documentation generated on Wed, 29 Jul 2015 13:57:10 +0000 by phpDocumentor 1.5.0-lsces