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