Add maxheight for listings
Some checks failed
DokuWiki Default Tasks / all (push) Has been cancelled

This commit is contained in:
2026-01-06 09:14:40 +01:00
parent 490a483df1
commit 9664dbb256
3 changed files with 75 additions and 17 deletions

View File

@@ -27,15 +27,11 @@ class Output
public function renderAsList($params)
{
if ($this->renderer instanceof \Doku_Renderer_xhtml) {
$this->renderer->doc .= '<div class="filetools-plugin">';
}
$this->openContainer($params);
$this->renderListItems($this->files, $params);
if ($this->renderer instanceof \Doku_Renderer_xhtml) {
$this->renderer->doc .= '</div>';
}
$this->closeContainer();
}
/**
@@ -79,16 +75,12 @@ class Output
*/
public function renderAsTable($params)
{
if ($this->renderer instanceof \Doku_Renderer_xhtml) {
$this->renderer->doc .= '<div class="filetools-plugin">';
}
$this->openContainer($params);
$items = $this->flattenResultTree($this->files);
$this->renderTableItems($items, $params);
if ($this->renderer instanceof \Doku_Renderer_xhtml) {
$this->renderer->doc .= '</div>';
}
$this->closeContainer();
}
/**
@@ -99,15 +91,53 @@ class Output
*/
public function renderAsFlatTable($params)
{
if ($this->renderer instanceof \Doku_Renderer_xhtml) {
$this->renderer->doc .= '<div class="filetools-plugin">';
}
$this->openContainer($params);
$this->renderTableItems($this->files, $params);
if ($this->renderer instanceof \Doku_Renderer_xhtml) {
$this->renderer->doc .= '</div>';
$this->closeContainer();
}
/**
* Open the wrapping container with an optional max-height and scroll behaviour.
*/
protected function openContainer($params): void
{
if (!($this->renderer instanceof \Doku_Renderer_xhtml)) {
return;
}
$style = $this->containerStyle($params);
$this->renderer->doc .= '<div class="filetools-plugin"' . $style . '>';
}
/**
* Close the wrapping container if XHTML renderer is in use.
*/
protected function closeContainer(): void
{
if (!($this->renderer instanceof \Doku_Renderer_xhtml)) {
return;
}
$this->renderer->doc .= '</div>';
}
/**
* Build the inline style attribute for the container based on the maxheight param.
*/
protected function containerStyle($params): string
{
if (!isset($params['maxheight'])) {
return '';
}
$maxHeight = (int)$params['maxheight'];
if ($maxHeight < 0) {
return '';
}
return ' style="max-height: ' . $maxHeight . 'px; overflow-y: auto;"';
}