From a80f32ab9d9d73bfe96990420c84443c781479e5 Mon Sep 17 00:00:00 2001
From: alexdraconian <78018187+alexdraconian@users.noreply.github.com>
Date: Mon, 7 Aug 2023 21:39:35 +0900
Subject: [PATCH] Metadata render fix
---
helper.php | 1 -
meta/SearchConfig.php | 5 +++--
syntax/output.php | 22 +++++++++++++++++-----
syntax/table.php | 15 ++++++++++-----
4 files changed, 30 insertions(+), 13 deletions(-)
diff --git a/helper.php b/helper.php
index 3cb91c68..48a7168a 100644
--- a/helper.php
+++ b/helper.php
@@ -31,7 +31,6 @@ class helper_plugin_struct extends DokuWiki_Plugin
* All descendants are also blacklisted.
*/
public const BLACKLIST_RENDERER = [
- 'Doku_Renderer_metadata',
'\renderer_plugin_qc'
];
diff --git a/meta/SearchConfig.php b/meta/SearchConfig.php
index 938d843d..4a53e331 100644
--- a/meta/SearchConfig.php
+++ b/meta/SearchConfig.php
@@ -113,8 +113,9 @@ protected function applyFilterVars($filter)
{
global $INPUT;
global $INFO;
- if (!isset($INFO['id'])) {
- $INFO['id'] = null;
+
+ if (is_null($INFO)) {
+ $INFO = pageinfo();
}
// apply inexpensive filters first
diff --git a/syntax/output.php b/syntax/output.php
index 58a10dee..26d7c9de 100644
--- a/syntax/output.php
+++ b/syntax/output.php
@@ -13,7 +13,7 @@
class syntax_plugin_struct_output extends DokuWiki_Syntax_Plugin
{
- protected $hasBeenRendered = false;
+ protected $hasBeenRendered = array('metadata'=>false, 'xhtml'=>false);
protected const XHTML_OPEN = '
';
protected const XHTML_CLOSE = '
';
@@ -97,13 +97,25 @@ public function render($format, Doku_Renderer $renderer, $data)
return true;
}
}
- if (!isset($INFO['id']) || ($ID != $INFO['id'])) return true;
- if (!$INFO['exists']) return true;
- if ($this->hasBeenRendered) return true;
+ if (!isset($INFO) || $format == "metadata") {
+ $pagename = pageinfo()['id'];
+ } else {
+ $pagename = $INFO['id'];
+ }
+
+ if ($ID != $pagename) return true;
+ if (!page_exists($pagename)) return true;
+ if ($this->hasBeenRendered['metadata'] && $format == 'metadata') return true;
+ if ($this->hasBeenRendered['xhtml'] && $format == 'xhtml') return true;
if (!preg_match(self::WHITELIST_ACTIONS, act_clean($ACT))) return true;
// do not render the output twice on the same page, e.g. when another page has been included
- $this->hasBeenRendered = true;
+ if ($format == 'metadata') {
+ $this->hasBeenRendered['metadata'] = true;
+ }
+ else if ($format == 'xhtml') {
+ $this->hasBeenRendered['xhtml'] = true;
+ }
try {
$assignments = Assignments::getInstance();
} catch (StructException $e) {
diff --git a/syntax/table.php b/syntax/table.php
index 36306be0..ef4768ea 100644
--- a/syntax/table.php
+++ b/syntax/table.php
@@ -108,9 +108,14 @@ public function render($format, Doku_Renderer $renderer, $config)
}
try {
- $search = $this->getSearchConfig($config);
- if ($format === 'struct_csv') {
- // no pagination in export
+ if ($format === "metadata") {
+ $search = $this->getSearchConfig($config, false);
+ } else {
+ $search = $this->getSearchConfig($config);
+ }
+
+ if ($format === 'struct_csv' || $format === "metadata") {
+ // no pagination in export or metadata render
$search->setLimit(0);
$search->setOffset(0);
}
@@ -139,9 +144,9 @@ public function render($format, Doku_Renderer $renderer, $config)
* @param array $config
* @return SearchConfig
*/
- protected function getSearchConfig($config)
+ protected function getSearchConfig($config, $dymamic = true)
{
- return new SearchConfig($config);
+ return new SearchConfig($config, $dymamic);
}