getLang('pagelink_unlinked'); if ($renderer instanceof \Doku_Renderer_xhtml) { $renderer->doc .= '' . hsc($text) . ''; return; } $renderer->cdata('[n/a: ' . $text . ']'); } /** * Read the current page UUID (if any). * * @return string The UUID or empty string */ protected function getPageUuidSafe(): string { global $ID; $pageId = is_string($ID) ? $ID : ''; if ($pageId === '') return ''; if (function_exists('cleanID')) { $pageId = (string)cleanID($pageId); } if ($pageId === '') return ''; $depth = (int)$this->getConf('pagelink_search_depth'); if ($depth < 0) $depth = 0; $pageLink = new PageLink((string)$this->getConf('paths'), $depth); $uuid = $pageLink->getPageUuid($pageId); return $uuid ?? ''; } /** * Resolve the current page's pagelink folder for the blobs alias. * * Results are cached per page ID within a single request. * * @return string The linked folder path or empty string if not linked */ 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]; } $depth = (int)$this->getConf('pagelink_search_depth'); if ($depth < 0) $depth = 0; $pageLink = new PageLink((string)$this->getConf('paths'), $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; } /** * Build a path config string with the blobs alias appended (if available). * * @param string|null $blobsRoot The blobs root folder (or null to auto-resolve) * @return string The path config string */ protected function buildPathConfigWithBlobs(?string $blobsRoot = null): string { $pathConfig = (string)$this->getConf('paths'); if ($blobsRoot === null) { $blobsRoot = $this->resolveBlobsRoot(); } if ($blobsRoot !== '') { $pathConfig = rtrim($pathConfig) . "\n" . $blobsRoot . "\nA> blobs"; } return $pathConfig; } /** * Create a Path helper with blobs alias support. * * @param string|null $blobsRoot The blobs root folder (or null to auto-resolve) * @return Path */ protected function createPathHelperWithBlobs(?string $blobsRoot = null): Path { return new Path($this->buildPathConfigWithBlobs($blobsRoot)); } /** * Create a Path helper using only the base paths config (no blobs alias). * * @return Path */ protected function createPathHelper(): Path { return new Path((string)$this->getConf('paths')); } }