[FEATURE] Improve the info popup
[Packages/TYPO3.CMS.git] / typo3 / show_item.php
1 <?php
2 /***************************************************************
3 * Copyright notice
4 *
5 * (c) 1999-2012 Kasper Skårhøj (kasperYYYY@typo3.com)
6 * All rights reserved
7 *
8 * This script is part of the TYPO3 project. The TYPO3 project is
9 * free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
13 *
14 * The GNU General Public License can be found at
15 * http://www.gnu.org/copyleft/gpl.html.
16 * A copy is found in the textfile GPL.txt and important notices to the license
17 * from the author is found in LICENSE.txt distributed with these scripts.
18 *
19 *
20 * This script is distributed in the hope that it will be useful,
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 * GNU General Public License for more details.
24 *
25 * This copyright notice MUST APPEAR in all copies of the script!
26 ***************************************************************/
27
28 $GLOBALS['BACK_PATH'] = '';
29 require_once('init.php');
30
31 /**
32 * Extension of transfer data class
33 *
34 * @author Kasper Skårhøj <kasperYYYY@typo3.com>
35 * @package TYPO3
36 * @subpackage core
37 */
38 class transferData extends t3lib_transferData {
39 /**
40 * @var string
41 */
42 var $formname = 'loadform';
43
44 /**
45 * @var boolean
46 */
47 var $loading = 1;
48
49 /**
50 * Extra for show_item.php:
51 *
52 * @var array
53 */
54 var $theRecord = array();
55
56 /**
57 * Register item function.
58 *
59 * @param string $table Table name
60 * @param integer $id Record uid
61 * @param string $field Field name
62 * @param string $content Content string.
63 * @return void
64 */
65 function regItem($table, $id, $field, $content) {
66 t3lib_div::loadTCA($table);
67 $config = $GLOBALS['TCA'][$table]['columns'][$field]['config'];
68 switch($config['type']) {
69 case 'input':
70 if (isset($config['checkbox']) && $content == $config['checkbox']) {
71 $content = '';
72 break;
73 }
74 if (t3lib_div::inList($config['eval'], 'date')) {
75 $content = date($GLOBALS['TYPO3_CONF_VARS']['SYS']['ddmmyy'], $content);
76 }
77 break;
78
79 case 'group':
80 case 'select':
81 break;
82 }
83
84 $this->theRecord[$field] = $content;
85 }
86 }
87
88 /**
89 * Script Class for showing information about an item.
90 *
91 * @author Kasper Skårhøj <kasperYYYY@typo3.com>
92 * @package TYPO3
93 * @subpackage core
94 */
95 class SC_show_item {
96 /**
97 * GET vars:
98 * Record table (or filename)
99 *
100 * @var string
101 */
102 var $table;
103
104 /**
105 * Record uid (or '' when filename)
106 *
107 * @var int
108 */
109 var $uid;
110
111 /**
112 * Internal, static:
113 * Page select clause
114 *
115 * @var string
116 */
117 var $perms_clause;
118
119 /**
120 * If TRUE, access to element is granted
121 *
122 * @var boolean
123 */
124 var $access;
125
126 /**
127 * Which type of element: "file" or "db"
128 *
129 * @var string
130 */
131 var $type;
132
133 /**
134 * Document Template Object
135 *
136 * @var template
137 */
138 var $doc;
139
140 /**
141 * Internal, dynamic:
142 * Content Accumulation
143 *
144 * @var string
145 */
146 var $content;
147
148 /**
149 * For type "db": Set to page record of the parent page of the item set
150 * (if type="db")
151 *
152 * @var array
153 */
154 var $pageinfo;
155
156 /**
157 * For type "db": The database record row.
158 *
159 * @var array
160 */
161 var $row;
162
163 /**
164 * The fileObject if present
165 *
166 * @var t3lib_file_File
167 */
168 protected $fileObject;
169
170 /**
171 * The folder obejct if present
172 *
173 * @var t3lib_file_Folder
174 */
175 protected $folderObject;
176
177 /**
178 * Initialization of the class
179 * Will determine if table/uid GET vars are database record or a file and if
180 * the user has access to view information about the item.
181 *
182 * @return void
183 */
184 function init() {
185 // Setting input variables.
186 $this->table = t3lib_div::_GET('table');
187 $this->uid = t3lib_div::_GET('uid');
188
189 // Initialize:
190 $this->perms_clause = $GLOBALS['BE_USER']->getPagePermsClause(1);
191 // Set to TRUE if there is access to the record / file.
192 $this->access = FALSE;
193 // Sets the type, "db" or "file". If blank, nothing can be shown.
194 $this->type = '';
195
196 // Checking if the $table value is really a table and if the user has
197 // access to it.
198 if (isset($GLOBALS['TCA'][$this->table])) {
199 t3lib_div::loadTCA($this->table);
200 $this->type = 'db';
201 $this->uid = intval($this->uid);
202
203 // Check permissions and uid value:
204 if ($this->uid && $GLOBALS['BE_USER']->check('tables_select', $this->table)) {
205 if ((string)$this->table == 'pages') {
206 $this->pageinfo = t3lib_BEfunc::readPageAccess($this->uid, $this->perms_clause);
207 $this->access = (is_array($this->pageinfo) ? 1 : 0);
208 $this->row = $this->pageinfo;
209 } else {
210 $this->row = t3lib_BEfunc::getRecordWSOL($this->table, $this->uid);
211 if ($this->row) {
212 $this->pageinfo = t3lib_BEfunc::readPageAccess($this->row['pid'], $this->perms_clause);
213 $this->access = (is_array($this->pageinfo) ? 1 : 0);
214 }
215 }
216
217 /** @var $treatData t3lib_transferData */
218 $treatData = t3lib_div::makeInstance('t3lib_transferData');
219 $treatData->renderRecord($this->table, $this->uid, 0, $this->row);
220 }
221
222 } elseif ($this->table == '_FILE' || $this->table == '_FOLDER' || $this->table == 'sys_file') {
223 $fileOrFolderObject = t3lib_file_Factory::getInstance()->retrieveFileOrFolderObject($this->uid);
224
225 if ($fileOrFolderObject instanceof t3lib_file_Folder) {
226 $this->folderObject = $fileOrFolderObject;
227 $this->access = $this->folderObject->checkActionPermission('read');
228 $this->type = 'folder';
229 } else {
230 $this->fileObject = $fileOrFolderObject;
231 $this->access = $this->fileObject->checkActionPermission('read');
232 $this->type = 'file';
233 $this->table = 'sys_file';
234 t3lib_div::loadTCA($this->table);
235
236 try {
237 $this->row = t3lib_BEfunc::getRecordWSOL($this->table, $this->fileObject->getUid());
238 } catch (Exception $e) {
239 $this->row = array();
240 }
241 }
242 }
243
244 // Initialize document template object:
245 $this->doc = t3lib_div::makeInstance('template');
246 $this->doc->backPath = $GLOBALS['BACK_PATH'];
247
248 // Starting the page by creating page header stuff:
249 $this->content .= $this->doc->startPage(
250 $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:show_item.php.viewItem')
251 );
252
253 $this->content .= '<h3 class="t3-row-header">' .
254 $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:show_item.php.viewItem') . '</h3>';
255 $this->content .= $this->doc->spacer(5);
256 }
257
258 /**
259 * Main function. Will generate the information to display for the item
260 * set internally.
261 *
262 * @return void
263 */
264 function main() {
265 if (!$this->access) {
266 return;
267 }
268
269 $returnLink = t3lib_div::sanitizeLocalUrl(t3lib_div::_GP('returnUrl'));
270 $returnLinkTag = $returnLink ? '<a href="' . $returnLink .
271 '" class="typo3-goBack">' : '<a href="#" onclick="window.close();">';
272
273 // render type by user func
274 $typeRendered = FALSE;
275 if (is_array ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/show_item.php']['typeRendering'])) {
276 foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/show_item.php']['typeRendering'] as $classRef) {
277 $typeRenderObj = t3lib_div::getUserObj($classRef);
278 // @TODO should have an interface
279 if (is_object($typeRenderObj) && method_exists($typeRenderObj, 'isValid')
280 && method_exists($typeRenderObj, 'render')
281 ) {
282 if ($typeRenderObj->isValid($this->type, $this)) {
283 $this->content .= $typeRenderObj->render($this->type, $this);
284 $typeRendered = TRUE;
285 break;
286 }
287 }
288 }
289 }
290
291 // If type was not rendered use default rendering functions
292 if (!$typeRendered) {
293 // Branch out based on type:
294 switch ($this->type) {
295 case 'db':
296 $this->renderDBInfo();
297 break;
298 case 'file':
299 $this->renderFileInfo($returnLinkTag);
300 break;
301 case 'folder':
302 // @todo: implement an info about a folder
303 break;
304 }
305 }
306
307 // If return Url is set, output link to go back:
308 if (t3lib_div::sanitizeLocalUrl(t3lib_div::_GP('returnUrl'))) {
309 $this->content = $this->doc->section(
310 '',
311 $returnLinkTag .
312 '<strong>'.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:labels.goBack', 1) .
313 '</strong></a><br /><br />'
314 ) . $this->content;
315
316 $this->content .= $this->doc->section(
317 '',
318 '<br />' . $returnLinkTag .
319 '<strong>' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:labels.goBack', 1) .
320 '</strong></a>'
321 );
322 }
323 }
324
325 /**
326 * Main function. Will generate the information to display for the item
327 * set internally.
328 *
329 * @return void
330 */
331 function renderDBInfo() {
332 // Print header, path etc:
333 // @TODO invalid context menu code in the output
334 $code = $this->doc->getHeader($this->table, $this->row, $this->pageinfo['_thePath'], 1) . '<br />';
335 $this->content .= $this->doc->section('', $code);
336 $tableRows = array();
337
338 $extraFields = array(
339 'crdate' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_general.xml:LGL.creationDate', 1),
340 'cruser_id' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_general.xml:LGL.creationUserId', 1),
341 'tstamp' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_general.xml:LGL.timestamp', 1)
342 );
343
344 foreach ($extraFields as $name => $value) {
345 $rowValue = t3lib_BEfunc::getProcessedValueExtra($this->table, $name, $this->row[$name]);
346
347 if ($name === 'cruser_id' && $rowValue) {
348 $userTemp = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows(
349 'username, realName',
350 'be_users',
351 'uid = ' . intval($rowValue)
352 );
353
354 if ($userTemp[0]['username'] !== '') {
355 $rowValue = $userTemp[0]['username'];
356 if ($userTemp[0]['realName'] !== '') {
357 $rowValue .= ' - '.$userTemp[0]['realName'];
358 }
359 }
360 }
361
362 $tableRows[] = '
363 <tr>
364 <td class="t3-col-header">' . $value . '</td>
365 <td>' . htmlspecialchars($rowValue) . '</td>
366 </tr>';
367 }
368
369 // Traverse the list of fields to display for the record:
370 $fieldList = t3lib_div::trimExplode(',', $GLOBALS['TCA'][$this->table]['interface']['showRecordFieldList'], 1);
371 foreach ($fieldList as $name) {
372 $name = trim($name);
373 if (!isset($GLOBALS['TCA'][$this->table]['columns'][$name])) {
374 continue;
375 }
376
377 $isExcluded = !(!$GLOBALS['TCA'][$this->table]['columns'][$name]['exclude'] ||
378 $GLOBALS['BE_USER']->check('non_exclude_fields', $this->table . ':' . $name));
379 if ($isExcluded) {
380 continue;
381 }
382
383 $uid = $this->row['uid'];
384 $itemValue = t3lib_BEfunc::getProcessedValue($this->table, $name, $this->row[$name], 0, 0, FALSE, $uid);
385 $itemLabel = $GLOBALS['LANG']->sL(t3lib_BEfunc::getItemLabel($this->table, $name), 1);
386 $tableRows[] = '
387 <tr>
388 <td class="t3-col-header">' . $itemLabel . '</td>
389 <td>' . htmlspecialchars($itemValue) . '</td>
390 </tr>';
391 }
392
393 // Create table from the information:
394 $tableCode = '
395 <table border="0" cellpadding="0" cellspacing="0" id="typo3-showitem" class="t3-table-info">
396 '.implode('', $tableRows).'
397 </table>';
398 $this->content .= $this->doc->section('', $tableCode);
399
400 // Add path and table information in the bottom:
401 $code = '';
402 $code .= $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:labels.path') . ': ' .
403 t3lib_div::fixed_lgd_cs($this->pageinfo['_thePath'], -48) . '<br />';
404 $code .= $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:labels.table') . ': ' .
405 $GLOBALS['LANG']->sL($GLOBALS['TCA'][$this->table]['ctrl']['title']) .
406 ' (' . $this->table . ') - UID: ' . $this->uid . '<br />';
407 $this->content .= $this->doc->section('', $code);
408
409 // References:
410 $this->content .= $this->doc->section(
411 $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:show_item.php.referencesToThisItem'),
412 $this->makeRef($this->table, $this->row['uid'])
413 );
414
415 $this->content .= $this->doc->section(
416 $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:show_item.php.referencesFromThisItem'),
417 $this->makeRefFrom($this->table, $this->row['uid'])
418 );
419 }
420
421 /**
422 * Main function. Will generate the information to display for the item
423 * set internally.
424 *
425 * @param string $returnLinkTag <a> tag closing/returning.
426 * @return void
427 */
428 function renderFileInfo($returnLinkTag) {
429 $fileExtension = $this->fileObject->getExtension();
430 $code = '<div class="fileInfoContainer">' .
431 t3lib_iconWorks::getSpriteIconForFile($fileExtension) .
432 '<strong>' .
433 $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:show_item.php.file', TRUE) .
434 ':</strong> ' . $this->fileObject->getName() .
435 '&nbsp;&nbsp;' .
436 '<strong>' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:show_item.php.filesize') .
437 ':</strong> ' .
438 t3lib_div::formatSize($this->fileObject->getSize()) .
439 '</div>
440 ';
441 $this->content .= $this->doc->section('', $code);
442 $this->content .= $this->doc->divider(2);
443
444 // If the file was an image...
445 // @todo: add this check in the domain model, or in the processing folder
446 if (t3lib_div::inList($GLOBALS['TYPO3_CONF_VARS']['GFX']['imagefile_ext'], $fileExtension)) {
447 // @todo: find a way to make getimagesize part of the t3lib_file object
448 $imgInfo = @getimagesize($this->fileObject->getForLocalProcessing(FALSE));
449
450 $thumbUrl = $this->fileObject->process(
451 t3lib_file_ProcessedFile::CONTEXT_IMAGEPREVIEW,
452 array('width' => '150m', 'height' => '150m')
453 )->getPublicUrl(TRUE);
454
455 $code = '<div class="fileInfoContainer fileDimensions">' .
456 '<strong>' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:show_item.php.dimensions') .
457 ':</strong> ' . $imgInfo[0] . 'x' . $imgInfo[1] . ' ' .
458 $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:show_item.php.pixels') . '</div>';
459
460 $code .= '<br />
461 <div align="center">' . $returnLinkTag . '<img src="' . $thumbUrl . '" alt="' .
462 htmlspecialchars(trim($this->fileObject->getName())) . '" title="' .
463 htmlspecialchars(trim($this->fileObject->getName())) . '" /></a></div>';
464 $this->content .= $this->doc->section('', $code);
465
466 } elseif ($fileExtension == 'ttf') {
467 $thumbUrl = $this->fileObject->process(
468 t3lib_file_ProcessedFile::CONTEXT_IMAGEPREVIEW,
469 array('width' => '530m', 'height' => '600m')
470 )->getPublicUrl(TRUE);
471
472 $thumb = '<br />
473 <div align="center">' . $returnLinkTag . '<img src="' . $thumbUrl . '" border="0" title="' .
474 htmlspecialchars(trim($this->fileObject->getName())) . '" alt="" /></a></div>';
475 $this->content .= $this->doc->section('', $thumb);
476 }
477
478 // Traverse the list of fields to display for the record:
479 $tableRows = array();
480 $showRecordFieldList = $GLOBALS['TCA'][$this->table]['interface']['showRecordFieldList'];
481 $fieldList = t3lib_div::trimExplode(',', $showRecordFieldList, TRUE);
482 foreach ($fieldList as $name) {
483 $name = trim($name);
484 if (!isset($GLOBALS['TCA'][$this->table]['columns'][$name])) {
485 continue;
486 }
487
488 $isExcluded = !(!$GLOBALS['TCA'][$this->table]['columns'][$name]['exclude'] ||
489 $GLOBALS['BE_USER']->check('non_exclude_fields', $this->table . ':' . $name));
490 if ($isExcluded) {
491 continue;
492 }
493
494 $uid = $this->row['uid'];
495 $itemValue = t3lib_BEfunc::getProcessedValue($this->table, $name, $this->row[$name], 0, 0, FALSE, $uid);
496 $itemLabel = $GLOBALS['LANG']->sL(t3lib_BEfunc::getItemLabel($this->table, $name), 1);
497 $tableRows[] = '
498 <tr>
499 <td class="t3-col-header">' . $itemLabel . '</td>
500 <td>' . htmlspecialchars($itemValue) . '</td>
501 </tr>';
502 }
503
504 // Create table from the information:
505 $tableCode = '
506 <table border="0" cellpadding="0" cellspacing="0" id="typo3-showitem" class="t3-table-info">
507 ' . implode('', $tableRows) . '
508 </table>';
509 $this->content .= $this->doc->section('', $tableCode);
510
511 // References:
512 if ($this->fileObject->isIndexed()) {
513 $header = $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:show_item.php.referencesToThisItem');
514 $this->content .= $this->doc->section($header, $this->makeRef('_FILE', $this->fileObject));
515 }
516 }
517
518 /**
519 * End page and print content
520 *
521 * @return void
522 */
523 function printContent() {
524 $this->content .= $this->doc->endPage();
525 $this->content = $this->doc->insertStylesAndJS($this->content);
526 echo $this->content;
527 }
528
529 /**
530 * Get table field name
531 *
532 * @param string $tableName Table name
533 * @param string $fieldName Field name
534 * @return string Field name
535 */
536 public function getFieldName($tableName, $fieldName) {
537 t3lib_div::loadTCA($tableName);
538 if ($GLOBALS['TCA'][$tableName]['columns'][$fieldName]['label'] !== NULL) {
539 $field = $GLOBALS['LANG']->sL($GLOBALS['TCA'][$tableName]['columns'][$fieldName]['label']);
540 if (trim($field) === '') {
541 $field = $fieldName;
542 }
543 } else {
544 $field = $fieldName;
545 }
546
547 return $field;
548 }
549
550 /**
551 * Returns the rendered record actions
552 *
553 * @param string $table
554 * @param integer $uid
555 * @return string
556 */
557 protected function getRecordActions($table, $uid) {
558 if ($table === '' || $uid < 0) {
559 return '';
560 }
561
562 $editOnClick = t3lib_BEfunc::editOnClick('&edit[' . $table . '][' . $uid . ']=edit', $GLOBALS['BACK_PATH']);
563 $icon = t3lib_iconWorks::getSpriteIcon('actions-document-open');
564 $pageActionIcons = '<a href="#" onclick="' . htmlspecialchars($editOnClick) . '">' . $icon . '</a>';
565
566 $historyOnClick = 'window.location.href=\'show_rechis.php?element=' . $table . '%3A' . $uid .
567 '&returnUrl=' . rawurlencode(t3lib_div::getIndpEnv('REQUEST_URI')) . '\'; return false;';
568 $icon = t3lib_iconWorks::getSpriteIcon('actions-document-history-open');
569 $pageActionIcons .= '<a href="#" onclick="' . $historyOnClick . '">' . $icon . '</a>';
570
571 if ($table === 'pages') {
572 $pageActionIcons .= $this->doc->viewPageIcon($uid, '');
573 }
574
575 return $pageActionIcons;
576 }
577
578 /**
579 * Make reference display
580 *
581 * @param string $table Table name
582 * @param string|t3lib_file_File $ref Filename or uid
583 * @return string HTML
584 */
585 function makeRef($table, $ref) {
586 // Look up the path:
587 if ($table === '_FILE') {
588 $rows = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows(
589 '*',
590 'sys_file_reference',
591 'uid_local=' . $ref->getUid()
592 );
593 } else {
594 $rows = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows(
595 '*',
596 'sys_refindex',
597 'ref_table=' . $GLOBALS['TYPO3_DB']->fullQuoteStr($table, 'sys_refindex') .
598 ' AND ref_uid=' . intval($ref) . ' AND deleted=0'
599 );
600 }
601 // Compile information for title tag:
602 $infoData = array();
603 if (count($rows)) {
604 $infoData[] = '<tr class="t3-row-header">' .
605 '<td>&nbsp;</td>' .
606 '<td>' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:show_item.php.table') . '</td>' .
607 '<td>' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:show_item.php.title') . '</td>' .
608 '<td>[uid]</td>' .
609 '<td>' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:show_item.php.field') . '</td>' .
610 '<td>' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:show_item.php.flexpointer') . '</td>' .
611 '<td>' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:show_item.php.softrefKey') . '</td>' .
612 '<td>' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:show_item.php.sorting') . '</td>' .
613 '</tr>';
614 }
615
616 foreach ($rows as $row) {
617 if($table === '_FILE') {
618 $row = $this->mapFileReferenceOnRefIndex($row);
619 }
620
621 $record = t3lib_BEfunc::getRecord($row['tablename'], $row['recuid']);
622 $parentRecord = t3lib_BEfunc::getRecord('pages', $record['pid']);
623 $actions = $this->getRecordActions($row['tablename'], $row['recuid']);
624 $infoData[] = '<tr class="bgColor4">' .
625 '<td style="white-space:nowrap;">' . $actions . '</td>' .
626 '<td>' . $GLOBALS['LANG']->sL($GLOBALS['TCA'][$row['tablename']]['ctrl']['title'], TRUE) . '</td>' .
627 '<td>' . t3lib_BEfunc::getRecordTitle($row['tablename'], $record, TRUE) . '</td>' .
628 '<td><span title="' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_common.xlf:page') . ': ' .
629 htmlspecialchars(t3lib_BEfunc::getRecordTitle('pages', $parentRecord)) .
630 ' (uid=' . $record['pid'] . ')">' . $record['uid'] . '</span></td>' .
631 '<td>' . htmlspecialchars($this->getFieldName($row['tablename'], $row['field'])) . '</td>' .
632 '<td>' . htmlspecialchars($row['flexpointer']) . '</td>' .
633 '<td>' . htmlspecialchars($row['softref_key']) . '</td>' .
634 '<td>' . htmlspecialchars($row['sorting']) . '</td>' .
635 '</tr>';
636 }
637
638 $referenceLine = '';
639 if (count($infoData)) {
640 $referenceLine = '<table border="0" cellpadding="0" cellspacing="0" class="typo3-dblist">' .
641 implode('', $infoData) . '</table>';
642 }
643
644 return $referenceLine;
645 }
646
647 /**
648 * Maps results from the fal file reference table on the
649 * structure of the normal reference index table.
650 *
651 * @param array $fileReference
652 * @return array
653 */
654 protected function mapFileReferenceOnRefIndex(array $fileReference) {
655 return array(
656 'recuid' => $fileReference['uid_foreign'],
657 'tablename' => $fileReference['tablenames'],
658 'field' => $fileReference['fieldname'],
659 'flexpointer' => '',
660 'softref_key' => '',
661 'sorting' => $fileReference['sorting_foreign']
662 );
663 }
664
665 /**
666 * Make reference display (what this elements points to)
667 *
668 * @param string $table Table name
669 * @param string $ref Filename or uid
670 * @return string HTML
671 */
672 function makeRefFrom($table, $ref) {
673 // Look up the path:
674 // @TODO files not respected (see makeRef)
675 $rows = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows(
676 '*',
677 'sys_refindex',
678 'tablename=' . $GLOBALS['TYPO3_DB']->fullQuoteStr($table, 'sys_refindex') .
679 ' AND recuid=' . intval($ref)
680 );
681
682 // Compile information for title tag:
683 $infoData = array();
684 if (count($rows)) {
685 $infoData[] = '<tr class="t3-row-header">' .
686 '<td>&nbsp;</td>' .
687 '<td>' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:show_item.php.field') . '</td>' .
688 '<td>' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:show_item.php.flexpointer') . '</td>' .
689 '<td>' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:show_item.php.softrefKey') . '</td>' .
690 '<td>' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:show_item.php.sorting') . '</td>' .
691 '<td>' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:show_item.php.refTable') . '</td>' .
692 '<td>' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:show_item.php.refUid') . '</td>' .
693 '<td>' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:show_item.php.refString') . '</td>' .
694 '</tr>';
695 }
696
697 foreach ($rows as $row) {
698 $actions = $this->getRecordActions($row['ref_table'], $row['ref_uid']);
699 $infoData[] = '<tr class="bgColor4">' .
700 '<td style="white-space:nowrap;">' . $actions . '</td>' .
701 '<td>' . htmlspecialchars($this->getFieldName($table, $row['field'])) . '</td>' .
702 '<td>' . htmlspecialchars($row['flexpointer']) . '</td>' .
703 '<td>' . htmlspecialchars($row['softref_key']) . '</td>' .
704 '<td>' . htmlspecialchars($row['sorting']) . '</td>' .
705 '<td>' . $GLOBALS['LANG']->sL($GLOBALS['TCA'][$row['ref_table']]['ctrl']['title'], TRUE) . '</td>' .
706 '<td>' . htmlspecialchars($row['ref_uid']) . '</td>' .
707 '<td>' . htmlspecialchars($row['ref_string']) . '</td>' .
708 '</tr>';
709 }
710
711 $referenceLine = '';
712 if (count($infoData)) {
713 $referenceLine = '<table border="0" cellpadding="0" cellspacing="0" class="typo3-dblist">' .
714 implode('', $infoData) . '</table>';
715 }
716
717 return $referenceLine;
718 }
719 }
720
721 /** @var $SOBE SC_show_item */
722 $SOBE = t3lib_div::makeInstance('SC_show_item');
723 $SOBE->init();
724 $SOBE->main();
725 $SOBE->printContent();
726
727 ?>