summaryrefslogtreecommitdiff
path: root/list_kitlocker.php
diff options
context:
space:
mode:
authorLester Caine <lester@lsces.co.uk>2026-06-19 12:37:21 +0100
committerLester Caine <lester@lsces.co.uk>2026-06-19 12:37:21 +0100
commit343c10aeb88a84924a5fb4602dc1b20400d19d56 (patch)
tree6e5e3ed3cc4fc3276d2067a7f67e7f0f588e88cd /list_kitlocker.php
parent7a3bb89372385a235522cdd46a9ff0a9fe13080f (diff)
downloadstock-343c10aeb88a84924a5fb4602dc1b20400d19d56.tar.gz
stock-343c10aeb88a84924a5fb4602dc1b20400d19d56.tar.bz2
stock-343c10aeb88a84924a5fb4602dc1b20400d19d56.zip
Add pagination to list_kitlocker
20 per page via BitBase::postGetList; stgrp filter preserved across pages. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Diffstat (limited to 'list_kitlocker.php')
-rw-r--r--list_kitlocker.php32
1 files changed, 28 insertions, 4 deletions
diff --git a/list_kitlocker.php b/list_kitlocker.php
index 33a7697..05313ba 100644
--- a/list_kitlocker.php
+++ b/list_kitlocker.php
@@ -8,6 +8,7 @@ namespace Bitweaver\Stock;
use Bitweaver\KernelTools;
use Bitweaver\Liberty\LibertyContent;
+use Bitweaver\BitBase;
require_once '../kernel/includes/setup_inc.php';
@@ -35,7 +36,16 @@ if( $stgrp ) {
$groupTitle = null;
}
-$items = $gBitDb->getAll(
+$maxRecords = max( 1, (int)( $_REQUEST['max_records'] ?? 20 ) );
+$page = max( 1, (int)( $_REQUEST['page'] ?? 1 ) );
+$offset = ( $page - 1 ) * $maxRecords;
+
+$totalCount = (int)$gBitDb->getOne(
+ "SELECT COUNT(*) FROM `{$X}liberty_content` lc WHERE 1=1 $whereSql",
+ $bindVars
+);
+
+$rs = $gBitDb->query(
"SELECT lc.`content_id`, lc.`title`, lc.`data`, lc.`format_guid`, lc.`content_type_guid`,
(SELECT FIRST 1 x.`xkey` FROM `{$X}liberty_xref` x
WHERE x.`content_id` = lc.`content_id` AND x.`item` = 'KLID') AS klid,
@@ -44,18 +54,32 @@ $items = $gBitDb->getAll(
FROM `{$X}liberty_content` lc
WHERE 1=1 $whereSql
ORDER BY lc.`title`",
- $bindVars
+ $bindVars, $maxRecords, $offset
);
-foreach( $items as &$row ) {
+$items = [];
+while( $row = $rs->fetchRow() ) {
$parseHash = [ 'data' => $row['data'], 'format_guid' => $row['format_guid'] ?? 'bithtml' ];
$row['parsed_data'] = LibertyContent::parseDataHash( $parseHash );
+ $items[] = $row;
+}
+
+$listHash = [
+ 'cant' => $totalCount,
+ 'max_records' => $maxRecords,
+ 'offset' => $offset,
+ 'page' => $page,
+ 'page_records' => count( $items ),
+];
+if( $stgrp ) {
+ $listHash['listInfo']['parameters']['stgrp'] = $stgrp;
}
-unset( $row );
+BitBase::postGetList( $listHash );
$gBitSmarty->assign( 'kitlockerItems', $items );
$gBitSmarty->assign( 'stgrp', $stgrp );
$gBitSmarty->assign( 'groupTitle', $groupTitle );
+$gBitSmarty->assign( 'listInfo', $listHash['listInfo'] );
$pageTitle = $groupTitle ?: KernelTools::tra( 'Kitlocker' );
$gBitSystem->setBrowserTitle( $pageTitle );