#65209FAL - link to File in IRRE
Description
Hi,
I’m creating a report with .HTML attached, and I would like to download it without passing by module filelist. I didn’t find, while editing a File Reference, how to get its file.
I would like something like this attachment:fal_link-to-file_example.png.
To do this, I add a field in TCA :
'bar_fal' => array(
'exclude' => true,
'label' => 'FAL link to File'
'config' => array(
'type' => 'user',
'userFunc' => '\Foo\\BarFal\\Userfuncs\\TCAField->displayLink'
)
)
The method called is :
/**
*
* @param array $PA
* @param \TYPO3\CMS\Backend\Form\FormEngine $pObj
* @return string
*/
public function displayLink(array $PA, \TYPO3\CMS\Backend\Form\FormEngine $pObj)
{
$formField = '';
if (is_numeric($PA['row']['uid'])) {
$fileReference = $this->resourceFactory->getFileReferenceObject($PA['row']['uid']); //\TYPO3\CMS\Core\Resource\ResourceFactory
if (!empty($fileReference)) {
$file = $fileReference->getOriginalFile();
if (!empty($file)) {
$fileUrl = $file->getPublicUrl(true);
if (!empty($fileUrl)) {
$filename = htmlspecialchars(trim($file->getName()));
$clickHere = \TYPO3\CMS\Extbase\Utility\LocalizationUtility::translate(
'fal.link',
'bar_fal'
);
$aOnClick = 'return top.openUrlInWindow(\'' . $fileUrl . '\', \'WebFile\');';
$formField = '<div><a href="#" title="' . $filename . '" onclick="' . htmlspecialchars($aOnClick) . '">' . $clickHere . '</a></div>';
}
}
}
}
return $formField;
}
It’s based on \TYPO3\CMS\Filelist\FileList->linkWrapFile(..);
To avoid error with dataMap, I unset it in hook (processDatamap_preProcessFieldArray).
What do you think ?
Reviews 0
No change resolves or names this issue in its commit message, and no comment links one.