[TikiWiki-commits] [Git][tikiwiki/tiki][master] 2 commits: [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 <69b2c21ccb934_3b1cf9af89922@gitlab-sidekiq-low-urgency-cpu-bound-v2-6c8bd5d54b-zxfqv.mail>

Victor Emanouilov pushed to branch master at Tiki Wiki CMS Groupware / Tiki


Commits:
e2e0a9f3 by Victor Emanouilov at 2026-03-12T15:36:14+02:00
[FIX] tracker item history - status field diff changes in different styles

- - - - -
1498ab88 by Victor Emanouilov at 2026-03-12T15:39:32+02:00
[FIX] return simplified smarty assignment

- - - - -


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
=====================================
@@ -679,7 +679,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
=====================================
@@ -10,6 +10,7 @@ namespace SmartyTiki\FunctionHandler;
 use Smarty\FunctionHandler\Base;
 use Smarty\Template;
 use TikiLib;
+use Tiki\Lib\Diff\DiffUtils;
 
 /**
  * To display with difference between two blocks of text, often wiki syntax or html
@@ -31,7 +32,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 +76,31 @@ class WikiDiff extends Base
 
             $html = $smarty->fetch('pagehistory.tpl');
             return $html;
+        } else if ($params['object_type'] === 'direct') {
+            $diff = DiffUtils::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/-/compare/b3b65ac3bd9766d2a1a49e753f2b6e1b9e1c090b...1498ab88fbaa595b4095966151e076b80b0beb45

-- 
View it on GitLab: https://gitlab.com/tikiwiki/tiki/-/compare/b3b65ac3bd9766d2a1a49e753f2b6e1b9e1c090b...1498ab88fbaa595b4095966151e076b80b0beb45
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.