style cleanup

This commit is contained in:
Andreas Gohr
2024-02-27 15:57:33 +01:00
parent 1eeb87d74f
commit 05f444a487
4 changed files with 16 additions and 14 deletions

View File

@@ -4,7 +4,6 @@ namespace dokuwiki\plugin\filelist;
class Crawler
{
/** @var string regexp to check extensions */
protected $ext;

View File

@@ -46,7 +46,7 @@ class Path
// this is an alias for the last read root
$line = trim(substr($line, 2));
if (!isset($paths[$lastRoot])) continue; // no last root, no alias
$alias = $this->cleanPath($line);
$alias = static::cleanPath($line);
$paths[$lastRoot]['alias'] = $alias;
$paths[$alias] = &$paths[$lastRoot]; // alias references the original
} elseif (str_starts_with($line, 'W>')) {
@@ -56,7 +56,7 @@ class Path
$paths[$lastRoot]['web'] = $line;
} else {
// this is a new path
$line = $this->cleanPath($line);
$line = static::cleanPath($line);
$lastRoot = $line;
$paths[$line] = [
'root' => $line,
@@ -78,13 +78,11 @@ class Path
*/
public function getPathInfo($path, $addTrailingSlash = true)
{
$path = $this->cleanPath($path, $addTrailingSlash);
$path = static::cleanPath($path, $addTrailingSlash);
$paths = $this->paths;
$allowed = array_keys($paths);
usort($allowed, function ($a, $b) {
return strlen($a) - strlen($b);
});
usort($allowed, static fn($a, $b) => strlen($a) - strlen($b));
$allowed = array_map('preg_quote_cb', $allowed);
$regex = '/^(' . implode('|', $allowed) . ')/';

View File

@@ -1,5 +1,7 @@
<?php
// phpcs:disable PSR1.Files.SideEffects.FoundWithSymbols
use dokuwiki\plugin\filelist\Path;
if (!defined('DOKU_INC')) define('DOKU_INC', __DIR__ . '/../../../');
@@ -37,4 +39,3 @@ try {
echo $e->getMessage();
exit;
}

View File

@@ -88,7 +88,7 @@ class syntax_plugin_filelist extends SyntaxPlugin
$path = Path::cleanPath($path, false);
$parts = explode('/', $path);
$pattern = array_pop($parts);
$base = join('/', $parts) . '/';
$base = implode('/', $parts) . '/';
return [$base, $pattern, $params];
}
@@ -121,7 +121,14 @@ class syntax_plugin_filelist extends SyntaxPlugin
$crawler = new Crawler($this->getConf('extensions'));
$crawler->setSortBy($params['sort']);
$crawler->setSortReverse($params['order'] === 'desc');
$result = $crawler->crawl($pathInfo['root'], $pathInfo['local'], $pattern, $params['recursive'], $params['titlefile']);
$result = $crawler->crawl(
$pathInfo['root'],
$pathInfo['local'],
$pattern,
$params['recursive'],
$params['titlefile']
);
// if we got nothing back, display a message
if ($result == []) {
@@ -139,10 +146,7 @@ class syntax_plugin_filelist extends SyntaxPlugin
case 'table':
$output->renderAsTable($params);
break;
}
return true;
}
}