registerArgument('row', 'array', 'content data', true);
$this->registerArgument('tableName', 'string', 'table name', true);
$this->registerArgument('fieldName', 'string', 'field name', true);
}
/**
* Render a constant
*
* @return string Value of constant
*/
public function render(): string
{
$table = $this->arguments['tableName'];
$field = $this->arguments['fieldName'];
$row = $this->arguments['row'];
$fileReferences = BackendUtility::resolveFileReferences($table, $field, $row);
$fileObject = is_array($fileReferences) ? current($fileReferences)->getOriginalFile() : null;
if ($fileObject && $fileObject->isMissing()) {
/** @var IconFactory $iconFactory */
$iconFactory = GeneralUtility::makeInstance(IconFactory::class);
$label = $this->getLanguageService()->sL(
'LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:warning.file_missing'
);
return $iconFactory
->getIcon('mimetypes-other-other', IconSize::MEDIUM, 'overlay-missing')
->setTitle($label . ' ' . $fileObject->getName())
->render();
}
$previewFile = $fileObject->process(
ProcessedFile::CONTEXT_IMAGEPREVIEW,
[
'width' => 64,
'height' => 64,
]
);
return $this->linkEditContent('
', $row );
}
protected function linkEditContent(string $linkText, $row): string
{
if (empty($linkText)) {
return $linkText;
}
$backendUser = $this->getBackendUser();
if (
$backendUser->check('tables_modify', 'tt_content')
&& $backendUser->recordEditAccessInternals('tt_content', $row)
&& (
new Permission(
$backendUser->calcPerms(BackendUtility::getRecord('pages', $row['pid']) ?? [])
)
)->editContentPermissionIsGranted()
) {
$urlParameters = [
'edit' => [
'tt_content' => [
$row['uid'] => 'edit',
],
],
// @extensionScannerIgnoreLine
'returnUrl' => $this->getRequest()->getAttribute('normalizedParams')->getRequestUri()
. '#element-tt_content-' . $row['uid'],
];
/** @var UriBuilder $uriBuilder */
$uriBuilder = GeneralUtility::makeInstance(UriBuilder::class);
$url = (string)$uriBuilder->buildUriFromRoute('record_edit', $urlParameters);
return '' . $linkText . '';
}
return $linkText;
}
protected function getBackendUser(): BackendUserAuthentication
{
return $GLOBALS['BE_USER'];
}
protected function getLanguageService(): LanguageService
{
return $GLOBALS['LANG'];
}
protected function getRequest(): ServerRequestInterface
{
return $GLOBALS['TYPO3_REQUEST'];
}
}