[TASK] Remove compat layer for new 6.0 classes
[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 foreach ($fieldList as $name) {
328 $name = trim($name);
329 if (!isset($GLOBALS['TCA'][$this->table]['columns'][$name])) {
330 continue;
331 }
332 $isExcluded = !(!$GLOBALS['TCA'][$this->table]['columns'][$name]['exclude'] || $GLOBALS['BE_USER']->check('non_exclude_fields', ($this->table . ':') . $name));
333 if ($isExcluded) {
334 continue;
335 }
336 $uid = $this->row['uid'];
337 $itemValue = \TYPO3\CMS\Backend\Utility\BackendUtility::getProcessedValue($this->table, $name, $this->row[$name], 0, 0, FALSE, $uid);
338 $itemLabel = $GLOBALS['LANG']->sL(\TYPO3\CMS\Backend\Utility\BackendUtility::getItemLabel($this->table, $name), 1);
339 $tableRows[] = ((('
340 <tr>
341 <td class="t3-col-header">' . $itemLabel) . '</td>
342 <td>') . htmlspecialchars($itemValue)) . '</td>
343 </tr>';
344 }
345 // Create table from the information:
346 $tableCode = ('
347 <table border="0" cellpadding="0" cellspacing="0" id="typo3-showitem" class="t3-table-info">
348 ' . implode('', $tableRows)) . '
349 </table>';
350 $this->content .= $this->doc->section('', $tableCode);
351 // References:
352 if ($this->fileObject->isIndexed()) {
353 $header = $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:show_item.php.referencesToThisItem');
354 $this->content .= $this->doc->section($header, $this->makeRef('_FILE', $this->fileObject));
355 }
356 }
357
358 /**
359 * End page and print content
360 *
361 * @return void
362 * @todo Define visibility
363 */
364 public function printContent() {
365 $this->content .= $this->doc->endPage();
366 $this->content = $this->doc->insertStylesAndJS($this->content);
367 echo $this->content;
368 }
369
370 /**
371 * Get table field name
372 *
373 * @param string $tableName Table name
374 * @param string $fieldName Field name
375 * @return string Field name
376 */
377 public function getFieldName($tableName, $fieldName) {
378 \TYPO3\CMS\Core\Utility\GeneralUtility::loadTCA($tableName);
379 if ($GLOBALS['TCA'][$tableName]['columns'][$fieldName]['label'] !== NULL) {
380 $field = $GLOBALS['LANG']->sL($GLOBALS['TCA'][$tableName]['columns'][$fieldName]['label']);
381 if (trim($field) === '') {
382 $field = $fieldName;
383 }
384 } else {
385 $field = $fieldName;
386 }
387 return $field;
388 }
389
390 /**
391 * Returns the rendered record actions
392 *
393 * @param string $table
394 * @param integer $uid
395 * @return string
396 */
397 protected function getRecordActions($table, $uid) {
398 if ($table === '' || $uid < 0) {
399 return '';
400 }
401 $editOnClick = \TYPO3\CMS\Backend\Utility\BackendUtility::editOnClick(((('&edit[' . $table) . '][') . $uid) . ']=edit', $GLOBALS['BACK_PATH']);
402 $icon = \TYPO3\CMS\Backend\Utility\IconUtility::getSpriteIcon('actions-document-open');
403 $pageActionIcons = ((('<a href="#" onclick="' . htmlspecialchars($editOnClick)) . '">') . $icon) . '</a>';
404 $historyOnClick = ((((('window.location.href=\'show_rechis.php?element=' . $table) . '%3A') . $uid) . '&returnUrl=') . rawurlencode(\TYPO3\CMS\Core\Utility\GeneralUtility::getIndpEnv('REQUEST_URI'))) . '\'; return false;';
405 $icon = \TYPO3\CMS\Backend\Utility\IconUtility::getSpriteIcon('actions-document-history-open');
406 $pageActionIcons .= ((('<a href="#" onclick="' . $historyOnClick) . '">') . $icon) . '</a>';
407 if ($table === 'pages') {
408 $pageActionIcons .= $this->doc->viewPageIcon($uid, '');
409 }
410 return $pageActionIcons;
411 }
412
413 /**
414 * Make reference display
415 *
416 * @param string $table Table name
417 * @param string|\TYPO3\CMS\Core\Resource\File $ref Filename or uid
418 * @return string HTML
419 * @todo Define visibility
420 */
421 public function makeRef($table, $ref) {
422 // Look up the path:
423 if ($table === '_FILE') {
424 $rows = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows('*', 'sys_file_reference', 'uid_local=' . $ref->getUid());
425 } else {
426 $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');
427 }
428 // Compile information for title tag:
429 $infoData = array();
430 if (count($rows)) {
431 $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>';
432 }
433 foreach ($rows as $row) {
434 if ($table === '_FILE') {
435 $row = $this->mapFileReferenceOnRefIndex($row);
436 }
437 $record = \TYPO3\CMS\Backend\Utility\BackendUtility::getRecord($row['tablename'], $row['recuid']);
438 $parentRecord = \TYPO3\CMS\Backend\Utility\BackendUtility::getRecord('pages', $record['pid']);
439 $actions = $this->getRecordActions($row['tablename'], $row['recuid']);
440 $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>';
441 }
442 $referenceLine = '';
443 if (count($infoData)) {
444 $referenceLine = ('<table border="0" cellpadding="0" cellspacing="0" class="typo3-dblist">' . implode('', $infoData)) . '</table>';
445 }
446 return $referenceLine;
447 }
448
449 /**
450 * Maps results from the fal file reference table on the
451 * structure of the normal reference index table.
452 *
453 * @param array $fileReference
454 * @return array
455 */
456 protected function mapFileReferenceOnRefIndex(array $fileReference) {
457 return array(
458 'recuid' => $fileReference['uid_foreign'],
459 'tablename' => $fileReference['tablenames'],
460 'field' => $fileReference['fieldname'],
461 'flexpointer' => '',
462 'softref_key' => '',
463 'sorting' => $fileReference['sorting_foreign']
464 );
465 }
466
467 /**
468 * Make reference display (what this elements points to)
469 *
470 * @param string $table Table name
471 * @param string $ref Filename or uid
472 * @return string HTML
473 * @todo Define visibility
474 */
475 public function makeRefFrom($table, $ref) {
476 // Look up the path:
477 // @TODO files not respected (see makeRef)
478 $rows = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows('*', 'sys_refindex', (('tablename=' . $GLOBALS['TYPO3_DB']->fullQuoteStr($table, 'sys_refindex')) . ' AND recuid=') . intval($ref));
479 // Compile information for title tag:
480 $infoData = array();
481 if (count($rows)) {
482 $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>';
483 }
484 foreach ($rows as $row) {
485 $actions = $this->getRecordActions($row['ref_table'], $row['ref_uid']);
486 $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>';
487 }
488 $referenceLine = '';
489 if (count($infoData)) {
490 $referenceLine = ('<table border="0" cellpadding="0" cellspacing="0" class="typo3-dblist">' . implode('', $infoData)) . '</table>';
491 }
492 return $referenceLine;
493 }
494
495 }
496
497
498 ?>