Skip to content
Snippets Groups Projects
Commit 4ea127a7 authored by Michael Oehlhof's avatar Michael Oehlhof Committed by Wouter Wolters
Browse files

[TASK] Code cleanup: ColorpickerController.php

backend/classes/Controller/Wizard/ColorpickerController.php
To get it "green" in PhpStorm several changes were made:

- set correct return type in PhpDoc comment
- makeInstance of GraphicalFunctions to call non-static function
  imageCreateFromFile
- change local variable names to lowerCamelCase

Resolves: #65431
Releases: master
Change-Id: I54182c8ed17423e1cbc1c97e424d92a58dd5e3a9
Reviewed-on: http://review.typo3.org/37404


Reviewed-by: default avatarChristian Kuhn <lolli@schwarzbu.ch>
Tested-by: default avatarChristian Kuhn <lolli@schwarzbu.ch>
Reviewed-by: default avatarWouter Wolters <typo3@wouterwolters.nl>
Tested-by: default avatarWouter Wolters <typo3@wouterwolters.nl>
parent 149a9418
Branches
Tags
No related merge requests found
...@@ -111,6 +111,11 @@ class ColorpickerController extends AbstractWizardController { ...@@ -111,6 +111,11 @@ class ColorpickerController extends AbstractWizardController {
*/ */
public $content; public $content;
/**
* @var string
*/
protected $exampleImg;
/** /**
* Constructor * Constructor
*/ */
...@@ -303,7 +308,7 @@ class ColorpickerController extends AbstractWizardController { ...@@ -303,7 +308,7 @@ class ColorpickerController extends AbstractWizardController {
/** /**
* Creates a color matrix table * Creates a color matrix table
* *
* @return void * @return string
*/ */
public function colorMatrix() { public function colorMatrix() {
$steps = 51; $steps = 51;
...@@ -341,7 +346,7 @@ class ColorpickerController extends AbstractWizardController { ...@@ -341,7 +346,7 @@ class ColorpickerController extends AbstractWizardController {
/** /**
* Creates a selector box with all HTML color names. * Creates a selector box with all HTML color names.
* *
* @return void * @return string
*/ */
public function colorList() { public function colorList() {
// Initialize variables: // Initialize variables:
...@@ -366,14 +371,16 @@ class ColorpickerController extends AbstractWizardController { ...@@ -366,14 +371,16 @@ class ColorpickerController extends AbstractWizardController {
/** /**
* Creates a color image selector * Creates a color image selector
* *
* @return void * @return string
*/ */
public function colorImage() { public function colorImage() {
// Handling color-picker image if any: // Handling color-picker image if any:
if (!$this->imageError) { if (!$this->imageError) {
if ($this->pickerImage) { if ($this->pickerImage) {
if (GeneralUtility::_POST('coords_x')) { if (GeneralUtility::_POST('coords_x')) {
$this->colorValue = '#' . $this->getIndex(\TYPO3\CMS\Core\Imaging\GraphicalFunctions::imageCreateFromFile($this->pickerImage), GeneralUtility::_POST('coords_x'), GeneralUtility::_POST('coords_y')); /* @var $image \TYPO3\CMS\Core\Imaging\GraphicalFunctions */
$image = GeneralUtility::makeInstance(\TYPO3\CMS\Core\Imaging\GraphicalFunctions::class);
$this->colorValue = '#' . $this->getIndex($image->imageCreateFromFile($this->pickerImage), GeneralUtility::_POST('coords_x'), GeneralUtility::_POST('coords_y'));
} }
$pickerFormImage = ' $pickerFormImage = '
<p class="c-head">' . $this->getLanguageService()->getLL('colorpicker_fromImage', TRUE) . '</p> <p class="c-head">' . $this->getLanguageService()->getLL('colorpicker_fromImage', TRUE) . '</p>
...@@ -400,18 +407,19 @@ class ColorpickerController extends AbstractWizardController { ...@@ -400,18 +407,19 @@ class ColorpickerController extends AbstractWizardController {
*/ */
public function getIndex($im, $x, $y) { public function getIndex($im, $x, $y) {
$rgb = ImageColorAt($im, $x, $y); $rgb = ImageColorAt($im, $x, $y);
$colorrgb = imagecolorsforindex($im, $rgb); $colorRgb = imagecolorsforindex($im, $rgb);
$index['r'] = dechex($colorrgb['red']); $index['r'] = dechex($colorRgb['red']);
$index['g'] = dechex($colorrgb['green']); $index['g'] = dechex($colorRgb['green']);
$index['b'] = dechex($colorrgb['blue']); $index['b'] = dechex($colorRgb['blue']);
$hexValue = array();
foreach ($index as $value) { foreach ($index as $value) {
if (strlen($value) == 1) { if (strlen($value) == 1) {
$hexvalue[] = strtoupper('0' . $value); $hexValue[] = strtoupper('0' . $value);
} else { } else {
$hexvalue[] = strtoupper($value); $hexValue[] = strtoupper($value);
} }
} }
$hex = implode('', $hexvalue); $hex = implode('', $hexValue);
return $hex; return $hex;
} }
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment