TYPO3 CMS  TYPO3_7-6
Typo3Color.php
Go to the documentation of this file.
1 <?php
3 
4 /*
5  * This file is part of the TYPO3 CMS project.
6  *
7  * It is free software; you can redistribute it and/or modify it under
8  * the terms of the GNU General Public License, either version 2
9  * of the License, or any later version.
10  *
11  * For the full copyright and license information, please read the
12  * LICENSE.txt file that was distributed with this source code.
13  *
14  * The TYPO3 project - inspiring people to share!
15  */
16 
19 
24 {
30  protected $pluginName = 'TYPO3Color';
31 
37  protected $pluginButtons = 'textcolor,bgcolor';
38 
45  'textcolor' => 'ForeColor',
46  'bgcolor' => 'HiliteColor'
47  ];
48 
55  public function main(array $configuration)
56  {
57  return parent::main($configuration)
58  && $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['rtehtmlarea']['allowStyleAttribute'];
59  }
60 
66  public function buildJavascriptConfiguration()
67  {
68  $jsArray = [];
69  $jsArray[] = 'RTEarea[editornumber].disableColorPicker = ' . (trim($this->configuration['thisConfig']['disableColorPicker']) ? 'true' : 'false') . ';';
70  // Building the array of configured colors
71  $HTMLAreaColorName = [];
72  if (is_array($this->configuration['RTEsetup']['properties']['colors.'])) {
73  foreach ($this->configuration['RTEsetup']['properties']['colors.'] as $colorName => $conf) {
74  $colorName = substr($colorName, 0, -1);
75  $colorLabel = $this->getPageConfigLabel($conf['name']);
76  $HTMLAreaColorName[$colorName] = [$colorLabel, strtoupper(substr($conf['value'], 1, 6))];
77  }
78  }
79  // Setting the list of colors if specified in the RTE config
80  if ($this->configuration['thisConfig']['colors']) {
81  $HTMLAreaColors = GeneralUtility::trimExplode(',', $this->cleanList($this->configuration['thisConfig']['colors']));
82  $HTMLAreaJSColors = [];
83  foreach ($HTMLAreaColors as $colorName) {
84  if ($HTMLAreaColorName[$colorName]) {
85  $HTMLAreaJSColors[] = $HTMLAreaColorName[$colorName];
86  }
87  }
88  $jsArray[] = 'RTEarea[editornumber].colors = ' . json_encode($HTMLAreaJSColors) . ';';
89  }
90  return implode(LF, $jsArray);
91  }
92 }
static trimExplode($delim, $string, $removeEmptyValues=false, $limit=0)
if(TYPO3_MODE==='BE') $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tsfebeuserauth.php']['frontendEditingController']['default']