Fixed bug #17265: CSH in Flexforms broken when label indices contain more than one dot
authorFrancois Suter <francois.suter@typo3.org>
Tue, 25 Jan 2011 20:51:14 +0000 (20:51 +0000)
committerFrancois Suter <francois.suter@typo3.org>
Tue, 25 Jan 2011 20:51:14 +0000 (20:51 +0000)
git-svn-id: https://svn.typo3.org/TYPO3v4/Core/trunk@10311 709f56b5-9817-0410-a4d7-c38de5d9e867

ChangeLog
typo3/sysext/lang/lang.php
typo3/view_help.php

index 3cdb91f..21e0915 100755 (executable)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2011-01-25  Francois Suter  <francois.suter@typo3.org>
+
+       * Fixed bug #17265: CSH in Flexforms broken when label indices contain more than one dot
+
 2011-01-25  Ernesto Baschny  <ernst@cron-it.de>
 
        * Re-added feature #17313: Since using new flags from sprites (#15668), the sys_language hasn't a flag-selector by icon (Thanks to Jo Hasenau)
index 1fcb9d0..244444b 100755 (executable)
@@ -403,30 +403,47 @@ class language {
                                        // Traverse all keys
                                if (is_array($LOCAL_LANG['default'])) {
                                        foreach ($LOCAL_LANG['default'] as $lkey => $lVal) {
+                                               $type = '';
+                                               $fieldName = '';
+
+                                                       // Exploding by '.':
+                                                       // 0-n => fieldname,
+                                                       // n+1 => type from (alttitle, description, details, syntax, image_descr,image,seeAlso),
+                                                       // n+2 => special instruction, if any
+                                               $keyParts = explode('.', $lkey);
+                                               $keyPartsCount = count($keyParts);
+                                                       // Check if last part is special instruction
+                                                       // Only "+" is currently supported
+                                               $specialInstruction = ($keyParts[$keyPartsCount - 1] == '+') ? TRUE : FALSE;
+                                               if ($specialInstruction) {
+                                                       array_pop($keyParts);
+                                               }
 
-                                                       // exploding by '.':
-                                                       // 0 => fieldname,
-                                                       // 1 => type from (alttitle, description, details, syntax, image_descr,image,seeAlso),
-                                                       // 2 => special instruction, see switch construct
-                                               $kParts = explode('.', $lkey);
+                                                       // If there are more than 2 parts, get the type from the last part
+                                                       // and merge back the other parts with a dot (.)
+                                                       // Otherwise just get type and field name straightaway
+                                               if ($keyPartsCount > 2) {
+                                                       $type = array_pop($keyParts);
+                                                       $fieldName = implode('.', $keyParts);
+                                               } else {
+                                                       $fieldName = $keyParts[0];
+                                                       $type = $keyParts[1];
+                                               }
 
                                                        // Detecting 'hidden' labels, converting to normal fieldname
-                                               if ($kParts[0] == '_') {
-                                                       $kParts[0] = '';
+                                               if ($fieldName == '_') {
+                                                       $fieldName = '';
                                                }
-                                               if (substr($kParts[0], 0, 1) == '_') {
-                                                       $kParts[0] = substr($kParts[0], 1);
+                                               if (substr($fieldName, 0, 1) == '_') {
+                                                       $fieldName = substr($fieldName, 1);
                                                }
 
-                                                       // Add label:
-                                               switch ((string)$kParts[2]) {
-                                                               // adding
-                                                       case '+':
-                                                               $TCA_DESCR[$table]['columns'][$kParts[0]][$kParts[1]] .= LF . $lVal;
-                                                               break;
-                                                               // Substituting:
-                                                       default:
-                                                               $TCA_DESCR[$table]['columns'][$kParts[0]][$kParts[1]] = $lVal;
+                                                       // Append label
+                                               if ($specialInstruction) {
+                                                       $TCA_DESCR[$table]['columns'][$fieldName][$type] .= LF . $lVal;
+                                               } else {
+                                                               // Substitute label
+                                                       $TCA_DESCR[$table]['columns'][$fieldName][$type] = $lVal;
                                                }
                                        }
                                }
index 6a84787..199f5ae 100644 (file)
@@ -175,9 +175,20 @@ class SC_view_help {
                $this->field = array_shift($identifierParts);
                        // There may be extra parts for FlexForms
                if (count($identifierParts) > 0) {
-                       $flexFormField = array_pop($identifierParts);
-                       $extraIdentifierInformation = $identifierParts;
-                               // Assemble a different main key and switch field to use flexform field name
+                               // There's at least one extra part
+                       $extraIdentifierInformation = array();
+                       $extraIdentifierInformation[] = array_shift($identifierParts);
+                               // Load the TCA details of the table
+                       t3lib_div::loadTCA($this->table);
+                               // If the ds_pointerField contains a comma, it means the choice of FlexForm DS
+                               // is determined by 2 parameters. In this case we have an extra identifier part
+                       if (strpos($TCA[$this->table]['columns'][$this->field]['config']['ds_pointerField'], ',') !== FALSE) {
+                               $extraIdentifierInformation[] = array_shift($identifierParts);
+                       }
+                               // The remaining parts make up the FlexForm field name itself
+                               // (reassembled with dots)
+                       $flexFormField = implode('.', $identifierParts);
+                               // Assemble a different main key and switch field to use FlexForm field name
                        $this->mainKey .= '.' . $this->field;
                        foreach ($extraIdentifierInformation as $extraKey) {
                                $this->mainKey .= '.' . $extraKey;