TYPO3 CMS  TYPO3_7-6
ElementInformationController.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 
28 
33 {
39  public $table;
40 
46  public $uid;
47 
51  protected $permsClause;
52 
56  public $access = false;
57 
65  public $type = '';
66 
70  public $doc;
71 
75  protected $content = '';
76 
83  public $pageInfo;
84 
90  protected $row;
91 
95  protected $fileObject;
96 
100  protected $folderObject;
101 
107  protected $titleTag;
108 
112  protected $iconFactory;
113 
117  public function __construct()
118  {
119  $this->iconFactory = GeneralUtility::makeInstance(IconFactory::class);
120  $GLOBALS['SOBE'] = $this;
121 
122  $this->init();
123  }
124 
131  public function init()
132  {
133  $this->table = GeneralUtility::_GET('table');
134  $this->uid = GeneralUtility::_GET('uid');
135 
136  $this->permsClause = $this->getBackendUser()->getPagePermsClause(1);
137  $this->doc = GeneralUtility::makeInstance(\TYPO3\CMS\Backend\Template\DocumentTemplate::class);
138  $this->doc->divClass = 'container';
139 
140  if (isset($GLOBALS['TCA'][$this->table])) {
141  $this->initDatabaseRecord();
142  } elseif ($this->table == '_FILE' || $this->table == '_FOLDER' || $this->table == 'sys_file') {
143  $this->initFileOrFolderRecord();
144  }
145  }
146 
150  protected function initDatabaseRecord()
151  {
152  $this->type = 'db';
153  $this->uid = (int)$this->uid;
154 
155  // Check permissions and uid value:
156  if ($this->uid && $this->getBackendUser()->check('tables_select', $this->table)) {
157  if ((string)$this->table == 'pages') {
158  $this->pageInfo = BackendUtility::readPageAccess($this->uid, $this->permsClause);
159  $this->access = is_array($this->pageInfo) ? 1 : 0;
160  $this->row = $this->pageInfo;
161  } else {
162  $this->row = BackendUtility::getRecordWSOL($this->table, $this->uid);
163  if ($this->row) {
164  $this->pageInfo = BackendUtility::readPageAccess($this->row['pid'], $this->permsClause);
165  $this->access = is_array($this->pageInfo) ? 1 : 0;
166  }
167  }
168  }
169  }
170 
174  protected function initFileOrFolderRecord()
175  {
176  $fileOrFolderObject = ResourceFactory::getInstance()->retrieveFileOrFolderObject($this->uid);
177 
178  if ($fileOrFolderObject instanceof Folder) {
179  $this->folderObject = $fileOrFolderObject;
180  $this->access = $this->folderObject->checkActionPermission('read');
181  $this->type = 'folder';
182  } else {
183  $this->fileObject = $fileOrFolderObject;
184  $this->access = $this->fileObject->checkActionPermission('read');
185  $this->type = 'file';
186  $this->table = 'sys_file';
187 
188  try {
189  $this->row = BackendUtility::getRecordWSOL($this->table, $fileOrFolderObject->getUid());
190  } catch (\Exception $e) {
191  $this->row = [];
192  }
193  }
194  }
195 
204  public function mainAction(ServerRequestInterface $request, ResponseInterface $response)
205  {
206  $this->main();
207 
208  $content = $this->doc->startPage($this->titleTag);
209  $content .= $this->doc->insertStylesAndJS($this->content);
210  $content .= $this->doc->endPage();
211 
212  $response->getBody()->write($content);
213  return $response;
214  }
215 
219  public function main()
220  {
221  if (!$this->access) {
222  return;
223  }
224 
225  // render type by user func
226  $typeRendered = false;
227  if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/show_item.php']['typeRendering'])) {
228  foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/show_item.php']['typeRendering'] as $classRef) {
229  $typeRenderObj = GeneralUtility::getUserObj($classRef);
230  // @todo should have an interface
231  if (is_object($typeRenderObj) && method_exists($typeRenderObj, 'isValid') && method_exists($typeRenderObj, 'render')) {
232  if ($typeRenderObj->isValid($this->type, $this)) {
233  $this->content .= $typeRenderObj->render($this->type, $this);
234  $typeRendered = true;
235  break;
236  }
237  }
238  }
239  }
240 
241  if (!$typeRendered) {
242  $this->content .= $this->renderPageTitle();
243  $this->content .= $this->renderPreview();
244  $this->content .= $this->renderPropertiesAsTable();
245  $this->content .= $this->renderReferences();
246  $this->content .= $this->renderBackButton();
247  }
248  }
249 
255  protected function renderPageTitle()
256  {
257  if ($this->type === 'folder') {
258  $table = $this->getLanguageService()->sL('LLL:EXT:lang/locallang_common.xlf:folder');
259  $title = $this->doc->getResourceHeader($this->folderObject, [' ', ''], false);
260  } elseif ($this->type === 'file') {
261  $table = $this->getLanguageService()->sL($GLOBALS['TCA'][$this->table]['ctrl']['title']);
262  $title = $this->doc->getResourceHeader($this->fileObject, [' ', ''], false);
263  } else {
264  $table = $this->getLanguageService()->sL($GLOBALS['TCA'][$this->table]['ctrl']['title']);
265  $title = $this->doc->getHeader($this->table, $this->row, $this->pageInfo['_thePath'], 1, [' ', ''], false);
266  }
267  // Set HTML title tag
268  $this->titleTag = $table . ': ' . strip_tags(BackendUtility::getRecordTitle($this->table, $this->row));
269  return '<h1>' .
270  ($table ? '<small>' . $table . '</small><br />' : '') .
271  $title .
272  '</h1>';
273  }
274 
280  protected function renderPreview()
281  {
282  // Perhaps @todo in future: Also display preview for records - without fileObject
283  if (!$this->fileObject) {
284  return '';
285  }
286 
287  $previewTag = '';
288  $showLink = '';
289 
290  // check if file is marked as missing
291  if ($this->fileObject->isMissing()) {
292  $previewTag .= '<span class="label label-danger">'
293  . htmlspecialchars(static::getLanguageService()->sL('LLL:EXT:lang/locallang_core.xlf:warning.file_missing'))
294  . '</span>&nbsp;' . htmlspecialchars($this->fileObject->getName()) . '<br />';
295  } else {
296 
298  $rendererRegistry = GeneralUtility::makeInstance(\TYPO3\CMS\Core\Resource\Rendering\RendererRegistry::class);
299  $fileRenderer = $rendererRegistry->getRenderer($this->fileObject);
300  $fileExtension = $this->fileObject->getExtension();
301  $url = $this->fileObject->getPublicUrl(true);
302 
303  // Check if there is a FileRenderer
304  if ($fileRenderer !== null) {
305  $previewTag = $fileRenderer->render(
306  $this->fileObject,
307  '590m',
308  '400m',
309  [],
310  true
311  );
312 
313  // else check if we can create an Image preview
314  } elseif (GeneralUtility::inList($GLOBALS['TYPO3_CONF_VARS']['GFX']['imagefile_ext'], $fileExtension)) {
315  $processedFile = $this->fileObject->process(
317  [
318  'width' => '590m',
319  'height' => '400m'
320  ]
321  );
322  // Create thumbnail image?
323  if ($processedFile) {
324  $thumbUrl = $processedFile->getPublicUrl(true);
325  $previewTag .= '<img class="img-responsive img-thumbnail" src="' . $thumbUrl . '" ' .
326  'width="' . $processedFile->getProperty('width') . '" ' .
327  'height="' . $processedFile->getProperty('height') . '" ' .
328  'alt="' . htmlspecialchars(trim($this->fileObject->getName())) . '" ' .
329  'title="' . htmlspecialchars(trim($this->fileObject->getName())) . '" />';
330  }
331  }
332 
333  // Show
334  if ($url) {
335  $showLink .= '
336  <a class="btn btn-primary" href="' . htmlspecialchars($url) . '" target="_blank">
337  ' . $this->iconFactory->getIcon('actions-document-view', Icon::SIZE_SMALL)->render() . '
338  ' . $this->getLanguageService()->sL('LLL:EXT:lang/locallang_core.xlf:labels.show', true) . '
339  </a>';
340  }
341  }
342 
343  return ($previewTag ? '<p>' . $previewTag . '</p>' : '') .
344  ($showLink ? '<p>' . $showLink . '</p>' : '');
345  }
346 
352  protected function renderPropertiesAsTable()
353  {
354  $tableRows = [];
355  $extraFields = [];
356 
357  $lang = $this->getLanguageService();
358  if (in_array($this->type, ['folder', 'file'], true)) {
359  if ($this->type === 'file') {
360  $extraFields['creation_date'] = $lang->sL('LLL:EXT:lang/locallang_general.xlf:LGL.creationDate', true);
361  $extraFields['modification_date'] = $lang->sL('LLL:EXT:lang/locallang_general.xlf:LGL.timestamp', true);
362  if ($this->fileObject->getType() === AbstractFile::FILETYPE_IMAGE) {
363  $extraFields['width'] = htmlspecialchars($lang->sL('LLL:EXT:lang/locallang_general.xlf:LGL.width'));
364  $extraFields['height'] = htmlspecialchars($lang->sL('LLL:EXT:lang/locallang_general.xlf:LGL.height'));
365  }
366  }
367  $extraFields['storage'] = $lang->sL('LLL:EXT:lang/locallang_tca.xlf:sys_file.storage', true);
368  $extraFields['folder'] = $lang->sL('LLL:EXT:lang/locallang_common.xlf:folder', true);
369  } else {
370  $extraFields['crdate'] = $lang->sL('LLL:EXT:lang/locallang_general.xlf:LGL.creationDate', true);
371  $extraFields['cruser_id'] = $lang->sL('LLL:EXT:lang/locallang_general.xlf:LGL.creationUserId', true);
372  $extraFields['tstamp'] = $lang->sL('LLL:EXT:lang/locallang_general.xlf:LGL.timestamp', true);
373 
374  // check if the special fields are defined in the TCA ctrl section of the table
375  foreach ($extraFields as $fieldName => $fieldLabel) {
376  if (isset($GLOBALS['TCA'][$this->table]['ctrl'][$fieldName])) {
377  $extraFields[$GLOBALS['TCA'][$this->table]['ctrl'][$fieldName]] = $fieldLabel;
378  } else {
379  unset($extraFields[$fieldName]);
380  }
381  }
382  }
383 
384  foreach ($extraFields as $name => $fieldLabel) {
385  $rowValue = '';
386  if (!isset($this->row[$name])) {
387  $resourceObject = $this->fileObject ?: $this->folderObject;
388  if ($name === 'storage') {
389  $rowValue = $resourceObject->getStorage()->getName();
390  } elseif ($name === 'folder') {
391  $rowValue = $resourceObject->getParentFolder()->getReadablePath();
392  } elseif ($name === 'width') {
393  $rowValue = $this->fileObject->getProperty('width') . 'px';
394  } elseif ($name === 'height') {
395  $rowValue = $this->fileObject->getProperty('height') . 'px';
396  }
397  } elseif ($name === 'creation_date' || $name === 'modification_date') {
398  $rowValue = BackendUtility::datetime($this->row[$name]);
399  } else {
400  $rowValue = BackendUtility::getProcessedValueExtra($this->table, $name, $this->row[$name]);
401  }
402  // show the backend username who created the issue
403  if ($name === 'cruser_id' && $rowValue) {
404  $creatorRecord = BackendUtility::getRecord('be_users', $rowValue);
405  if ($creatorRecord) {
407  $avatar = GeneralUtility::makeInstance(Avatar::class);
408  $icon = $avatar->render($creatorRecord);
409  $rowValue = '
410  <div class="media">
411  <div class="media-left">
412  ' . $icon . '
413  </div>
414  <div class="media-body">
415  <strong>' . htmlspecialchars($creatorRecord['username']) . '</strong><br>
416  ' . ($creatorRecord['realName'] ? htmlspecialchars($creatorRecord['realName']) : '') . '
417  </div>
418  </div>';
419  }
420  }
421 
422  $tableRows[] = '
423  <tr>
424  <th class="col-nowrap">' . rtrim($fieldLabel, ':') . '</th>
425  <td>' . ($name === 'cruser_id' ? $rowValue : htmlspecialchars($rowValue)) . '</td>
426  </tr>';
427  }
428 
429  // Traverse the list of fields to display for the record:
430  $fieldList = GeneralUtility::trimExplode(',', $GLOBALS['TCA'][$this->table]['interface']['showRecordFieldList'], true);
431  foreach ($fieldList as $name) {
432  $name = trim($name);
433  $uid = $this->row['uid'];
434 
435  if (!isset($GLOBALS['TCA'][$this->table]['columns'][$name])) {
436  continue;
437  }
438 
439  // Storage is already handled above
440  if ($this->type === 'file' && $name === 'storage') {
441  continue;
442  }
443 
444  // format file size as bytes/kilobytes/megabytes
445  if ($this->type === 'file' && $name === 'size') {
446  $this->row[$name] = GeneralUtility::formatSize($this->row[$name], $this->getLanguageService()->sL('LLL:EXT:lang/locallang_common.xlf:byteSizeUnits', true));
447  }
448 
449  $isExcluded = !(!$GLOBALS['TCA'][$this->table]['columns'][$name]['exclude'] || $this->getBackendUser()->check('non_exclude_fields', $this->table . ':' . $name));
450  if ($isExcluded) {
451  continue;
452  }
453 
454  $itemValue = BackendUtility::getProcessedValue($this->table, $name, $this->row[$name], 0, 0, false, $uid);
455  $itemLabel = $lang->sL(BackendUtility::getItemLabel($this->table, $name), true);
456  $tableRows[] = '
457  <tr>
458  <th class="col-nowrap">' . $itemLabel . '</th>
459  <td>' . htmlspecialchars($itemValue) . '</td>
460  </tr>';
461  }
462 
463  return '
464  <div class="table-fit table-fit-wrap">
465  <table class="table table-striped table-hover">
466  ' . implode('', $tableRows) . '
467  </table>
468  </div>';
469  }
470 
476  protected function renderReferences()
477  {
478  $content = '';
479 
480  switch ($this->type) {
481  case 'db': {
482  $references = $this->makeRef($this->table, $this->row['uid']);
483  if (!empty($references)) {
484  $content .= '<h3>' . $this->getLanguageService()->sL('LLL:EXT:lang/locallang_core.xlf:show_item.php.referencesToThisItem', true) . '</h3>';
485  $content .= $references;
486  }
487 
488  $referencesFrom = $this->makeRefFrom($this->table, $this->row['uid']);
489  if (!empty($referencesFrom)) {
490  $content .= '<h3>' . $this->getLanguageService()->sL('LLL:EXT:lang/locallang_core.xlf:show_item.php.referencesFromThisItem', true) . '</h3>';
491  $content .= $referencesFrom;
492  }
493  break;
494  }
495 
496  case 'file': {
497  if ($this->fileObject && $this->fileObject->isIndexed()) {
498  $references = $this->makeRef('_FILE', $this->fileObject);
499 
500  if (!empty($references)) {
501  $content .= '<h3>' . $this->getLanguageService()->sL('LLL:EXT:lang/locallang_core.xlf:show_item.php.referencesToThisItem', true) . '</h3>';
502  $content .= $references;
503  }
504  }
505  break;
506  }
507  }
508 
509  return $content;
510  }
511 
517  protected function renderBackButton()
518  {
519  $backLink = '';
520  $returnUrl = GeneralUtility::sanitizeLocalUrl(GeneralUtility::_GET('returnUrl'));
521  if ($returnUrl) {
522  $backLink .= '
523  <a class="btn btn-primary" href="' . htmlspecialchars($returnUrl) . '">
524  ' . $this->iconFactory->getIcon('actions-view-go-back', Icon::SIZE_SMALL)->render() . '
525  ' . $this->getLanguageService()->sL('LLL:EXT:lang/locallang_common.xlf:back', true) . '
526  </a>';
527  }
528  return $backLink;
529  }
530 
537  protected function renderFileInformationAsTable($fieldList)
538  {
539  $tableRows = [];
540  foreach ($fieldList as $name) {
541  if (!isset($GLOBALS['TCA'][$this->table]['columns'][$name])) {
542  continue;
543  }
544  $isExcluded = !(!$GLOBALS['TCA'][$this->table]['columns'][$name]['exclude'] || $this->getBackendUser()->check('non_exclude_fields', $this->table . ':' . $name));
545  if ($isExcluded) {
546  continue;
547  }
548  $uid = $this->row['uid'];
549  $itemValue = BackendUtility::getProcessedValue($this->table, $name, $this->row[$name], 0, 0, false, $uid);
550  $itemLabel = $this->getLanguageService()->sL(BackendUtility::getItemLabel($this->table, $name), true);
551  $tableRows[] = '
552  <tr>
553  <th>' . $itemLabel . '</th>
554  <td>' . htmlspecialchars($itemValue) . '</td>
555  </tr>';
556  }
557 
558  if (!$tableRows) {
559  return '';
560  }
561 
562  return '
563  <div class="table-fit table-fit-wrap">
564  <table class="table table-striped table-hover">
565  ' . implode('', $tableRows) . '
566  </table>
567  </div>';
568  }
569 
576  public function printContent()
577  {
579  echo $this->doc->startPage($this->titleTag) .
580  $this->doc->insertStylesAndJS($this->content) .
581  $this->doc->endPage();
582  }
583 
591  public function getLabelForTableColumn($tableName, $fieldName)
592  {
593  if ($GLOBALS['TCA'][$tableName]['columns'][$fieldName]['label'] !== null) {
594  $field = $this->getLanguageService()->sL($GLOBALS['TCA'][$tableName]['columns'][$fieldName]['label']);
595  if (trim($field) === '') {
596  $field = $fieldName;
597  }
598  } else {
599  $field = $fieldName;
600  }
601  return $field;
602  }
603 
611  protected function getRecordActions($table, $uid)
612  {
613  if ($table === '' || $uid < 0) {
614  return '';
615  }
616 
617  // Edit button
618  $urlParameters = [
619  'edit' => [
620  $table => [
621  $uid => 'edit'
622  ]
623  ],
624  'returnUrl' => GeneralUtility::getIndpEnv('REQUEST_URI')
625  ];
626  $url = BackendUtility::getModuleUrl('record_edit', $urlParameters);
627  $pageActionIcons = '
628  <a class="btn btn-default btn-sm" href="' . htmlspecialchars($url) . '">
629  ' . $this->iconFactory->getIcon('actions-document-open', Icon::SIZE_SMALL)->render() . '
630  </a>';
631 
632  // History button
633  $urlParameters = [
634  'element' => $table . ':' . $uid,
635  'returnUrl' => GeneralUtility::getIndpEnv('REQUEST_URI')
636  ];
637  $url = BackendUtility::getModuleUrl('record_history', $urlParameters);
638  $pageActionIcons .= '
639  <a class="btn btn-default btn-sm" href="' . htmlspecialchars($url) . '">
640  ' . $this->iconFactory->getIcon('actions-document-history-open', Icon::SIZE_SMALL)->render() . '
641  </a>';
642 
643  if ($table === 'pages') {
644  // Recordlist button
645  $url = BackendUtility::getModuleUrl('web_list', ['id' => $uid, 'returnUrl' => GeneralUtility::getIndpEnv('REQUEST_URI')]);
646  $pageActionIcons .= '
647  <a class="btn btn-default btn-sm" href="' . htmlspecialchars($url) . '" title="' . $this->getLanguageService()->sL('LLL:EXT:lang/locallang_core.xlf:labels.showList') . '">
648  ' . $this->iconFactory->getIcon('actions-system-list-open', Icon::SIZE_SMALL)->render() . '
649  </a>';
650 
651  // View page button
653  $pageActionIcons .= '
654  <a class="btn btn-default btn-sm" href="#" onclick="' . htmlspecialchars($viewOnClick) . '" title="' . $this->getLanguageService()->sL('LLL:EXT:lang/locallang_core.xlf:labels.showPage', true) . '">
655  ' . $this->iconFactory->getIcon('actions-document-view', Icon::SIZE_SMALL)->render() . '
656  </a>';
657  }
658 
659  return '
660  <div class="btn-group" role="group">
661  ' . $pageActionIcons . '
662  </div>';
663  }
664 
672  protected function makeRef($table, $ref)
673  {
674  $lang = $this->getLanguageService();
675  // Files reside in sys_file table
676  if ($table === '_FILE') {
677  $selectTable = 'sys_file';
678  $selectUid = $ref->getUid();
679  } else {
680  $selectTable = $table;
681  $selectUid = $ref;
682  }
683  $rows = $this->getDatabaseConnection()->exec_SELECTgetRows(
684  '*',
685  'sys_refindex',
686  'ref_table=' . $this->getDatabaseConnection()->fullQuoteStr($selectTable, 'sys_refindex') . ' AND ref_uid=' . (int)$selectUid . ' AND deleted=0'
687  );
688 
689  // Compile information for title tag:
690  $infoData = [];
691  $infoDataHeader = '';
692  if (!empty($rows)) {
693  $infoDataHeader = '
694  <tr>
695  <th class="col-icon"></th>
696  <th class="col-title">' . $lang->sL('LLL:EXT:lang/locallang_core.xlf:show_item.php.title') . '</th>
697  <th>' . $lang->sL('LLL:EXT:lang/locallang_core.xlf:show_item.php.table') . '</th>
698  <th>' . $lang->sL('LLL:EXT:lang/locallang_core.xlf:show_item.php.uid') . '</th>
699  <th>' . $lang->sL('LLL:EXT:lang/locallang_core.xlf:show_item.php.field') . '</th>
700  <th>' . $lang->sL('LLL:EXT:lang/locallang_core.xlf:show_item.php.flexpointer') . '</th>
701  <th>' . $lang->sL('LLL:EXT:lang/locallang_core.xlf:show_item.php.softrefKey') . '</th>
702  <th>' . $lang->sL('LLL:EXT:lang/locallang_core.xlf:show_item.php.sorting') . '</th>
703  <th class="col-control"></th>
704  </tr>';
705  }
706  foreach ($rows as $row) {
707  if ($row['tablename'] === 'sys_file_reference') {
708  $row = $this->transformFileReferenceToRecordReference($row);
709  if ($row['tablename'] === null || $row['recuid'] === null) {
710  return '';
711  }
712  }
713  $record = BackendUtility::getRecord($row['tablename'], $row['recuid']);
714  if ($record) {
715  $parentRecord = BackendUtility::getRecord('pages', $record['pid']);
716  $parentRecordTitle = is_array($parentRecord)
717  ? BackendUtility::getRecordTitle('pages', $parentRecord)
718  : '';
719  $icon = $this->iconFactory->getIconForRecord($row['tablename'], $record, Icon::SIZE_SMALL)->render();
720  $actions = $this->getRecordActions($row['tablename'], $row['recuid']);
721  $urlParameters = [
722  'edit' => [
723  $row['tablename'] => [
724  $row['recuid'] => 'edit'
725  ]
726  ],
727  'returnUrl' => GeneralUtility::getIndpEnv('REQUEST_URI')
728  ];
729  $url = BackendUtility::getModuleUrl('record_edit', $urlParameters);
730  $infoData[] = '
731  <tr>
732  <td class="col-icon">
733  <a href="' . htmlspecialchars($url) . '" title="id=' . $record['uid'] . '">
734  ' . $icon . '
735  </a>
736  </td>
737  <td class="col-title">
738  <a href="' . htmlspecialchars($url) . '" title="id=' . $record['uid'] . '" >
739  ' . BackendUtility::getRecordTitle($row['tablename'], $record, true) . '
740  </a>
741  </td>
742  <td>' . $lang->sL($GLOBALS['TCA'][$row['tablename']]['ctrl']['title'], true) . '</td>
743  <td>
744  <span title="' . $lang->sL('LLL:EXT:lang/locallang_common.xlf:page') . ': '
745  . htmlspecialchars($parentRecordTitle) . ' (uid=' . $record['pid'] . ')">
746  ' . $record['uid'] . '
747  </span>
748  </td>
749  <td>' . htmlspecialchars($this->getLabelForTableColumn($row['tablename'], $row['field'])) . '</td>
750  <td>' . htmlspecialchars($row['flexpointer']) . '</td>
751  <td>' . htmlspecialchars($row['softref_key']) . '</td>
752  <td>' . htmlspecialchars($row['sorting']) . '</td>
753  <td class="col-control">' . $actions . '</td>
754  </tr>';
755  } else {
756  $infoData[] = '
757  <tr>
758  <td class="col-icon"></td>
759  <td class="col-title">' . $lang->sL('LLL:EXT:lang/locallang_core.xlf:show_item.php.missing_record') . ' (uid=' . (int)$row['recuid'] . ')</td>
760  <td>' . htmlspecialchars($lang->sL($GLOBALS['TCA'][$row['tablename']]['ctrl']['title']) ?: $row['tablename']) . '</td>
761  <td></td>
762  <td>' . htmlspecialchars($this->getLabelForTableColumn($row['tablename'], $row['field'])) . '</td>
763  <td>' . htmlspecialchars($row['flexpointer']) . '</td>
764  <td>' . htmlspecialchars($row['softref_key']) . '</td>
765  <td>' . htmlspecialchars($row['sorting']) . '</td>
766  <td class="col-control"></td>
767  </tr>';
768  }
769  }
770  $referenceLine = '';
771  if (!empty($infoData)) {
772  $referenceLine = '
773  <div class="table-fit">
774  <table class="table table-striped table-hover">
775  <thead>' . $infoDataHeader . '</thead>
776  <tbody>' . implode('', $infoData) . '</tbody>
777  </table>
778  </div>';
779  }
780  return $referenceLine;
781  }
782 
790  protected function makeRefFrom($table, $ref)
791  {
792  $lang = $this->getLanguageService();
793  $rows = $this->getDatabaseConnection()->exec_SELECTgetRows(
794  '*',
795  'sys_refindex',
796  'tablename=' . $this->getDatabaseConnection()->fullQuoteStr($table, 'sys_refindex') . ' AND recuid=' . (int)$ref
797  );
798 
799  // Compile information for title tag:
800  $infoData = [];
801  $infoDataHeader = '';
802  if (!empty($rows)) {
803  $infoDataHeader = '
804  <tr>
805  <th class="col-icon"></th>
806  <th class="col-title">' . $lang->sL('LLL:EXT:lang/locallang_core.xlf:show_item.php.title') . '</th>
807  <th>' . $lang->sL('LLL:EXT:lang/locallang_core.xlf:show_item.php.table') . '</th>
808  <th>' . $lang->sL('LLL:EXT:lang/locallang_core.xlf:show_item.php.uid') . '</th>
809  <th>' . $lang->sL('LLL:EXT:lang/locallang_core.xlf:show_item.php.field') . '</th>
810  <th>' . $lang->sL('LLL:EXT:lang/locallang_core.xlf:show_item.php.flexpointer') . '</th>
811  <th>' . $lang->sL('LLL:EXT:lang/locallang_core.xlf:show_item.php.softrefKey') . '</th>
812  <th>' . $lang->sL('LLL:EXT:lang/locallang_core.xlf:show_item.php.sorting') . '</th>
813  <th>' . $lang->sL('LLL:EXT:lang/locallang_core.xlf:show_item.php.refString') . '</th>
814  <th class="col-control"></th>
815  </tr>';
816  }
817  foreach ($rows as $row) {
818  $record = BackendUtility::getRecord($row['ref_table'], $row['ref_uid']);
819  if ($record) {
820  $icon = $this->iconFactory->getIconForRecord($row['tablename'], $record, Icon::SIZE_SMALL)->render();
821  $actions = $this->getRecordActions($row['ref_table'], $row['ref_uid']);
822 
823  $urlParameters = [
824  'edit' => [
825  $row['ref_table'] => [
826  $row['ref_uid'] => 'edit'
827  ]
828  ],
829  'returnUrl' => GeneralUtility::getIndpEnv('REQUEST_URI')
830  ];
831  $url = BackendUtility::getModuleUrl('record_edit', $urlParameters);
832  $infoData[] = '
833  <tr>
834  <td class="col-icon">
835  <a href="' . htmlspecialchars($url) . '" title="id=' . $record['uid'] . '">
836  ' . $icon . '
837  </a>
838  </td>
839  <td class="col-title">
840  <a href="' . htmlspecialchars($url) . '" title="id=' . $record['uid'] . '" >
841  ' . BackendUtility::getRecordTitle($row['ref_table'], $record, true) . '
842  </a>
843  </td>
844  <td>' . $lang->sL($GLOBALS['TCA'][$row['ref_table']]['ctrl']['title'], true) . '</td>
845  <td>' . htmlspecialchars($row['ref_uid']) . '</td>
846  <td>' . htmlspecialchars($this->getLabelForTableColumn($table, $row['field'])) . '</td>
847  <td>' . htmlspecialchars($row['flexpointer']) . '</td>
848  <td>' . htmlspecialchars($row['softref_key']) . '</td>
849  <td>' . htmlspecialchars($row['sorting']) . '</td>
850  <td>' . htmlspecialchars($row['ref_string']) . '</td>
851  <td class="col-control">' . $actions . '</td>
852  </tr>';
853  } else {
854  $infoData[] = '
855  <tr>
856  <td class="col-icon"></td>
857  <td class="col-title">' . $lang->sL('LLL:EXT:lang/locallang_core.xlf:show_item.php.missing_record') . ' (uid=' . (int)$row['recuid'] . ')</td>
858  <td>' . $lang->sL($GLOBALS['TCA'][$row['ref_table']]['ctrl']['title'], true) . '</td>
859  <td></td>
860  <td>' . htmlspecialchars($this->getLabelForTableColumn($table, $row['field'])) . '</td>
861  <td>' . htmlspecialchars($row['flexpointer']) . '</td>
862  <td>' . htmlspecialchars($row['softref_key']) . '</td>
863  <td>' . htmlspecialchars($row['sorting']) . '</td>
864  <td>' . htmlspecialchars($row['ref_string']) . '</td>
865  <td class="col-control"></td>
866  </tr>';
867  }
868  }
869 
870  if (empty($infoData)) {
871  return '';
872  }
873 
874  return '
875  <div class="table-fit">
876  <table class="table table-striped table-hover">
877  <thead>' . $infoDataHeader . '</thead>
878  <tbody>' . implode('', $infoData) . '</tbody>
879  </table>
880  </div>';
881  }
882 
889  protected function transformFileReferenceToRecordReference(array $referenceRecord)
890  {
891  $fileReference = $this->getDatabaseConnection()->exec_SELECTgetSingleRow(
892  '*',
893  'sys_file_reference',
894  'uid=' . (int)$referenceRecord['recuid']
895  );
896  return [
897  'recuid' => $fileReference['uid_foreign'],
898  'tablename' => $fileReference['tablenames'],
899  'field' => $fileReference['fieldname'],
900  'flexpointer' => '',
901  'softref_key' => '',
902  'sorting' => $fileReference['sorting_foreign']
903  ];
904  }
905 
911  protected function getLanguageService()
912  {
913  return $GLOBALS['LANG'];
914  }
915 
921  protected function getBackendUser()
922  {
923  return $GLOBALS['BE_USER'];
924  }
925 
931  protected function getDatabaseConnection()
932  {
933  return $GLOBALS['TYPO3_DB'];
934  }
935 }
static readPageAccess($id, $perms_clause)
static getItemLabel($table, $col, $printAllWrap='')
mainAction(ServerRequestInterface $request, ResponseInterface $response)
static getProcessedValueExtra($table, $fN, $fV, $fixed_lgd_chars=0, $uid=0, $forceResult=true, $pid=0)
$rendererRegistry
static BEgetRootLine($uid, $clause='', $workspaceOL=false)
static trimExplode($delim, $string, $removeEmptyValues=false, $limit=0)
static getRecordTitle($table, $row, $prep=false, $forceResult=true)
static viewOnClick($pageUid, $backPath='', $rootLine=null, $anchorSection='', $alternativeUrl='', $additionalGetVars='', $switchFocus=true)
static formatSize($sizeInBytes, $labels='', $base=0)
static getRecord($table, $uid, $fields=' *', $where='', $useDeleteClause=true)
if(TYPO3_MODE==='BE') $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tsfebeuserauth.php']['frontendEditingController']['default']
static getRecordWSOL($table, $uid, $fields=' *', $where='', $useDeleteClause=true, $unsetMovePointers=false)