[TikiWiki-commits] [Git][tikiwiki/tiki][27.x] [FIX] return simplified smarty assignment

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

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


Commits:
e326591c by Victor Emanouilov at 2026-03-12T15:40:15+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
             case 'vimeo_uploader':
                 $this->functionHandlers[$functionName] = new \SmartyTiki\FunctionHandler\VimeoUploader();
                 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}
                     {assign var='fieldId' value=$hist.fieldId}
                     {assign var='field_value' 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 -1}_{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/e326591cf46dd0934def5cbeaa2ec2ec3be2938b

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