Add directory listing syntax
Some checks failed
DokuWiki Default Tasks / all (push) Has been cancelled
Some checks failed
DokuWiki Default Tasks / all (push) Has been cancelled
This commit is contained in:
84
Output.php
84
Output.php
@@ -91,6 +91,25 @@ class Output
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Render a flat list (files and/or directories) as a table.
|
||||
*
|
||||
* @param array $params
|
||||
* @return void
|
||||
*/
|
||||
public function renderAsFlatTable($params)
|
||||
{
|
||||
if ($this->renderer instanceof \Doku_Renderer_xhtml) {
|
||||
$this->renderer->doc .= '<div class="filetools-plugin">';
|
||||
}
|
||||
|
||||
$this->renderTableItems($this->files, $params);
|
||||
|
||||
if ($this->renderer instanceof \Doku_Renderer_xhtml) {
|
||||
$this->renderer->doc .= '</div>';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Renders the files as a table, including details if configured that way.
|
||||
@@ -147,7 +166,11 @@ class Output
|
||||
|
||||
if ($params['showsize']) {
|
||||
$renderer->tablecell_open(1, 'right');
|
||||
$renderer->cdata(filesize_h($item['size']));
|
||||
if (!empty($item['isdir'])) {
|
||||
$renderer->cdata('');
|
||||
} else {
|
||||
$renderer->cdata(filesize_h($item['size']));
|
||||
}
|
||||
$renderer->tablecell_close();
|
||||
}
|
||||
|
||||
@@ -217,6 +240,11 @@ class Output
|
||||
|
||||
protected function renderItemLink($item, $cachebuster = false)
|
||||
{
|
||||
if (!empty($item['isdir'])) {
|
||||
$this->renderDirectoryLink($item);
|
||||
return;
|
||||
}
|
||||
|
||||
if ($this->renderer instanceof \Doku_Renderer_xhtml) {
|
||||
$this->renderItemLinkXHTML($item, $cachebuster);
|
||||
} else {
|
||||
@@ -224,6 +252,60 @@ class Output
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Render a directory like a normal media link, but with open behaviour.
|
||||
*
|
||||
* @param array $item
|
||||
* @return void
|
||||
*/
|
||||
protected function renderDirectoryLink($item)
|
||||
{
|
||||
$caption = $item['name'] ?? '';
|
||||
$path = $item['path'] ?? '';
|
||||
|
||||
if ($caption === '') {
|
||||
$caption = '[n/a]';
|
||||
}
|
||||
|
||||
if (!($this->renderer instanceof \Doku_Renderer_xhtml)) {
|
||||
$this->renderer->cdata($caption);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!is_string($path) || $path === '') {
|
||||
$this->renderer->cdata('[n/a]');
|
||||
return;
|
||||
}
|
||||
|
||||
global $conf;
|
||||
/** @var \Doku_Renderer_xhtml $renderer */
|
||||
$renderer = $this->renderer;
|
||||
|
||||
$syntax = plugin_load('syntax', 'luxtools');
|
||||
$serviceUrl = $syntax ? trim((string)$syntax->getConf('open_service_url')) : '';
|
||||
$serviceToken = $syntax ? trim((string)$syntax->getConf('open_service_token')) : '';
|
||||
|
||||
// Prepare a DokuWiki-style media link with a folder icon class.
|
||||
$link = [
|
||||
'target' => $conf['target']['extern'],
|
||||
'style' => '',
|
||||
'pre' => '',
|
||||
'suf' => '',
|
||||
'name' => $caption,
|
||||
'url' => '#',
|
||||
'title' => $renderer->_xmlEntities($path),
|
||||
'more' => ' class="filetools-open media mediafile mf_folder" data-path="' . hsc($path) . '"',
|
||||
];
|
||||
if ($conf['relnofollow']) $link['more'] .= ' rel="nofollow"';
|
||||
if ($serviceUrl !== '') {
|
||||
$link['more'] .= ' data-service-url="' . hsc($serviceUrl) . '"';
|
||||
}
|
||||
if ($serviceToken !== '') {
|
||||
$link['more'] .= ' data-service-token="' . hsc($serviceToken) . '"';
|
||||
}
|
||||
$renderer->doc .= $renderer->_formatLink($link);
|
||||
}
|
||||
|
||||
/**
|
||||
* Render a file link on the XHTML renderer
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user