TYPO3 CMS  TYPO3_7-6
ContextMenu.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 = 'ContextMenu';
31 
38  public function main(array $configuration)
39  {
40  return parent::main($configuration)
41  && !($this->configuration['client']['browser'] === 'opera' || $this->configuration['thisConfig']['contextMenu.']['disabled']);
42  }
43 
49  public function buildJavascriptConfiguration()
50  {
51  $jsArray = [];
52  if (is_array($this->configuration['thisConfig']['contextMenu.'])) {
53  $jsArray[] = 'RTEarea[editornumber].contextMenu = ' . $this->buildNestedJSArray($this->configuration['thisConfig']['contextMenu.']) . ';';
54  if ($this->configuration['thisConfig']['contextMenu.']['showButtons']) {
55  $jsArray[] = 'RTEarea[editornumber].contextMenu.showButtons = ' . json_encode(GeneralUtility::trimExplode(',', $this->cleanList(GeneralUtility::strtolower($this->configuration['thisConfig']['contextMenu.']['showButtons'])), true)) . ';';
56  }
57  if ($this->configuration['thisConfig']['contextMenu.']['hideButtons']) {
58  $jsArray[] = 'RTEarea[editornumber].contextMenu.hideButtons = ' . json_encode(GeneralUtility::trimExplode(',', $this->cleanList(GeneralUtility::strtolower($this->configuration['thisConfig']['contextMenu.']['hideButtons'])), true)) . ';';
59  }
60  }
61  return implode(LF, $jsArray);
62  }
63 
73  protected function buildNestedJSArray($conf)
74  {
75  $convertedConf = GeneralUtility::removeDotsFromTS($conf);
76  return str_replace([':"0"', ':"\\/^(', ')$\\/i"', ':"\\/^(', ')$\\/"', '[]'], [':false', ':/^(', ')$/i', ':/^(', ')$/', '{}'], json_encode($convertedConf));
77  }
78 }
static trimExplode($delim, $string, $removeEmptyValues=false, $limit=0)