[TikiWiki-commits] [Git][tikiwiki/tiki][27.x] [BP][FIX] tracker URL field: restore wiki-link label rendering in URL-as-link mode

"Victor Emanouilov \(@kroky\) via TikiWiki-cvs" <[email protected]>
Newsgroups gmane.comp.cms.tiki.cvs
Message-ID <69c66a6e557ea_3b18f2a4197fb@gitlab-sidekiq-low-urgency-cpu-bound-v2-5495dc5557-2tnww.mail>

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


Commits:
5d77885d by Sammy Ndabo at 2026-03-27T11:22:20+00:00
[BP][FIX] tracker URL field: restore wiki-link label rendering in URL-as-link mode
---
* [FIX] tracker URL field: restore wiki-link label rendering in URL-as-link mode
---
* [FIX] tracker URL field: restore wiki-link label rendering in URL-as-link mode
---
* [FIX] Url.php: preserve wiki link labels in URL field output

* [DOC] Url.php: clarify normalization behavior for wiki link rendering

* [FIX] tracker URL field: restore wiki-link label rendering in URL-as-link mode

See merge request tikiwiki/tiki!9662

(cherry picked from commit 94f46ed309d3a97217149a5eed27529882177f6b)

See merge request tikiwiki/tiki!9738

(cherry picked from commit 709af66f82e79a73398eec561e488d7c25354c1b)

See merge request tikiwiki/tiki!9739

- - - - -


1 changed file:

- lib/core/Tracker/Field/Url.php


Changes:

=====================================
lib/core/Tracker/Field/Url.php
=====================================
@@ -84,8 +84,10 @@ class Tracker_Field_Url extends \Tracker\Field\AbstractItemField implements \Tra
     public function renderOutput($context = [])
     {
         $smarty = TikiLib::lib('smarty');
+        $rawValue = (string) $this->getConfiguration('value');
+        $parsedWikiLink = self::extractParsedWikiLinkData(trim($rawValue));
 
-        $url = self::normalizeStoredValueToUrl((string) $this->getConfiguration('value'));
+        $url = self::normalizeStoredValueToUrl($rawValue);
 
         if ($url === '' || ($context['list_mode'] ?? '') === 'csv' || $this->getOption('linkToURL') == 1) {
             return $url;
@@ -102,7 +104,7 @@ class Tracker_Field_Url extends \Tracker\Field\AbstractItemField implements \Tra
                 [
                     'type' => 'external',
                     'id' => $url,
-                    'title' => $url,
+                    'title' => $parsedWikiLink['label'] ?? $url,
                 ],
                 $smarty->getEmptyInternalTemplate()
             );
@@ -154,7 +156,7 @@ class Tracker_Field_Url extends \Tracker\Field\AbstractItemField implements \Tra
         }
 
         if (self::isWikiSyntaxLink($trimmed)) {
-            $resolvedHref = self::extractFirstHrefFromParsedWikiLink($trimmed);
+            $resolvedHref = self::extractParsedWikiLinkData($trimmed)['href'] ?? null;
             if ($resolvedHref === null) {
                 return tr('Invalid wiki syntax. The link target could not be resolved.');
             }
@@ -231,19 +233,26 @@ class Tracker_Field_Url extends \Tracker\Field\AbstractItemField implements \Tra
             return $value;
         }
 
-        $resolvedHref = self::extractFirstHrefFromParsedWikiLink($trimmed);
+        $resolvedHref = self::extractParsedWikiLinkData($trimmed)['href'] ?? null;
+        // Normalization keeps only the resolved target URL.
+        // The optional wiki-link label is extracted separately for rendering.
         return $resolvedHref ?? $value;
     }
 
-    protected static function extractFirstHrefFromParsedWikiLink(string $value): ?string
+    protected static function extractParsedWikiLinkData(string $value): ?array
     {
         $parsed = TikiLib::lib('parser')->parse_data_simple($value);
 
-        if (! preg_match('/<a\b[^>]*\bhref=(["\'])(.*?)\1/i', $parsed, $matches)) {
+        if (! preg_match('/<a\b[^>]*\bhref=(["\'])(.*?)\1[^>]*>(.*?)<\/a>/is', $parsed, $matches)) {
             return null;
         }
 
-        return html_entity_decode($matches[2], ENT_QUOTES, 'UTF-8');
+        $label = trim(html_entity_decode(strip_tags($matches[3]), ENT_QUOTES, 'UTF-8'));
+
+        return [
+            'href' => html_entity_decode($matches[2], ENT_QUOTES, 'UTF-8'),
+            'label' => $label !== '' ? $label : null,
+        ];
     }
 
     protected static function isSyntacticallyValidUrl(string $url): bool



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

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