[TASK] Use new way to register colorpicker wizard 45/27945/5
authorAlexander Schnitzler <typo3@alexanderschnitzler.de>
Fri, 28 Feb 2014 14:00:01 +0000 (15:00 +0100)
committerHelmut Hummel <helmut.hummel@typo3.org>
Sat, 1 Mar 2014 16:18:16 +0000 (17:18 +0100)
Resolves: #56436
Releases: 6.2
Change-Id: Ia789abbbdf7ab11a4ab13ea6aa195bc79ba6dc25
Reviewed-on: https://review.typo3.org/27945
Reviewed-by: Wouter Wolters
Tested-by: Wouter Wolters
Reviewed-by: Helmut Hummel
Tested-by: Helmut Hummel
typo3/sysext/backend/Classes/Controller/Wizard/ColorpickerController.php
typo3/sysext/backend/Classes/Form/FormEngine.php
typo3/sysext/backend/Modules/Wizards/ColorpickerWizard/conf.php [new file with mode: 0644]
typo3/sysext/backend/Modules/Wizards/ColorpickerWizard/index.php [new file with mode: 0644]
typo3/sysext/backend/ext_tables.php
typo3/wizard_colorpicker.php

index f2a037e..1335d00 100644 (file)
@@ -27,6 +27,7 @@ namespace TYPO3\CMS\Backend\Controller\Wizard;
  *  This copyright notice MUST APPEAR in all copies of the script!
  ***************************************************************/
 
+use TYPO3\CMS\Backend\Utility\BackendUtility;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
 
 /**
@@ -149,10 +150,10 @@ class ColorpickerController {
                                $this->imageError = 'ERROR: The image, "' . $this->exampleImg . '", could not be found!';
                        }
                }
-               // Setting field-change functions:
-               $fieldChangeFuncArr = unserialize($this->fieldChangeFunc);
                $update = '';
                if ($this->areFieldChangeFunctionsValid()) {
+                       // Setting field-change functions:
+                       $fieldChangeFuncArr = unserialize($this->fieldChangeFunc);
                        unset($fieldChangeFuncArr['alert']);
                        foreach ($fieldChangeFuncArr as $v) {
                                $update .= '
@@ -208,7 +209,7 @@ class ColorpickerController {
                } else {
                        // Putting together the items into a form:
                        $content = '
-                               <form name="colorform" method="post" action="wizard_colorpicker.php">
+                               <form name="colorform" method="post" action="' . htmlspecialchars(BackendUtility::getModuleUrl('wizard_colorpicker')) . '">
                                        ' . $this->colorMatrix() . '
                                        ' . $this->colorList() . '
                                        ' . $this->colorImage() . '
@@ -275,7 +276,19 @@ class ColorpickerController {
                ');
                $this->content = $GLOBALS['TBE_TEMPLATE']->startPage($GLOBALS['LANG']->getLL('colorpicker_title'));
                // URL for the inner main frame:
-               $url = 'wizard_colorpicker.php?showPicker=1' . '&colorValue=' . rawurlencode($this->P['currentValue']) . '&fieldName=' . rawurlencode($this->P['itemName']) . '&formName=' . rawurlencode($this->P['formName']) . '&exampleImg=' . rawurlencode($this->P['exampleImg']) . '&md5ID=' . rawurlencode($this->P['md5ID']) . '&fieldChangeFunc=' . rawurlencode(serialize($this->P['fieldChangeFunc'])) . '&fieldChangeFuncHash=' . $this->P['fieldChangeFuncHash'];
+               $url = BackendUtility::getModuleUrl(
+                       'wizard_colorpicker',
+                       array(
+                               'showPicker' => 1,
+                               'colorValue' => $this->P['currentValue'],
+                               'fieldName' => $this->P['itemName'],
+                               'formName' => $this->P['formName'],
+                               'exampleImg' => $this->P['exampleImg'],
+                               'md5ID' => $this->P['md5ID'],
+                               'fieldChangeFunc' => serialize($this->P['fieldChangeFunc']),
+                               'fieldChangeFuncHash' => $this->P['fieldChangeFuncHash'],
+                       )
+               );
                $this->content .= '
                        <frameset rows="*,1" framespacing="0" frameborder="0" border="0">
                                <frame name="content" src="' . htmlspecialchars($url) . '" marginwidth="0" marginheight="0" frameborder="0" scrolling="auto" noresize="noresize" />
index ed76fdf..7e7b04a 100644 (file)
@@ -4180,11 +4180,8 @@ TBE_EDITOR.customEvalFunctions[\'' . $evalData . '\'] = function(value) {
                                                                        // Illeagal configuration, fail silently
                                                                        break;
                                                                }
+
                                                                $url = $this->backPath . $wScript . (strstr($wScript, '?') ? '' : '?');
-                                                               // If there is no script and the type is "colorbox", break right away:
-                                                               if ((string) $wConf['type'] == 'colorbox' && !$wConf['script']) {
-                                                                       break;
-                                                               }
                                                                // If "script" type, create the links around the icon:
                                                                if ((string) $wConf['type'] == 'script') {
                                                                        $aUrl = $url . GeneralUtility::implodeArrayForUrl('', array('P' => $params));
@@ -4197,37 +4194,37 @@ TBE_EDITOR.customEvalFunctions[\'' . $evalData . '\'] = function(value) {
                                                                        $params['fieldChangeFunc'] = $fieldChangeFunc;
                                                                        $params['fieldChangeFuncHash'] = GeneralUtility::hmac(serialize($fieldChangeFunc));
                                                                        switch ((string) $wConf['type']) {
-                                                                       case 'popup':
-
-                                                                       case 'colorbox':
-                                                                               // Current form value is passed as P[currentValue]!
-                                                                               $addJS = $wConf['popup_onlyOpenIfSelected'] ? 'if (!TBE_EDITOR.curSelected(\'' . $itemName . $listFlag . '\')){alert(' . GeneralUtility::quoteJSvalue($this->getLL('m_noSelItemForEdit')) . '); return false;}' : '';
-                                                                               $curSelectedValues = '+\'&P[currentSelectedValues]=\'+TBE_EDITOR.curSelected(\'' . $itemName . $listFlag . '\')';
-                                                                               $aOnClick = 'this.blur();' . $addJS . 'vHWin=window.open(\'' . $url . GeneralUtility::implodeArrayForUrl('', array('P' => $params)) . '\'+\'&P[currentValue]=\'+TBE_EDITOR.rawurlencode(' . $this->elName($itemName) . '.value,200)' . $curSelectedValues . ',\'popUp' . $md5ID . '\',\'' . $wConf['JSopenParams'] . '\');' . 'vHWin.focus();return false;';
-                                                                               // Setting "colorBoxLinks" - user LATER to wrap around the color box as well:
-                                                                               $colorBoxLinks = array('<a href="#" onclick="' . htmlspecialchars($aOnClick) . '">', '</a>');
-                                                                               if ((string) $wConf['type'] == 'popup') {
-                                                                                       $outArr[] = $colorBoxLinks[0] . $icon . $colorBoxLinks[1];
-                                                                               }
-                                                                               break;
-                                                                       case 'userFunc':
-                                                                               // Reference set!
-                                                                               $params['item'] = &$item;
-                                                                               $params['icon'] = $icon;
-                                                                               $params['iTitle'] = $iTitle;
-                                                                               $params['wConf'] = $wConf;
-                                                                               $params['row'] = $row;
-                                                                               $outArr[] = GeneralUtility::callUserFunction($wConf['userFunc'], $params, $this);
-                                                                               break;
-                                                                       case 'slider':
-                                                                               // Reference set!
-                                                                               $params['item'] = &$item;
-                                                                               $params['icon'] = $icon;
-                                                                               $params['iTitle'] = $iTitle;
-                                                                               $params['wConf'] = $wConf;
-                                                                               $params['row'] = $row;
-                                                                               $wizard = GeneralUtility::makeInstance('TYPO3\\CMS\\Backend\\Form\\Element\\ValueSlider');
-                                                                               $outArr[] = call_user_func_array(array(&$wizard, 'renderWizard'), array(&$params, &$this));
+                                                                               case 'popup':
+                                                                               case 'colorbox':
+                                                                                       // Current form value is passed as P[currentValue]!
+                                                                                       $addJS = $wConf['popup_onlyOpenIfSelected'] ? 'if (!TBE_EDITOR.curSelected(\'' . $itemName . $listFlag . '\')){alert(' . GeneralUtility::quoteJSvalue($this->getLL('m_noSelItemForEdit')) . '); return false;}' : '';
+                                                                                       $curSelectedValues = '+\'&P[currentSelectedValues]=\'+TBE_EDITOR.curSelected(\'' . $itemName . $listFlag . '\')';
+                                                                                       $aOnClick = 'this.blur();' . $addJS . 'vHWin=window.open(\'' . $url . GeneralUtility::implodeArrayForUrl('', array('P' => $params)) . '\'+\'&P[currentValue]=\'+TBE_EDITOR.rawurlencode(' . $this->elName($itemName) . '.value,200)' . $curSelectedValues . ',\'popUp' . $md5ID . '\',\'' . $wConf['JSopenParams'] . '\');' . 'vHWin.focus();return false;';
+                                                                                       // Setting "colorBoxLinks" - user LATER to wrap around the color box as well:
+                                                                                       $colorBoxLinks = array('<a href="#" onclick="' . htmlspecialchars($aOnClick) . '">', '</a>');
+                                                                                       if ((string) $wConf['type'] == 'popup') {
+                                                                                               $outArr[] = $colorBoxLinks[0] . $icon . $colorBoxLinks[1];
+                                                                                       }
+                                                                                       break;
+                                                                               case 'userFunc':
+                                                                                       // Reference set!
+                                                                                       $params['item'] = &$item;
+                                                                                       $params['icon'] = $icon;
+                                                                                       $params['iTitle'] = $iTitle;
+                                                                                       $params['wConf'] = $wConf;
+                                                                                       $params['row'] = $row;
+                                                                                       $outArr[] = GeneralUtility::callUserFunction($wConf['userFunc'], $params, $this);
+                                                                                       break;
+                                                                               case 'slider':
+                                                                                       // Reference set!
+                                                                                       $params['item'] = &$item;
+                                                                                       $params['icon'] = $icon;
+                                                                                       $params['iTitle'] = $iTitle;
+                                                                                       $params['wConf'] = $wConf;
+                                                                                       $params['row'] = $row;
+                                                                                       $wizard = GeneralUtility::makeInstance('TYPO3\\CMS\\Backend\\Form\\Element\\ValueSlider');
+                                                                                       $outArr[] = call_user_func_array(array(&$wizard, 'renderWizard'), array(&$params, &$this));
+                                                                                       break;
                                                                        }
                                                                }
                                                                // Hide the real form element?
@@ -4273,7 +4270,7 @@ TBE_EDITOR.customEvalFunctions[\'' . $evalData . '\'] = function(value) {
                                                        break;
                                        }
                                        // Color wizard colorbox:
-                                       if ((string) $wConf['type'] == 'colorbox') {
+                                       if ((string) $wConf['type'] === 'colorbox') {
                                                $dim = GeneralUtility::intExplode('x', $wConf['dim']);
                                                $dX = MathUtility::forceIntegerInRange($dim[0], 1, 200, 20);
                                                $dY = MathUtility::forceIntegerInRange($dim[1], 1, 200, 20);
diff --git a/typo3/sysext/backend/Modules/Wizards/ColorpickerWizard/conf.php b/typo3/sysext/backend/Modules/Wizards/ColorpickerWizard/conf.php
new file mode 100644 (file)
index 0000000..2d01a52
--- /dev/null
@@ -0,0 +1,6 @@
+<?php
+//required for mod.php
+$MCONF['name'] = 'wizard_colorpicker';
+$MCONF['script'] = '_DISPATCH';
+$MCONF['access'] = '';
+?>
diff --git a/typo3/sysext/backend/Modules/Wizards/ColorpickerWizard/index.php b/typo3/sysext/backend/Modules/Wizards/ColorpickerWizard/index.php
new file mode 100644 (file)
index 0000000..9539df1
--- /dev/null
@@ -0,0 +1,33 @@
+<?php
+/***************************************************************
+ *  Copyright notice
+ *
+ *  (c) 2014 2014 Alexander Schnitzler (typo3@alexanderschnitzler.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 text file 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!
+ ***************************************************************/
+
+/**
+ * Wizard for choosing colors in TCEforms
+ */
+$colorpickerController = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Backend\\Controller\\Wizard\\ColorpickerController');
+$colorpickerController->main();
+$colorpickerController->printContent();
index 901d6f2..9287c16 100644 (file)
@@ -39,4 +39,10 @@ if (TYPO3_MODE === 'BE') {
                'wizard_rte',
                \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath($_EXTKEY) . 'Modules/Wizards/RteWizard/'
        );
+
+       // Register colorpicker wizard
+       \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addModulePath(
+               'wizard_colorpicker',
+               \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath($_EXTKEY) . 'Modules/Wizards/ColorpickerWizard/'
+       );
 }
\ No newline at end of file
index 166fc08..87e2fdf 100644 (file)
@@ -34,6 +34,9 @@
  */
 require __DIR__ . '/init.php';
 
+\TYPO3\CMS\Core\Utility\GeneralUtility::deprecationLog('The way registering a wizard in TCA has chan
+ged in 6.2. Please set module[name]=wizard_colorpicker instead of script=wizard_colorpicker.php in your TCA. This
+script will be removed in two versions.');
 $colorpickerController = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Backend\\Controller\\Wizard\\ColorpickerController');
 $colorpickerController->main();
 $colorpickerController->printContent();