TYPO3CMS  8
 All Classes Namespaces Files Functions Variables Pages
FileInfoHook.php
Go to the documentation of this file.
1 <?php
2 namespace TYPO3\CMS\Core\Resource\Hook;
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 
23 
28 {
35  public function renderFileInfo(array $propertyArray)
36  {
37  $fileRecord = $propertyArray['row'];
38  $fileObject = null;
39  if ($fileRecord['uid'] > 0) {
40  $fileObject = ResourceFactory::getInstance()->getFileObject((int)$fileRecord['uid']);
41  }
42  return $this->renderFileInformationContent($fileObject);
43  }
44 
51  public function renderFileMetadataInfo(array $propertyArray)
52  {
53  $fileMetadataRecord = $propertyArray['row'];
54  $fileObject = null;
55  if (!empty($fileMetadataRecord['file']) && $fileMetadataRecord['file'][0] > 0) {
56  $fileObject = ResourceFactory::getInstance()->getFileObject((int)$fileMetadataRecord['file'][0]);
57  }
58 
59  return $this->renderFileInformationContent($fileObject);
60  }
61 
68  protected function renderFileInformationContent(File $file = null)
69  {
71  $lang = $GLOBALS['LANG'];
72 
73  if ($file !== null) {
74  $processedFile = $file->process(ProcessedFile::CONTEXT_IMAGEPREVIEW, ['width' => 150, 'height' => 150]);
75  $previewImage = $processedFile->getPublicUrl(true);
76  $content = '';
77  if ($file->isMissing()) {
78  $content .= '<span class="label label-danger label-space-right">'
79  . htmlspecialchars($lang->sL('LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:warning.file_missing'))
80  . '</span>';
81  }
82  if ($previewImage) {
83  $content .= '<img src="' . htmlspecialchars($previewImage) . '" ' .
84  'width="' . $processedFile->getProperty('width') . '" ' .
85  'height="' . $processedFile->getProperty('height') . '" ' .
86  'alt="" class="t3-tceforms-sysfile-imagepreview" />';
87  }
88  $content .= '<strong>' . htmlspecialchars($file->getName()) . '</strong>';
89  $content .= ' (' . htmlspecialchars(GeneralUtility::formatSize($file->getSize())) . 'bytes)<br />';
90  $content .= BackendUtility::getProcessedValue('sys_file', 'type', $file->getType()) . ' (' . $file->getMimeType() . ')<br />';
91  $content .= htmlspecialchars($lang->sL('LLL:EXT:lang/Resources/Private/Language/locallang_misc.xlf:fileMetaDataLocation')) . ': ';
92  $content .= htmlspecialchars($file->getStorage()->getName()) . ' - ' . htmlspecialchars($file->getIdentifier()) . '<br />';
93  $content .= '<br />';
94  } else {
95  $content = '<h2>' . htmlspecialchars($lang->sL('LLL:EXT:lang/Resources/Private/Language/locallang_misc.xlf:fileMetaErrorInvalidRecord')) . '</h2>';
96  }
97 
98  return $content;
99  }
100 }
renderFileMetadataInfo(array $propertyArray)
static formatSize($sizeInBytes, $labels= '', $base=0)
if(TYPO3_MODE=== 'BE') $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tsfebeuserauth.php']['frontendEditingController']['default']