[TikiWiki-commits] [Git][tikiwiki/tiki][master] [ENH] Add pagination support for wiki page attachments
"ushindi bienvenu \(@usbbush\) via TikiWiki-cvs" <[email protected]>
| Newsgroups | gmane.comp.cms.tiki.cvs |
|---|---|
| Message-ID | <6a74307034356_3819f3985709b@gitlab-sidekiq-low-urgency-cpu-bound-v2-566d4c6b4d-m82dn.mail> |
ushindi bienvenu pushed to branch master at Tiki Wiki CMS Groupware / Tiki
Commits:
dfdade16 by Moïse Nturubika at 2026-08-06T06:41:27+00:00
[ENH] Add pagination support for wiki page attachments
---
* [FIX][ENH] Fix Smarty syntax errors in file gallery template and add pagination to wiki page attachments
See merge request tikiwiki/tiki!10582
- - - - -
2 changed files:
- lib/smarty_tiki/FunctionHandler/Attachments.php
- templates/fgal_attachments.tpl
Changes:
=====================================
lib/smarty_tiki/FunctionHandler/Attachments.php
=====================================
@@ -64,11 +64,18 @@ class Attachments extends Base
// Get URL params specific to this smarty function that should be assigned in smarty
$url_override_prefix = 's_f_attachments';
- $url_overrided_arguments = [ 'sort_mode', 'remove', 'galleryId', 'comment', 'upload', 'page' ];
+ $url_overrided_arguments = [ 'sort_mode', 'remove', 'galleryId', 'comment', 'upload', 'page', 'offset', 'maxRecords' ];
$smarty->set_request_overriders($url_override_prefix, $url_overrided_arguments);
$params['sort_mode'] = $_REQUEST[$url_override_prefix . '-sort_mode'] ?? 'created_desc';
+ // Pagination: read offset and maxRecords from the request (prefixed)
+ $offset = max(0, (int)($_REQUEST[$url_override_prefix . '-offset'] ?? 0));
+ $maxRecords = (int)($_REQUEST[$url_override_prefix . '-maxRecords'] ?? $prefs['maxRecords']);
+ if ($maxRecords <= 0) {
+ $maxRecords = $prefs['maxRecords'];
+ }
+
// Force some gallery display parameters before fgal_listing_conf.php reads $gal_info
$gal_info['show_checked'] = 'n';
$gal_info['show_creator'] = 'y';
@@ -76,9 +83,9 @@ class Attachments extends Base
// Get listing display config
include_once('fgal_listing_conf.php');
- // Get list of files in the gallery
+ // Get list of files in the gallery (paginated)
if (! empty($galleryId)) {
- $files = $filegallib->get_files(0, -1, $params['sort_mode'], '', $galleryId);
+ $files = $filegallib->get_files($offset, $maxRecords, $params['sort_mode'], '', $galleryId);
} else {
$files = ['data' => [], 'count' => 0];
}
@@ -103,6 +110,8 @@ class Attachments extends Base
$params['gal_info'] = $gal_info;
$params['files'] = $files['data'];
$params['count'] = $files['count'];
+ $params['offset'] = $offset;
+ $params['maxRecords'] = $maxRecords;
$params['from_wiki_page'] = true;
$return = "\n" . $smarty->plugin_fetch('fgal_attachments.tpl', $params) . "\n";
=====================================
templates/fgal_attachments.tpl
=====================================
@@ -19,10 +19,20 @@
{* Generate table if view permissions granted and if count of attached files > 0 *}
{if ($tiki_p_wiki_view_attachments == 'y' || $tiki_p_wiki_admin_attachments == 'y') && count($files) > 0}
+ {if $count > $maxRecords}
+ <div class="clearboth mb-2">
+ {pagination_links count=$count step=$maxRecords offset=$offset offset_arg="s_f_attachments-offset"}{/pagination_links}
+ </div>
+ {/if}
<fieldset>
<legend>{tr}Attached files{/tr}</legend>
{include file='list_file_gallery_content.tpl'}
</fieldset>
+ {if $count > $maxRecords}
+ <div class="clearboth mt-2">
+ {pagination_links count=$count step=$maxRecords offset=$offset offset_arg="s_f_attachments-offset"}{/pagination_links}
+ </div>
+ {/if}
{/if}
{if ($tiki_p_wiki_attach_files eq 'y' or $tiki_p_wiki_admin_attachments eq 'y')
View it on GitLab: https://gitlab.com/tikiwiki/tiki/-/commit/dfdade16ff410008f2721d4e3f1c36fe16430bef
--
View it on GitLab: https://gitlab.com/tikiwiki/tiki/-/commit/dfdade16ff410008f2721d4e3f1c36fe16430bef
You're receiving this email because of your account on gitlab.com. Manage all notifications: https://gitlab.com/-/profile/notifications | Help: https://gitlab.com/help
_______________________________________________
TikiWiki-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/tikiwiki-cvs