src/Contao/View/Contao2BackendView/EventListener/ColorPickerWizardListener.php
public static function getWizard($propInfo, EnvironmentInterface $environment)
    {
        $wizard    = '';
        $propExtra = $propInfo->getExtra();

        if (\is_array($propExtra) && \array_key_exists('colorpicker', $propExtra) && $propExtra['colorpicker']) {
            $pickerText = $environment->getTranslator()->translate('colorpicker', 'MSC');
            $event      = new GenerateHtmlEvent(
                'pickcolor.svg',
                $pickerText,
                \sprintf(
                    'style="%s" title="%s" id="moo_%s"',
                    'vertical-align:top;cursor:pointer',
                    StringUtil::specialchars($pickerText),
                    $propInfo->getName()
                )
            );

            $environment->getEventDispatcher()->dispatch(ContaoEvents::IMAGE_GET_HTML, $event);

            // Support single fields as well (see contao/core#5240)
            $strKey = $propExtra['multiple'] ? $propInfo->getName() . '_0' : $propInfo->getName();

            $wizard .= \sprintf(
                ' %1$s <script>var cl;window.addEvent("domready", function() { new MooRainbow("moo_%2$s", {' .
                'id: "ctrl_%3$s", startColor: ((cl = $("ctrl_%3$s").value.hexToRgb(true)) ? cl : [255, 0, 0]),' .
                'imgPath: "%4$s", onComplete: function(color) {$("ctrl_%3$s").value = color.hex.replace("#", "");}});' .
                '});</script>',
                $event->getHtml(),
                $propInfo->getName(),
                $strKey,
                'assets/colorpicker/images/'
            );
        }

        return $wizard;
    }
public static function getWizard($propInfo, EnvironmentInterface $environment)
    {
        $wizard    = '';
        $propExtra = $propInfo->getExtra();

        if (\is_array($propExtra) && \array_key_exists('colorpicker', $propExtra) && $propExtra['colorpicker']) {
            $pickerText = $environment->getTranslator()->translate('colorpicker', 'MSC');
            $event      = new GenerateHtmlEvent(
                'pickcolor.svg',
                $pickerText,
                \sprintf(
                    'style="%s" title="%s" id="moo_%s"',
                    'vertical-align:top;cursor:pointer',
                    StringUtil::specialchars($pickerText),
                    $propInfo->getName()
                )
            );

            $environment->getEventDispatcher()->dispatch(ContaoEvents::IMAGE_GET_HTML, $event);

            // Support single fields as well (see contao/core#5240)
            $strKey = $propExtra['multiple'] ? $propInfo->getName() . '_0' : $propInfo->getName();

            $wizard .= \sprintf(
                ' %1$s <script>var cl;window.addEvent("domready", function() { new MooRainbow("moo_%2$s", {' .
                'id: "ctrl_%3$s", startColor: ((cl = $("ctrl_%3$s").value.hexToRgb(true)) ? cl : [255, 0, 0]),' .
                'imgPath: "%4$s", onComplete: function(color) {$("ctrl_%3$s").value = color.hex.replace("#", "");}});' .
                '});</script>',
                $event->getHtml(),
                $propInfo->getName(),
                $strKey,
                'assets/colorpicker/images/'
            );
        }

        return $wizard;
    }
public static function getWizard ( $ propInfo , EnvironmentInterface $ environment ) { $ wizard = '' ; $ propExtra = $ propInfo -> getExtra ( ) ; if ( \ is_array ( $ propExtra ) && \ array_key_exists ( 'colorpicker' , $ propExtra ) && $ propExtra [ 'colorpicker' ] ) { $ pickerText = $ environment -> getTranslator ( ) -> translate ( 'colorpicker' , 'MSC' ) ; $ event = new GenerateHtmlEvent ( 'pickcolor.svg' , $ pickerText , \ sprintf ( 'style="%s" title="%s" id="moo_%s"' , 'vertical-align:top;cursor:pointer' , StringUtil :: specialchars ( $ pickerText ) , $ propInfo -> getName ( ) ) ) ; $ environment -> getEventDispatcher ( ) -> dispatch ( ContaoEvents :: IMAGE_GET_HTML , $ event ) ; // Support single fields as well (see contao/core#5240) $ strKey = $ propExtra [ 'multiple' ] ? $ propInfo -> getName ( ) . '_0' : $ propInfo -> getName ( ) ; $ wizard .= \ sprintf ( ' %1$s <script>var cl;window.addEvent("domready", function() { new MooRainbow("moo_%2$s", {' . 'id: "ctrl_%3$s", startColor: ((cl = $("ctrl_%3$s").value.hexToRgb(true)) ? cl : [255, 0, 0]),' . 'imgPath: "%4$s", onComplete: function(color) {$("ctrl_%3$s").value = color.hex.replace("#", "");}});' . '});</script>' , $ event -> getHtml ( ) , $ propInfo -> getName ( ) , $ strKey , 'assets/colorpicker/images/' ) ; } return $ wizard ; }
Append wizard icons.

@param PropertyInterface    $propInfo    The property for which the wizards shall be generated.
@param EnvironmentInterface $environment The environment.

@return string

@SuppressWarnings(PHPMD.Superglobals)
@SuppressWarnings(PHPMD.CamelCaseVariableName)
Append wizard icons .