[TASK] Drop "iconsInOptionTags" option 51/43251/3
authorMathias Brodala <mbrodala@pagemachine.de>
Sat, 12 Sep 2015 19:02:15 +0000 (21:02 +0200)
committerChristian Kuhn <lolli@schwarzbu.ch>
Sun, 13 Sep 2015 00:07:59 +0000 (02:07 +0200)
Resolves: #69736
Releases: master
Change-Id: Ia09f202a75ed0f873fa1934bf2b2305ab3653222
Reviewed-on: http://review.typo3.org/43251
Reviewed-by: Nicole Cordes <typo3@cordes.co>
Tested-by: Nicole Cordes <typo3@cordes.co>
Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch>
Tested-by: Christian Kuhn <lolli@schwarzbu.ch>
13 files changed:
typo3/sysext/backend/Classes/Form/Container/InlineControlContainer.php
typo3/sysext/backend/Classes/Form/Element/SelectMultipleSideBySideElement.php
typo3/sysext/backend/Classes/Form/Element/SelectSingleBoxElement.php
typo3/sysext/backend/Classes/Form/Element/SelectSingleElement.php
typo3/sysext/backend/Classes/Form/Utility/FormEngineUtility.php
typo3/sysext/core/Classes/Migrations/TcaMigration.php
typo3/sysext/core/Configuration/TCA/be_groups.php
typo3/sysext/core/Configuration/TCA/be_users.php
typo3/sysext/core/Configuration/TCA/pages.php
typo3/sysext/core/Documentation/Changelog/master/Important-69736-SelectOptionIconsInOptionTagsRemoved.rst [new file with mode: 0644]
typo3/sysext/core/Tests/Unit/Migrations/TcaMigrationTest.php
typo3/sysext/frontend/Configuration/TCA/tt_content.php
typo3/sysext/workspaces/Configuration/TCA/sys_workspace.php

index f224d05..4d9ca36 100644 (file)
@@ -600,13 +600,9 @@ class InlineControlContainer extends AbstractContainer {
                        $nameObject = $this->inlineStackProcessor->getCurrentStructureDomObjectIdPrefix($this->data['inlineFirstPid']);;
                        // Create option tags:
                        $opt = array();
-                       $styleAttrValue = '';
                        foreach ($selItems as $p) {
-                               if ($config['iconsInOptionTags']) {
-                                       $styleAttrValue = FormEngineUtility::optionTagStyle($p[2]);
-                               }
                                if (!in_array($p[1], $uniqueIds)) {
-                                       $opt[] = '<option value="' . htmlspecialchars($p[1]) . '"' . ($styleAttrValue ? ' style="' . htmlspecialchars($styleAttrValue) . '"' : '') . '>' . htmlspecialchars($p[0]) . '</option>';
+                                       $opt[] = '<option value="' . htmlspecialchars($p[1]) . '">' . htmlspecialchars($p[0]) . '</option>';
                                }
                        }
                        // Put together the selector box:
index 695b893..ec2ddfa 100644 (file)
@@ -146,13 +146,8 @@ class SelectMultipleSideBySideElement extends AbstractFormElement {
                if (!$disabled) {
                        // Create option tags:
                        $opt = array();
-                       $styleAttrValue = '';
                        foreach ($selItems as $p) {
-                               if ($config['iconsInOptionTags']) {
-                                       $styleAttrValue = FormEngineUtility::optionTagStyle($p[2]);
-                               }
                                $opt[] = '<option value="' . htmlspecialchars($p[1]) . '"'
-                                       . ($styleAttrValue ? ' style="' . htmlspecialchars($styleAttrValue) . '"' : '')
                                        . ' title="' . $p[0] . '">' . $p[0] . '</option>';
                        }
                        // Put together the selector box:
index ef6f670..f1a8710 100644 (file)
@@ -108,14 +108,8 @@ class SelectSingleBoxElement extends AbstractFormElement {
                        if ((string)$p[1] === '--div--') {
                                $nonSel = ' onclick="this.selected=0;" class="formcontrol-select-divider"';
                        }
-                       // Icon style for option tag:
-                       $styleAttrValue = '';
-                       if ($config['iconsInOptionTags']) {
-                               $styleAttrValue = FormEngineUtility::optionTagStyle($p[2]);
-                       }
                        // Compile <option> tag:
-                       $opt[] = '<option value="' . htmlspecialchars($p[1]) . '"' . $sM . $nonSel
-                               . ($styleAttrValue ? ' style="' . htmlspecialchars($styleAttrValue) . '"' : '') . '>'
+                       $opt[] = '<option value="' . htmlspecialchars($p[1]) . '"' . $sM . $nonSel . '>'
                                . htmlspecialchars($p[0], ENT_COMPAT, 'UTF-8', FALSE) . '</option>';
                        $c++;
                }
index 64ff57e..15f0dba 100644 (file)
@@ -177,11 +177,6 @@ class SelectSingleElement extends AbstractFormElement {
                                // ICON
                                if ($icon && !$suppressIcons && (!$onlySelectedIconShown || $selected)) {
                                        $onClick = 'document.editform[' . GeneralUtility::quoteJSvalue($parameterArray['itemFormElName']) . '].selectedIndex=' . $selectItemCounter . ';';
-                                       if ($config['iconsInOptionTags']) {
-                                               $onClick .= 'document.getElementById(' . GeneralUtility::quoteJSvalue($selectId . '_icon') . ').innerHTML = '
-                                                       . 'document.editform[' . GeneralUtility::quoteJSvalue($parameterArray['itemFormElName']) . ']'
-                                                       . '.options[' . $selectItemCounter . '].getAttribute(\'data-icon\'); ';
-                                       }
                                        $onClick .= implode('', $parameterArray['fieldChangeFunc']);
                                        $onClick .= 'this.blur();return false;';
                                        $selectIcons[] = array(
@@ -225,23 +220,11 @@ class SelectSingleElement extends AbstractFormElement {
 
                // Create item form fields:
                $sOnChange = 'if (this.options[this.selectedIndex].value==\'--div--\') {this.selectedIndex=' . $selectedIndex . ';} ';
-               if ($config['iconsInOptionTags']) {
-                       $sOnChange .= 'document.getElementById(' . GeneralUtility::quoteJSvalue($selectId . '_icon') . ').innerHTML = this.options[this.selectedIndex].getAttribute(\'data-icon\'); ';
-               }
                $sOnChange .= implode('', $parameterArray['fieldChangeFunc']);
 
-               // Add icons in option tags
-               $prepend = '';
-               $append = '';
-               if ($config['iconsInOptionTags']) {
-                       $prepend = '<div class="input-group"><div id="' . $selectId . '_icon" class="input-group-addon input-group-icon t3js-formengine-select-prepend">' . $selectedIcon . '</div>';
-                       $append = '</div>';
-               }
-
                // Build the element
                $out .= '
                        <div class="form-control-wrap">
-                               ' . $prepend . '
                                <select'
                                        . ' id="' . $selectId . '"'
                                        . ' name="' . htmlspecialchars($parameterArray['itemFormElName']) . '"'
@@ -254,7 +237,6 @@ class SelectSingleElement extends AbstractFormElement {
                                        . '>
                                        ' . $options . '
                                </select>
-                               ' . $append . '
                        </div>';
 
                // Create icon table:
index 6faefac..9d5417f 100644 (file)
@@ -206,36 +206,6 @@ class FormEngineUtility {
        }
 
        /**
-        * Creates style attribute content for option tags in a selector box, primarily setting
-        * it up to show the icon of an element as background image (works in mozilla)
-        *
-        * @param string $iconString Icon string for option item
-        * @return string Style attribute content, if any
-        * @internal
-        */
-       static public function optionTagStyle($iconString) {
-               if (!$iconString) {
-                       return '';
-               }
-               list($selIconFile, $selIconInfo) = static::getIcon($iconString);
-               if (empty($selIconFile)) {
-                       // Skip background style if image is unavailable
-                       return '';
-               }
-               $padLeft = $selIconInfo[0] + 4;
-               if ($padLeft >= 18 && $padLeft <= 24) {
-                       // In order to get the same padding for all option tags even if icon sizes differ a little,
-                       // set it to 22 if it was between 18 and 24 pixels
-                       $padLeft = 22;
-               }
-               $padTop = MathUtility::forceIntegerInRange(($selIconInfo[1] - 12) / 2, 0);
-               $styleAttr = 'background: #fff url(' . $selIconFile . ') 0% 50% no-repeat; height: '
-                       . MathUtility::forceIntegerInRange(($selIconInfo[1] + 2 - $padTop), 0)
-                       . 'px; padding-top: ' . $padTop . 'px; padding-left: ' . $padLeft . 'px;';
-               return $styleAttr;
-       }
-
-       /**
         * Extracts FlexForm parts of a form element name like
         * data[table][uid][field][sDEF][lDEF][FlexForm][vDEF]
         * Helper method used in inline
index 0b0aec4..7fb1945 100644 (file)
@@ -46,6 +46,7 @@ class TcaMigration {
                $tca = $this->migrateShowItemAdditionalPaletteToOwnPalette($tca);
                $tca = $this->migrateIconsForFormFieldWizardsToNewLocation($tca);
                $tca = $this->migrateExtAndSysextPathToEXTPath($tca);
+               $tca = $this->migrateIconsInOptionTags($tca);
                // @todo: if showitem/defaultExtras wizards[xy] is migrated to columnsOverrides here, enableByTypeConfig could be dropped
                return $tca;
        }
@@ -441,4 +442,28 @@ class TcaMigration {
                }
                return $tca;
        }
+
+       /**
+        * Migrate "iconsInOptionTags" for "select" TCA fields
+        *
+        * @param array $tca Incoming TCA
+        * @return array Migrated TCA
+        */
+       protected function migrateIconsInOptionTags($tca) {
+               $newTca = $tca;
+
+               foreach ($newTca as $table => &$tableDefinition) {
+                       if (!isset($tableDefinition['columns']) || !is_array($tableDefinition['columns'])) {
+                               continue;
+                       }
+                       foreach ($tableDefinition['columns'] as $fieldName => &$fieldConfig) {
+                               if (isset($fieldConfig['config']['iconsInOptionTags'])) {
+                                       unset($fieldConfig['config']['iconsInOptionTags']);
+                                       $this->messages[] = 'Configuration option "iconsInOptionTags" was removed from field "' . $fieldName . '" in TCA table "' . $table . '"';
+                               }
+                       }
+               }
+
+               return $newTca;
+       }
 }
index e4fe348..c4b3ccd 100644 (file)
@@ -61,7 +61,6 @@ return array(
                                'size' => '3',
                                'maxitems' => 100,
                                'autoSizeMax' => 10,
-                               'iconsInOptionTags' => 1,
                                'wizards' => array(
                                        '_VERTICAL' => 1,
                                        'edit' => array(
@@ -152,7 +151,6 @@ return array(
                                'autoSizeMax' => 50,
                                'maxitems' => 20,
                                'renderMode' => 'checkbox',
-                               'iconsInOptionTags' => 1
                        )
                ),
                'tables_modify' => array(
@@ -164,7 +162,6 @@ return array(
                                'autoSizeMax' => 50,
                                'maxitems' => 100,
                                'renderMode' => 'checkbox',
-                               'iconsInOptionTags' => 1
                        )
                ),
                'tables_select' => array(
@@ -176,7 +173,6 @@ return array(
                                'autoSizeMax' => 50,
                                'maxitems' => 100,
                                'renderMode' => 'checkbox',
-                               'iconsInOptionTags' => 1
                        )
                ),
                'non_exclude_fields' => array(
@@ -243,7 +239,6 @@ return array(
                                'autoSizeMax' => 50,
                                'maxitems' => 100,
                                'renderMode' => 'checkbox',
-                               'iconsInOptionTags' => 1
                        )
                ),
                'description' => array(
@@ -281,7 +276,6 @@ return array(
                                'size' => '5',
                                'autoSizeMax' => 50,
                                'maxitems' => 20,
-                               'iconsInOptionTags' => 1
                        )
                ),
                'category_perms' => array(
index b6ee292..45665e5 100644 (file)
@@ -66,7 +66,6 @@ return array(
                                'foreign_table_where' => 'ORDER BY be_groups.title',
                                'size' => '5',
                                'maxitems' => '20',
-                               'iconsInOptionTags' => 1,
                                'enableMultiSelectFilterTextfield' => TRUE,
                                'wizards' => array(
                                        '_VERTICAL' => 1,
@@ -152,7 +151,6 @@ return array(
                                'size' => '3',
                                'maxitems' => 100,
                                'autoSizeMax' => 10,
-                               'iconsInOptionTags' => 1,
                                'wizards' => array(
                                        '_VERTICAL' => 1,
                                        'edit' => array(
@@ -322,7 +320,6 @@ return array(
                                'autoSizeMax' => 50,
                                'maxitems' => '100',
                                'renderMode' => 'checkbox',
-                               'iconsInOptionTags' => 1
                        )
                ),
                'allowed_languages' => array(
@@ -401,4 +398,4 @@ return array(
                        --div--;LLL:EXT:lang/locallang_tca.xlf:be_users.tabs.access, starttime,endtime,
                        --div--;LLL:EXT:lang/locallang_tca.xlf:be_users.tabs.extended')
        )
-);
\ No newline at end of file
+);
index 9f97096..12322d0 100644 (file)
@@ -124,7 +124,6 @@ return array(
                                        )
                                ),
                                'default' => (string)\TYPO3\CMS\Frontend\Page\PageRepository::DOKTYPE_DEFAULT,
-                               'iconsInOptionTags' => 1,
                                'noIconsBelowSelect' => 1
                        )
                ),
@@ -724,7 +723,6 @@ return array(
                                        )
                                ),
                                'default' => '',
-                               'iconsInOptionTags' => 1,
                                'noIconsBelowSelect' => 1
                        )
                ),
diff --git a/typo3/sysext/core/Documentation/Changelog/master/Important-69736-SelectOptionIconsInOptionTagsRemoved.rst b/typo3/sysext/core/Documentation/Changelog/master/Important-69736-SelectOptionIconsInOptionTagsRemoved.rst
new file mode 100644 (file)
index 0000000..c0c1cd1
--- /dev/null
@@ -0,0 +1,10 @@
+===========================================================
+Important: #69736 - Select option iconsInOptionTags removed
+===========================================================
+
+Description
+===========
+
+The option ``iconsInOptionTags`` of TCA ``select`` fields was removed due to little support in browsers.
+
+The usage of this option results in a deprecation log entry and is automatically removed in TCA tables during bootstrap.
\ No newline at end of file
index e9dc18a..826424f 100644 (file)
@@ -525,4 +525,36 @@ class TcaMigrationTest extends UnitTestCase {
                $subject = new TcaMigration();
                $this->assertEquals($expected, $subject->migrate($input));
        }
+
+       /**
+        * @test
+        */
+       public function migrateRemovesIconsInOptionTags() {
+               $input = array(
+                       'aTable' => array(
+                               'columns' => array(
+                                       'foo' => array(
+                                               'config' => array(
+                                                       'type' => 'select',
+                                                       'iconsInOptionTags' => 1,
+                                               ),
+                                       ),
+                               ),
+                       ),
+               );
+               $expected = array(
+                       'aTable' => array(
+                               'columns' => array(
+                                       'foo' => array(
+                                               'config' => array(
+                                                       'type' => 'select',
+                                               ),
+                                       ),
+                               ),
+                       ),
+               );
+
+               $subject = new TcaMigration();
+               $this->assertEquals($expected, $subject->migrate($input));
+       }
 }
index 8b57044..6186fe1 100644 (file)
@@ -119,7 +119,6 @@ return array(
                                'default' => 'text',
                                'authMode' => $GLOBALS['TYPO3_CONF_VARS']['BE']['explicitADmode'],
                                'authMode_enforce' => 'strict',
-                               'iconsInOptionTags' => 1,
                                'noIconsBelowSelect' => 1
                        )
                ),
@@ -566,7 +565,6 @@ return array(
                                ),
                                'selicon_cols' => 6,
                                'default' => '0',
-                               'iconsInOptionTags' => 1
                        )
                ),
                'imageborder' => array(
@@ -802,7 +800,6 @@ return array(
                                'itemsProcFunc' => \TYPO3\CMS\Frontend\Hooks\TableColumnHooks::class . '->sortPluginList',
                                'default' => '',
                                'authMode' => $GLOBALS['TYPO3_CONF_VARS']['BE']['explicitADmode'],
-                               'iconsInOptionTags' => 1,
                                'noIconsBelowSelect' => 1
                        )
                ),
index 032e925..4057931 100644 (file)
@@ -94,7 +94,6 @@ return array(
                                'maxitems' => 25,
                                'autoSizeMax' => 10,
                                'renderMode' => 'checkbox',
-                               'iconsInOptionTags' => 1
                        )
                ),
                'publish_time' => array(