Commit a34d067a authored by Oliver Bartsch's avatar Oliver Bartsch Committed by Benni Mack
Browse files

[TASK] Process _PATH_ field also in directory listing

In #87974 the special _PATH_ field was added to
FileList, to be displayed on the search result view.

To be consistent, this special field is now also
processed on building the directory listing, while
it currently has no visual effect, since the _PATH_
field is only dynamically added to in a search
context.

Resolves: #94505
Releases: master
Change-Id: I100ab601dcf28f7acdb9bf999cf08cfa350ffd4f
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/69760


Tested-by: core-ci's avatarcore-ci <typo3@b13.com>
Tested-by: Jochen's avatarJochen <rothjochen@gmail.com>
Tested-by: Benni Mack's avatarBenni Mack <benni@typo3.org>
Reviewed-by: Jochen's avatarJochen <rothjochen@gmail.com>
Reviewed-by: Benni Mack's avatarBenni Mack <benni@typo3.org>
parent 1eda4529
......@@ -34,6 +34,7 @@ use TYPO3\CMS\Core\Resource\FolderInterface;
use TYPO3\CMS\Core\Resource\InaccessibleFolder;
use TYPO3\CMS\Core\Resource\ProcessedFile;
use TYPO3\CMS\Core\Resource\ResourceFactory;
use TYPO3\CMS\Core\Resource\ResourceInterface;
use TYPO3\CMS\Core\Resource\Search\FileSearchDemand;
use TYPO3\CMS\Core\Resource\Utility\ListUtility;
use TYPO3\CMS\Core\Type\Bitmask\JsConfirmation;
......@@ -620,6 +621,9 @@ class FileList
case '_REF_':
$theData[$field] = $this->makeRef($folderObject);
break;
case '_PATH_':
$theData[$field] = $this->makePath($folderObject);
break;
default:
$theData[$field] = GeneralUtility::fixed_lgd_cs($theData[$field] ?? '', $this->fixedL);
}
......@@ -801,11 +805,7 @@ class FileList
$theData[$field] = $this->makeRef($fileObject);
break;
case '_PATH_':
$theData[$field] = '';
$method = 'getReadablePath';
if (is_callable([$fileObject->getParentFolder(), $method])) {
$theData[$field] = htmlspecialchars($fileObject->getParentFolder()->$method());
}
$theData[$field] = $this->makePath($fileObject);
break;
case 'file':
// Edit metadata of file
......@@ -1194,6 +1194,30 @@ class FileList
return $this->generateReferenceToolTip($referenceCount, $fileOrFolderObject);
}
/**
* Generate readable path
*
* @param ResourceInterface $resource
* @return string
*/
protected function makePath(ResourceInterface $resource): string
{
$folder = null;
$method = 'getReadablePath';
if ($resource instanceof FileInterface) {
$folder = $resource->getParentFolder();
} elseif ($resource instanceof FolderInterface) {
$folder = $resource;
}
if ($folder === null || !is_callable([$folder, $method])) {
return '';
}
return htmlspecialchars($folder->$method());
}
/**
* Returns an instance of LanguageService
*
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment