diff options
| author | Lester Caine <lester@lsces.co.uk> | 2026-05-26 14:55:36 +0100 |
|---|---|---|
| committer | Lester Caine <lester@lsces.co.uk> | 2026-05-26 14:55:36 +0100 |
| commit | 70c559432ece25dd3def8c64ddb7c1908b4d49e0 (patch) | |
| tree | 9627e43fbe0d0eb082e4d54fa47773cda77e58f7 /modules | |
| parent | 0579f237e179c8815c1c44d9c5cef94ad2a33588 (diff) | |
| download | stock-70c559432ece25dd3def8c64ddb7c1908b4d49e0.tar.gz stock-70c559432ece25dd3def8c64ddb7c1908b4d49e0.tar.bz2 stock-70c559432ece25dd3def8c64ddb7c1908b4d49e0.zip | |
Add xref support, assembly/component views, and import tooling
- add_xref.php, edit_xref.php: xref record add/edit for stock content types
- admin xref group/source pages for stock_assembly and stock_component
- assembly_views/: auto_flow, fixed_grid, position_number, simple_list layouts
- Full assembly and component listing, tree, ordering, and detail pages
- Import tooling (ImportAssembly, ImportComponent, load scripts)
- liberty_plugins for assembly and component data types
- schema_inc.php updated; StockAssembly, StockBase, StockComponent,
StockMovement classes updated with xref group/item/multiple renames
- Templates updated throughout for xref rename (source→item, group→x_group)
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Diffstat (limited to 'modules')
| -rwxr-xr-x | modules/help_mod_components.tpl | 23 | ||||
| -rwxr-xr-x | modules/mod_components.php | 71 | ||||
| -rwxr-xr-x | modules/mod_components.tpl | 35 | ||||
| -rwxr-xr-x | modules/mod_navigation.tpl | 38 |
4 files changed, 147 insertions, 20 deletions
diff --git a/modules/help_mod_components.tpl b/modules/help_mod_components.tpl new file mode 100755 index 0000000..1cf53bf --- /dev/null +++ b/modules/help_mod_components.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_components.php b/modules/mod_components.php new file mode 100755 index 0000000..a164cb1 --- /dev/null +++ b/modules/mod_components.php @@ -0,0 +1,71 @@ +<?php +/** + * @package stock + * @subpackage modules + */ + +namespace Bitweaver\Stock; + +use Bitweaver\KernelTools; +use Bitweaver\Users\RoleUser; +global $gQueryUserId, $gContent, $moduleParams; + +$component = 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['assembly_id'] = $gContent->mAssemblyId; + $display = $displayCount >= $thumbCount; +} + +if( $display ) { + $listHash['max_records'] = $module_rows ?? 3; + if( $gQueryUserId ) { + $listHash['user_id'] = $gQueryUserId; + } elseif( !empty( $_REQUEST['user_id'] ) ) { + $gBitSmarty->assign( 'userComponents', $_REQUEST['user_id'] ); + $listHash['user_id'] = $_REQUEST['user_id']; + } elseif( !empty( $listHash['recent_users'] ) ) { + $listHash['recent_users'] = true; + } + + $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; + + $components = $component->getList( $listHash ); + + if( empty( $title ) && $components ) { + $moduleTitle = match( $sort_mode ) { + 'random' => 'Random', + 'created_desc' => 'Recent', + 'hits_desc' => 'Popular', + default => 'Random', + }; + + $moduleTitle .= ' Components'; + $moduleTitle = KernelTools::tra( $moduleTitle ); + + if( !empty( $listHash['user_id'] ) ) { + $moduleTitle .= ' '.KernelTools::tra('by').' '.RoleUser::getDisplayNameFromHash( current( $components ), true ); + } elseif( !empty( $listHash['recent_users'] ) ) { + $moduleTitle .= ' '.KernelTools::tra( 'by' ).' <a href="'.USERS_PKG_URL.'">'.KernelTools::tra( 'New Users' ).'</a>'; + } + + $gBitSmarty->assign( 'moduleTitle', $moduleTitle ); + } else { + $gBitSmarty->assign( 'moduleTitle', $title ); + } + + $gBitSmarty->assign( 'modComponents', $components ); + $gBitSmarty->assign( 'module_params', $listHash ); + $gBitSmarty->assign( 'maxlen', isset( $listHash['maxlen'] ) ? (int)$listHash['maxlen'] : 0 ); + $gBitSmarty->assign( 'maxlendesc', isset( $listHash['maxlendesc'] ) ? (int)$listHash['maxlendesc'] : 0 ); +} diff --git a/modules/mod_components.tpl b/modules/mod_components.tpl new file mode 100755 index 0000000..b4e8973 --- /dev/null +++ b/modules/mod_components.tpl @@ -0,0 +1,35 @@ +{strip} +{if $gBitSystem->isPackageActive( 'stock' ) && $modComponents} + {bitmodule title="$moduleTitle" name="stock_components"} + <ul class="list-unstyled"> + {foreach from=$modComponents item=modComp} + <li class="{cycle values='odd,even'} item"> + <a href="{$modComp.display_url|escape}"> + {if $maxlen gt 0} + {$modComp.title|escape|truncate:$maxlen:"...":true} + {else} + {$modComp.title|escape} + {/if} + </a> + {if !empty($module_params.description)} + <br /> + {if $maxlendesc gt 0} + {$modComp.data|escape|truncate:$maxlendesc:"...":true} + {else} + {$modComp.data|escape} + {/if} + {/if} + {if !$userComponents} + <br />{tr}By{/tr} {displayname hash=$modComp} + {/if} + </li> + {foreachelse} + <li></li> + {/foreach} + </ul> + {if $userComponents} + <a href="{$smarty.const.STOCK_PKG_URL}list_components.php?user_id={$userComponents}">{tr}See more...{/tr}</a> + {/if} + {/bitmodule} +{/if} +{/strip} diff --git a/modules/mod_navigation.tpl b/modules/mod_navigation.tpl index f70502a..16e87b0 100755 --- a/modules/mod_navigation.tpl +++ b/modules/mod_navigation.tpl @@ -1,26 +1,24 @@ {strip} -{if $gGallery} +{if $gBitSystem->isPackageActive('stock')} {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 class="d-grid gap-1"> + {if $gBitUser->hasPermission('p_stock_view')} + <a class="btn btn-default btn-block" href="{$smarty.const.STOCK_PKG_URL}list_assemblies.php">{booticon iname="fa-list" iexplain="List Assemblies"} {tr}Assemblies{/tr}</a> + <a class="btn btn-default btn-block" href="{$smarty.const.STOCK_PKG_URL}list_components.php">{booticon iname="fa-tags" iexplain="List Components"} {tr}Components{/tr}</a> + {/if} + {if $gBitUser->hasPermission('p_stock_create')} + <a class="btn btn-primary btn-block" href="{$smarty.const.STOCK_PKG_URL}edit.php">{booticon iname="fa-plus" iexplain="Add Assembly"} {tr}Add Assembly{/tr}</a> + <a class="btn btn-primary btn-block" href="{$smarty.const.STOCK_PKG_URL}edit_component.php">{booticon iname="fa-plus" iexplain="Add Component"} {tr}Add Component{/tr}</a> + {/if} + {if $gContent && $gContent->isValid() && $gContent->hasUpdatePermission()} + {if $gContent->mAssemblyId} + <a class="btn btn-warning btn-block" href="{$smarty.const.STOCK_PKG_URL}edit.php?assembly_id={$gContent->mAssemblyId}">{booticon iname="fa-pen-to-square" iexplain="Edit"} {tr}Edit Assembly{/tr}</a> + <a class="btn btn-default btn-block" href="{$smarty.const.STOCK_PKG_URL}component_order.php?assembly_id={$gContent->mAssemblyId}">{booticon iname="fa-sort" iexplain="Order"} {tr}Component Order{/tr}</a> + {elseif $gContent->mComponentId} + <a class="btn btn-warning btn-block" href="{$smarty.const.STOCK_PKG_URL}edit_component.php?content_id={$gContent->mContentId}">{booticon iname="fa-pen-to-square" iexplain="Edit"} {tr}Edit Component{/tr}</a> + {/if} + {/if} </div> {/bitmodule} {/if} {/strip} - |
