[TikiWiki-commits] [Git][tikiwiki/tiki][29.x] [FIX] tracker item history - status field diff changes in different styles

"Victor Emanouilov \(@kroky\) via TikiWiki-cvs" <[email protected]>
Newsgroups gmane.comp.cms.tiki.cvs
Message-ID <69b2c1d162e4b_3b18a0b0788c3@gitlab-sidekiq-low-urgency-cpu-bound-v2-6c8bd5d54b-5vnq8.mail>

Victor Emanouilov pushed to branch 29.x at Tiki Wiki CMS Groupware / Tiki


Commits:
1878a38e by Victor Emanouilov at 2026-03-12T15:38:11+02:00
[FIX] tracker item history - status field diff changes in different styles

- - - - -


3 changed files:

- lib/smarty_tiki/Extension/SmartyTikiExtension.php
- lib/smarty_tiki/FunctionHandler/WikiDiff.php
- templates/tracker/item_history.tpl


Changes:

=====================================
lib/smarty_tiki/Extension/SmartyTikiExtension.php
=====================================
@@ -673,7 +673,7 @@ class SmartyTikiExtension extends \Smarty\Extension\Base
                 $this->functionHandlers[$functionName] = new \SmartyTiki\FunctionHandler\VarDump();
                 break;
                 break;
-            case 'wiki_diff':
+            case 'wikidiff':
                 $this->functionHandlers[$functionName] = new \SmartyTiki\FunctionHandler\WikiDiff();
                 break;
             case 'wikistructure':


=====================================
lib/smarty_tiki/FunctionHandler/WikiDiff.php
=====================================
@@ -31,7 +31,7 @@ class WikiDiff extends Base
 
         $params = array_merge($defaults, $params);
 
-        if (! $params['object_id']) {
+        if ($params['object_type'] === 'wiki page' && ! $params['object_id']) {
             return '<span class="text-danger">' . tra('wikidiff: error - no object_id specified') . '</span>';
         }
 
@@ -75,6 +75,32 @@ class WikiDiff extends Base
 
             $html = $smarty->fetch('pagehistory.tpl');
             return $html;
+        } else if ($params['object_type'] === 'direct') {
+            require_once('lib/Diff/difflib.php');
+            $diff = diff2($params['oldver'], $params['newver'], $params['diff_style']);
+            $result = '';
+
+            if (is_array($diff)) {
+                // unidiff mode
+                foreach ($diff as $part) {
+                    if ($part["type"] == "diffdeleted") {
+                        foreach ($part["data"] as $chunk) {
+                            $result .= "<blockquote>- $chunk</blockquote>";
+                        }
+                    }
+                    if ($part["type"] == "diffadded") {
+                        foreach ($part["data"] as $chunk) {
+                            $result .= "<blockquote>+ $chunk</blockquote>";
+                        }
+                    }
+                }
+            } else {
+                $result = strpos($diff, '<tr') === 0 ? '<table>' . $diff . '</table>' : $diff;
+                $result = preg_replace('/<tr class="diffheader">.*?<\/tr>/', '', $result);
+                $result = str_replace('<table>', '<table class="table">', $result);
+            }
+
+            return $result;
         } else {
             // TODO for other types, e.g. tracker items
 


=====================================
templates/tracker/item_history.tpl
=====================================
@@ -77,7 +77,7 @@
                 {if $hist.value neq $hist.new or $hist.version == 0}
                     {$fieldId=$hist.fieldId}
                     {$field_value=$field_option[$fieldId]}
-                    {if is_array($field_value) and ($field_value.visibleInHistoryMode eq 'y' or $hist.version == 0)}
+                    {if is_array($field_value) and ($field_value.visibleInHistoryMode eq 'y' or $hist.version == 0 or $hist.fieldId == -1)}
                         <tr>
                             <td class="id"><strong>{$hist.version|escape}</strong></td>
                             <td class="date"><strong>{if not empty($hist.lastModif)}{$hist.lastModif|tiki_short_datetime}{/if}</strong></td>
@@ -89,7 +89,7 @@
                                 {if $fieldId eq HISTLIB_INVALID_FIELDID_THAT_MEANS_TRACKER_ITEM_STATUS_CHANGE}_{tr}Status{/tr}_{else}{$field_option[$fieldId].name}{/if}
                             </td>
                             {if empty($diff_style)}
-                                {if !empty($field_value.fieldId)}
+                                {if !empty($field_value.fieldId) && $field_value.fieldId > 0}
                                     <td class="text">{$field_value.value=$hist.value}{trackeroutput field=$field_value list_mode=csv item=$item_info history=y process=y}</td>
                                     <td class="text">{$field_value.value=$hist.new}{trackeroutput field=$field_value list_mode=csv item=$item_info history=y process=y}</td>
                                 {else}
@@ -98,8 +98,12 @@
                                 {/if}
                             {else}
                                 <td colspan="2" class="tracker-diff {$diff_style}">
-                                    {$field_value.value=$hist.new}
-                                    {trackeroutput field=$field_value list_mode='y' history=y item=$item_info process=y oldValue=$hist.value diff_style=$diff_style}
+                                    {if !empty($field_value.fieldId) && $field_value.fieldId > 0}
+                                        {$field_value.value=$hist.new}
+                                        {trackeroutput field=$field_value list_mode='y' history=y item=$item_info process=y oldValue=$hist.value diff_style=$diff_style}
+                                    {else}
+                                        {wikidiff object_type=direct oldver=$hist.value newver=$hist.new diff_style=$diff_style}
+                                    {/if}
                                 </td>
                             {/if}
                         </tr>



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

-- 
View it on GitLab: https://gitlab.com/tikiwiki/tiki/-/commit/1878a38e8378c2a69780d34d53ec70fa29806649
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.