[TikiWiki-commits] [Git][tikiwiki/tiki][master] [ENH] Wiki Files Attachments: add view modes and pagination for file display
"Bruno Kambere \(@kambereBr\) via TikiWiki-cvs" <[email protected]>
| Newsgroups | gmane.comp.cms.tiki.cvs |
|---|---|
| Message-ID | <6a7b099db940a_3830e790c59262@gitlab-sidekiq-low-urgency-cpu-bound-v2-84dcc76b6c-s6rft.mail> |
Bruno Kambere pushed to branch master at Tiki Wiki CMS Groupware / Tiki
Commits:
64ca6343 by Alvin Bauma at 2026-08-11T14:21:37+03:00
[ENH] Wiki Files Attachments: add view modes and pagination for file display
---
* [ENH] Wiki Files Attachments: add view modes and pagination for file display
See merge request tikiwiki/tiki!10389
- - - - -
3 changed files:
- lib/smarty_tiki/FunctionHandler/Attachments.php
- templates/attachments.tpl
- templates/fgal_attachments.tpl
Changes:
=====================================
lib/smarty_tiki/FunctionHandler/Attachments.php
=====================================
@@ -64,28 +64,55 @@ 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', 'offset', 'maxRecords' ];
+ $url_overrided_arguments = [ 'sort_mode', 'view', 'offset', 'maxRecords', 'fileId', 'maxWidth', 'remove', 'galleryId', 'comment', 'upload', 'page' ];
$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'];
+ $params['view'] = $_REQUEST[$url_override_prefix . '-view'] ?? 'list';
+ if (! in_array($params['view'], ['browse', 'list', 'page'])) {
+ $params['view'] = 'list';
+ }
+ if (! isset($_REQUEST[$url_override_prefix . '-view']) && ! empty($_REQUEST[$url_override_prefix . '-fileId'])) {
+ $params['view'] = 'page';
+ }
+
+ // Pagination: read offset from the request (prefixed)
+ $params['offset'] = max(0, (int)($_REQUEST[$url_override_prefix . '-offset'] ?? 0));
+
+ if ($params['view'] === 'page') {
+ $params['maxRecords'] = 1;
+ } elseif ($params['view'] === 'browse') {
+ $params['maxRecords'] = -1;
+ } else {
+ $params['maxRecords'] = (int)($_REQUEST[$url_override_prefix . '-maxRecords'] ?? $prefs['maxRecords']);
+ if ($params['maxRecords'] <= 0) {
+ $params['maxRecords'] = $prefs['maxRecords'];
+ }
+ }
+
+ $params['maxWidth'] = (int)($_REQUEST[$url_override_prefix . '-maxWidth'] ?? 300);
+ if ($params['maxWidth'] <= 0) {
+ $params['maxWidth'] = 300;
}
+ $requestedFileId = (int)($_REQUEST[$url_override_prefix . '-fileId'] ?? 0);
+ $params['fileId'] = $requestedFileId > 0 ? $requestedFileId : 0;
+
// Force some gallery display parameters before fgal_listing_conf.php reads $gal_info
$gal_info['show_checked'] = 'n';
$gal_info['show_creator'] = 'y';
+ // Pre-set $view so fgal_listing_conf.php (which reads $_REQUEST['view'] otherwise) doesn't
+ // pick up an unrelated 'view' request param and overwrite it with something else.
+ $view = $params['view'];
+
// Get listing display config
include_once('fgal_listing_conf.php');
// Get list of files in the gallery (paginated)
if (! empty($galleryId)) {
- $files = $filegallib->get_files($offset, $maxRecords, $params['sort_mode'], '', $galleryId);
+ $files = $filegallib->get_files($params['offset'], $params['maxRecords'], $params['sort_mode'], '', $galleryId);
} else {
$files = ['data' => [], 'count' => 0];
}
@@ -110,9 +137,19 @@ 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;
+ $params['thumbnail_size'] = $prefs['fgal_thumb_max_size'];
+
+ if ($params['view'] === 'page') {
+ $params['file'] = $files['data'][0] ?? null;
+
+ if ($params['fileId'] > 0 && empty($params['file']) && ! empty($galleryId)) {
+ $singleFile = $filegallib->get_file_info($params['fileId']);
+ if (! empty($singleFile) && (int)$singleFile['galleryId'] === (int)$galleryId) {
+ $params['file'] = $singleFile;
+ }
+ }
+ }
$return = "\n" . $smarty->plugin_fetch('fgal_attachments.tpl', $params) . "\n";
=====================================
templates/attachments.tpl
=====================================
@@ -115,7 +115,7 @@
</div>
<div class="tiki-form-group row">
- <label class="col-sm-2 col-form-label" for="attach-comment">{tr}Comment{/tr}</label>
+ <label class="col-sm-2 col-form-label" for="attach-comment">{tr}Description{/tr}</label>
<div class="col-sm-8">
<input class="form-control" type="text" name="attach_comment" maxlength="250" id="attach-comment" placeholder="{tr}File upload comment{/tr}...">
</div>
=====================================
templates/fgal_attachments.tpl
=====================================
@@ -17,24 +17,6 @@
{/if}
>
- {* 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')
and (empty($attach_box) or $attach_box ne 'n')}
<div class="file-upload card bg-body-tertiary">
@@ -51,7 +33,7 @@
</div>
</div>
<div class="mb-3 row">
- <label class="col-sm-2 col-form-label" for="attach-comment">{tr}Comment{/tr}</label>
+ <label class="col-sm-2 col-form-label" for="attach-comment">{tr}Description{/tr}</label>
<div class="col-sm-8">
<input class="form-control" type="text" name="s_f_attachments-comment" maxlength="250" id="attach-comment" placeholder="{tr}File upload comment{/tr}...">
</div>
@@ -70,5 +52,78 @@
</div>
</div>
{/if}
+
+ {* 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}
+ <fieldset>
+ <div class="d-flex justify-content-between align-items-center mb-2">
+ <legend class="mb-0">{tr}Attached files{/tr}</legend>
+ <div class="btn-group">
+ <a class="btn btn-info btn-sm dropdown-toggle" data-bs-toggle="dropdown" href="#" title="{tr}Views mode{/tr}" role="button">
+ {tr}Views mode{/tr}
+ </a>
+ <ul class="dropdown-menu dropdown-menu-end">
+ {if $view neq 'browse'}
+ <li>
+ <a class="dropdown-item" href="{query _type='relative' view='browse' fileId='NULL' offset='NULL'}#attachments">{icon name="view"} {tr}Browse{/tr}</a>
+ </li>
+ {/if}
+ {if $view neq 'list'}
+ <li>
+ <a class="dropdown-item" href="{query _type='relative' view='list' fileId='NULL' offset='NULL'}#attachments">{icon name="list"} {tr}List{/tr}</a>
+ </li>
+ {/if}
+ {if $view neq 'page' and $count gt 0}
+ <li>
+ <a class="dropdown-item" href="{query _type='relative' view='page' offset='0'}#attachments">{icon name="textfile"} {tr}Page{/tr}</a>
+ </li>
+ {/if}
+ </ul>
+ </div>
+ </div>
+
+ {if $view eq 'page'}
+ <div class="pageview mb-3">
+ <form id="size-form-attachments" class="form d-flex flex-row flex-wrap align-items-end gap-1" action="">
+ {ticket}
+ <input type="hidden" name="s_f_attachments-view" value="page">
+ <input type="hidden" name="s_f_attachments-offset" value="{$offset}">
+ <input type="hidden" name="s_f_attachments-maxRecords" value="1">
+ <div class="row col-sm-4">
+ <label for="maxWidthAttachment" class="col-form-label">{tr}Maximum width{/tr}</label>
+ <div class="input-group col-sm-2">
+ <input id="maxWidthAttachment" class="form-control" type="number" name="s_f_attachments-maxWidth" value="{$maxWidth}">
+ <span class="input-group-text">{tr}pixels{/tr}</span>
+ </div>
+ </div>
+ <input type="submit" class="wikiaction btn btn-primary" name="setSize" value="{tr}Submit{/tr}">
+ </form>
+ </div>
+ {pagination_links count=$count step=$maxRecords offset=$offset offset_arg="s_f_attachments-offset"}
+ {query _type='relative' view='page' maxWidth=$maxWidth maxRecords=$maxRecords}
+ {/pagination_links}
+ <div class="mt-3">
+ {$show_infos='y'}
+ {include file='fgal_view_page.tpl'}
+ </div>
+ {elseif $view eq 'browse'}
+ {$show_infos='y'}
+ {include file='browse_file_gallery.tpl'}
+ {else}
+ {$show_infos='n'}
+ {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}
+ {include file='list_file_gallery_content.tpl'}
+ {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}
+ </fieldset>
+ {/if}
</div>
{/if}
View it on GitLab: https://gitlab.com/tikiwiki/tiki/-/commit/64ca63439b41954dab9ca5798c72334cf3a134c2
--
View it on GitLab: https://gitlab.com/tikiwiki/tiki/-/commit/64ca63439b41954dab9ca5798c72334cf3a134c2
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