TYPO3 CMS  TYPO3_7-6
FileInfoHook.php
Go to the documentation of this file.
1 <?php
3 
4 /*
5  * This file is part of the TYPO3 CMS project.
6  *
7  * It is free software; you can redistribute it and/or modify it under
8  * the terms of the GNU General Public License, either version 2
9  * of the License, or any later version.
10  *
11  * For the full copyright and license information, please read the
12  * LICENSE.txt file that was distributed with this source code.
13  *
14  * The TYPO3 project - inspiring people to share!
15  */
16 
20 
25 {
32  public function renderFileInfo(array $propertyArray)
33  {
34  $fileRecord = $propertyArray['row'];
35  $fileObject = null;
36  if ($fileRecord['uid'] > 0) {
37  $fileObject = ResourceFactory::getInstance()->getFileObject((int)$fileRecord['uid']);
38  }
39  return $this->renderFileInformationContent($fileObject);
40  }
41 
48  public function renderFileMetadataInfo(array $propertyArray)
49  {
50  $fileMetadataRecord = $propertyArray['row'];
51  $fileObject = null;
52  if (!empty($fileMetadataRecord['file']) && $fileMetadataRecord['file'][0] > 0) {
53  $fileObject = ResourceFactory::getInstance()->getFileObject((int)$fileMetadataRecord['file'][0]);
54  }
55 
56  return $this->renderFileInformationContent($fileObject);
57  }
58 
65  protected function renderFileInformationContent(\TYPO3\CMS\Core\Resource\File $file = null)
66  {
67  if ($file !== null) {
68  $content = '';
69  if ($file->isMissing()) {
70  $content .= '<span class="label label-danger label-space-right">'
71  . htmlspecialchars($GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:warning.file_missing'))
72  . '</span>';
73  }
74  if (GeneralUtility::inList($GLOBALS['TYPO3_CONF_VARS']['GFX']['imagefile_ext'], $file->getExtension())) {
75  $processedFile = $file->process(\TYPO3\CMS\Core\Resource\ProcessedFile::CONTEXT_IMAGEPREVIEW, ['width' => 150, 'height' => 150]);
76  $previewImage = $processedFile->getPublicUrl(true);
77  if ($previewImage) {
78  $content .= '<img src="' . htmlspecialchars($previewImage) . '" ' .
79  'width="' . $processedFile->getProperty('width') . '" ' .
80  'height="' . $processedFile->getProperty('height') . '" ' .
81  'alt="" class="t3-tceforms-sysfile-imagepreview" />';
82  }
83  }
84  $content .= '<strong>' . htmlspecialchars($file->getName()) . '</strong>';
85  $content .= ' (' . htmlspecialchars(\TYPO3\CMS\Core\Utility\GeneralUtility::formatSize($file->getSize())) . 'bytes)<br />';
86  $content .= BackendUtility::getProcessedValue('sys_file', 'type', $file->getType()) . ' (' . $file->getMimeType() . ')<br />';
87  $content .= $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_misc.xlf:fileMetaDataLocation', true) . ': ';
88  $content .= htmlspecialchars($file->getStorage()->getName()) . ' - ' . htmlspecialchars($file->getIdentifier()) . '<br />';
89  $content .= '<br />';
90  } else {
91  $content = '<h2>' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_misc.xlf:fileMetaErrorInvalidRecord', true) . '</h2>';
92  }
93 
94  return $content;
95  }
96 }
renderFileInformationContent(\TYPO3\CMS\Core\Resource\File $file=null)
static formatSize($sizeInBytes, $labels='', $base=0)
renderFileMetadataInfo(array $propertyArray)
if(TYPO3_MODE==='BE') $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tsfebeuserauth.php']['frontendEditingController']['default']