94cd94c8b194d6f2f1d40b5d64e8c1aa58e591fb
[Packages/TYPO3.CMS.git] / typo3 / sysext / backend / Classes / Controller / ContentElement / ElementInformationController.php
1 <?php
2 namespace TYPO3\CMS\Backend\Controller\ContentElement;
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
17 use TYPO3\CMS\Backend\Utility\BackendUtility;
18 use TYPO3\CMS\Backend\Utility\IconUtility;
19 use TYPO3\CMS\Core\Resource\ProcessedFile;
20 use TYPO3\CMS\Core\Utility\GeneralUtility;
21
22 /**
23 * Script Class for showing information about an item.
24 *
25 * @author Kasper Skårhøj <kasperYYYY@typo3.com>
26 */
27 class ElementInformationController {
28
29 /**
30 * Record table name
31 *
32 * @var string
33 */
34 public $table;
35
36 /**
37 * Record uid
38 *
39 * @var int
40 */
41 public $uid;
42
43 /**
44 * @var string
45 */
46 protected $permsClause;
47
48 /**
49 * @var bool
50 */
51 public $access = FALSE;
52
53 /**
54 * Which type of element:
55 * - "file"
56 * - "db"
57 *
58 * @var string
59 */
60 public $type = '';
61
62 /**
63 * @var \TYPO3\CMS\Backend\Template\DocumentTemplate
64 */
65 public $doc;
66
67 /**
68 * @var string
69 */
70 protected $content = '';
71
72 /**
73 * For type "db": Set to page record of the parent page of the item set
74 * (if type="db")
75 *
76 * @var array
77 */
78 public $pageinfo;
79
80 /**
81 * Database records identified by table/uid
82 *
83 * @var array
84 */
85 protected $row;
86
87 /**
88 * @var \TYPO3\CMS\Core\Resource\File
89 */
90 protected $fileObject;
91
92 /**
93 * @var \TYPO3\CMS\Core\Resource\Folder
94 */
95 protected $folderObject;
96
97 /**
98 * Constructor
99 */
100 public function __construct() {
101 $GLOBALS['BACK_PATH'] = '';
102 $GLOBALS['SOBE'] = $this;
103
104 $this->init();
105 }
106
107 /**
108 * Determines if table/uid point to database record or file and
109 * if user has access to view information
110 *
111 * @return void
112 */
113 public function init() {
114 $this->table = GeneralUtility::_GET('table');
115 $this->uid = GeneralUtility::_GET('uid');
116
117 $this->perms_clause = $GLOBALS['BE_USER']->getPagePermsClause(1);
118 $this->doc = GeneralUtility::makeInstance(\TYPO3\CMS\Backend\Template\DocumentTemplate::class);
119
120 if (isset($GLOBALS['TCA'][$this->table])) {
121 $this->initDatabaseRecord();
122 } elseif ($this->table == '_FILE' || $this->table == '_FOLDER' || $this->table == 'sys_file') {
123 $this->initFileOrFolderRecord();
124 }
125 }
126
127 /**
128 * Init database records (table)
129 */
130 protected function initDatabaseRecord() {
131 $this->type = 'db';
132 $this->uid = (int)$this->uid;
133
134 // Check permissions and uid value:
135 if ($this->uid && $GLOBALS['BE_USER']->check('tables_select', $this->table)) {
136 if ((string)$this->table == 'pages') {
137 $this->pageinfo = BackendUtility::readPageAccess($this->uid, $this->perms_clause);
138 $this->access = is_array($this->pageinfo) ? 1 : 0;
139 $this->row = $this->pageinfo;
140 } else {
141 $this->row = BackendUtility::getRecordWSOL($this->table, $this->uid);
142 if ($this->row) {
143 $this->pageinfo = BackendUtility::readPageAccess($this->row['pid'], $this->perms_clause);
144 $this->access = is_array($this->pageinfo) ? 1 : 0;
145 }
146 }
147 /** @var $treatData \TYPO3\CMS\Backend\Form\DataPreprocessor */
148 $treatData = GeneralUtility::makeInstance(\TYPO3\CMS\Backend\Form\DataPreprocessor::class);
149 $treatData->renderRecord($this->table, $this->uid, 0, $this->row);
150 }
151 }
152
153 /**
154 * Init file/folder parameters
155 */
156 protected function initFileOrFolderRecord() {
157 $fileOrFolderObject = \TYPO3\CMS\Core\Resource\ResourceFactory::getInstance()->
158 retrieveFileOrFolderObject($this->uid);
159
160 if ($fileOrFolderObject instanceof \TYPO3\CMS\Core\Resource\Folder) {
161 $this->folderObject = $fileOrFolderObject;
162 $this->access = $this->folderObject->checkActionPermission('read');
163 $this->type = 'folder';
164 } else {
165 $this->fileObject = $fileOrFolderObject;
166 $this->access = $this->fileObject->checkActionPermission('read');
167 $this->type = 'file';
168 $this->table = 'sys_file_metadata';
169
170 try {
171 $metaData = $fileOrFolderObject->_getMetaData();
172 $this->row = BackendUtility::getRecordWSOL($this->table, $metaData['uid']);
173 } catch (\Exception $e) {
174 $this->row = array();
175 }
176 }
177 }
178
179 /**
180 * @return void
181 */
182 public function main() {
183 if (!$this->access) {
184 return;
185 }
186
187 // render type by user func
188 $typeRendered = FALSE;
189 if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/show_item.php']['typeRendering'])) {
190 foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/show_item.php']['typeRendering'] as $classRef) {
191 $typeRenderObj = GeneralUtility::getUserObj($classRef);
192 // @TODO should have an interface
193 if (is_object($typeRenderObj) && method_exists($typeRenderObj, 'isValid') && method_exists($typeRenderObj, 'render')) {
194 if ($typeRenderObj->isValid($this->type, $this)) {
195 $this->content .= $typeRenderObj->render($this->type, $this);
196 $typeRendered = TRUE;
197 break;
198 }
199 }
200 }
201 }
202
203 if (!$typeRendered) {
204 $this->content .= $this->renderPageTitle();
205 $this->content .= $this->renderPreview();
206 $this->content .= $this->renderPropertiesAsTable();
207 $this->content .= $this->renderReferences();
208 }
209 }
210
211 /**
212 * Render page title with icon, table title and record title
213 *
214 * @return string
215 */
216 protected function renderPageTitle() {
217 if ($this->type === 'folder') {
218 $table = $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_common.xlf:folder');
219 $title = $this->doc->getResourceHeader($this->folderObject, array(' ', ''), FALSE);
220 } elseif ($this->type === 'file') {
221 $table = $GLOBALS['LANG']->sL($GLOBALS['TCA'][$this->table]['ctrl']['title']);
222 $title = $this->doc->getResourceHeader($this->fileObject, array(' ', ''), FALSE);
223 } else {
224 $table = $GLOBALS['LANG']->sL($GLOBALS['TCA'][$this->table]['ctrl']['title']);
225 $title = $this->doc->getHeader($this->table, $this->row, $this->pageinfo['_thePath'], 1, array(' ', ''), FALSE);
226 }
227
228 return '<h1>' .
229 ($table ? '<small>' . $table . '</small><br />' : '') .
230 $title .
231 '</h1>';
232 }
233
234 /**
235 * Render preview for current record
236 *
237 * @return string
238 */
239 protected function renderPreview() {
240 // Perhaps @TODO in future: Also display preview for records - without fileObject
241 if (!$this->fileObject) {
242 return;
243 }
244
245 $previewTag = '';
246 $downloadLink = '';
247
248 // check if file is marked as missing
249 if ($this->fileObject->isMissing()) {
250 $flashMessage = \TYPO3\CMS\Core\Resource\Utility\BackendUtility::getFlashMessageForMissingFile($this->fileObject);
251 $previewTag .= $flashMessage->render();
252
253 } else {
254
255 /** @var \TYPO3\CMS\Core\Resource\Rendering\RendererRegistry $rendererRegistry */
256 $rendererRegistry = GeneralUtility::makeInstance(\TYPO3\CMS\Core\Resource\Rendering\RendererRegistry::class);
257 $fileRenderer = $rendererRegistry->getRenderer($this->fileObject);
258 $fileExtension = $this->fileObject->getExtension();
259 $url = $this->fileObject->getPublicUrl(TRUE);
260
261 // Check if there is a FileRenderer
262 if ($fileRenderer !== NULL) {
263 $previewTag = $fileRenderer->render(
264 $this->fileObject,
265 '590m',
266 '400m',
267 array(),
268 TRUE
269 );
270
271 // else check if we can create an Image preview
272 } elseif (GeneralUtility::inList($GLOBALS['TYPO3_CONF_VARS']['GFX']['imagefile_ext'], $fileExtension)) {
273 $thumbUrl = $this->fileObject->process(
274 ProcessedFile::CONTEXT_IMAGEPREVIEW,
275 array(
276 'width' => '590m',
277 'height' => '400m'
278 )
279 )->getPublicUrl(TRUE);
280
281 // Create thumbnail image?
282 if ($thumbUrl) {
283 $previewTag .= '<img src="' . $thumbUrl . '" ' .
284 'alt="' . htmlspecialchars(trim($this->fileObject->getName())) . '" ' .
285 'title="' . htmlspecialchars(trim($this->fileObject->getName())) . '" />';
286 }
287 }
288
289 // Download
290 if ($url) {
291 $downloadLink .= '<a href="' . htmlspecialchars($url) . '" target="_blank" class="t3-button">' .
292 IconUtility::getSpriteIcon('actions-edit-download') . ' ' .
293 $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_common.xlf:download', TRUE) .
294 '</a>';
295 }
296 }
297
298 return ($previewTag ? '<p>' . $previewTag . '</p>' : '') .
299 ($downloadLink ? '<p>' . $downloadLink . '</p>' : '');
300 }
301
302 /**
303 * Render property array as html table
304 *
305 * @return string
306 */
307 protected function renderPropertiesAsTable() {
308 $tableRows = array();
309 $extraFields = array();
310
311 if ($this->type !== 'folder') {
312 $extraFields = array(
313 'crdate' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_general.xlf:LGL.creationDate', TRUE),
314 'cruser_id' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_general.xlf:LGL.creationUserId', TRUE),
315 'tstamp' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_general.xlf:LGL.timestamp', TRUE)
316 );
317 }
318
319 if (in_array($this->type, array('folder', 'file'), TRUE)) {
320 $extraFields['storage'] = $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_tca.xlf:sys_file.storage', TRUE);
321 $extraFields['folder'] = $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_common.xlf:folder', TRUE);
322 }
323
324 foreach ($extraFields as $name => $value) {
325 $rowValue = BackendUtility::getProcessedValueExtra($this->table, $name, $this->row[$name]);
326 if ($name === 'cruser_id' && $rowValue) {
327 $userTemp = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows('username, realName', 'be_users', 'uid = ' . (int)$rowValue);
328 if ($userTemp[0]['username'] !== '') {
329 $rowValue = $userTemp[0]['username'];
330 if ($userTemp[0]['realName'] !== '') {
331 $rowValue .= ' - ' . $userTemp[0]['realName'];
332 }
333 }
334 } elseif ($rowValue === NULL) {
335 $resourceObject = $this->fileObject ?: $this->folderObject;
336 if ($name === 'storage') {
337 $rowValue = $resourceObject->getStorage()->getName();
338 } elseif ($name === 'folder') {
339 $rowValue = $resourceObject->getParentFolder()->getIdentifier();
340 }
341 }
342 $tableRows[] = '
343 <tr>
344 <td><strong>' . rtrim($value, ':') . '</strong></td>
345 <td>' . htmlspecialchars($rowValue) . '</td>
346 </tr>';
347 }
348
349 // Traverse the list of fields to display for the record:
350 $fieldList = GeneralUtility::trimExplode(',', $GLOBALS['TCA'][$this->table]['interface']['showRecordFieldList'], TRUE);
351 foreach ($fieldList as $name) {
352 $name = trim($name);
353 $uid = $this->row['uid'];
354
355 if (!isset($GLOBALS['TCA'][$this->table]['columns'][$name])) {
356 continue;
357 }
358
359 $isExcluded = !(!$GLOBALS['TCA'][$this->table]['columns'][$name]['exclude'] || $GLOBALS['BE_USER']->check('non_exclude_fields', $this->table . ':' . $name));
360 if ($isExcluded) {
361 continue;
362 }
363
364 $itemValue = BackendUtility::getProcessedValue($this->table, $name, $this->row[$name], 0, 0, FALSE, $uid);
365 $itemLabel = $GLOBALS['LANG']->sL(BackendUtility::getItemLabel($this->table, $name), TRUE);
366 $tableRows[] = '
367 <tr>
368 <td><strong>' . $itemLabel . '</strong></td>
369 <td>' . htmlspecialchars($itemValue) . '</td>
370 </tr>';
371 }
372
373 return '<table class="t3-table">' . implode('', $tableRows) . '</table>';
374 }
375
376 /**
377 * Render references section (references from and references to current record)
378 *
379 * @return string
380 */
381 protected function renderReferences() {
382 $content = '';
383
384 switch ($this->type) {
385 case 'db': {
386 $references = $this->makeRef($this->table, $this->row['uid']);
387 if (!empty($references)) {
388 $content .= $this->doc->section($GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:show_item.php.referencesToThisItem'), $references);
389 }
390
391 $referencesFrom = $this->makeRefFrom($this->table, $this->row['uid']);
392 if (!empty($referencesFrom)) {
393 $content .= $this->doc->section($GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:show_item.php.referencesFromThisItem'), $referencesFrom);
394 }
395 break;
396 }
397
398 case 'file': {
399 if ($this->fileObject && $this->fileObject->isIndexed()) {
400 $references = $this->makeRef('_FILE', $this->fileObject);
401
402 if (!empty($references)) {
403 $header = $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:show_item.php.referencesToThisItem');
404 $content .= $this->doc->section($header, $references);
405 }
406 }
407 break;
408 }
409 }
410
411 return $content;
412 }
413
414 /**
415 * Renders file properties as html table
416 *
417 * @param array $fieldList
418 * @return string
419 */
420 protected function renderFileInformationAsTable($fieldList) {
421 $tableRows = array();
422 foreach ($fieldList as $name) {
423 if (!isset($GLOBALS['TCA'][$this->table]['columns'][$name])) {
424 continue;
425 }
426 $isExcluded = !(!$GLOBALS['TCA'][$this->table]['columns'][$name]['exclude'] || $GLOBALS['BE_USER']->check('non_exclude_fields', $this->table . ':' . $name));
427 if ($isExcluded) {
428 continue;
429 }
430 $uid = $this->row['uid'];
431 $itemValue = BackendUtility::getProcessedValue($this->table, $name, $this->row[$name], 0, 0, FALSE, $uid);
432 $itemLabel = $GLOBALS['LANG']->sL(BackendUtility::getItemLabel($this->table, $name), TRUE);
433 $tableRows[] = '
434 <tr>
435 <td><strong>' . $itemLabel . '</strong></td>
436 <td>' . htmlspecialchars($itemValue) . '</td>
437 </tr>';
438 }
439
440 if (!$tableRows) {
441 return '';
442 }
443
444 return '<table id="typo3-showitem" class="t3-table-info">' .
445 implode('', $tableRows) .
446 '</table>';
447 }
448
449 /**
450 * End page and print content
451 *
452 * @return void
453 */
454 public function printContent() {
455 echo $this->doc->startPage('') .
456 $this->doc->insertStylesAndJS($this->content) .
457 $this->doc->endPage();
458 }
459
460 /**
461 * Get field name for specified table/column name
462 *
463 * @param string $tableName Table name
464 * @param string $fieldName Column name
465 * @return string label
466 */
467 public function getLabelForTableColumn($tableName, $fieldName) {
468 if ($GLOBALS['TCA'][$tableName]['columns'][$fieldName]['label'] !== NULL) {
469 $field = $GLOBALS['LANG']->sL($GLOBALS['TCA'][$tableName]['columns'][$fieldName]['label']);
470 if (trim($field) === '') {
471 $field = $fieldName;
472 }
473 } else {
474 $field = $fieldName;
475 }
476 return $field;
477 }
478
479 /**
480 * Returns the rendered record actions
481 *
482 * @param string $table
483 * @param int $uid
484 * @return string
485 */
486 protected function getRecordActions($table, $uid) {
487 if ($table === '' || $uid < 0) {
488 return '';
489 }
490
491 $editOnClick = BackendUtility::editOnClick('&edit[' . $table . '][' . $uid . ']=edit', $GLOBALS['BACK_PATH']);
492 $icon = IconUtility::getSpriteIcon('actions-document-open');
493 $pageActionIcons = '<a href="#" onclick="' . htmlspecialchars($editOnClick) . '">' . $icon . '</a>';
494 $historyOnClick = 'window.location.href=' .
495 GeneralUtility::quoteJSvalue(
496 BackendUtility::getModuleUrl(
497 'record_history',
498 array(
499 'element' => $table . ':' . $uid,
500 'returnUrl' => GeneralUtility::getIndpEnv('REQUEST_URI')
501 )
502 )
503 ) . '; return false;';
504
505 $icon = IconUtility::getSpriteIcon('actions-document-history-open');
506 $pageActionIcons .= '<a href="#" onclick="' . htmlspecialchars($historyOnClick) . '">' . $icon . '</a>';
507 if ($table === 'pages') {
508 $pageActionIcons .= $this->doc->viewPageIcon($uid, '');
509 }
510 return $pageActionIcons;
511 }
512
513 /**
514 * Make reference display
515 *
516 * @param string $table Table name
517 * @param string|\TYPO3\CMS\Core\Resource\File $ref Filename or uid
518 * @return string HTML
519 */
520 protected function makeRef($table, $ref) {
521 // Files reside in sys_file table
522 if ($table === '_FILE') {
523 $selectTable = 'sys_file';
524 $selectUid = $ref->getUid();
525 } else {
526 $selectTable = $table;
527 $selectUid = $ref;
528 }
529 $rows = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows(
530 '*',
531 'sys_refindex',
532 'ref_table=' . $GLOBALS['TYPO3_DB']->fullQuoteStr($selectTable, 'sys_refindex') . ' AND ref_uid=' . (int)$selectUid . ' AND deleted=0'
533 );
534
535 // Compile information for title tag:
536 $infoData = array();
537 if (count($rows)) {
538 $infoDataHeader = '<tr>' . '<td>&nbsp;</td>' . '<td>' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:show_item.php.table') . '</td>' . '<td>' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:show_item.php.title') . '</td>' . '<td>[uid]</td>' . '<td>' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:show_item.php.field') . '</td>' . '<td>' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:show_item.php.flexpointer') . '</td>' . '<td>' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:show_item.php.softrefKey') . '</td>' . '<td>' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:show_item.php.sorting') . '</td>' . '</tr>';
539 }
540 foreach ($rows as $row) {
541 if ($row['tablename'] === 'sys_file_reference') {
542 $row = $this->transformFileReferenceToRecordReference($row);
543 }
544 $record = BackendUtility::getRecord($row['tablename'], $row['recuid']);
545 $parentRecord = BackendUtility::getRecord('pages', $record['pid']);
546 $actions = $this->getRecordActions($row['tablename'], $row['recuid']);
547 $infoData[] = '<tr>' .
548 '<td style="white-space:nowrap;">' . $actions . '</td>' .
549 '<td>' . $GLOBALS['LANG']->sL($GLOBALS['TCA'][$row['tablename']]['ctrl']['title'], TRUE) . '</td>' .
550 '<td>' . BackendUtility::getRecordTitle($row['tablename'], $record, TRUE) . '</td>' .
551 '<td><span title="' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_common.xlf:page') . ': ' .
552 htmlspecialchars(BackendUtility::getRecordTitle('pages', $parentRecord)) . ' (uid=' . $record['pid'] . ')">' .
553 $record['uid'] . '</span></td>' .
554 '<td>' . htmlspecialchars($this->getLabelForTableColumn($row['tablename'], $row['field'])) . '</td>' .
555 '<td>' . htmlspecialchars($row['flexpointer']) . '</td>' . '<td>' . htmlspecialchars($row['softref_key']) . '</td>' .
556 '<td>' . htmlspecialchars($row['sorting']) . '</td>' .
557 '</tr>';
558 }
559 $referenceLine = '';
560 if (count($infoData)) {
561 $referenceLine = '<table class="t3-table">' .
562 '<thead>' . $infoDataHeader . '</thead>' .
563 '<tbody>' .
564 implode('', $infoData) .
565 '</tbody></table>';
566 }
567 return $referenceLine;
568 }
569
570 /**
571 * Make reference display (what this elements points to)
572 *
573 * @param string $table Table name
574 * @param string $ref Filename or uid
575 * @return string HTML
576 */
577 protected function makeRefFrom($table, $ref) {
578 $rows = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows(
579 '*',
580 'sys_refindex',
581 'tablename=' . $GLOBALS['TYPO3_DB']->fullQuoteStr($table, 'sys_refindex') . ' AND recuid=' . (int)$ref
582 );
583
584 // Compile information for title tag:
585 $infoData = array();
586 if (count($rows)) {
587 $infoDataHeader = '<tr class="t3-row-header">' .
588 '<td>&nbsp;</td>' .
589 '<td>' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:show_item.php.field') . '</td>' .
590 '<td>' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:show_item.php.flexpointer') . '</td>' .
591 '<td>' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:show_item.php.softrefKey') . '</td>' .
592 '<td>' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:show_item.php.sorting') . '</td>' .
593 '<td>' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:show_item.php.refTable') . '</td>' .
594 '<td>' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:show_item.php.refUid') . '</td>' .
595 '<td>' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:show_item.php.refString') . '</td>' .
596 '</tr>';
597 }
598 foreach ($rows as $row) {
599 $actions = $this->getRecordActions($row['ref_table'], $row['ref_uid']);
600 $infoData[] = '<tr>' .
601 '<td style="white-space:nowrap;">' . $actions . '</td>' .
602 '<td>' . htmlspecialchars($this->getLabelForTableColumn($table, $row['field'])) . '</td>' .
603 '<td>' . htmlspecialchars($row['flexpointer']) . '</td>' .
604 '<td>' . htmlspecialchars($row['softref_key']) . '</td>' .
605 '<td>' . htmlspecialchars($row['sorting']) . '</td>' .
606 '<td>' . $GLOBALS['LANG']->sL($GLOBALS['TCA'][$row['ref_table']]['ctrl']['title'], TRUE) . '</td>' .
607 '<td>' . htmlspecialchars($row['ref_uid']) . '</td>' .
608 '<td>' . htmlspecialchars($row['ref_string']) . '</td>' .
609 '</tr>';
610 }
611
612 if (empty($infoData)) {
613 return;
614 }
615
616 return '<table class="t3-table">' .
617 '<thead>' . $infoDataHeader . '</thead>' .
618 '<tbody>' .
619 implode('', $infoData) .
620 '</tbody></table>';
621 }
622
623 /**
624 * Convert FAL file reference (sys_file_reference) to reference index (sys_refindex) table format
625 *
626 * @param array $referenceRecord
627 * @return array
628 */
629 protected function transformFileReferenceToRecordReference(array $referenceRecord) {
630 $fileReference = $GLOBALS['TYPO3_DB']->exec_SELECTgetSingleRow(
631 '*',
632 'sys_file_reference',
633 'uid=' . (int)$referenceRecord['recuid']
634 );
635 return array(
636 'recuid' => $fileReference['uid_foreign'],
637 'tablename' => $fileReference['tablenames'],
638 'field' => $fileReference['fieldname'],
639 'flexpointer' => '',
640 'softref_key' => '',
641 'sorting' => $fileReference['sorting_foreign']
642 );
643 }
644
645 }