[TikiWiki-commits] [Git][tikiwiki/tiki][30.x] [BP][FIX] Tracker: Item view title rendering when using certain field types as main field

"MAGENE Sem Joel \(@Jomagene\) via TikiWiki-cvs" <[email protected]>
Newsgroups gmane.comp.cms.tiki.cvs
Message-ID <6a3cf6542ea32_38198d68993ef@gitlab-sidekiq-low-urgency-cpu-bound-v2-d68649794-nhtd2.mail>

MAGENE Sem Joel pushed to branch 30.x at Tiki Wiki CMS Groupware / Tiki


Commits:
c3d23c39 by Landry Bitege at 2026-06-25T09:28:56+00:00
[BP][FIX] Tracker: Item view title rendering when using certain field types as main field
---
* [FIX] Tracker: Item view title rendering when using certain field types as main field
---
* [FIX] Tracker: Item view title rendering when using certain field types as main field

See merge request tikiwiki/tiki!9836

(cherry picked from commit d87ab249a3acd9ab559964ec227ef7bcadc74774)

See merge request tikiwiki/tiki!10596

- - - - -


12 changed files:

- lib/core/Tracker/Field/AbstractItemField.php
- lib/core/Tracker/Field/BarCode.php
- lib/core/Tracker/Field/Category.php
- lib/core/Tracker/Field/Checkbox.php
- lib/core/Tracker/Field/CountrySelector.php
- lib/core/Tracker/Field/Dropdown.php
- lib/core/Tracker/Field/EmailFolder.php
- lib/core/Tracker/Field/Files.php
- lib/core/Tracker/Field/Heading.php
- lib/core/Tracker/Field/Language.php
- lib/core/Tracker/Field/Wiki.php
- lib/trackers/trackerlib.php


Changes:

=====================================
lib/core/Tracker/Field/AbstractItemField.php
=====================================
@@ -714,4 +714,22 @@ abstract class AbstractItemField implements ItemFieldInterface, IndexableInterfa
         // Specific field types can override this behavior.
         return true;
     }
+
+    /**
+     * Return a plain text representation of the field value
+     * Intended for simple contexts like titles (isMain)
+     *
+     * @param array $context
+     * @return string
+     */
+    public function renderText($context = [])
+    {
+        $out = $this->renderInnerOutput($context);
+
+        if (is_array($out)) {
+            $out = implode(', ', $out);
+        }
+
+        return trim(strip_tags((string) $out));
+    }
 }


=====================================
lib/core/Tracker/Field/BarCode.php
=====================================
@@ -167,4 +167,17 @@ class Tracker_Field_BarCode extends Tracker_Field_Text
         }
         return true;
     }
+
+    /**
+    * Return a plain text representation of the barcode
+    *
+    * @param array $context
+    * @return string
+    */
+    public function renderText($context = [])
+    {
+        $data = $this->getValueAndFormat($this->getValue());
+
+        return isset($data['value']) ? (string) $data['value'] : '';
+    }
 }


=====================================
lib/core/Tracker/Field/Category.php
=====================================
@@ -348,6 +348,36 @@ class Tracker_Field_Category extends \Tracker\Field\AbstractItemField implements
         }
     }
 
+    /**
+     * Return plain text representation of selected categories
+     *
+     * @param array $context
+     * @return string
+     */
+    public function renderText($context = [])
+    {
+        $data = $this->getFieldData();
+        $selected_categories = $data['selected_categories'];
+        $categories = $data['list'];
+
+        if (! is_array($selected_categories)) {
+            $selected_categories = [];
+        }
+        if (! is_array($categories)) {
+            $categories = [];
+        }
+        $out = [];
+        foreach ($categories as $category) {
+            foreach ($selected_categories as $categId) {
+                if ($category['categId'] == $categId) {
+                    $out[] = $category['name'];
+                }
+            }
+        }
+
+        return implode(', ', $out);
+    }
+
     public function handleSave($value, $oldValue)
     {
         if (is_array($value) && isset($value['incremental'])) {


=====================================
lib/core/Tracker/Field/Checkbox.php
=====================================
@@ -94,6 +94,26 @@ class Tracker_Field_Checkbox extends \Tracker\Field\AbstractItemField implements
         }
     }
 
+    /**
+     * Return plain text representation of checkbox
+     *
+     * @param array $context
+     * @return string
+     */
+    public function renderText($context = [])
+    {
+        $fieldData = $this->getFieldData();
+        $value = $fieldData['value'] ?? '';
+
+        if ($value === 'y') {
+            return tra('Yes');
+        } elseif ($value === 'n') {
+            return tra('No');
+        } else {
+            return $value;
+        }
+    }
+
     public function getDocumentPart(Search_Type_Factory_Interface $typeFactory)
     {
         $baseKey = $this->getBaseKey();


=====================================
lib/core/Tracker/Field/CountrySelector.php
=====================================
@@ -186,13 +186,14 @@ class Tracker_Field_CountrySelector extends \Tracker\Field\AbstractItemField imp
         }
 
         foreach ($current as $index => $value) {
-            $label = $flags[$value];
+            $label = $flags[$value] ?? '';
+
             if ($context['list_mode'] != 'csv') {
                 if ($this->getOption('name_flag') != 1) {
                     $out .= $this->renderImage($value, $label);
                 }
                 if ($this->getOption('name_flag') == 0) {
-                    $out .= ' ';
+                    $out .= ' ';
                 }
             }
             $out .= $label;
@@ -204,6 +205,23 @@ class Tracker_Field_CountrySelector extends \Tracker\Field\AbstractItemField imp
         return $out;
     }
 
+    /**
+     * Return plain text representation of selected countries
+     *
+     * @param array $context
+     * @return string
+     */
+    public function renderText($context = [])
+    {
+        $current = $this->getConfiguration('value');
+
+        if (empty($current)) {
+            return '';
+        }
+
+        return $current;
+    }
+
     private function renderImage($code, $label)
     {
         $smarty = TikiLib::lib('smarty');


=====================================
lib/core/Tracker/Field/Dropdown.php
=====================================
@@ -214,6 +214,29 @@ class Tracker_Field_Dropdown extends \Tracker\Field\AbstractItemField implements
         }
     }
 
+        /**
+     * Return plain text representation of selected option(s)
+     *
+     * @param array $context
+     * @return string
+     */
+    public function renderText($context = [])
+    {
+        $data = $this->getFieldData();
+        $selected = $data['selected'];
+
+        if (! is_array($selected)) {
+            $selected = [];
+        }
+
+        if (! empty($context['list_mode']) && $context['list_mode'] === 'csv') {
+            return implode(', ', $selected);
+        } else {
+            $labels = array_map([$this, 'getValueLabel'], $selected);
+            return implode(', ', $labels);
+        }
+    }
+
     private function getValueLabel($value)
     {
         $possibilities = $this->getPossibleItemValues();


=====================================
lib/core/Tracker/Field/EmailFolder.php
=====================================
@@ -324,6 +324,28 @@ class Tracker_Field_EmailFolder extends Tracker_Field_Files implements \Tracker\
         ]);
     }
 
+    /**
+     * Return a plain text
+     * Intended for simple contexts like titles (isMain)
+     *
+     * @param array $context
+     * @return string
+     */
+    public function renderText($context = [])
+    {
+        $emails = $this->getConfiguration('emails');
+        $output = "";
+        foreach ($this->getFolders() as $folder => $folderName) {
+            if (! empty($emails[$folder])) {
+                $output .= $folderName . ":\n";
+                foreach ($emails[$folder] as $email) {
+                    $output .= "- " . $email['subject'] . "\n";
+                }
+            }
+        }
+        return $output;
+    }
+
     public function handleSave($value, $oldValue)
     {
         $existing = json_decode($oldValue, true);


=====================================
lib/core/Tracker/Field/Files.php
=====================================
@@ -453,7 +453,6 @@ class Tracker_Field_Files extends \Tracker\Field\AbstractItemField implements \T
         global $mimetypes;
         global $tikipath;
 
-
         include('lib/mime/mimetypes.php');
         $galleryId = (int)$this->getOption('galleryId');
 
@@ -663,6 +662,25 @@ class Tracker_Field_Files extends \Tracker\Field\AbstractItemField implements \T
         return $ret;
     }
 
+    /**
+     * Render the field as plain text
+     *
+     * @param array $context
+     * @return string
+     */
+    public function renderText($context = [])
+    {
+        $value = $this->getValue();
+        if (empty($value)) {
+            return '';
+        }
+        $fileIds = array_filter(explode(',', $value));
+        $fileInfo = $this->getFileInfo($fileIds);
+        return implode(', ', array_map(function ($file) {
+            return $file['name'];
+        }, $fileInfo));
+    }
+
     private function isMimeType(array $mimes, string $fileType, array $extensions): bool
     {
         foreach ($extensions as $ext) {


=====================================
lib/core/Tracker/Field/Heading.php
=====================================
@@ -63,7 +63,7 @@ class Tracker_Field_Heading extends \Tracker\Field\AbstractItemField implements
     public function renderOutput($context = [])
     {
         if (isset($context['list_mode']) && $context['list_mode'] === 'csv') {
-            return;
+            return "";
         }
         global $prefs;
         $headerlib = TikiLib::lib('header');
@@ -134,6 +134,11 @@ class Tracker_Field_Heading extends \Tracker\Field\AbstractItemField implements
         return $html;
     }
 
+    public function renderText($context = [])
+    {
+        return tra($this->getConfiguration('name'));
+    }
+
     public function importRemote($value)
     {
         return '';


=====================================
lib/core/Tracker/Field/Language.php
=====================================
@@ -79,6 +79,13 @@ class Tracker_Field_Language extends \Tracker\Field\AbstractItemField implements
         );
     }
 
+    public function renderText($context = [])
+    {
+        $selected = $this->getConfiguration('value');
+        $languages = $this->getLanguages();
+        return $languages[$selected] ?? tr('None');
+    }
+
     public function handleSave($value, $oldValue)
     {
         return [


=====================================
lib/core/Tracker/Field/Wiki.php
=====================================
@@ -374,6 +374,17 @@ class Tracker_Field_Wiki extends Tracker_Field_Text implements \Tracker\Field\Ex
         return $this->attemptParse($this->getConfiguration('page_data'));
     }
 
+    /**
+     * Render the field value as plain text.
+     * @param mixed $context
+     * @return string
+     */
+    public function renderText($context = [])
+    {
+        $data = $this->getFieldData();
+        return $this->attemptParse($data['page_data']);
+    }
+
     public function getDocumentPart(Search_Type_Factory_Interface $typeFactory)
     {
         $data = [];


=====================================
lib/trackers/trackerlib.php
=====================================
@@ -4194,11 +4194,10 @@ class TrackerLib extends TikiLib
             $handler = $this->get_field_handler($field, $item);
 
             if ($handler) {
-                $field_ins = $handler->getFieldData();
-                $value_ins = $handler->renderOutput(['list_mode' => 'y', 'isMain_context' => true]);
-                if (is_array($value_ins)) {
-                    $value = array_merge($value_ins, $field_ins);
-                }
+                $value = $handler->renderText([
+                    'list_mode' => 'y',
+                    'isMain_context' => true
+                ]);
             }
 
             if (! empty($value)) {



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

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