2 namespace TYPO3\CMS\Backend\Controller\Wizard;
88 public $HTMLcolorList =
'aqua,black,blue,fuchsia,gray,green,lime,maroon,navy,olive,purple,red,silver,teal,yellow,white';
124 parent::__construct();
149 $this->imageError =
'';
150 if ($this->exampleImg) {
152 if (!$this->pickerImage || !@is_file($this->pickerImage)) {
153 $this->imageError =
'ERROR: The image, "' . $this->exampleImg .
'", could not be found!';
159 $fieldChangeFuncArr = unserialize($this->fieldChangeFunc);
160 unset($fieldChangeFuncArr[
'alert']);
161 foreach ($fieldChangeFuncArr as $v) {
162 $update[] =
'parent.opener.' . $v;
168 'TYPO3/CMS/Backend/Wizard/Colorpicker',
169 'function(Colorpicker) {
170 Colorpicker.setFieldChangeFunctions({
171 fieldChangeFunctions: function() {'
172 . implode(
'', $update) .
178 $this->content .= $this->doc->startPage($this->
getLanguageService()->getLL(
'colorpicker_title'));
193 $this->content .= $this->doc->endPage();
194 $this->content = $this->doc->insertStylesAndJS($this->content);
196 $response->
getBody()->write($this->content);
213 <form name="colorform" method="post" action="' . htmlspecialchars(BackendUtility::getModuleUrl(
'wizard_colorpicker')) .
'">
216 ' . $this->colorImage() .
'
219 <p class="c-head">' . $this->
getLanguageService()->getLL(
'colorpicker_colorValue',
true) .
'</p>
220 <table border="0" cellpadding="0" cellspacing="3">
223 <input id="colorValue" type="text" ' . $this->doc->formWidth(7) .
' maxlength="10" name="colorValue" value="' . htmlspecialchars($this->colorValue) .
'" />
225 <td style="background-color:' . htmlspecialchars($this->colorValue) .
'; border: 1px solid black;">
226 <span style="color: black;">' . $this->
getLanguageService()->getLL(
'colorpicker_black',
true) .
'</span> <span style="color: white;">' . $this->
getLanguageService()->getLL(
'colorpicker_white',
true) .
'</span>
229 <input class="btn btn-default" type="submit" id="colorpicker-saveclose" value="' . $this->
getLanguageService()->getLL(
'colorpicker_setClose',
true) .
'" />
234 <!-- Hidden fields with values that has to be kept constant -->
235 <input type="hidden" name="showPicker" value="1" />
236 <input type="hidden" name="fieldChangeFunc" value="' . htmlspecialchars($this->fieldChangeFunc) .
'" />
237 <input type="hidden" name="fieldChangeFuncHash" value="' . htmlspecialchars($this->fieldChangeFuncHash) .
'" />
238 <input type="hidden" name="fieldName" value="' . htmlspecialchars($this->fieldName) .
'" />
239 <input type="hidden" name="formName" value="' . htmlspecialchars($this->formName) .
'" />
240 <input type="hidden" name="md5ID" value="' . htmlspecialchars($this->md5ID) .
'" />
241 <input type="hidden" name="exampleImg" value="' . htmlspecialchars($this->exampleImg) .
'" />
244 $this->content .=
'<h2>' . $this->
getLanguageService()->getLL(
'colorpicker_title',
true) .
'</h2>';
258 $this->content .= $this->doc->endPage();
259 $this->content = $this->doc->insertStylesAndJS($this->content);
273 if (!window.opener) {
274 alert("ERROR: Sorry, no link to main window... Closing");
281 $url = BackendUtility::getModuleUrl(
282 'wizard_colorpicker',
285 'colorValue' => $this->wizardParameters[
'currentValue'],
286 'fieldName' => $this->wizardParameters[
'itemName'],
287 'formName' => $this->wizardParameters[
'formName'],
288 'exampleImg' => $this->wizardParameters[
'exampleImg'],
289 'md5ID' => $this->wizardParameters[
'md5ID'],
290 'fieldChangeFunc' => serialize($this->wizardParameters[
'fieldChangeFunc']),
291 'fieldChangeFuncHash' => $this->wizardParameters[
'fieldChangeFuncHash'],
295 <frameset rows="*,1" framespacing="0" frameborder="0" border="0">
296 <frame name="content" src="' . htmlspecialchars(
$url) .
'" marginwidth="0" marginheight="0" frameborder="0" scrolling="auto" noresize="noresize" />
297 <frame name="menu" src="' . htmlspecialchars(BackendUtility::getModuleUrl(
'dummy')) .
'" marginwidth="0" marginheight="0" frameborder="0" scrolling="no" noresize="noresize" />
317 for ($rr = 0; $rr < 256; $rr += $steps) {
318 for ($gg = 0; $gg < 256; $gg += $steps) {
319 for ($bb = 0; $bb < 256; $bb += $steps) {
320 $color[] =
'#' . substr((
'0' . dechex($rr)), -2) . substr((
'0' . dechex($gg)), -2) . substr((
'0' . dechex($bb)), -2);
328 while (isset($color[$columns * $rows])) {
330 for ($i = 0; $i < $columns; $i++) {
331 $tCells[] =
'<td bgcolor="' . $color[($columns * $rows + $i)] .
'" class="t3js-colorpicker-value" data-color-value="' . htmlspecialchars($color[($columns * $rows + $i)]) .
'" title="' . htmlspecialchars($color[($columns * $rows + $i)]) .
'"> </td>';
333 $tRows[] =
'<tr>' . implode(
'', $tCells) .
'</tr>';
336 return '<p class="c-head">' . $this->
getLanguageService()->getLL(
'colorpicker_fromMatrix',
true) .
'</p>
337 <table style="width:100%; border: 1px solid black; cursor:crosshair;">' . implode(
'', $tRows) .
'</table>';
348 $colors = explode(
',', $this->HTMLcolorList);
349 $currentValue = strtolower($this->colorValue);
351 $opt[] =
'<option value=""></option>';
353 foreach ($colors as $colorName) {
354 $opt[] =
'<option style="background-color: ' . $colorName .
';" value="' . htmlspecialchars($colorName) .
'"' . ($currentValue === $colorName ?
' selected="selected"' :
'') .
'>' . htmlspecialchars($colorName) .
'</option>';
357 return '<p class="c-head">' . $this->
getLanguageService()->getLL(
'colorpicker_fromList',
true) .
'</p>
358 <select class="t3js-colorpicker-selector">' . implode(LF, $opt) .
'</select><br />';
366 public function colorImage()
369 if (!$this->imageError) {
370 if ($this->pickerImage) {
377 <p class="c-head">' . $this->
getLanguageService()->getLL(
'colorpicker_fromImage',
true) .
'</p>
378 <input type="image" src="../' . \TYPO3\CMS\Core\Utility\PathUtility::stripPathSitePrefix($this->pickerImage) .
'" name="coords" style="cursor:crosshair;" /><br />';
380 $pickerFormImage =
'';
384 <p class="c-head">' . htmlspecialchars($this->imageError) .
'</p>';
386 return $pickerFormImage;
401 $rgb = ImageColorAt($im, $x, $y);
402 $colorRgb = imagecolorsforindex($im, $rgb);
403 $index[
'r'] = dechex($colorRgb[
'red']);
404 $index[
'g'] = dechex($colorRgb[
'green']);
405 $index[
'b'] = dechex($colorRgb[
'blue']);
407 foreach ($index as $value) {
408 if (strlen($value) === 1) {
409 $hexValue[] = strtoupper(
'0' . $value);
411 $hexValue[] = strtoupper($value);
414 $hex = implode(
'', $hexValue);
426 return $this->fieldChangeFunc && $this->fieldChangeFuncHash && $this->fieldChangeFuncHash ===
GeneralUtility::hmac($this->fieldChangeFunc);