Feature #65209

FAL - link to File in IRRE

Added by Guy Couronné almost 5 years ago. Updated over 4 years ago.

Status:
Closed
Priority:
Could have
Assignee:
-
Category:
Backend User Interface
Target version:
-
Start date:
2015-02-20
Due date:
% Done:

0%

PHP Version:
Tags:
Complexity:
Sprint Focus:

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 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 ?

fal_link-to-file_example.png View (19.9 KB) Guy Couronné, 2015-02-20 23:14

History

#1 Updated by Frans Saris over 4 years ago

  • Status changed from New to Needs Feedback

With 6.2.10 there is an info icon added to the header of the IRRE element that opens the file info window. There is a download link present.

I guess that is the same as you try to achieve.

#2 Updated by Guy Couronné over 4 years ago

I pulled 6.2.10 and that's exactly what I need.

This could be closed.

#3 Updated by Alexander Opitz over 4 years ago

  • Status changed from Needs Feedback to Closed

Thanks for feedback.

Also available in: Atom PDF