[TikiWiki-commits] [Git][tikiwiki/tiki][master] [FIX] Plugin Zotero: improved zotero footnote display

Benoit Grégoire (@benoitg) via TikiWiki-cvs <[email protected]>
Newsgroups gmane.comp.cms.tiki.cvs
Message-ID <68e57216abd2c_2cdf5c058424@gitlab-sidekiq-low-urgency-cpu-bound-v2-75c5f57b9b-95xkg.mail>

Benoit Grégoire pushed to branch master at Tiki Wiki CMS Groupware / Tiki


Commits:
486176df by Espoir Baraka at 2025-10-07T19:55:30+00:00
[FIX] Plugin Zotero: improved zotero footnote display
---
* [FIX] Zotero: improve zotero footnote display

See merge request tikiwiki/tiki!8717

- - - - -


1 changed file:

- lib/wiki-plugins/wikiplugin_zotero.php


Changes:

=====================================
lib/wiki-plugins/wikiplugin_zotero.php
=====================================
@@ -76,8 +76,33 @@ function wikiplugin_zotero($data, $params)
         $cachelib->cacheItem($cacheKey, serialize($info), 'zotero');
     }
 
-    $content = $info['content'];
-    $content = str_replace('<div', '<span', $content);
-    $content = str_replace('</div>', '</span>', $content);
-    return "{FOOTNOTE()}~np~{$content} {$note}~/np~{FOOTNOTE}";
+    // Get the title from Zotero data
+    // Some Zotero entries don't have a direct 'title' field (e.g., notes or attachments)
+    // In these cases, extract the title from the content field to display something meaningful
+    $title = isset($info['title']) ? $info['title'] : '';
+
+    if (empty($title)) {
+        // Extract title from HTML content
+        // Replace block-level HTML tags with newlines to preserve structure
+        $content = $info['content'];
+        $content = preg_replace('/<\/(p|div|h[1-6]|li|tr|br)>/i', "\n", $content);
+
+        // Strip remaining HTML tags and decode entities
+        $textContent = strip_tags($content);
+        $textContent = html_entity_decode($textContent, ENT_QUOTES, 'UTF-8');
+        $textContent = trim($textContent);
+
+        // Use first non-empty line as title
+        $lines = array_filter(array_map('trim', explode("\n", $textContent)));
+        $title = ! empty($lines) ? reset($lines) : '';
+    }
+
+    // Combine title with note if provided
+    $footnoteContent = $title;
+    if (! empty($note)) {
+        $footnoteContent .= ' - ' . $note;
+    }
+
+    // Return the footnote with the title
+    return "{FOOTNOTE()}{$footnoteContent}{FOOTNOTE}";
 }



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

-- 
View it on GitLab: https://gitlab.com/tikiwiki/tiki/-/commit/486176df48964fb6f440ff7205758edbabae3a21
You're receiving this email because of your account on gitlab.com.

_______________________________________________
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.