TYPO3 CMS  TYPO3_8-7
UserFileInlineLabelService.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 
22 
27 {
33  public function getInlineLabel(array &$params)
34  {
35  $sysFileFields = isset($params['options']['sys_file']) && is_array($params['options']['sys_file'])
36  ? $params['options']['sys_file']
37  : [];
38 
39  if (empty($sysFileFields)) {
40  // Nothing to do
41  $params['title'] = $params['row']['uid'];
42  return;
43  }
44 
45  // In case of a group field uid_local is a resolved array
46  $fileRecord = $params['row']['uid_local'][0]['row'];
47 
48  // Configuration
49  $title = [];
50  foreach ($sysFileFields as $field) {
51  $value = '';
52  if ($field === 'title') {
53  if (isset($params['row']['title'])) {
54  $fullTitle = $params['row']['title'];
55  } else {
56  try {
57  $metaDataRepository = GeneralUtility::makeInstance(MetaDataRepository::class);
58  $metaData = $metaDataRepository->findByFileUid($fileRecord['uid']);
59  $fullTitle = $metaData['title'];
60  } catch (InvalidUidException $e) {
65  $fullTitle = '';
66  }
67  }
68 
69  $value = BackendUtility::getRecordTitlePrep(htmlspecialchars($fullTitle));
70  } else {
71  if (isset($params['row'][$field])) {
72  $value = htmlspecialchars($params['row'][$field]);
73  } elseif (isset($fileRecord[$field])) {
74  $value = BackendUtility::getRecordTitlePrep($fileRecord[$field]);
75  }
76  }
77  if ((string)$value === '') {
78  continue;
79  }
80  $labelText = LocalizationUtility::translate('LLL:EXT:lang/Resources/Private/Language/locallang_tca.xlf:sys_file.' . $field, 'lang');
81  $title[] = '<dt>' . htmlspecialchars($labelText) . '</dt>' . '<dd>' . $value . '</dd>';
82  }
83  $params['title'] = '<dl>' . implode('', $title) . '</dl>';
84  }
85 }
static translate($key, $extensionName=null, $arguments=null)
static makeInstance($className,... $constructorArguments)
static getRecordTitlePrep($title, $titleLength=0)