Skip to content

Commit a80f32a

Browse files
committed
Metadata render fix
1 parent cdc8974 commit a80f32a

File tree

4 files changed

+30
-13
lines changed

4 files changed

+30
-13
lines changed

helper.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ class helper_plugin_struct extends DokuWiki_Plugin
3131
* All descendants are also blacklisted.
3232
*/
3333
public const BLACKLIST_RENDERER = [
34-
'Doku_Renderer_metadata',
3534
'\renderer_plugin_qc'
3635
];
3736

meta/SearchConfig.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,8 +113,9 @@ protected function applyFilterVars($filter)
113113
{
114114
global $INPUT;
115115
global $INFO;
116-
if (!isset($INFO['id'])) {
117-
$INFO['id'] = null;
116+
117+
if (is_null($INFO)) {
118+
$INFO = pageinfo();
118119
}
119120

120121
// apply inexpensive filters first

syntax/output.php

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
class syntax_plugin_struct_output extends DokuWiki_Syntax_Plugin
1515
{
16-
protected $hasBeenRendered = false;
16+
protected $hasBeenRendered = array('metadata'=>false, 'xhtml'=>false);
1717

1818
protected const XHTML_OPEN = '<div id="plugin__struct_output">';
1919
protected const XHTML_CLOSE = '</div>';
@@ -97,13 +97,25 @@ public function render($format, Doku_Renderer $renderer, $data)
9797
return true;
9898
}
9999
}
100-
if (!isset($INFO['id']) || ($ID != $INFO['id'])) return true;
101-
if (!$INFO['exists']) return true;
102-
if ($this->hasBeenRendered) return true;
100+
if (!isset($INFO) || $format == "metadata") {
101+
$pagename = pageinfo()['id'];
102+
} else {
103+
$pagename = $INFO['id'];
104+
}
105+
106+
if ($ID != $pagename) return true;
107+
if (!page_exists($pagename)) return true;
108+
if ($this->hasBeenRendered['metadata'] && $format == 'metadata') return true;
109+
if ($this->hasBeenRendered['xhtml'] && $format == 'xhtml') return true;
103110
if (!preg_match(self::WHITELIST_ACTIONS, act_clean($ACT))) return true;
104111

105112
// do not render the output twice on the same page, e.g. when another page has been included
106-
$this->hasBeenRendered = true;
113+
if ($format == 'metadata') {
114+
$this->hasBeenRendered['metadata'] = true;
115+
}
116+
else if ($format == 'xhtml') {
117+
$this->hasBeenRendered['xhtml'] = true;
118+
}
107119
try {
108120
$assignments = Assignments::getInstance();
109121
} catch (StructException $e) {

syntax/table.php

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -108,9 +108,14 @@ public function render($format, Doku_Renderer $renderer, $config)
108108
}
109109

110110
try {
111-
$search = $this->getSearchConfig($config);
112-
if ($format === 'struct_csv') {
113-
// no pagination in export
111+
if ($format === "metadata") {
112+
$search = $this->getSearchConfig($config, false);
113+
} else {
114+
$search = $this->getSearchConfig($config);
115+
}
116+
117+
if ($format === 'struct_csv' || $format === "metadata") {
118+
// no pagination in export or metadata render
114119
$search->setLimit(0);
115120
$search->setOffset(0);
116121
}
@@ -139,9 +144,9 @@ public function render($format, Doku_Renderer $renderer, $config)
139144
* @param array $config
140145
* @return SearchConfig
141146
*/
142-
protected function getSearchConfig($config)
147+
protected function getSearchConfig($config, $dymamic = true)
143148
{
144-
return new SearchConfig($config);
149+
return new SearchConfig($config, $dymamic);
145150
}
146151

147152

0 commit comments

Comments
 (0)