style cleanup
This commit is contained in:
@@ -4,7 +4,6 @@ namespace dokuwiki\plugin\filelist;
|
|||||||
|
|
||||||
class Crawler
|
class Crawler
|
||||||
{
|
{
|
||||||
|
|
||||||
/** @var string regexp to check extensions */
|
/** @var string regexp to check extensions */
|
||||||
protected $ext;
|
protected $ext;
|
||||||
|
|
||||||
|
|||||||
12
Path.php
12
Path.php
@@ -46,7 +46,7 @@ class Path
|
|||||||
// this is an alias for the last read root
|
// this is an alias for the last read root
|
||||||
$line = trim(substr($line, 2));
|
$line = trim(substr($line, 2));
|
||||||
if (!isset($paths[$lastRoot])) continue; // no last root, no alias
|
if (!isset($paths[$lastRoot])) continue; // no last root, no alias
|
||||||
$alias = $this->cleanPath($line);
|
$alias = static::cleanPath($line);
|
||||||
$paths[$lastRoot]['alias'] = $alias;
|
$paths[$lastRoot]['alias'] = $alias;
|
||||||
$paths[$alias] = &$paths[$lastRoot]; // alias references the original
|
$paths[$alias] = &$paths[$lastRoot]; // alias references the original
|
||||||
} elseif (str_starts_with($line, 'W>')) {
|
} elseif (str_starts_with($line, 'W>')) {
|
||||||
@@ -56,11 +56,11 @@ class Path
|
|||||||
$paths[$lastRoot]['web'] = $line;
|
$paths[$lastRoot]['web'] = $line;
|
||||||
} else {
|
} else {
|
||||||
// this is a new path
|
// this is a new path
|
||||||
$line = $this->cleanPath($line);
|
$line = static::cleanPath($line);
|
||||||
$lastRoot = $line;
|
$lastRoot = $line;
|
||||||
$paths[$line] = [
|
$paths[$line] = [
|
||||||
'root' => $line,
|
'root' => $line,
|
||||||
'web' => DOKU_BASE . 'lib/plugins/filelist/file.php?root=' . rawurlencode($line).'&file=',
|
'web' => DOKU_BASE . 'lib/plugins/filelist/file.php?root=' . rawurlencode($line) . '&file=',
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -78,13 +78,11 @@ class Path
|
|||||||
*/
|
*/
|
||||||
public function getPathInfo($path, $addTrailingSlash = true)
|
public function getPathInfo($path, $addTrailingSlash = true)
|
||||||
{
|
{
|
||||||
$path = $this->cleanPath($path, $addTrailingSlash);
|
$path = static::cleanPath($path, $addTrailingSlash);
|
||||||
|
|
||||||
$paths = $this->paths;
|
$paths = $this->paths;
|
||||||
$allowed = array_keys($paths);
|
$allowed = array_keys($paths);
|
||||||
usort($allowed, function ($a, $b) {
|
usort($allowed, static fn($a, $b) => strlen($a) - strlen($b));
|
||||||
return strlen($a) - strlen($b);
|
|
||||||
});
|
|
||||||
$allowed = array_map('preg_quote_cb', $allowed);
|
$allowed = array_map('preg_quote_cb', $allowed);
|
||||||
$regex = '/^(' . implode('|', $allowed) . ')/';
|
$regex = '/^(' . implode('|', $allowed) . ')/';
|
||||||
|
|
||||||
|
|||||||
3
file.php
3
file.php
@@ -1,5 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
// phpcs:disable PSR1.Files.SideEffects.FoundWithSymbols
|
||||||
|
|
||||||
use dokuwiki\plugin\filelist\Path;
|
use dokuwiki\plugin\filelist\Path;
|
||||||
|
|
||||||
if (!defined('DOKU_INC')) define('DOKU_INC', __DIR__ . '/../../../');
|
if (!defined('DOKU_INC')) define('DOKU_INC', __DIR__ . '/../../../');
|
||||||
@@ -37,4 +39,3 @@ try {
|
|||||||
echo $e->getMessage();
|
echo $e->getMessage();
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
14
syntax.php
14
syntax.php
@@ -88,7 +88,7 @@ class syntax_plugin_filelist extends SyntaxPlugin
|
|||||||
$path = Path::cleanPath($path, false);
|
$path = Path::cleanPath($path, false);
|
||||||
$parts = explode('/', $path);
|
$parts = explode('/', $path);
|
||||||
$pattern = array_pop($parts);
|
$pattern = array_pop($parts);
|
||||||
$base = join('/', $parts) . '/';
|
$base = implode('/', $parts) . '/';
|
||||||
|
|
||||||
return [$base, $pattern, $params];
|
return [$base, $pattern, $params];
|
||||||
}
|
}
|
||||||
@@ -121,7 +121,14 @@ class syntax_plugin_filelist extends SyntaxPlugin
|
|||||||
$crawler = new Crawler($this->getConf('extensions'));
|
$crawler = new Crawler($this->getConf('extensions'));
|
||||||
$crawler->setSortBy($params['sort']);
|
$crawler->setSortBy($params['sort']);
|
||||||
$crawler->setSortReverse($params['order'] === 'desc');
|
$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 we got nothing back, display a message
|
||||||
if ($result == []) {
|
if ($result == []) {
|
||||||
@@ -139,10 +146,7 @@ class syntax_plugin_filelist extends SyntaxPlugin
|
|||||||
case 'table':
|
case 'table':
|
||||||
$output->renderAsTable($params);
|
$output->renderAsTable($params);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user