V1
This commit is contained in:
@@ -4,6 +4,7 @@ use dokuwiki\Extension\SyntaxPlugin;
|
||||
use dokuwiki\plugin\luxtools\Crawler;
|
||||
use dokuwiki\plugin\luxtools\Output;
|
||||
use dokuwiki\plugin\luxtools\Path;
|
||||
use dokuwiki\plugin\luxtools\PageLink;
|
||||
|
||||
require_once(__DIR__ . '/../autoload.php');
|
||||
|
||||
@@ -208,7 +209,12 @@ abstract class syntax_plugin_luxtools_abstract extends SyntaxPlugin
|
||||
protected function getPathInfoSafe(string $basePath, \Doku_Renderer $renderer)
|
||||
{
|
||||
try {
|
||||
$pathHelper = new Path($this->getConf('paths'));
|
||||
$pathConfig = (string)$this->getConf('paths');
|
||||
$blobsRoot = $this->resolveBlobsRoot();
|
||||
if ($blobsRoot !== '') {
|
||||
$pathConfig = rtrim($pathConfig) . "\n" . $blobsRoot . "\nA> blobs";
|
||||
}
|
||||
$pathHelper = new Path($pathConfig);
|
||||
return $pathHelper->getPathInfo($basePath);
|
||||
} catch (\Exception $e) {
|
||||
$this->renderError($renderer, 'error_outsidejail');
|
||||
@@ -216,6 +222,50 @@ abstract class syntax_plugin_luxtools_abstract extends SyntaxPlugin
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Resolve the current page's pagelink folder for the blobs alias.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function resolveBlobsRoot(): string
|
||||
{
|
||||
static $cached = [];
|
||||
|
||||
global $ID;
|
||||
$pageId = is_string($ID) ? $ID : '';
|
||||
if ($pageId === '') return '';
|
||||
|
||||
if (function_exists('cleanID')) {
|
||||
$pageId = (string)cleanID($pageId);
|
||||
}
|
||||
if ($pageId === '') return '';
|
||||
|
||||
if (isset($cached[$pageId])) {
|
||||
return (string)$cached[$pageId];
|
||||
}
|
||||
|
||||
$pathConfig = (string)$this->getConf('paths');
|
||||
$depth = (int)$this->getConf('pagelink_search_depth');
|
||||
if ($depth < 0) $depth = 0;
|
||||
|
||||
$pageLink = new PageLink($pathConfig, $depth);
|
||||
$uuid = $pageLink->getPageUuid($pageId);
|
||||
if ($uuid === null) {
|
||||
$cached[$pageId] = '';
|
||||
return '';
|
||||
}
|
||||
|
||||
$linkInfo = $pageLink->resolveUuid($uuid);
|
||||
$folder = $linkInfo['folder'] ?? '';
|
||||
if (!is_string($folder) || $folder === '') {
|
||||
$cached[$pageId] = '';
|
||||
return '';
|
||||
}
|
||||
|
||||
$cached[$pageId] = $folder;
|
||||
return $folder;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create and configure a Crawler instance.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user