/** * Render references section (references from and references to current record) * * @return string */ protected function renderReferences() { $content = ''; switch ($this->type) { case 'db': $references = $this->makeRef($this->table, $this->row['uid']); if (!empty($references)) { $content .= '<h3>' . $this->getLanguageService()->sL('LLL:EXT:lang/locallang_core.xlf:show_item.php.referencesToThisItem', true) . '</h3>'; $content .= $references; } $referencesFrom = $this->makeRefFrom($this->table, $this->row['uid']); if (!empty($referencesFrom)) { $content .= '<h3>' . $this->getLanguageService()->sL('LLL:EXT:lang/locallang_core.xlf:show_item.php.referencesFromThisItem', true) . '</h3>'; $content .= $referencesFrom; } break; case 'file': if ($this->fileObject && $this->fileObject->isIndexed()) { $references = $this->makeRef('_FILE', $this->fileObject); if (!empty($references)) { $content .= '<h3>' . $this->getLanguageService()->sL('LLL:EXT:lang/locallang_core.xlf:show_item.php.referencesToThisItem', true) . '</h3>'; $content .= $references; } } break; } return $content; }
protected function renderReferences() { $content = ''; switch ($this->type) { case 'db': $references = $this->makeRef($this->table, $this->row['uid']); if (!empty($references)) { $content .= $this->doc->section($GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:show_item.php.referencesToThisItem'), $references); } $referencesFrom = $this->makeRefFrom($this->table, $this->row['uid']); if (!empty($referencesFrom)) { $content .= $this->doc->section($GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:show_item.php.referencesFromThisItem'), $referencesFrom); } break; case 'file': if ($this->fileObject && $this->fileObject->isIndexed()) { $references = $this->makeRef('_FILE', $this->fileObject); if (!empty($references)) { $header = $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:show_item.php.referencesToThisItem'); $content .= $this->doc->section($header, $references); } } break; } return $content; }
/** * Main function. Will generate the information to display for the item * set internally. * * @param string $returnLinkTag <a> tag closing/returning. * @return void * @todo Define visibility */ public function renderFileInfo($returnLinkTag) { $fileExtension = $this->fileObject->getExtension(); $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() . ' ' . '<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> '; $this->content .= $this->doc->section('', $code); $this->content .= $this->doc->divider(2); // If the file was an image... // @todo: add this check in the domain model, or in the processing folder if (\TYPO3\CMS\Core\Utility\GeneralUtility::inList($GLOBALS['TYPO3_CONF_VARS']['GFX']['imagefile_ext'], $fileExtension)) { // @todo: find a way to make getimagesize part of the t3lib_file object $imgInfo = @getimagesize($this->fileObject->getForLocalProcessing(FALSE)); $thumbUrl = $this->fileObject->process(\TYPO3\CMS\Core\Resource\ProcessedFile::CONTEXT_IMAGEPREVIEW, array('width' => '150m', 'height' => '150m'))->getPublicUrl(TRUE); $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>'; $code .= '<br /> <div align="center">' . $returnLinkTag . '<img src="' . $thumbUrl . '" alt="' . htmlspecialchars(trim($this->fileObject->getName())) . '" title="' . htmlspecialchars(trim($this->fileObject->getName())) . '" /></a></div>'; $this->content .= $this->doc->section('', $code); } elseif ($fileExtension == 'ttf') { $thumbUrl = $this->fileObject->process(\TYPO3\CMS\Core\Resource\ProcessedFile::CONTEXT_IMAGEPREVIEW, array('width' => '530m', 'height' => '600m'))->getPublicUrl(TRUE); $thumb = '<br /> <div align="center">' . $returnLinkTag . '<img src="' . $thumbUrl . '" border="0" title="' . htmlspecialchars(trim($this->fileObject->getName())) . '" alt="" /></a></div>'; $this->content .= $this->doc->section('', $thumb); } // Traverse the list of fields to display for the record: $tableRows = array(); $showRecordFieldList = $GLOBALS['TCA'][$this->table]['interface']['showRecordFieldList']; $fieldList = \TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode(',', $showRecordFieldList, TRUE); foreach ($fieldList as $name) { $name = trim($name); if (!isset($GLOBALS['TCA'][$this->table]['columns'][$name])) { continue; } $isExcluded = !(!$GLOBALS['TCA'][$this->table]['columns'][$name]['exclude'] || $GLOBALS['BE_USER']->check('non_exclude_fields', $this->table . ':' . $name)); if ($isExcluded) { continue; } $uid = $this->row['uid']; $itemValue = \TYPO3\CMS\Backend\Utility\BackendUtility::getProcessedValue($this->table, $name, $this->row[$name], 0, 0, FALSE, $uid); $itemLabel = $GLOBALS['LANG']->sL(\TYPO3\CMS\Backend\Utility\BackendUtility::getItemLabel($this->table, $name), 1); $tableRows[] = ' <tr> <td class="t3-col-header">' . $itemLabel . '</td> <td>' . htmlspecialchars($itemValue) . '</td> </tr>'; } // Create table from the information: $tableCode = ' <table border="0" cellpadding="0" cellspacing="0" id="typo3-showitem" class="t3-table-info"> ' . implode('', $tableRows) . ' </table>'; $this->content .= $this->doc->section('', $tableCode); // References: if ($this->fileObject->isIndexed()) { $header = $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:show_item.php.referencesToThisItem'); $this->content .= $this->doc->section($header, $this->makeRef('_FILE', $this->fileObject)); } }
/** * Get references section (references from and references to current record) * * @return array */ protected function getReferences() : array { $references = []; switch ($this->type) { case 'db': $references['refLines'] = $this->makeRef($this->table, $this->row['uid']); $references['refFromLines'] = $this->makeRefFrom($this->table, $this->row['uid']); break; case 'file': if ($this->fileObject && $this->fileObject->isIndexed()) { $references['refLines'] = $this->makeRef('_FILE', $this->fileObject); } break; } return $references; }
/** * Wraps filenames in links which opens the metadata editor. * * @param string $code String to be wrapped in links * @param File $fileObject File to be linked * @return string HTML */ public function linkWrapFile($code, File $fileObject) { try { if ($fileObject instanceof File && $fileObject->isIndexed() && $fileObject->checkActionPermission('write') && $this->getBackendUser()->check('tables_modify', 'sys_file_metadata')) { $metaData = $fileObject->_getMetaData(); $data = array('sys_file_metadata' => array($metaData['uid'] => 'edit')); $editOnClick = BackendUtility::editOnClick(GeneralUtility::implodeArrayForUrl('edit', $data), '', $this->listUrl()); $title = htmlspecialchars($this->getLanguageService()->sL('LLL:EXT:lang/locallang_core.xlf:cm.editMetadata')); $code = '<a href="#" title="' . $title . '" onclick="' . htmlspecialchars($editOnClick) . '">' . GeneralUtility::fixed_lgd_cs($code, $this->fixedL) . '</a>'; } } catch (\Exception $e) { // intentional fall-through } return $code; }
/** * Wraps filenames in links which opens the metadata editor. * * @param string $code String to be wrapped in links * @param File $fileObject File to be linked * @return string HTML */ public function linkWrapFile($code, File $fileObject) { try { if ($fileObject instanceof File && $fileObject->isIndexed() && $fileObject->checkActionPermission('write') && $this->getBackendUser()->check('tables_modify', 'sys_file_metadata')) { $metaData = $fileObject->_getMetaData(); $urlParameters = ['edit' => ['sys_file_metadata' => [$metaData['uid'] => 'edit']], 'returnUrl' => $this->listURL()]; $url = BackendUtility::getModuleUrl('record_edit', $urlParameters); $title = htmlspecialchars($this->getLanguageService()->sL('LLL:EXT:lang/locallang_core.xlf:cm.editMetadata')); $code = '<a href="' . htmlspecialchars($url) . '" title="' . $title . '">' . GeneralUtility::fixed_lgd_cs($code, $this->fixedL) . '</a>'; } } catch (\Exception $e) { // intentional fall-through } return $code; }