summaryrefslogtreecommitdiff
path: root/modules/mod_images.php
diff options
context:
space:
mode:
authorLester Caine <lester@lsces.co.uk>2026-05-21 19:26:26 +0100
committerLester Caine <lester@lsces.co.uk>2026-05-21 19:26:26 +0100
commit4ba9b3906b27e3571767689d2764b67dfe007e30 (patch)
tree494f4e6a65d34a4338c14de4144595a2df8c65b5 /modules/mod_images.php
downloadstock-4ba9b3906b27e3571767689d2764b67dfe007e30.tar.gz
stock-4ba9b3906b27e3571767689d2764b67dfe007e30.tar.bz2
stock-4ba9b3906b27e3571767689d2764b67dfe007e30.zip
Initial stock package — forked from fisheye
StockAssembly (was FisheyeGallery), StockComponent (was FisheyeImage), StockBase (was FisheyeBase). All fisheye_ table prefixes and FISHEYE_ constants renamed to stock_/STOCK_. DB schema will need rework before install; this gives a non-clashing base to diverge from fisheye. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Diffstat (limited to 'modules/mod_images.php')
-rwxr-xr-xmodules/mod_images.php86
1 files changed, 86 insertions, 0 deletions
diff --git a/modules/mod_images.php b/modules/mod_images.php
new file mode 100755
index 0000000..a01f8e4
--- /dev/null
+++ b/modules/mod_images.php
@@ -0,0 +1,86 @@
+<?php
+/**
+ * @version $Header$
+ * @package stock
+ * @subpackage modules
+ */
+
+/**
+ * required setup
+ */
+namespace Bitweaver\Stock;
+
+use Bitweaver\KernelTools;
+use Bitweaver\Users\RoleUser;
+global $gQueryUserId, $gContent, $moduleParams;
+// makes things in older modules easier
+// extract( $moduleParams );
+
+$image = new StockComponent();
+
+$display = true;
+
+$listHash = $moduleParams->value;
+
+if( !empty( $gContent ) && $gContent->getField( 'content_type_guid' ) == STOCKASSEMBLY_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"] ) );
+}