[FEATURE] Add meta info to the FAL IRRE element header 16/21916/20
authorTim Lochmueller <tim@fruit-lab.de>
Fri, 5 Jul 2013 09:52:47 +0000 (11:52 +0200)
committerSteffen Ritter <info@rs-websystems.de>
Fri, 5 Jul 2013 19:34:37 +0000 (21:34 +0200)
Implement the UX-Team functionility of the FAL IRRE element header via a
label_userFunc in the sys_file_reference. Furthermore add a
configuration in the ctrl-section of the sys_file_reference TCA to
support additional fields in the output of the header.
This can be used by any extension.

Resolves: #36052
Releases: 6.2
Change-Id: I7770044c11a6c1a1bcb51a3bfc11b85923653196
Reviewed-on: https://review.typo3.org/21916
Reviewed-by: Philipp Gampe
Tested-by: Philipp Gampe
Reviewed-by: Markus Klein
Tested-by: Markus Klein
Reviewed-by: Steffen Ritter
Tested-by: Steffen Ritter
typo3/sysext/backend/Classes/Form/Element/InlineElement.php
typo3/sysext/core/Classes/Resource/Service/UserFileInlineLabelService.php [new file with mode: 0644]
typo3/sysext/core/Configuration/TCA/sys_file_reference.php
typo3/sysext/t3skin/stylesheets/structure/element_tceforms.css
typo3/sysext/t3skin/stylesheets/visual/element_tceforms.css

index fb8806c..1ac0a13 100644 (file)
@@ -521,6 +521,7 @@ class InlineElement {
                                'row' => $rec,
                                'title' => '',
                                'isOnSymmetricSide' => $isOnSymmetricSide,
+                               'options' => isset($GLOBALS['TCA'][$foreign_table]['ctrl']['label_userFunc_options']) ? $GLOBALS['TCA'][$foreign_table]['ctrl']['label_userFunc_options'] : array(),
                                'parent' => array(
                                        'uid' => $parentUid,
                                        'config' => $config
@@ -2478,4 +2479,4 @@ class InlineElement {
 }
 
 
-?>
\ No newline at end of file
+?>
diff --git a/typo3/sysext/core/Classes/Resource/Service/UserFileInlineLabelService.php b/typo3/sysext/core/Classes/Resource/Service/UserFileInlineLabelService.php
new file mode 100644 (file)
index 0000000..3b8d3a3
--- /dev/null
@@ -0,0 +1,82 @@
+<?php
+namespace TYPO3\CMS\Core\Resource\Service;
+
+/***************************************************************
+ *  Copyright notice
+ *
+ *  (c) 2013 Tim Lochmueller <tim@fruit-lab.de>
+ *  All rights reserved
+ *
+ *  This script is part of the TYPO3 project. The TYPO3 project is
+ *  free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  The GNU General Public License can be found at
+ *  http://www.gnu.org/copyleft/gpl.html.
+ *  A copy is found in the textfile GPL.txt and important notices to the license
+ *  from the author is found in LICENSE.txt distributed with these scripts.
+ *
+ *
+ *  This script is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  This copyright notice MUST APPEAR in all copies of the script!
+ ***************************************************************/
+
+use TYPO3\CMS\Backend\Utility\BackendUtility;
+use TYPO3\CMS\Extbase\Utility\LocalizationUtility;
+
+/**
+ * User file inline label service
+ */
+class UserFileInlineLabelService {
+
+       /**
+        * Get the user function label for the file_reference table
+        *
+        * @param array $params
+        * @return void
+        */
+       public function getInlineLabel(array &$params) {
+               $sysFileFields = isset($params['options']['sys_file']) && is_array($params['options']['sys_file'])
+                       ? $params['options']['sys_file']
+                       : array();
+
+               if (!count($sysFileFields)) {
+                       // Nothing to do
+                       return;
+               }
+
+               $fileInfo = BackendUtility::splitTable_Uid($params['row']['uid_local'], 2);
+               $fileRecord = BackendUtility::getRecord($fileInfo[0], $fileInfo[1]);
+
+               // Configuration
+               $title = array();
+               foreach ($sysFileFields as $field) {
+                       $value = '';
+                       if ($field === 'title') {
+                               $value = isset($params['row']['title'])
+                                       ? $params['row']['title']
+                                       : BackendUtility::getRecordTitle('sys_file', $fileRecord, TRUE);
+                       } else {
+                               if (isset($params['row'][$field])) {
+                                       $value = $params['row'][$field];
+                               } elseif (isset($fileRecord[$field])) {
+                                       $value = BackendUtility::getRecordTitlePrep($fileRecord[$field]);
+                               }
+                       }
+                       if (!strlen($value)) {
+                               continue;
+                       }
+                       $labelText = LocalizationUtility::translate('LLL:EXT:lang/locallang_tca.xlf:sys_file.' . $field, 'lang');
+                       $title[] = '<dt>' . htmlspecialchars($labelText) . '</dt>' . '<dd>' . htmlspecialchars($value) . '</dd>';
+               }
+               $params['title'] = '<dl>' . implode('', $title) . '</dl>';
+       }
+}
+
+?>
\ No newline at end of file
index b8548a4..e43c39f 100644 (file)
@@ -3,6 +3,13 @@ return array(
        'ctrl' => array(
                'title' => 'LLL:EXT:lang/locallang_tca.xlf:sys_file_reference',
                'label' => 'uid',
+               'label_userFunc' => 'EXT:core/Classes/Resource/Service/UserFileInlineLabelService.php:TYPO3\\CMS\\Core\\Resource\\Service\\UserFileInlineLabelService->getInlineLabel',
+               'label_userFunc_options' => array(
+                       'sys_file' => array(
+                               'title',
+                               'name'
+                       )
+               ),
                'tstamp' => 'tstamp',
                'crdate' => 'crdate',
                'cruser_id' => 'cruser_id',
@@ -256,4 +263,4 @@ return array(
                )
        )
 );
-?>
+?>
\ No newline at end of file
index ea8c92c..a9bce06 100644 (file)
@@ -462,6 +462,19 @@ div.t3-form-field-header-inline td {
        text-align:left;
 }
 
+.t3-form-field-header-inline td.t3-form-field-header-inline-summary dl {
+       overflow: hidden;
+}
+
+.t3-form-field-header-inline td.t3-form-field-header-inline-summary dl dt {
+       float: left;
+       clear: left;
+       margin-right: 10px;
+}
+.t3-form-field-header-inline td.t3-form-field-header-inline-summary dl dd {
+       float: left;
+}
+
 .t3-form-field-header-inline td.t3-form-field-header-inline-icon {
        width:25px;
 }
index fd86a4e..1ba4c4a 100644 (file)
@@ -430,6 +430,10 @@ TCEforms Inline-Relational-Record-Editing
        cursor: pointer;
 }
 
+.t3-form-field-header-inline td.t3-form-field-header-inline-summary dl dt {
+       font-weight: bold;
+}
+
 /* - - - - - - - - - - - - - - - - - - - - -
 TCEforms Sections
 - - - - - - - - - - - - - - - - - - - - - */