[TikiWiki-commits] [Git][tikiwiki/tiki][master] [FIX][ENH] Wiki page history: fix prev/next navigation and clean up version action links

"luci \(@luciash\) via TikiWiki-cvs" <[email protected]>
Newsgroups gmane.comp.cms.tiki.cvs
Message-ID <6a7447de45f9_3819f41040379@gitlab-sidekiq-low-urgency-cpu-bound-v2-687bc4475-wlztr.mail>

luci pushed to branch master at Tiki Wiki CMS Groupware / Tiki


Commits:
fd8e2700 by Landry Bitege at 2026-08-06T08:21:23+00:00
[FIX][ENH] Wiki page history: fix prev/next navigation and clean up version action links
---
* [FIX][ENH] Wiki page history: fix prev/next navigation and clean up version action links

See merge request tikiwiki/tiki!10725

- - - - -


4 changed files:

- lib/smarty_tiki/BlockHandler/PaginationLinks.php
- templates/pagehistory.tpl
- templates/tiki-pagehistory.tpl
- tiki-pagehistory.php


Changes:

=====================================
lib/smarty_tiki/BlockHandler/PaginationLinks.php
=====================================
@@ -36,6 +36,8 @@ use Smarty\Template;
  *      (dots are not replaced by links, it's just a separation text):
  *      1 2 3 ... k-2 k-1 k k+1 k+2 ...  n-2 n-1 n
  *  - offset_arg: Name of the URL argument that contains the offset. Defaults to 'offset'.
+ *  - offset_min: Lowest reachable offset. The "previous" link is disabled (and clamped) at this offset. Defaults to 0.
+ *      Useful when the offset is 1-based (e.g. comparing adjacent versions where offset 0 is invalid).
  *    - zero_based_offset: Items addressed as zero-based (defaults to 'y'). If 'n' then "one based" offset used (1 to count + 1)
  *        (jb tiki5: only fully tested without reloffset and step=1)
  *    - show_numbers: Show/hide direct_pagination links, current and total numbers (Defaults to 'y')
@@ -77,6 +79,9 @@ class PaginationLinks extends Base
         if (! isset($params['offset_arg'])) {
             $params['offset_arg'] = 'offset';
         }
+        if (! isset($params['offset_min'])) {
+            $params['offset_min'] = 0;
+        }
         if (! isset($params['zero_based_offset'])) {
             $params['zero_based_offset'] = 'y';
         }
@@ -186,7 +191,7 @@ class PaginationLinks extends Base
             )) . '&amp;' . $params['offset_arg'] . '=' . $params['offset'];
             $real_offset = $params['offset'] + $params['reloff'];
         } else {
-            $prev_offset_val = max($zero_based_min, $params['offset'] - $params['step']);
+            $prev_offset_val = max($zero_based_min, $params['offset_min'], $params['offset'] - $params['step']);
             $prev_offset = $params['offset_arg'] . '=' . $prev_offset_val;
             $next_offset_val = min($params['count'] - $zero_based_maxminus, $params['offset'] + $params['step']);
             $next_offset = $params['offset_arg'] . '=' . $next_offset_val;
@@ -250,7 +255,7 @@ class PaginationLinks extends Base
                 $html .= '<ul class="pagination justify-content-center">';
 
                 if ($prefs['nextprev_pagination'] != 'n' || $params['show_numbers'] !== 'y') {
-                    if ($params['offset'] == 0) {
+                    if ($params['offset'] <= $params['offset_min']) {
                         $html .= '<li class="page-item disabled"><span class="page-link">' .
                             ($params['noimg'] ? tr('Previous') : '«') . '</span></li>';
                     } else {


=====================================
templates/pagehistory.tpl
=====================================
@@ -3,7 +3,7 @@
         <h2>{tr _0=$old.version _1=$new.version}Comparing version %0 with version %1{/tr}</h2>
     {/if}
     {if $curver.version|default:null ne $preview && $object_curver eq 'y'}
-        {self_link _script="tiki-pagehistory.php" page=$page preview=$curver.version|escape:'url' _title="{tr}Go to current version{/tr}"}{tr}Go to current version{/tr}{/self_link}
+        {self_link _noauto="y" _script="tiki-pagehistory.php" page=$page preview=$curver.version|escape:'url' _title="{tr}Preview current version{/tr}"}{tr}Preview current version{/tr}{/self_link}
     {/if}
     <div class="table-responsive">
         <table class="table diff">
@@ -41,9 +41,9 @@
                 {if $smarty.request.oldver_idx + 1 eq $smarty.request.newver_idx or $smarty.request.oldver_idx eq $smarty.request.newver_idx}
                     <td colspan="4">
                         {if isset($show_all_versions) and $show_all_versions eq "n"}
-                            {pagination_links count=$ver_count offset=$smarty.request.bothver_idx offset_arg="bothver_idx" itemname="{tr}Session{/tr}" show_numbers="n"}{/pagination_links}
+                            {pagination_links count=$ver_count offset=$smarty.request.bothver_idx offset_arg="bothver_idx" offset_min="1" itemname="{tr}Session{/tr}" show_numbers="n"}{/pagination_links}
                         {else}
-                            {pagination_links count=$ver_count offset=$smarty.request.bothver_idx offset_arg="bothver_idx" itemname="{tr}Version{/tr}" show_numbers="n"}{/pagination_links}
+                            {pagination_links count=$ver_count offset=$smarty.request.bothver_idx offset_arg="bothver_idx" offset_min="1" itemname="{tr}Version{/tr}" show_numbers="n"}{/pagination_links}
                         {/if}
                     </td>
                 {else}


=====================================
templates/tiki-pagehistory.tpl
=====================================
@@ -317,13 +317,13 @@
                                 {actions}
                                     {strip}
                                         <action>
-                                            {self_link page=$page preview=$info.version _icon_name="view" _menu_text='y' _menu_icon='y'}
+                                            {self_link _noauto="y" page=$page preview=$info.version _icon_name="view" _menu_text='y' _menu_icon='y'}
                                                 {tr}View{/tr}
                                             {/self_link}
                                         </action>
                                         {if $tiki_p_wiki_view_source eq "y" and $prefs.feature_source eq "y"}
                                             <action>
-                                                {self_link page=$page source=$info.version _icon_name="code" _menu_text='y' _menu_icon='y'}
+                                                {self_link _noauto="y" page=$page source=$info.version _icon_name="code" _menu_text='y' _menu_icon='y'}
                                                     {tr}Source{/tr}
                                                 {/self_link}
                                             </action>
@@ -412,32 +412,32 @@
                                 {actions}
                                     {strip}
                                         <action>
-                                            {self_link page=$page preview=$element.version _icon_name="view" _menu_text='y' _menu_icon='y'}
+                                            {self_link _noauto="y" page=$page preview=$element.version _icon_name="view" _menu_text='y' _menu_icon='y'}
                                                 {tr}View{/tr}
                                             {/self_link}
                                         </action>
                                         {if $tiki_p_wiki_view_source eq "y" and $prefs.feature_source eq "y"}
                                             <action>
-                                                {self_link page=$page source=$element.version _icon_name="code" _menu_text='y' _menu_icon='y'}
+                                                {self_link _noauto="y" page=$page source=$element.version _icon_name="code" _menu_text='y' _menu_icon='y'}
                                                     {tr}Source{/tr}
                                                 {/self_link}
                                             </action>
                                         {/if}
                                         {if $prefs.default_wiki_diff_style eq "old"}
                                             <action>
-                                                {self_link page=$page diff2=$element.version diff_style="sideview" _icon_name="copy" _menu_text='y' _menu_icon='y'}
+                                                {self_link _noauto="y" page=$page diff2=$element.version diff_style="sideview" _icon_name="copy" _menu_text='y' _menu_icon='y'}
                                                     {tr}Compare{/tr}
                                                 {/self_link}
                                             </action>
                                             <action>
-                                                {self_link page=$page diff2=$element.version diff_style="unidiff" _icon_name="difference" _menu_text='y' _menu_icon='y'}
+                                                {self_link _noauto="y" page=$page diff2=$element.version diff_style="unidiff" _icon_name="difference" _menu_text='y' _menu_icon='y'}
                                                     {tr}Difference{/tr}
                                                 {/self_link}
                                             </action>
                                         {/if}
                                         {if $tiki_p_rollback eq 'y' && $lock neq true && $current neq $element.version}
                                             <action>
-                                                {self_link _script="tiki-rollback.php" page=$page version=$element.version _icon_name="undo" _menu_text='y' _menu_icon='y'}
+                                                {self_link _noauto="y" _script="tiki-rollback.php" page=$page version=$element.version _icon_name="undo" _menu_text='y' _menu_icon='y'}
                                                     {tr _0=$element.version}Revert to version %0{/tr}
                                                 {/self_link}
                                             </action>


=====================================
tiki-pagehistory.php
=====================================
@@ -237,8 +237,10 @@ foreach ($history as &$h) { // as $h has been used by reference before it needs
 }
 $history_versions = array_reverse($history_versions);
 $history_sessions = array_reverse($history_sessions);
-$history_versions[] = (int) $info['version'];   // current is last one
-$history_sessions[] = 0;
+if (empty($history_versions) || end($history_versions) !== (int) $info['version']) {
+    $history_versions[] = (int) $info['version'];   // current is last one (only if not already in history)
+    $history_sessions[] = 0;
+}
 $smarty->assign_by_ref('history', $history);
 
 // for pagination



View it on GitLab: https://gitlab.com/tikiwiki/tiki/-/commit/fd8e270004dfd0e0c782779d24824d2395c7b4c9

-- 
View it on GitLab: https://gitlab.com/tikiwiki/tiki/-/commit/fd8e270004dfd0e0c782779d24824d2395c7b4c9
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
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.