diff options
| -rwxr-xr-x | admin/admin_stock_inc.php | 8 | ||||
| -rwxr-xr-x | admin/schema_inc.php | 5 | ||||
| -rwxr-xr-x | includes/bit_setup_inc.php | 3 | ||||
| -rwxr-xr-x | includes/classes/StockAssembly.php | 56 | ||||
| -rwxr-xr-x | includes/display_stock_assembly_inc.php | 2 | ||||
| -rwxr-xr-x | modules/mod_components.php | 3 | ||||
| -rwxr-xr-x | templates/admin_stock.tpl | 41 | ||||
| -rwxr-xr-x | templates/view_assembly.tpl | 4 |
8 files changed, 5 insertions, 117 deletions
diff --git a/admin/admin_stock_inc.php b/admin/admin_stock_inc.php index 881d6d2..cd81680 100755 --- a/admin/admin_stock_inc.php +++ b/admin/admin_stock_inc.php @@ -97,10 +97,6 @@ $formImageLists = [ ]; $gBitSmarty->assign( 'formImageLists', $formImageLists ); -use Bitweaver\Stock\StockAssembly; - -$gBitSmarty->assign( 'galleryPaginationTypes', StockAssembly::getAllLayouts() ); - $sortOptions = [ '' => KernelTools::tra( 'None' ), 'lc.title_desc' => KernelTools::tra( 'Title' ). ' - '.KernelTools::tra( 'descending' ), @@ -129,9 +125,7 @@ if (!empty($_REQUEST['stockAdminSubmit'])) { simple_set_toggle($item, STOCK_PKG_NAME); } - foreach( [ 'default_assembly_pagination', 'rows_per_page', 'cols_per_page', 'total_per_page', 'lines_per_page', 'stock_gallery_default_sort_mode' ] as $key ) { - $gBitSystem->storeConfig($key, $_REQUEST[$key], STOCK_PKG_NAME); - } + $gBitSystem->storeConfig( 'stock_gallery_default_sort_mode', $_REQUEST['stock_gallery_default_sort_mode'] ?? '', STOCK_PKG_NAME ); foreach ($formImageLists as $item => $data) { simple_set_toggle( $item, STOCK_PKG_NAME ); diff --git a/admin/schema_inc.php b/admin/schema_inc.php index d76e921..edf8463 100755 --- a/admin/schema_inc.php +++ b/admin/schema_inc.php @@ -47,11 +47,6 @@ $gBitInstaller->registerPreferences( STOCK_PKG_NAME, [ [ STOCK_PKG_NAME, 'stock_item_list_creator', 'n' ], [ STOCK_PKG_NAME, 'stock_item_list_hits', 'n' ], [ STOCK_PKG_NAME, 'stock_item_list_attid', 'n' ], - // Pagination defaults - [ STOCK_PKG_NAME, 'default_gallery_pagination', 'position_number' ], - [ STOCK_PKG_NAME, 'rows_per_page', '5' ], - [ STOCK_PKG_NAME, 'cols_per_page', '3' ], - [ STOCK_PKG_NAME, 'total_per_page', '20' ], // Movement statuses [ STOCK_PKG_NAME, 'stock_movement_statuses', 'draft,pending,complete,cancelled' ], [ STOCK_PKG_NAME, 'stock_movement_status_draft', 'Draft' ], diff --git a/includes/bit_setup_inc.php b/includes/bit_setup_inc.php index 88c6415..0fd18c2 100755 --- a/includes/bit_setup_inc.php +++ b/includes/bit_setup_inc.php @@ -20,9 +20,6 @@ $gBitSystem->registerPackage( $pRegisterHash ); if( $gBitSystem->isPackageActive( 'stock' ) ) { // && $gBitUser->hasPermission( 'p_stock_view' )) { - // Default Preferences Defines - define ( 'STOCK_DEFAULT_ROWS_PER_PAGE', 5 ); - define ( 'STOCK_DEFAULT_COLS_PER_PAGE', 2 ); define ( 'STOCK_DEFAULT_THUMBNAIL_SIZE', 'large' ); $menuHash = [ diff --git a/includes/classes/StockAssembly.php b/includes/classes/StockAssembly.php index 54342ad..5765031 100755 --- a/includes/classes/StockAssembly.php +++ b/includes/classes/StockAssembly.php @@ -16,10 +16,6 @@ use Bitweaver\Liberty\LibertyContent; define('STOCKASSEMBLY_CONTENT_TYPE_GUID', 'stockassembly'); -define( 'STOCK_PAGINATION_FIXED_GRID', 'fixed_grid' ); -define( 'STOCK_PAGINATION_AUTO_FLOW', 'auto_flow' ); -define( 'STOCK_PAGINATION_POSITION_NUMBER', 'position_number' ); -define( 'STOCK_PAGINATION_SIMPLE_LIST', 'simple_list' ); #[\AllowDynamicProperties] class StockAssembly extends StockBase { @@ -190,25 +186,11 @@ class StockAssembly extends StockBase { $this->mInfo['creator'] = $rs['creator_real_name'] ?? $rs['creator_user']; $this->mInfo['editor'] = $rs['modifier_real_name'] ?? $rs['modifier_user']; - $this->mInfo['rows_per_page'] = $gBitSystem->getConfig( 'stock_gallery_default_rows_per_page', STOCK_DEFAULT_ROWS_PER_PAGE ); - $this->mInfo['cols_per_page'] = $gBitSystem->getConfig( 'stock_gallery_default_cols_per_page', STOCK_DEFAULT_COLS_PER_PAGE ); if( empty( $this->mInfo['thumbnail_size'] ) ) { $this->mInfo['thumbnail_size'] = $this->getPreference( 'stock_gallery_default_thumbnail_size', null ); } $this->mInfo['access_answer'] = ''; - $this->mInfo['num_components'] = $this->getComponentCount(); - if( $this->getPreference( 'assembly_pagination' ) == STOCK_PAGINATION_POSITION_NUMBER ) { - $this->mInfo['num_pages'] = $this->mDb->getOne( "SELECT COUNT( distinct( floor(`item_position`) ) ) FROM `".BIT_DB_PREFIX."stock_assembly_map` WHERE assembly_content_id=?", [ $this->mContentId ] ); - } else { - $pagination = $this->getPreference( 'assembly_pagination' ); - if( in_array( $pagination, [ STOCK_PAGINATION_AUTO_FLOW, STOCK_PAGINATION_SIMPLE_LIST ] ) ) { - $this->mInfo['images_per_page'] = (int)$this->getPreference( 'total_per_page', $this->mInfo['rows_per_page'] ); - } else { - $this->mInfo['images_per_page'] = $this->mInfo['cols_per_page'] * $this->mInfo['rows_per_page']; - } - $this->mInfo['num_pages'] = (int)$this->mInfo['num_components'] / $this->mInfo['images_per_page'] + ($this->mInfo['num_components'] % $this->mInfo['images_per_page'] == 0 ? 0 : 1); - } } return !empty( $this->mInfo ); @@ -245,24 +227,8 @@ class StockAssembly extends StockBase { // load for just a single page if( $pListHash['page'] != -1 ) { - if( $this->getLayout() == STOCK_PAGINATION_POSITION_NUMBER ) { - $query = "SELECT DISTINCT(FLOOR(`item_position`)) - FROM `".BIT_DB_PREFIX."stock_assembly_map` - WHERE assembly_content_id=? - ORDER BY floor(item_position)"; - $mantissa = $this->mDb->getOne( $query, [ $this->mContentId ], 1, $pListHash['page'] - 1 ); - // gallery image order with no positions set will have null mantissa, and all images will be shown - if( !is_null( $mantissa ) ) { - $whereSql .= " AND floor(item_position)=? "; - array_push( $bindVars, $mantissa ); - } - } elseif( $this->getLayout() == STOCK_PAGINATION_FIXED_GRID ) { - $rowCount = ($this->mInfo['rows_per_page'] ?? 3) * ($this->mInfo['cols_per_page'] ?? 3); - $offset = $rowCount * ( (int) $pListHash['page'] - 1); - } else { - $rowCount = $pListHash['max_records']; - $offset = $rowCount * ( (int) $pListHash['page'] - 1); - } + $rowCount = $pListHash['max_records']; + $offset = $rowCount * ( (int) $pListHash['page'] - 1); } if( empty($rowCount) ) $rowCount = $pListHash['max_records'] ?? 10; $this->mItems = []; @@ -638,24 +604,6 @@ class StockAssembly extends StockBase { } - /** - * @return string Pagination layout preference (one of STOCK_PAGINATION_* constants). - */ - public function getLayout() { - global $gBitSystem; - return $this->getPreference( 'assembly_pagination', $gBitSystem->getConfig( 'default_assembly_pagination', STOCK_PAGINATION_FIXED_GRID ) ); - } - - /** @return array Map of STOCK_PAGINATION_* constant → human-readable label. */ - public static function getAllLayouts() { - return [ - STOCK_PAGINATION_FIXED_GRID => 'Fixed Grid', - STOCK_PAGINATION_AUTO_FLOW => 'Auto-Flow', - STOCK_PAGINATION_POSITION_NUMBER => 'Position Number', - STOCK_PAGINATION_SIMPLE_LIST => 'Simple List', - ]; - } - /** @return string Absolute path to the display_stock_assembly_inc.php setup file. */ public function getRenderFile() { return STOCK_PKG_INCLUDE_PATH.'display_stock_assembly_inc.php'; diff --git a/includes/display_stock_assembly_inc.php b/includes/display_stock_assembly_inc.php index 54fbb6f..51b16b1 100755 --- a/includes/display_stock_assembly_inc.php +++ b/includes/display_stock_assembly_inc.php @@ -10,7 +10,7 @@ $displayHash = [ 'perm_name' => 'p_stock_view' ]; $gContent->invokeServices( 'content_display_function', $displayHash ); $listHash = $_REQUEST; -$listHash['max_records'] = $gContent->mInfo["images_per_page"] ?? $max_records; +$listHash['max_records'] = $max_records; $gContent->loadComponents( $listHash ); $gContent->loadParentAssemblies(); diff --git a/modules/mod_components.php b/modules/mod_components.php index 4115ed3..db923cd 100755 --- a/modules/mod_components.php +++ b/modules/mod_components.php @@ -17,10 +17,7 @@ $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_content_id'] = $gContent->mContentId; - $display = $displayCount >= $thumbCount; } if( $display ) { diff --git a/templates/admin_stock.tpl b/templates/admin_stock.tpl index cc68dff..b02ab7d 100755 --- a/templates/admin_stock.tpl +++ b/templates/admin_stock.tpl @@ -1,18 +1,3 @@ -{literal} -<script>//<![CDATA[ -function updateGalleryPagination() { - BitBase.hideById('fixed_grid-pagination'); - BitBase.hideById('auto_flow-pagination'); - BitBase.hideById('position_number-pagination'); - BitBase.hideById('simple_list-pagination'); - - var input = document.getElementById('gallery-pagination'); - var i = input.selectedIndex; - var select = input.options[i].value; - BitBase.showById(select+'-pagination'); -} -//]]></script> -{/literal} {strip} {form} @@ -84,29 +69,6 @@ function updateGalleryPagination() { </div> {/legend} - {legend legend="Default Assembly Display Settings"} - <div class="form-group"> - {formhelp note="The settings below determine what the default display options will be set to for new assemblies."} - </div> - - <div class="form-group"> - {html_options id="gallery-pagination" name="default_gallery_pagination" id="gallery-pagination" options=$galleryPaginationTypes selected=$gBitSystem->getConfig('default_gallery_pagination',$smarty.const.STOCK_PAGINATION_FIXED_GRID) onchange="updateGalleryPagination();"} - - <div id="fixed_grid-pagination"> - <input type="text" id="gallery-rows-per-page" name="rows_per_page" size="2" maxlength="2" value="{$gBitSystem->getConfig('stock_gallery_default_rows_per_page')}"/> {tr}Rows per page{/tr}<br/> - <input type="text" id="gallery-cols-per-page" name="cols_per_page" size="2" maxlength="2" value="{$gBitSystem->getConfig('stock_gallery_default_cols_per_page')}"/> {tr}Columns per page{/tr} - </div> - <div id="auto_flow-pagination"> - <input type="text" id="gallery-rows-per-page" name="total_per_page" size="2" maxlength="2" value="{$gBitSystem->getConfig('stock_gallery_default_rows_per_page')}"/> {tr}Total components per page{/tr} - </div> - <div id="position_number-pagination"> - {formhelp note="Components are ordered by package group and position within the package. Use the Component Order page to assign positions."} - </div> - <div id="simple_list-pagination"> - <input type="text" id="gallery-rows-per-page" name="lines_per_page" size="2" maxlength="2" value="{$gBitSystem->getConfig('stock_gallery_default_rows_per_page')}"/> {tr}Total lines per page{/tr} - </div> - </div> - {/legend} {/jstab} {jstab title="Components"} @@ -133,6 +95,3 @@ function updateGalleryPagination() { {/form} {/strip} -<script>//<![CDATA[ -updateGalleryPagination(); -//]]></script> diff --git a/templates/view_assembly.tpl b/templates/view_assembly.tpl index 07b7ff9..e3ebb94 100755 --- a/templates/view_assembly.tpl +++ b/templates/view_assembly.tpl @@ -1,7 +1,5 @@ -{assign var=galLayout value=$gContent->getLayout()} <div class="floaticon"> {if $gContent->hasUpdatePermission()} - {include file="bitpackage:liberty/services_inc.tpl" serviceLocation='icon' serviceHash=$gContent->mInfo} <a title="{tr}Edit{/tr}" href="{$smarty.const.STOCK_PKG_URL}edit_assembly.php?content_id={$gContent->mContentId}">{biticon ipackage="icons" iname="edit" iexplain="Edit Assembly"}</a> <a title="{tr}Component Order{/tr}" href="{$smarty.const.STOCK_PKG_URL}component_order.php?content_id={$gContent->mContentId}">{biticon ipackage="icons" iname="view-sort-ascending" iexplain="Component Order"}</a> {/if} @@ -12,7 +10,7 @@ <a title="{tr}Delete Assembly{/tr}" href="{$smarty.const.STOCK_PKG_URL}edit_assembly.php?content_id={$gContent->mContentId}&delete=1">{biticon ipackage="icons" iname="user-trash" iexplain="Delete Assembly"}</a> {/if} </div> -{include file="`$smarty.const.STOCK_PKG_PATH`assembly_views/`$galLayout`/stock_`$galLayout`_inc.tpl"} +{include file="bitpackage:stock/stock_simple_list_inc.tpl"} {if $gXrefInfo->mGroups} {jstabs} |
