[TASK] Improve show_item for FAL files
[Packages/TYPO3.CMS.git] / typo3 / sysext / backend / Classes / Controller / ContentElement / ElementInformationController.php
1 <?php
2 namespace TYPO3\CMS\Backend\Controller\ContentElement;
3
4 /**
5 * Script Class for showing information about an item.
6 *
7 * @author Kasper Skårhøj <kasperYYYY@typo3.com>
8 * @package TYPO3
9 * @subpackage core
10 */
11 class ElementInformationController {
12
13 /**
14 * GET vars:
15 * Record table (or filename)
16 *
17 * @var string
18 * @todo Define visibility
19 */
20 public $table;
21
22 /**
23 * Record uid (or '' when filename)
24 *
25 * @var int
26 * @todo Define visibility
27 */
28 public $uid;
29
30 /**
31 * Internal, static:
32 * Page select clause
33 *
34 * @var string
35 * @todo Define visibility
36 */
37 public $perms_clause;
38
39 /**
40 * If TRUE, access to element is granted
41 *
42 * @var boolean
43 * @todo Define visibility
44 */
45 public $access;
46
47 /**
48 * Which type of element: "file" or "db"
49 *
50 * @var string
51 * @todo Define visibility
52 */
53 public $type;
54
55 /**
56 * Document Template Object
57 *
58 * @var \TYPO3\CMS\Backend\Template\DocumentTemplate
59 * @todo Define visibility
60 */
61 public $doc;
62
63 /**
64 * Internal, dynamic:
65 * Content Accumulation
66 *
67 * @var string
68 * @todo Define visibility
69 */
70 public $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 * @todo Define visibility
78 */
79 public $pageinfo;
80
81 /**
82 * For type "db": The database record row.
83 *
84 * @var array
85 * @todo Define visibility
86 */
87 public $row;
88
89 /**
90 * The fileObject if present
91 *
92 * @var \TYPO3\CMS\Core\Resource\File
93 */
94 protected $fileObject;
95
96 /**
97 * The folder obejct if present
98 *
99 * @var \TYPO3\CMS\Core\Resource\Folder
100 */
101 protected $folderObject;
102
103 /**
104 * Initialization of the class
105 * Will determine if table/uid GET vars are database record or a file and if
106 * the user has access to view information about the item.
107 *
108 * @return void
109 * @todo Define visibility
110 */
111 public function init() {
112 // Setting input variables.
113 $this->table = \TYPO3\CMS\Core\Utility\GeneralUtility::_GET('table');
114 $this->uid = \TYPO3\CMS\Core\Utility\GeneralUtility::_GET('uid');
115 // Initialize:
116 $this->perms_clause = $GLOBALS['BE_USER']->getPagePermsClause(1);
117 // Set to TRUE if there is access to the record / file.
118 $this->access = FALSE;
119 // Sets the type, "db" or "file". If blank, nothing can be shown.
120 $this->type = '';
121 // Checking if the $table value is really a table and if the user has
122 // access to it.
123 if (isset($GLOBALS['TCA'][$this->table])) {
124 \TYPO3\CMS\Core\Utility\GeneralUtility::loadTCA($this->table);
125 $this->type = 'db';
126 $this->uid = intval($this->uid);
127 // Check permissions and uid value:
128 if ($this->uid && $GLOBALS['BE_USER']->check('tables_select', $this->table)) {
129 if ((string) $this->table == 'pages') {
130 $this->pageinfo = \TYPO3\CMS\Backend\Utility\BackendUtility::readPageAccess($this->uid, $this->perms_clause);
131 $this->access = is_array($this->pageinfo) ? 1 : 0;
132 $this->row = $this->pageinfo;
133 } else {
134 $this->row = \TYPO3\CMS\Backend\Utility\BackendUtility::getRecordWSOL($this->table, $this->uid);
135 if ($this->row) {
136 $this->pageinfo = \TYPO3\CMS\Backend\Utility\BackendUtility::readPageAccess($this->row['pid'], $this->perms_clause);
137 $this->access = is_array($this->pageinfo) ? 1 : 0;
138 }
139 }
140 /** @var $treatData \TYPO3\CMS\Backend\Form\DataPreprocessor */
141 $treatData = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Backend\\Form\\DataPreprocessor');
142 $treatData->renderRecord($this->table, $this->uid, 0, $this->row);
143 }
144 } elseif ($this->table == '_FILE' || $this->table == '_FOLDER' || $this->table == 'sys_file') {
145 $fileOrFolderObject = \TYPO3\CMS\Core\Resource\ResourceFactory::getInstance()->retrieveFileOrFolderObject($this->uid);
146 if ($fileOrFolderObject instanceof \TYPO3\CMS\Core\Resource\Folder) {
147 $this->folderObject = $fileOrFolderObject;
148 $this->access = $this->folderObject->checkActionPermission('read');
149 $this->type = 'folder';
150 } else {
151 $this->fileObject = $fileOrFolderObject;
152 $this->access = $this->fileObject->checkActionPermission('read');
153 $this->type = 'file';
154 $this->table = 'sys_file';
155 \TYPO3\CMS\Core\Utility\GeneralUtility::loadTCA($this->table);
156 try {
157 $this->row = \TYPO3\CMS\Backend\Utility\BackendUtility::getRecordWSOL($this->table, $this->fileObject->getUid());
158 } catch (\Exception $e) {
159 $this->row = array();
160 }
161 }
162 }
163 // Initialize document template object:
164 $this->doc = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Backend\\Template\\DocumentTemplate');
165 $this->doc->backPath = $GLOBALS['BACK_PATH'];
166 // Starting the page by creating page header stuff:
167 $this->content .= $this->doc->startPage($GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:show_item.php.viewItem'));
168 $this->content .= '<h3 class="t3-row-header">' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:show_item.php.viewItem') . '</h3>';
169 $this->content .= $this->doc->spacer(5);
170 }
171
172 /**
173 * Main function. Will generate the information to display for the item
174 * set internally.
175 *
176 * @return void
177 * @todo Define visibility
178 */
179 public function main() {
180 if (!$this->access) {
181 return;
182 }
183 $returnLink = \TYPO3\CMS\Core\Utility\GeneralUtility::sanitizeLocalUrl(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('returnUrl'));
184 $returnLinkTag = $returnLink ? '<a href="' . $returnLink . '" class="typo3-goBack">' : '<a href="#" onclick="window.close();">';
185 // render type by user func
186 $typeRendered = FALSE;
187 if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/show_item.php']['typeRendering'])) {
188 foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/show_item.php']['typeRendering'] as $classRef) {
189 $typeRenderObj = \TYPO3\CMS\Core\Utility\GeneralUtility::getUserObj($classRef);
190 // @TODO should have an interface
191 if (is_object($typeRenderObj) && method_exists($typeRenderObj, 'isValid') && method_exists($typeRenderObj, 'render')) {
192 if ($typeRenderObj->isValid($this->type, $this)) {
193 $this->content .= $typeRenderObj->render($this->type, $this);
194 $typeRendered = TRUE;
195 break;
196 }
197 }
198 }
199 }
200 // If type was not rendered use default rendering functions
201 if (!$typeRendered) {
202 // Branch out based on type:
203 switch ($this->type) {
204 case 'db':
205 $this->renderDBInfo();
206 break;
207 case 'file':
208 $this->renderFileInfo($returnLinkTag);
209 break;
210 case 'folder':
211 // @todo: implement an info about a folder
212 break;
213 }
214 }
215 // If return Url is set, output link to go back:
216 if (\TYPO3\CMS\Core\Utility\GeneralUtility::sanitizeLocalUrl(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('returnUrl'))) {
217 $this->content = $this->doc->section('', ($returnLinkTag . '<strong>' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:labels.goBack', 1) . '</strong></a><br /><br />')) . $this->content;
218 $this->content .= $this->doc->section('', '<br />' . $returnLinkTag . '<strong>' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:labels.goBack', 1) . '</strong></a>');
219 }
220 }
221
222 /**
223 * Main function. Will generate the information to display for the item
224 * set internally.
225 *
226 * @return void
227 * @todo Define visibility
228 */
229 public function renderDBInfo() {
230 // Print header, path etc:
231 // @TODO invalid context menu code in the output
232 $code = $this->doc->getHeader($this->table, $this->row, $this->pageinfo['_thePath'], 1) . '<br />';
233 $this->content .= $this->doc->section('', $code);
234 $tableRows = array();
235 $extraFields = array(
236 'crdate' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_general.xml:LGL.creationDate', 1),
237 'cruser_id' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_general.xml:LGL.creationUserId', 1),
238 'tstamp' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_general.xml:LGL.timestamp', 1)
239 );
240 foreach ($extraFields as $name => $value) {
241 $rowValue = \TYPO3\CMS\Backend\Utility\BackendUtility::getProcessedValueExtra($this->table, $name, $this->row[$name]);
242 if ($name === 'cruser_id' && $rowValue) {
243 $userTemp = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows('username, realName', 'be_users', 'uid = ' . intval($rowValue));
244 if ($userTemp[0]['username'] !== '') {
245 $rowValue = $userTemp[0]['username'];
246 if ($userTemp[0]['realName'] !== '') {
247 $rowValue .= ' - ' . $userTemp[0]['realName'];
248 }
249 }
250 }
251 $tableRows[] = '
252 <tr>
253 <td class="t3-col-header">' . $value . '</td>
254 <td>' . htmlspecialchars($rowValue) . '</td>
255 </tr>';
256 }
257 // Traverse the list of fields to display for the record:
258 $fieldList = \TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode(',', $GLOBALS['TCA'][$this->table]['interface']['showRecordFieldList'], 1);
259 foreach ($fieldList as $name) {
260 $name = trim($name);
261 if (!isset($GLOBALS['TCA'][$this->table]['columns'][$name])) {
262 continue;
263 }
264 $isExcluded = !(!$GLOBALS['TCA'][$this->table]['columns'][$name]['exclude'] || $GLOBALS['BE_USER']->check('non_exclude_fields', $this->table . ':' . $name));
265 if ($isExcluded) {
266 continue;
267 }
268 $uid = $this->row['uid'];
269 $itemValue = \TYPO3\CMS\Backend\Utility\BackendUtility::getProcessedValue($this->table, $name, $this->row[$name], 0, 0, FALSE, $uid);
270 $itemLabel = $GLOBALS['LANG']->sL(\TYPO3\CMS\Backend\Utility\BackendUtility::getItemLabel($this->table, $name), 1);
271 $tableRows[] = '
272 <tr>
273 <td class="t3-col-header">' . $itemLabel . '</td>
274 <td>' . htmlspecialchars($itemValue) . '</td>
275 </tr>';
276 }
277 // Create table from the information:
278 $tableCode = '
279 <table border="0" cellpadding="0" cellspacing="0" id="typo3-showitem" class="t3-table-info">
280 ' . implode('', $tableRows) . '
281 </table>';
282 $this->content .= $this->doc->section('', $tableCode);
283 // Add path and table information in the bottom:
284 $code = '';
285 $code .= $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:labels.path') . ': ' . \TYPO3\CMS\Core\Utility\GeneralUtility::fixed_lgd_cs($this->pageinfo['_thePath'], -48) . '<br />';
286 $code .= $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:labels.table') . ': ' . $GLOBALS['LANG']->sL($GLOBALS['TCA'][$this->table]['ctrl']['title']) . ' (' . $this->table . ') - UID: ' . $this->uid . '<br />';
287 $this->content .= $this->doc->section('', $code);
288 // References:
289 $this->content .= $this->doc->section($GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:show_item.php.referencesToThisItem'), $this->makeRef($this->table, $this->row['uid']));
290 $this->content .= $this->doc->section($GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:show_item.php.referencesFromThisItem'), $this->makeRefFrom($this->table, $this->row['uid']));
291 }
292
293 /**
294 * Main function. Will generate the information to display for the item
295 * set internally.
296 *
297 * @param string $returnLinkTag <a> tag closing/returning.
298 * @return void
299 * @todo Define visibility
300 */
301 public function renderFileInfo($returnLinkTag) {
302 $fileExtension = $this->fileObject->getExtension();
303 $code = '<div class="fileInfoContainer">' . \TYPO3\CMS\Backend\Utility\IconUtility::getSpriteIconForFile($fileExtension) . '<strong>' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:show_item.php.file', TRUE) . ':</strong> ' . $this->fileObject->getName() . '&nbsp;&nbsp;' . '<strong>' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:show_item.php.filesize') . ':</strong> ' . \TYPO3\CMS\Core\Utility\GeneralUtility::formatSize($this->fileObject->getSize()) . '</div>
304 ';
305 $this->content .= $this->doc->section('', $code);
306 $this->content .= $this->doc->divider(2);
307 // If the file was an image...
308 // @todo: add this check in the domain model, or in the processing folder
309 if (\TYPO3\CMS\Core\Utility\GeneralUtility::inList($GLOBALS['TYPO3_CONF_VARS']['GFX']['imagefile_ext'], $fileExtension)) {
310 // @todo: find a way to make getimagesize part of the t3lib_file object
311 $imgInfo = @getimagesize($this->fileObject->getForLocalProcessing(FALSE));
312 $thumbUrl = $this->fileObject->process(\TYPO3\CMS\Core\Resource\ProcessedFile::CONTEXT_IMAGEPREVIEW, array('width' => '150m', 'height' => '150m'))->getPublicUrl(TRUE);
313 $code = '<div class="fileInfoContainer fileDimensions">' . '<strong>' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:show_item.php.dimensions') . ':</strong> ' . $imgInfo[0] . 'x' . $imgInfo[1] . ' ' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:show_item.php.pixels') . '</div>';
314 $code .= '<br />
315 <div align="center">' . $returnLinkTag . '<img src="' . $thumbUrl . '" alt="' . htmlspecialchars(trim($this->fileObject->getName())) . '" title="' . htmlspecialchars(trim($this->fileObject->getName())) . '" /></a></div>';
316 $this->content .= $this->doc->section('', $code);
317 } elseif ($fileExtension == 'ttf') {
318 $thumbUrl = $this->fileObject->process(\TYPO3\CMS\Core\Resource\ProcessedFile::CONTEXT_IMAGEPREVIEW, array('width' => '530m', 'height' => '600m'))->getPublicUrl(TRUE);
319 $thumb = '<br />
320 <div align="center">' . $returnLinkTag . '<img src="' . $thumbUrl . '" border="0" title="' . htmlspecialchars(trim($this->fileObject->getName())) . '" alt="" /></a></div>';
321 $this->content .= $this->doc->section('', $thumb);
322 }
323 // Traverse the list of fields to display for the record:
324 $tableRows = array();
325 $showRecordFieldList = $GLOBALS['TCA'][$this->table]['interface']['showRecordFieldList'];
326 $fieldList = \TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode(',', $showRecordFieldList, TRUE);
327
328 foreach ($fieldList as $name) {
329 // Ignored fields
330 if ($name === 'size') {
331 continue;
332 }
333 if (!isset($GLOBALS['TCA'][$this->table]['columns'][$name])) {
334 continue;
335 }
336 $isExcluded = !(!$GLOBALS['TCA'][$this->table]['columns'][$name]['exclude'] || $GLOBALS['BE_USER']->check('non_exclude_fields', $this->table . ':' . $name));
337 if ($isExcluded) {
338 continue;
339 }
340 $uid = $this->row['uid'];
341 $itemValue = \TYPO3\CMS\Backend\Utility\BackendUtility::getProcessedValue($this->table, $name, $this->row[$name], 0, 0, FALSE, $uid);
342 $itemLabel = $GLOBALS['LANG']->sL(\TYPO3\CMS\Backend\Utility\BackendUtility::getItemLabel($this->table, $name), 1);
343 $tableRows[] = '
344 <tr>
345 <td class="t3-col-header">' . $itemLabel . '</td>
346 <td>' . htmlspecialchars($itemValue) . '</td>
347 </tr>';
348 }
349 // Create table from the information:
350 $tableCode = '
351 <table border="0" cellpadding="0" cellspacing="0" id="typo3-showitem" class="t3-table-info">
352 ' . implode('', $tableRows) . '
353 </table>';
354 $this->content .= $this->doc->section('', $tableCode);
355 // References:
356 if ($this->fileObject->isIndexed()) {
357 $header = $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:show_item.php.referencesToThisItem');
358 $this->content .= $this->doc->section($header, $this->makeRef('_FILE', $this->fileObject));
359 }
360 }
361
362 /**
363 * End page and print content
364 *
365 * @return void
366 * @todo Define visibility
367 */
368 public function printContent() {
369 $this->content .= $this->doc->endPage();
370 $this->content = $this->doc->insertStylesAndJS($this->content);
371 echo $this->content;
372 }
373
374 /**
375 * Get table field name
376 *
377 * @param string $tableName Table name
378 * @param string $fieldName Field name
379 * @return string Field name
380 */
381 public function getFieldName($tableName, $fieldName) {
382 \TYPO3\CMS\Core\Utility\GeneralUtility::loadTCA($tableName);
383 if ($GLOBALS['TCA'][$tableName]['columns'][$fieldName]['label'] !== NULL) {
384 $field = $GLOBALS['LANG']->sL($GLOBALS['TCA'][$tableName]['columns'][$fieldName]['label']);
385 if (trim($field) === '') {
386 $field = $fieldName;
387 }
388 } else {
389 $field = $fieldName;
390 }
391 return $field;
392 }
393
394 /**
395 * Returns the rendered record actions
396 *
397 * @param string $table
398 * @param integer $uid
399 * @return string
400 */
401 protected function getRecordActions($table, $uid) {
402 if ($table === '' || $uid < 0) {
403 return '';
404 }
405 $editOnClick = \TYPO3\CMS\Backend\Utility\BackendUtility::editOnClick('&edit[' . $table . '][' . $uid . ']=edit', $GLOBALS['BACK_PATH']);
406 $icon = \TYPO3\CMS\Backend\Utility\IconUtility::getSpriteIcon('actions-document-open');
407 $pageActionIcons = '<a href="#" onclick="' . htmlspecialchars($editOnClick) . '">' . $icon . '</a>';
408 $historyOnClick = 'window.location.href=\'show_rechis.php?element=' . $table . '%3A' . $uid . '&returnUrl=' . rawurlencode(\TYPO3\CMS\Core\Utility\GeneralUtility::getIndpEnv('REQUEST_URI')) . '\'; return false;';
409 $icon = \TYPO3\CMS\Backend\Utility\IconUtility::getSpriteIcon('actions-document-history-open');
410 $pageActionIcons .= '<a href="#" onclick="' . $historyOnClick . '">' . $icon . '</a>';
411 if ($table === 'pages') {
412 $pageActionIcons .= $this->doc->viewPageIcon($uid, '');
413 }
414 return $pageActionIcons;
415 }
416
417 /**
418 * Make reference display
419 *
420 * @param string $table Table name
421 * @param string|\TYPO3\CMS\Core\Resource\File $ref Filename or uid
422 * @return string HTML
423 * @todo Define visibility
424 */
425 public function makeRef($table, $ref) {
426 // Look up the path:
427 if ($table === '_FILE') {
428 $rows = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows('*', 'sys_file_reference', 'uid_local=' . $ref->getUid());
429 } else {
430 $rows = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows('*', 'sys_refindex', 'ref_table=' . $GLOBALS['TYPO3_DB']->fullQuoteStr($table, 'sys_refindex') . ' AND ref_uid=' . intval($ref) . ' AND deleted=0');
431 }
432 // Compile information for title tag:
433 $infoData = array();
434 if (count($rows)) {
435 $infoData[] = '<tr class="t3-row-header">' . '<td>&nbsp;</td>' . '<td>' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:show_item.php.table') . '</td>' . '<td>' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:show_item.php.title') . '</td>' . '<td>[uid]</td>' . '<td>' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:show_item.php.field') . '</td>' . '<td>' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:show_item.php.flexpointer') . '</td>' . '<td>' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:show_item.php.softrefKey') . '</td>' . '<td>' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:show_item.php.sorting') . '</td>' . '</tr>';
436 }
437 foreach ($rows as $row) {
438 if ($table === '_FILE') {
439 $row = $this->mapFileReferenceOnRefIndex($row);
440 }
441 $record = \TYPO3\CMS\Backend\Utility\BackendUtility::getRecord($row['tablename'], $row['recuid']);
442 $parentRecord = \TYPO3\CMS\Backend\Utility\BackendUtility::getRecord('pages', $record['pid']);
443 $actions = $this->getRecordActions($row['tablename'], $row['recuid']);
444 $infoData[] = '<tr class="bgColor4">' . '<td style="white-space:nowrap;">' . $actions . '</td>' . '<td>' . $GLOBALS['LANG']->sL($GLOBALS['TCA'][$row['tablename']]['ctrl']['title'], TRUE) . '</td>' . '<td>' . \TYPO3\CMS\Backend\Utility\BackendUtility::getRecordTitle($row['tablename'], $record, TRUE) . '</td>' . '<td><span title="' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_common.xlf:page') . ': ' . htmlspecialchars(\TYPO3\CMS\Backend\Utility\BackendUtility::getRecordTitle('pages', $parentRecord)) . ' (uid=' . $record['pid'] . ')">' . $record['uid'] . '</span></td>' . '<td>' . htmlspecialchars($this->getFieldName($row['tablename'], $row['field'])) . '</td>' . '<td>' . htmlspecialchars($row['flexpointer']) . '</td>' . '<td>' . htmlspecialchars($row['softref_key']) . '</td>' . '<td>' . htmlspecialchars($row['sorting']) . '</td>' . '</tr>';
445 }
446 $referenceLine = '';
447 if (count($infoData)) {
448 $referenceLine = '<table border="0" cellpadding="0" cellspacing="0" class="typo3-dblist">' . implode('', $infoData) . '</table>';
449 }
450 return $referenceLine;
451 }
452
453 /**
454 * Maps results from the fal file reference table on the
455 * structure of the normal reference index table.
456 *
457 * @param array $fileReference
458 * @return array
459 */
460 protected function mapFileReferenceOnRefIndex(array $fileReference) {
461 return array(
462 'recuid' => $fileReference['uid_foreign'],
463 'tablename' => $fileReference['tablenames'],
464 'field' => $fileReference['fieldname'],
465 'flexpointer' => '',
466 'softref_key' => '',
467 'sorting' => $fileReference['sorting_foreign']
468 );
469 }
470
471 /**
472 * Make reference display (what this elements points to)
473 *
474 * @param string $table Table name
475 * @param string $ref Filename or uid
476 * @return string HTML
477 * @todo Define visibility
478 */
479 public function makeRefFrom($table, $ref) {
480 // Look up the path:
481 // @TODO files not respected (see makeRef)
482 $rows = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows('*', 'sys_refindex', 'tablename=' . $GLOBALS['TYPO3_DB']->fullQuoteStr($table, 'sys_refindex') . ' AND recuid=' . intval($ref));
483 // Compile information for title tag:
484 $infoData = array();
485 if (count($rows)) {
486 $infoData[] = '<tr class="t3-row-header">' . '<td>&nbsp;</td>' . '<td>' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:show_item.php.field') . '</td>' . '<td>' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:show_item.php.flexpointer') . '</td>' . '<td>' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:show_item.php.softrefKey') . '</td>' . '<td>' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:show_item.php.sorting') . '</td>' . '<td>' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:show_item.php.refTable') . '</td>' . '<td>' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:show_item.php.refUid') . '</td>' . '<td>' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:show_item.php.refString') . '</td>' . '</tr>';
487 }
488 foreach ($rows as $row) {
489 $actions = $this->getRecordActions($row['ref_table'], $row['ref_uid']);
490 $infoData[] = '<tr class="bgColor4">' . '<td style="white-space:nowrap;">' . $actions . '</td>' . '<td>' . htmlspecialchars($this->getFieldName($table, $row['field'])) . '</td>' . '<td>' . htmlspecialchars($row['flexpointer']) . '</td>' . '<td>' . htmlspecialchars($row['softref_key']) . '</td>' . '<td>' . htmlspecialchars($row['sorting']) . '</td>' . '<td>' . $GLOBALS['LANG']->sL($GLOBALS['TCA'][$row['ref_table']]['ctrl']['title'], TRUE) . '</td>' . '<td>' . htmlspecialchars($row['ref_uid']) . '</td>' . '<td>' . htmlspecialchars($row['ref_string']) . '</td>' . '</tr>';
491 }
492 $referenceLine = '';
493 if (count($infoData)) {
494 $referenceLine = '<table border="0" cellpadding="0" cellspacing="0" class="typo3-dblist">' . implode('', $infoData) . '</table>';
495 }
496 return $referenceLine;
497 }
498
499 }
500
501
502 ?>