[FEATURE] Refactor ElementInfo / show_item 69/21469/5
authorFelix Kopp <felix-source@phorax.com>
Sun, 16 Jun 2013 21:08:22 +0000 (23:08 +0200)
committerChristian Kuhn <lolli@schwarzbu.ch>
Tue, 2 Jul 2013 11:47:31 +0000 (13:47 +0200)
Splits up functionality to represent sections.

Cleanup for html base: h1/paddings/p.

First step for MVC structuring; Render = View.

Brings visual improvements:
- human readable headline: table+title
- increase preview image dimensions
- download link to reference absolute file
- reference list table styling

Implementing folders' info is not in scope.

Change-Id: Ia411404a99df2d07dcce2d959ae324ec39966e04
Resolves: #49164
Releases: 6.2
Reviewed-on: https://review.typo3.org/21469
Reviewed-by: Wouter Wolters
Tested-by: Wouter Wolters
Reviewed-by: Christian Kuhn
Tested-by: Christian Kuhn
typo3/sysext/backend/Classes/Controller/ContentElement/ElementInformationController.php
typo3/sysext/backend/Resources/Public/JavaScript/backend.js
typo3/sysext/t3skin/stylesheets/structure/element_infopopup.css

index 0432608..1a3d220 100644 (file)
@@ -40,63 +40,47 @@ use TYPO3\CMS\Core\Utility\GeneralUtility;
 class ElementInformationController {
 
        /**
-        * GET vars:
-        * Record table (or filename)
+        * Record table name
         *
         * @var string
-        * @todo Define visibility
         */
        public $table;
 
        /**
-        * Record uid  (or '' when filename)
+        * Record uid
         *
         * @var int
-        * @todo Define visibility
         */
        public $uid;
 
        /**
-        * Internal, static:
-        * Page select clause
-        *
         * @var string
-        * @todo Define visibility
         */
-       public $perms_clause;
+       protected $permsClause;
 
        /**
-        * If TRUE, access to element is granted
-        *
         * @var boolean
-        * @todo Define visibility
         */
-       public $access;
+       public $access = FALSE;
 
        /**
-        * Which type of element: "file" or "db"
+        * Which type of element:
+        * - "file"
+        * - "db"
         *
         * @var string
-        * @todo Define visibility
         */
-       public $type;
+       public $type = '';
 
        /**
-        * Document Template Object
-        *
         * @var \TYPO3\CMS\Backend\Template\DocumentTemplate
-        * @todo Define visibility
         */
        public $doc;
 
        /**
-        * Internal, dynamic:
-        * Content Accumulation
-        *
         * @var string
-        * @todo Define visibility
         */
-       public $content;
+       protected $content = '';
 
        /**
         * For type "db": Set to page record of the parent page of the item set
@@ -108,107 +92,101 @@ class ElementInformationController {
        public $pageinfo;
 
        /**
-        * For type "db": The database record row.
+        * Database records identified by table/uid
         *
         * @var array
-        * @todo Define visibility
         */
-       public $row;
+       protected $row;
 
        /**
-        * The fileObject if present
-        *
         * @var \TYPO3\CMS\Core\Resource\File
         */
        protected $fileObject;
 
        /**
-        * The folder obejct if present
-        *
         * @var \TYPO3\CMS\Core\Resource\Folder
         */
        protected $folderObject;
 
        /**
-        * Initialization of the class
-        * Will determine if table/uid GET vars are database record or a file and if
-        * the user has access to view information about the item.
+        * Determines if table/uid point to database record or file and
+        * if user has access to view information
         *
         * @return void
-        * @todo Define visibility
         */
        public function init() {
-               // Setting input variables.
                $this->table = GeneralUtility::_GET('table');
                $this->uid = GeneralUtility::_GET('uid');
-               // Initialize:
+
                $this->perms_clause = $GLOBALS['BE_USER']->getPagePermsClause(1);
-               // Set to TRUE if there is access to the record / file.
-               $this->access = FALSE;
-               // Sets the type, "db" or "file". If blank, nothing can be shown.
-               $this->type = '';
-               // Checking if the $table value is really a table and if the user has
-               // access to it.
+               $this->doc = GeneralUtility::makeInstance('TYPO3\\CMS\\Backend\\Template\\DocumentTemplate');
+
                if (isset($GLOBALS['TCA'][$this->table])) {
-                       $this->type = 'db';
-                       $this->uid = intval($this->uid);
-                       // Check permissions and uid value:
-                       if ($this->uid && $GLOBALS['BE_USER']->check('tables_select', $this->table)) {
-                               if ((string) $this->table == 'pages') {
-                                       $this->pageinfo = BackendUtility::readPageAccess($this->uid, $this->perms_clause);
-                                       $this->access = is_array($this->pageinfo) ? 1 : 0;
-                                       $this->row = $this->pageinfo;
-                               } else {
-                                       $this->row = BackendUtility::getRecordWSOL($this->table, $this->uid);
-                                       if ($this->row) {
-                                               $this->pageinfo = BackendUtility::readPageAccess($this->row['pid'], $this->perms_clause);
-                                               $this->access = is_array($this->pageinfo) ? 1 : 0;
-                                       }
-                               }
-                               /** @var $treatData \TYPO3\CMS\Backend\Form\DataPreprocessor */
-                               $treatData = GeneralUtility::makeInstance('TYPO3\\CMS\\Backend\\Form\\DataPreprocessor');
-                               $treatData->renderRecord($this->table, $this->uid, 0, $this->row);
-                       }
+                       $this->initDatabaseRecord();
                } elseif ($this->table == '_FILE' || $this->table == '_FOLDER' || $this->table == 'sys_file') {
-                       $fileOrFolderObject = \TYPO3\CMS\Core\Resource\ResourceFactory::getInstance()->retrieveFileOrFolderObject($this->uid);
-                       if ($fileOrFolderObject instanceof \TYPO3\CMS\Core\Resource\Folder) {
-                               $this->folderObject = $fileOrFolderObject;
-                               $this->access = $this->folderObject->checkActionPermission('read');
-                               $this->type = 'folder';
+                       $this->initFileOrFolderRecord();
+               }
+       }
+
+       /**
+        * Init database records (table)
+        */
+       protected function initDatabaseRecord() {
+               $this->type = 'db';
+               $this->uid = intval($this->uid);
+
+               // Check permissions and uid value:
+               if ($this->uid && $GLOBALS['BE_USER']->check('tables_select', $this->table)) {
+                       if ((string) $this->table == 'pages') {
+                               $this->pageinfo = BackendUtility::readPageAccess($this->uid, $this->perms_clause);
+                               $this->access = is_array($this->pageinfo) ? 1 : 0;
+                               $this->row = $this->pageinfo;
                        } else {
-                               $this->fileObject = $fileOrFolderObject;
-                               $this->access = $this->fileObject->checkActionPermission('read');
-                               $this->type = 'file';
-                               $this->table = 'sys_file';
-                               try {
-                                       $this->row = BackendUtility::getRecordWSOL($this->table, $this->fileObject->getUid());
-                               } catch (\Exception $e) {
-                                       $this->row = array();
+                               $this->row = BackendUtility::getRecordWSOL($this->table, $this->uid);
+                               if ($this->row) {
+                                       $this->pageinfo = BackendUtility::readPageAccess($this->row['pid'], $this->perms_clause);
+                                       $this->access = is_array($this->pageinfo) ? 1 : 0;
                                }
                        }
+                       /** @var $treatData \TYPO3\CMS\Backend\Form\DataPreprocessor */
+                       $treatData = GeneralUtility::makeInstance('TYPO3\\CMS\\Backend\\Form\\DataPreprocessor');
+                       $treatData->renderRecord($this->table, $this->uid, 0, $this->row);
+               }
+       }
+
+       /**
+        * Init file/folder parameters
+        */
+       protected function initFileOrFolderRecord() {
+               $fileOrFolderObject = \TYPO3\CMS\Core\Resource\ResourceFactory::getInstance()->
+                               retrieveFileOrFolderObject($this->uid);
+
+               if ($fileOrFolderObject instanceof \TYPO3\CMS\Core\Resource\Folder) {
+                       $this->folderObject = $fileOrFolderObject;
+                       $this->access = $this->folderObject->checkActionPermission('read');
+                       $this->type = 'folder';
+               } else {
+                       $this->fileObject = $fileOrFolderObject;
+                       $this->access = $this->fileObject->checkActionPermission('read');
+                       $this->type = 'file';
+                       $this->table = 'sys_file';
+
+                       try {
+                               $this->row = BackendUtility::getRecordWSOL($this->table, $this->fileObject->getUid());
+                       } catch (\Exception $e) {
+                               $this->row = array();
+                       }
                }
-               // Initialize document template object:
-               $this->doc = GeneralUtility::makeInstance('TYPO3\\CMS\\Backend\\Template\\DocumentTemplate');
-               $this->doc->backPath = $GLOBALS['BACK_PATH'];
-               // Starting the page by creating page header stuff:
-               $this->content .= $this->doc->startPage($GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:show_item.php.viewItem'));
-               $this->content .= '<h3 class="t3-row-header">' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:show_item.php.viewItem') . '</h3>';
-               $this->content .= $this->doc->spacer(5);
        }
 
        /**
-        * Main function. Will generate the information to display for the item
-        * set internally.
-        *
         * @return void
-        * @todo Define visibility
         */
        public function main() {
                if (!$this->access) {
                        return;
                }
-               $returnLink = GeneralUtility::sanitizeLocalUrl(GeneralUtility::_GP('returnUrl'));
-               $returnLinkTag = $returnLink ? '<a href="' . $returnLink . '" class="typo3-goBack">' : '<a href="#" onclick="window.close();">';
+
                // render type by user func
                $typeRendered = FALSE;
                if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/show_item.php']['typeRendering'])) {
@@ -224,46 +202,91 @@ class ElementInformationController {
                                }
                        }
                }
-               // If type was not rendered use default rendering functions
+
                if (!$typeRendered) {
-                       // Branch out based on type:
-                       switch ($this->type) {
-                       case 'db':
-                               $this->renderDBInfo();
-                               break;
-                       case 'file':
-                               $this->renderFileInfo($returnLinkTag);
-                               break;
-                       case 'folder':
-                               // @todo: implement an info about a folder
-                               break;
-                       }
+                       $this->content .= $this->renderPageTitle();
+                       $this->content .= $this->renderPreview();
+                       $this->content .= $this->renderPropertiesAsTable();
+                       $this->content .= $this->renderReferences();
                }
-               // If return Url is set, output link to go back:
-               if (GeneralUtility::sanitizeLocalUrl(GeneralUtility::_GP('returnUrl'))) {
-                       $this->content = $this->doc->section('', ($returnLinkTag . '<strong>' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:labels.goBack', 1) . '</strong></a><br /><br />')) . $this->content;
-                       $this->content .= $this->doc->section('', '<br />' . $returnLinkTag . '<strong>' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:labels.goBack', 1) . '</strong></a>');
+       }
+
+       /**
+        * Render page title with icon, table title and record title
+        *
+        * @return string
+        */
+       protected function renderPageTitle() {
+               if ($this->type === 'folder') {
+                       $title = IconUtility::getSpriteIcon('apps-filetree-folder-default') . ' ' .
+                                       $this->folderObject->getName();
+               } else {
+                       $table = $GLOBALS['LANG']->sL($GLOBALS['TCA'][$this->table]['ctrl']['title']);
+                       $title = $this->doc->getHeader($this->table, $this->row, $this->pageinfo['_thePath'], 1, array(' ', ''));
                }
+
+               return '<h1>' .
+                               ($table ? '<small>' . $table . '</small><br />' : '') .
+                               $title .
+                               '</h1>';
        }
 
        /**
-        * Main function. Will generate the information to display for the item
-        * set internally.
+        * Render preview for current record
         *
-        * @return      void
-        * @todo Define visibility
+        * @return string
         */
-       public function renderDBInfo() {
-               // Print header, path etc:
-               // @TODO invalid context menu code in the output
-               $code = $this->doc->getHeader($this->table, $this->row, $this->pageinfo['_thePath'], 1) . '<br />';
-               $this->content .= $this->doc->section('', $code);
+       protected function renderPreview() {
+               // Perhaps @TODO in future: Also display preview for records - without fileObject
+               if (!$this->fileObject) {
+                       return;
+               }
+
+               $fileExtension = $this->fileObject->getExtension();
+               if (GeneralUtility::inList($GLOBALS['TYPO3_CONF_VARS']['GFX']['imagefile_ext'], $fileExtension)) {
+                       $thumbUrl = $this->fileObject->process(
+                               ProcessedFile::CONTEXT_IMAGEPREVIEW,
+                               array(
+                                       'width' => '400m',
+                                       'height' => '400m'
+                               )
+                       )->getPublicUrl(TRUE);
+               }
+
+               // Create thumbnail image?
+               if ($thumbUrl) {
+                       $imageTag = '<img src="' . $thumbUrl . '" ' .
+                                       'alt="' . htmlspecialchars(trim($this->fileObject->getName())) . '" ' .
+                                       'title="' . htmlspecialchars(trim($this->fileObject->getName())) . '" />';
+               }
+
+               // Display download link?
+               if ($this->fileObject->getPublicUrl()) {
+                       $downloadLink = '<a href="../' . $this->fileObject->getPublicUrl() . '" target="_blank">' .
+                                       $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_common.xlf:download', 1) .
+                                       '</a>';
+               }
+
+               return ($imageTag ? '<p>' . $imageTag . '</p>' : '') .
+                               ($downloadLink ? '<p>' . $downloadLink . '</p>' : '');
+       }
+
+       /**
+        * Render property array as html table
+        *
+        * @return string
+        */
+       protected function renderPropertiesAsTable() {
                $tableRows = array();
-               $extraFields = array(
-                       'crdate' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_general.xlf:LGL.creationDate', 1),
-                       'cruser_id' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_general.xlf:LGL.creationUserId', 1),
-                       'tstamp' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_general.xlf:LGL.timestamp', 1)
-               );
+
+               if ($this->type !== 'folder') {
+                       $extraFields = array(
+                               'crdate' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_general.xlf:LGL.creationDate', 1),
+                               'cruser_id' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_general.xlf:LGL.creationUserId', 1),
+                               'tstamp' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_general.xlf:LGL.timestamp', 1)
+                       );
+               }
+
                foreach ($extraFields as $name => $value) {
                        $rowValue = BackendUtility::getProcessedValueExtra($this->table, $name, $this->row[$name]);
                        if ($name === 'cruser_id' && $rowValue) {
@@ -277,22 +300,26 @@ class ElementInformationController {
                        }
                        $tableRows[] = '
                                <tr>
-                                       <td class="t3-col-header">' . $value . '</td>
+                                       <td class="t3-col-header">' . rtrim($value, ':') . '</td>
                                        <td>' . htmlspecialchars($rowValue) . '</td>
                                </tr>';
                }
+
                // Traverse the list of fields to display for the record:
-               $fieldList = GeneralUtility::trimExplode(',', $GLOBALS['TCA'][$this->table]['interface']['showRecordFieldList'], 1);
+               $fieldList = GeneralUtility::trimExplode(',', $GLOBALS['TCA'][$this->table]['interface']['showRecordFieldList'], TRUE);
                foreach ($fieldList as $name) {
                        $name = trim($name);
+                       $uid = $this->row['uid'];
+
                        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 = BackendUtility::getProcessedValue($this->table, $name, $this->row[$name], 0, 0, FALSE, $uid);
                        $itemLabel = $GLOBALS['LANG']->sL(BackendUtility::getItemLabel($this->table, $name), 1);
                        $tableRows[] = '
@@ -301,68 +328,59 @@ class ElementInformationController {
                                        <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);
-               // Add path and table information in the bottom:
-               $code = '';
-               $code .= $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:labels.path') . ': ' . GeneralUtility::fixed_lgd_cs($this->pageinfo['_thePath'], -48) . '<br />';
-               $code .= $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:labels.table') . ': ' . $GLOBALS['LANG']->sL($GLOBALS['TCA'][$this->table]['ctrl']['title']) . ' (' . $this->table . ') - UID: ' . $this->uid . '<br />';
-               $this->content .= $this->doc->section('', $code);
-               // References:
-               $references = $this->makeRef($this->table, $this->row['uid']);
-               if (!empty($references)) {
-                       $this->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)) {
-                       $this->content .= $this->doc->section($GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:show_item.php.referencesFromThisItem'), $referencesFrom);
+
+               return '<table id="typo3-showitem" class="t3-table-info">' .
+                               implode('', $tableRows) .
+                               '</table>';
+       }
+
+       /*
+        * 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 .= $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.
+        * Renders file properties as html table
         *
-        * @param string $returnLinkTag <a> tag closing/returning.
-        * @return void
-        * @todo Define visibility
+        * @param array $fieldList
+        * @return string
         */
-       public function renderFileInfo($returnLinkTag) {
-               $fileExtension = $this->fileObject->getExtension();
-               $code = '<div class="fileInfoContainer">' . IconUtility::getSpriteIconForFile($fileExtension) . '<strong>' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:show_item.php.file', TRUE) . ':</strong> ' . $this->fileObject->getName() . '&nbsp;&nbsp;' . '<strong>' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:show_item.php.filesize') . ':</strong> ' . 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 (GeneralUtility::inList($GLOBALS['TYPO3_CONF_VARS']['GFX']['imagefile_ext'], $fileExtension)) {
-                       // @todo: find a way to make getimagesize part of the \TYPO3\CMS\Core\Resource\File object
-                       $imgInfo = @getimagesize($this->fileObject->getForLocalProcessing(FALSE));
-                       $thumbUrl = $this->fileObject->process(ProcessedFile::CONTEXT_IMAGEPREVIEW, array('width' => '150m', 'height' => '150m'))->getPublicUrl(TRUE);
-                       $code = '<div class="fileInfoContainer fileDimensions">' . '<strong>' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:show_item.php.dimensions') . ':</strong> ' . $imgInfo[0] . 'x' . $imgInfo[1] . ' ' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf: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(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:
+       protected function renderFileInformationAsTable($fieldList) {
                $tableRows = array();
-               $showRecordFieldList = $GLOBALS['TCA'][$this->table]['interface']['showRecordFieldList'];
-               $fieldList = GeneralUtility::trimExplode(',', $showRecordFieldList, TRUE);
-
                foreach ($fieldList as $name) {
-                       // Ignored fields
-                       if ($name === 'size') {
-                               continue;
-                       }
                        if (!isset($GLOBALS['TCA'][$this->table]['columns'][$name])) {
                                continue;
                        }
@@ -379,43 +397,35 @@ class ElementInformationController {
                                        <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()) {
-                       $references = $this->makeRef('_FILE', $this->fileObject);
-
-                       if (!empty($references)) {
-                               $header = $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:show_item.php.referencesToThisItem');
-                               $this->content .= $this->doc->section($header, $references);
-                       }
+
+               if (!$tableRows) {
+                       return '';
                }
+
+               return '<table id="typo3-showitem" class="t3-table-info">' .
+                               implode('', $tableRows) .
+                               '</table>';
        }
 
        /**
         * End page and print content
         *
         * @return void
-        * @todo Define visibility
         */
        public function printContent() {
-               $this->content .= $this->doc->endPage();
-               $this->content = $this->doc->insertStylesAndJS($this->content);
-               echo $this->content;
+               echo $this->doc->startPage('') .
+                               $this->doc->insertStylesAndJS($this->content) .
+                               $this->doc->endPage();
        }
 
        /**
-        * Get table field name
+        * Get field name for specified table/column name
         *
         * @param string $tableName Table name
-        * @param string $fieldName Field name
-        * @return string Field name
+        * @param string $fieldName Column name
+        * @return string label
         */
-       public function getFieldName($tableName, $fieldName) {
+       public function getLabelForTableColumn($tableName, $fieldName) {
                if ($GLOBALS['TCA'][$tableName]['columns'][$fieldName]['label'] !== NULL) {
                        $field = $GLOBALS['LANG']->sL($GLOBALS['TCA'][$tableName]['columns'][$fieldName]['label']);
                        if (trim($field) === '') {
@@ -438,10 +448,13 @@ class ElementInformationController {
                if ($table === '' || $uid < 0) {
                        return '';
                }
+
                $editOnClick = BackendUtility::editOnClick('&edit[' . $table . '][' . $uid . ']=edit', $GLOBALS['BACK_PATH']);
                $icon = IconUtility::getSpriteIcon('actions-document-open');
                $pageActionIcons = '<a href="#" onclick="' . htmlspecialchars($editOnClick) . '">' . $icon . '</a>';
-               $historyOnClick = 'window.location.href=\'show_rechis.php?element=' . $table . '%3A' . $uid . '&returnUrl=' . rawurlencode(GeneralUtility::getIndpEnv('REQUEST_URI')) . '\'; return false;';
+               $historyOnClick = 'window.location.href=\'show_rechis.php?element=' . $table . '%3A' .
+                               $uid . '&returnUrl=' . rawurlencode(GeneralUtility::getIndpEnv('REQUEST_URI')) . '\'; return false;';
+
                $icon = IconUtility::getSpriteIcon('actions-document-history-open');
                $pageActionIcons .= '<a href="#" onclick="' . $historyOnClick . '">' . $icon . '</a>';
                if ($table === 'pages') {
@@ -456,9 +469,8 @@ class ElementInformationController {
         * @param string $table Table name
         * @param string|\TYPO3\CMS\Core\Resource\File $ref Filename or uid
         * @return string HTML
-        * @todo Define visibility
         */
-       public function makeRef($table, $ref) {
+       protected function makeRef($table, $ref) {
                // Files reside in sys_file table
                if ($table === '_FILE') {
                        $selectTable = 'sys_file';
@@ -472,10 +484,11 @@ class ElementInformationController {
                        'sys_refindex',
                        'ref_table=' . $GLOBALS['TYPO3_DB']->fullQuoteStr($selectTable, 'sys_refindex') . ' AND ref_uid=' . intval($selectUid) . ' AND deleted=0'
                );
+
                // Compile information for title tag:
                $infoData = array();
                if (count($rows)) {
-                       $infoData[] = '<tr class="t3-row-header">' . '<td>&nbsp;</td>' . '<td>' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:show_item.php.table') . '</td>' . '<td>' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:show_item.php.title') . '</td>' . '<td>[uid]</td>' . '<td>' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:show_item.php.field') . '</td>' . '<td>' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:show_item.php.flexpointer') . '</td>' . '<td>' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:show_item.php.softrefKey') . '</td>' . '<td>' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:show_item.php.sorting') . '</td>' . '</tr>';
+                       $infoDataHeader = '<tr class="t3-row-header">' . '<td>&nbsp;</td>' . '<td>' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:show_item.php.table') . '</td>' . '<td>' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:show_item.php.title') . '</td>' . '<td>[uid]</td>' . '<td>' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:show_item.php.field') . '</td>' . '<td>' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:show_item.php.flexpointer') . '</td>' . '<td>' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:show_item.php.softrefKey') . '</td>' . '<td>' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:show_item.php.sorting') . '</td>' . '</tr>';
                }
                foreach ($rows as $row) {
                        if ($row['tablename'] === 'sys_file_reference') {
@@ -484,68 +497,100 @@ class ElementInformationController {
                        $record = BackendUtility::getRecord($row['tablename'], $row['recuid']);
                        $parentRecord = BackendUtility::getRecord('pages', $record['pid']);
                        $actions = $this->getRecordActions($row['tablename'], $row['recuid']);
-                       $infoData[] = '<tr class="bgColor4">' . '<td style="white-space:nowrap;">' . $actions . '</td>' . '<td>' . $GLOBALS['LANG']->sL($GLOBALS['TCA'][$row['tablename']]['ctrl']['title'], TRUE) . '</td>' . '<td>' . BackendUtility::getRecordTitle($row['tablename'], $record, TRUE) . '</td>' . '<td><span title="' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_common.xlf:page') . ': ' . htmlspecialchars(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>';
+                       $infoData[] = '<tr class="db_list_normal">' .
+                                       '<td style="white-space:nowrap;">' . $actions . '</td>' .
+                                       '<td>' . $GLOBALS['LANG']->sL($GLOBALS['TCA'][$row['tablename']]['ctrl']['title'], TRUE) . '</td>' .
+                                       '<td>' . BackendUtility::getRecordTitle($row['tablename'], $record, TRUE) . '</td>' .
+                                       '<td><span title="' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_common.xlf:page') . ': ' .
+                                                       htmlspecialchars(BackendUtility::getRecordTitle('pages', $parentRecord)) . ' (uid=' . $record['pid'] . ')">' .
+                                                       $record['uid'] . '</span></td>' .
+                                       '<td>' . htmlspecialchars($this->getLabelForTableColumn($row['tablename'], $row['field'])) . '</td>' .
+                                       '<td>' . htmlspecialchars($row['flexpointer']) . '</td>' . '<td>' . htmlspecialchars($row['softref_key']) . '</td>' .
+                                       '<td>' . htmlspecialchars($row['sorting']) . '</td>' .
+                                       '</tr>';
                }
                $referenceLine = '';
                if (count($infoData)) {
-                       $referenceLine = '<table border="0" cellpadding="0" cellspacing="0" class="typo3-dblist">' . implode('', $infoData) . '</table>';
+                       $referenceLine = '<table border="0" cellpadding="0" cellspacing="0" class="typo3-dblist">' .
+                                       '<thead>' . $infoDataHeader . '</thead>' .
+                                       '<tbody>' .
+                                       implode('', $infoData) .
+                                       '</tbody></table>';
                }
                return $referenceLine;
        }
 
        /**
-        * Maps results from the fal file reference table on the
-        * structure of  the normal reference index table.
-        *
-        * @param array $referenceRecord
-        * @return array
-        */
-       protected function transformFileReferenceToRecordReference(array $referenceRecord) {
-               $fileReference = $GLOBALS['TYPO3_DB']->exec_SELECTgetSingleRow(
-                       '*',
-                       'sys_file_reference',
-                       'uid=' . (int)$referenceRecord['recuid']
-               );
-               return array(
-                       'recuid' => $fileReference['uid_foreign'],
-                       'tablename' => $fileReference['tablenames'],
-                       'field' => $fileReference['fieldname'],
-                       'flexpointer' => '',
-                       'softref_key' => '',
-                       'sorting' => $fileReference['sorting_foreign']
-               );
-       }
-
-       /**
         * Make reference display (what this elements points to)
         *
         * @param string $table Table name
         * @param string $ref Filename or uid
         * @return string HTML
-        * @todo Define visibility
         */
-       public function makeRefFrom($table, $ref) {
-               // Look up the path:
-               // @TODO files not respected (see makeRef)
+       protected function makeRefFrom($table, $ref) {
                $rows = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows(
                        '*',
                        'sys_refindex',
                        'tablename=' . $GLOBALS['TYPO3_DB']->fullQuoteStr($table, 'sys_refindex') . ' AND recuid=' . intval($ref)
                );
+
                // Compile information for title tag:
                $infoData = array();
                if (count($rows)) {
-                       $infoData[] = '<tr class="t3-row-header">' . '<td>&nbsp;</td>' . '<td>' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:show_item.php.field') . '</td>' . '<td>' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:show_item.php.flexpointer') . '</td>' . '<td>' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:show_item.php.softrefKey') . '</td>' . '<td>' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:show_item.php.sorting') . '</td>' . '<td>' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:show_item.php.refTable') . '</td>' . '<td>' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:show_item.php.refUid') . '</td>' . '<td>' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:show_item.php.refString') . '</td>' . '</tr>';
+                       $infoData[] = '<tr class="t3-row-header">' .
+                                       '<td>&nbsp;</td>' .
+                                       '<td>' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:show_item.php.field') . '</td>' .
+                                       '<td>' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:show_item.php.flexpointer') . '</td>' .
+                                       '<td>' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:show_item.php.softrefKey') . '</td>' .
+                                       '<td>' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:show_item.php.sorting') . '</td>' .
+                                       '<td>' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:show_item.php.refTable') . '</td>' .
+                                       '<td>' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:show_item.php.refUid') . '</td>' .
+                                       '<td>' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:show_item.php.refString') . '</td>' .
+                                       '</tr>';
                }
                foreach ($rows as $row) {
                        $actions = $this->getRecordActions($row['ref_table'], $row['ref_uid']);
-                       $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>';
+                       $infoData[] = '<tr>' .
+                                       '<td style="white-space:nowrap;">' . $actions . '</td>' .
+                                       '<td>' . htmlspecialchars($this->getLabelForTableColumn($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>';
                }
-               $referenceLine = '';
-               if (count($infoData)) {
-                       $referenceLine = '<table border="0" cellpadding="0" cellspacing="0" class="typo3-dblist">' . implode('', $infoData) . '</table>';
+
+               if (empty($infoData)) {
+                       return;
                }
-               return $referenceLine;
+
+               return '<table border="0" cellpadding="0" cellspacing="0" class="typo3-dblist">' .
+                               implode('', $infoData) .
+                               '</table>';
+       }
+
+       /**
+        * Convert FAL file reference (sys_file_reference) to reference index (sys_refindex) table format
+        *
+        * @param array $referenceRecord
+        * @return array
+        */
+       protected function transformFileReferenceToRecordReference(array $referenceRecord) {
+               $fileReference = $GLOBALS['TYPO3_DB']->exec_SELECTgetSingleRow(
+                       '*',
+                       'sys_file_reference',
+                       'uid=' . (int)$referenceRecord['recuid']
+               );
+               return array(
+                       'recuid' => $fileReference['uid_foreign'],
+                       'tablename' => $fileReference['tablenames'],
+                       'field' => $fileReference['fieldname'],
+                       'flexpointer' => '',
+                       'softref_key' => '',
+                       'sorting' => $fileReference['sorting_foreign']
+               );
        }
 
 }
index 96ea324..7014b8b 100644 (file)
@@ -114,10 +114,12 @@ function str_replace(match,replace,string)        {       //
 /**
  * Launcing information window for records/files (fileref as "table" argument)
  */
-function launchView(table,uid,bP)      {       //
-       var backPath= bP ? bP : "";
-       var thePreviewWindow="";
-       thePreviewWindow = window.open(TS.PATH_typo3+"show_item.php?table="+encodeURIComponent(table)+"&uid="+encodeURIComponent(uid),"ShowItem"+TS.uniqueID,"width=550,height=600,status=0,menubar=0,resizable=0,location=0,directories=0,scrollbars=1,toolbar=0");
+function launchView(table, uid, bP) {
+       var backPath = bP ? bP : "";
+       var thePreviewWindow = "";
+       thePreviewWindow = window.open(TS.PATH_typo3 + "show_item.php?table=" + encodeURIComponent(table) + "&uid=" + encodeURIComponent(uid),
+                       "ShowItem" + TS.uniqueID,
+                       "width=650,height=600,status=0,menubar=0,resizable=0,location=0,directories=0,scrollbars=1,toolbar=0");
        if (thePreviewWindow && thePreviewWindow.focus) {
                thePreviewWindow.focus();
        }
index b5af8f6..b093283 100644 (file)
@@ -2,21 +2,18 @@
 Information popup, show_item.php
 - - - - - - - - - - - - - - - - - - - - - */
 
-#typo3-show-item-php {
-       width: 100%;
-}
-#typo3-show-item-php > div {
-       padding: 0 10px;
+body#typo3-show-item-php {
+       padding: 12px 24px;
+       height: auto;
 }
 
-#typo3-show-item-php h3 {
-       margin-top: 0;
-       padding-left: 10px;
+#typo3-show-item-php h1 small {
+       color: #aaa;
+       font-size: 0.7em;
 }
 
-table#typo3-showitem {
-       margin: 10px 0;
-}
+#typo3-show-item-php table { margin-bottom: 1.5em; }
+       #typo3-show-item-php table td { line-height: normal; height: auto; padding: 6px; }
 
 #typo3-show-item-php div.fileInfoContainer.fileDimensions {
        margin-left: 18px;