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