diff options
| author | Lester Caine <lester@lsces.co.uk> | 2026-05-21 19:26:26 +0100 |
|---|---|---|
| committer | Lester Caine <lester@lsces.co.uk> | 2026-05-21 19:26:26 +0100 |
| commit | 4ba9b3906b27e3571767689d2764b67dfe007e30 (patch) | |
| tree | 494f4e6a65d34a4338c14de4144595a2df8c65b5 /modules | |
| download | stock-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')
| -rwxr-xr-x | modules/help_mod_images.tpl | 23 | ||||
| -rwxr-xr-x | modules/mod_banner_rand.php | 34 | ||||
| -rwxr-xr-x | modules/mod_banner_rand.tpl | 22 | ||||
| -rwxr-xr-x | modules/mod_images.php | 86 | ||||
| -rwxr-xr-x | modules/mod_images.tpl | 41 | ||||
| -rwxr-xr-x | modules/mod_navigation.tpl | 26 | ||||
| -rwxr-xr-x | modules/mod_specials.php | 40 | ||||
| -rwxr-xr-x | modules/mod_specials.tpl | 14 |
8 files changed, 286 insertions, 0 deletions
diff --git a/modules/help_mod_images.tpl b/modules/help_mod_images.tpl new file mode 100755 index 0000000..1cf53bf --- /dev/null +++ b/modules/help_mod_images.tpl @@ -0,0 +1,23 @@ +<p class="note"> + {tr}Display images from the stock gallery. If <kbd>maxlen</kbd> is set, the image's title is shown, and truncated to the specified number of letters. If <kbd class="param">description</kbd> is set, the image's description is shown and can be truncated by setting <kbd>maxlendesc</kbd>. <kbd>recent_users</kbd> will display the most recent image from the most recent users.{/tr} + <br /> + <span class="example">{tr}Example:{/tr} <kbd>sort_mode=hits&maxlen=111&description=yes&maxlendesc=222</kbd></span> +</p> + +<dl> + <dt class="param"><kbd>sort_mode</kbd></dt> + <dd><em>{tr}String{/tr}</em></dd> + <dd><abbr title="{tr}default{/tr}" class="default">random</abbr>, created, hits</dd> + + <dt class="param"><kbd>maxlen</kbd></dt> + <dd><em>{tr}Boolean{/tr}</em></dd> + + <dt class="param"><kbd>description</kbd></dt> + <dd><em>{tr}Boolean{/tr}</em></dd> + + <dt class="param"><kbd>maxlendesc</kbd></dt> + <dd><em>{tr}Numeric{/tr}</em></dd> + + <dt class="param"><kbd>recent_users</kbd></dt> + <dd><em>{tr}Boolean{/tr}</em></dd> +</dl> diff --git a/modules/mod_banner_rand.php b/modules/mod_banner_rand.php new file mode 100755 index 0000000..9afbec1 --- /dev/null +++ b/modules/mod_banner_rand.php @@ -0,0 +1,34 @@ +<?php +/** + * @version $Header$ + * @package stock + * @subpackage modules + */ + +/** + * required setup + */ +namespace Bitweaver\Stock; + +global $gBitSmarty, $gContent; +// makes things in older modules easier + +if ( !empty($gBitSmarty->tpl_vars) ) { + $tpls = $gBitSmarty->tpl_vars; + $module_params = $tpls['moduleParams']; + $listHash = $module_params->value; + $listHash['gallery_id'] = $module_params->value['module_rows']; +} +$image = new StockComponent(); + +$display = true; + +$listHash['size'] = 'extra-large'; +$listHash['max_records'] = 5; +$listHash['sort_mode'] = 'random'; + +$images = $image->getList( $listHash ); +$moduleTitle = 'Banner Image'; +$gBitSmarty->assign( 'moduleTitle', $moduleTitle ); +$gBitSmarty->assign( 'modImages', $images ); +$gBitSmarty->assign( 'module_params', $listHash ); diff --git a/modules/mod_banner_rand.tpl b/modules/mod_banner_rand.tpl new file mode 100755 index 0000000..5548307 --- /dev/null +++ b/modules/mod_banner_rand.tpl @@ -0,0 +1,22 @@ +{strip} +<div id="xsbanner" class="col-xs-12 visible-xs"> + <div id="banner-xs" class="visible-xs"> + </div> +</div> +<div id="banner" class="col-xs-12 hidden-xs"> + <div id="banner"> + <ul id="background"> + {foreach from=$modImages item=modImg} + <li><img src="/liberty/download/file/{$modImg.image_id|default:0}" title="{$modImg.title|default:''}" alt="{$modImg.title|default:''}" /></li> + {/foreach} + </ul> + </div> + <div id="overlay"> + <div id="banner-md" class="visible-sm visible-md"> + </div> + <div id="banner-lg" class="visible-lg"> + </div> + </div> +</div> +<div class="clear"></div> +{/strip} 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"] ) ); +} diff --git a/modules/mod_images.tpl b/modules/mod_images.tpl new file mode 100755 index 0000000..e192a46 --- /dev/null +++ b/modules/mod_images.tpl @@ -0,0 +1,41 @@ +{strip} +{if $gBitSystem->isPackageActive( 'stock' ) && $modImages} + {bitmodule title="$moduleTitle" name="stock_images"} + <ul class="list-unstyled"> + {foreach from=$modImages item=modImg} + <li class="{cycle values='odd,even'} item"> + <a href="{$modImg.display_url}" title="{$modImg.title|escape} - {$modImg.last_modified|bit_short_datetime}, by {displayname user=$modImg.modifier_user ?? '' real_name=$modImg.modifier_real_name ?? '' nolink=1}{if (strlen($modImg.title) > $maxlen) && ($maxlen > 0)}, {$modImg.title|escape}{/if}"> + <img src="{$modImg.thumbnail_url}" title="{$modImg.title|escape}" alt="{$modImg.title|escape}" /> + + {if !empty($modImg.has_machine_name)} + <br /> + {if $maxlen gt 0} + {$modImg.title|escape|truncate:$maxlen:"...":true} + {else} + {$modImg.title|escape} + {/if} + {/if} + </a> + + {if !empty($module_params.description)} + <br /> + {if $maxlendesc gt 0} + {$modImg.data|escape|truncate:$maxlendesc:"...":true} + {else} + {$modImg.data|escape} + {/if} + {/if} + {if !$userGallery} + <br/>{tr}By{/tr} {displayname hash=$modImg} + {/if} + </li> + {foreachelse} + <li></li> + {/foreach} + </ul> + {if $userGallery} + <a href="{$smarty.const.STOCK_PKG_URL}index.php?user_id={$userGallery}">{tr}See more...{/tr}</a> + {/if} + {/bitmodule} +{/if} +{/strip} diff --git a/modules/mod_navigation.tpl b/modules/mod_navigation.tpl new file mode 100755 index 0000000..f70502a --- /dev/null +++ b/modules/mod_navigation.tpl @@ -0,0 +1,26 @@ +{strip} +{if $gGallery} + {bitmodule title="$moduleTitle" name="stock_navigation"} + <div class="pull-left"> + {if $gGallery->mInfo.previous_image_id} + <a href="{$gContent->getImageUrl($gGallery->mInfo.previous_image_id)|escape}"> + <img src="{$gGallery->mInfo.previous_image_avatar}" /> + <br /> + « {tr}previous{/tr} + </a> + {else} {/if} + </div> + + <div class="pull-right"> + {if $gGallery->mInfo.next_image_id} + <a href="{$gContent->getImageUrl($gGallery->mInfo.next_image_id)|escape}"> + <img src="{$gGallery->mInfo.next_image_avatar}" /> + <br /> + {tr}next{/tr} » + </a> + {else} {/if} + </div> + {/bitmodule} +{/if} +{/strip} + diff --git a/modules/mod_specials.php b/modules/mod_specials.php new file mode 100755 index 0000000..fc37db4 --- /dev/null +++ b/modules/mod_specials.php @@ -0,0 +1,40 @@ +<?php +/** + * @version $Header$ + * @package stock + * @subpackage modules + */ + +/** + * required setup + */ +namespace Bitweaver\Stock; + +use Bitweaver\KernelTools; +global $gQueryUserId, $gContent, $moduleParams; + +// makes things in older modules easier +extract( $moduleParams ); + +$image = new StockComponent(); + +$display = true; + +$listHash = $module_params; +$listHash['gallery_id'] = 3; + +if( $display ) { + $listHash['size'] = 'medium'; + $listHash['max_records'] = 5; + $listHash['sort_mode'] = 'random'; + $images = $image->getList( $listHash ); + + $moduleTitle = 'Specials'; + $moduleTitle = KernelTools::tra( $moduleTitle ); + + $gBitSmarty->assign( 'moduleTitle', $moduleTitle ); + $gBitSmarty->assign( 'modImages', $images ); + $gBitSmarty->assign( 'module_params', $module_params ); + $gBitSmarty->assign( 'maxlen', $module_params["maxlen"] ?? 0 ); + $gBitSmarty->assign( 'maxlendesc', $module_params["maxlendesc"] ?? 0 ); +} diff --git a/modules/mod_specials.tpl b/modules/mod_specials.tpl new file mode 100755 index 0000000..97a35f6 --- /dev/null +++ b/modules/mod_specials.tpl @@ -0,0 +1,14 @@ +{strip} +{if $gBitSystem->isPackageActive( 'stock' ) && $modImages} + <ul id="specials"> + {foreach from=$modImages item=modImg} + <li> + <h1>{$modImg.title|escape}</h1> + <a href="{$modImg.display_url}" alt="{$modImg.title|escape}" title="{$modImg.title|escape} - {$modImg.last_modified|bit_short_datetime}, by {displayname user=$modImg.modifier_user real_name=$modImg.modifier_real_name nolink=1}{if (strlen($modImg.title) > $maxlen) && ($maxlen > 0)}, {$modImg.title|escape}{/if}"> + <img src="{$modImg.thumbnail_url}" title="{$modImg.title|escape}" alt="{$modImg.title|escape}" /> + </a> + </li> + {/foreach} + </ul> +{/if} +{/strip} |
