TYPO3 CMS  TYPO3_6-2
UserFileInlineLabelService.php
Go to the documentation of this file.
1 <?php
3 
20 
25 
32  public function getInlineLabel(array &$params) {
33  $sysFileFields = isset($params['options']['sys_file']) && is_array($params['options']['sys_file'])
34  ? $params['options']['sys_file']
35  : array();
36 
37  if (!count($sysFileFields)) {
38  // Nothing to do
39  $params['title'] = $params['row']['uid'];
40  return;
41  }
42 
43  $fileInfo = BackendUtility::splitTable_Uid($params['row']['uid_local'], 2);
44  $fileRecord = BackendUtility::getRecord($fileInfo[0], $fileInfo[1]);
45 
46  // Configuration
47  $title = array();
48  foreach ($sysFileFields as $field) {
49  $value = '';
50  if ($field === 'title') {
51  if (isset($params['row']['title'])) {
52  $fullTitle = $params['row']['title'];
53  } else {
54  try {
55  $metaDataRepository = GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Resource\\Index\\MetaDataRepository');
56  $metaData = $metaDataRepository->findByFileUid($fileRecord['uid']);
57  $fullTitle = $metaData['title'];
58  } catch (\TYPO3\CMS\Core\Resource\Exception\InvalidUidException $e) {
63  }
64  }
65 
66  $value = BackendUtility::getRecordTitlePrep(htmlspecialchars($fullTitle));
67  } else {
68  if (isset($params['row'][$field])) {
69  $value = htmlspecialchars($params['row'][$field]);
70  } elseif (isset($fileRecord[$field])) {
71  $value = BackendUtility::getRecordTitlePrep($fileRecord[$field]);
72  }
73  }
74  if (!strlen($value)) {
75  continue;
76  }
77  $labelText = LocalizationUtility::translate('LLL:EXT:lang/locallang_tca.xlf:sys_file.' . $field, 'lang');
78  $title[] = '<dt>' . htmlspecialchars($labelText) . '</dt>' . '<dd>' . $value . '</dd>';
79  }
80  $params['title'] = '<dl>' . implode('', $title) . '</dl>';
81  }
82 }
static getRecordTitlePrep($title, $titleLength=0)
static translate($key, $extensionName, $arguments=NULL)