[BUGFIX] Cleanup in SelectTreeElement 97/43697/5
authorAndreas Fernandez <a.fernandez@scripting-base.de>
Thu, 1 Oct 2015 14:07:22 +0000 (16:07 +0200)
committerNicole Cordes <typo3@cordes.co>
Thu, 1 Oct 2015 16:47:26 +0000 (18:47 +0200)
* Remove unnecessary $treeData variable
* Fix broken JS in onChange handler
* Enforce int casting of $width

Resolves: #70272
Releases: master
Change-Id: I76b2233a30f6c033839f53404340485f7302f9ca
Reviewed-on: http://review.typo3.org/43697
Reviewed-by: Helmut Hummel <helmut.hummel@typo3.org>
Tested-by: Andreas Bouche <andreas.bouche@flagbit.de>
Reviewed-by: Nicole Cordes <typo3@cordes.co>
Tested-by: Nicole Cordes <typo3@cordes.co>
Reviewed-by: Wouter Wolters <typo3@wouterwolters.nl>
Tested-by: Wouter Wolters <typo3@wouterwolters.nl>
typo3/sysext/backend/Classes/Form/Element/SelectTreeElement.php

index 8cbce6b..5b5f26d 100644 (file)
@@ -98,7 +98,6 @@ class SelectTreeElement extends AbstractFormElement {
                */
 
                $itemArray[] = $treeData;
-               $treeData = json_encode($itemArray);
                $id = md5($parameterArray['itemFormElName']);
                if (isset($config['size']) && (int)$config['size'] > 0) {
                        $height = (int)$config['size'] * 20;
@@ -166,13 +165,13 @@ class SelectTreeElement extends AbstractFormElement {
                $resultArray = $this->initializeResultArray();
                $resultArray['extJSCODE'] .= LF .
                        'Ext.onReady(function() {
-                       TYPO3.Components.Tree.StandardTreeItemData["' . $id . '"] = ' . $treeData . ';
+                       TYPO3.Components.Tree.StandardTreeItemData["' . $id . '"] = ' . json_encode($itemArray) . ';
                        var tree' . $id . ' = new TYPO3.Components.Tree.StandardTree({
                                id: "' . $id . '",
                                showHeader: ' . (int)$header . ',
-                               onChange: "' . $onChange . '",
+                               onChange: ' . GeneralUtility::quoteJSvalue($onChange) . ',
                                countSelectedNodes: ' . count($selectedNodes) . ',
-                               width: ' . $width . ',
+                               width: ' . (int)$width . ',
                                listeners: {
                                        click: function(node, event) {
                                                if (typeof(node.attributes.checked) == "boolean") {