TYPO3 CMS  TYPO3_7-6
Spellchecker.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 
21 
26 {
32  protected $pluginName = 'SpellChecker';
33 
39  protected $pluginButtons = 'spellcheck';
40 
47  'spellcheck' => 'SpellCheck'
48  ];
49 
55  protected $spellCheckerModes = ['ultra', 'fast', 'normal', 'bad-spellers'];
56 
63  public function main(array $configuration)
64  {
65  return parent::main($configuration)
66  && ExtensionManagementUtility::isLoaded('static_info_tables')
67  && !in_array(
68  $this->configuration['language'],
69  GeneralUtility::trimExplode(',', $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['rtehtmlarea']['plugins']['SpellChecker']['noSpellCheckLanguages'])
70  );
71  }
72 
78  public function buildJavascriptConfiguration()
79  {
80  $jsArray = [];
81  $button = 'spellcheck';
82  // Set the SpellChecker mode
83  $spellCheckerMode = isset($GLOBALS['BE_USER']->userTS['options.']['HTMLAreaPspellMode']) ? trim($GLOBALS['BE_USER']->userTS['options.']['HTMLAreaPspellMode']) : 'normal';
84  if (!in_array($spellCheckerMode, $this->spellCheckerModes)) {
85  $spellCheckerMode = 'normal';
86  }
87  // Set the use of personal dictionary
88  $enablePersonalDicts = $this->configuration['thisConfig']['buttons.'][$button . '.']['enablePersonalDictionaries'] && !empty($GLOBALS['BE_USER']->userTS['options.']['enablePersonalDicts']);
89  if (in_array($button, $this->toolbar)) {
90  if (!is_array($this->configuration['thisConfig']['buttons.']) || !is_array($this->configuration['thisConfig']['buttons.'][$button . '.'])) {
91  $jsArray[] = 'RTEarea[editornumber].buttons.' . $button . ' = new Object();';
92  }
93  $jsArray[] = 'RTEarea[editornumber].buttons.' . $button . '.contentTypo3Language = "' . $this->configuration['contentTypo3Language'] . '";';
94  $jsArray[] = 'RTEarea[editornumber].buttons.' . $button . '.contentISOLanguage = "' . $this->configuration['contentISOLanguage'] . '";';
95  $jsArray[] = 'RTEarea[editornumber].buttons.' . $button . '.spellCheckerMode = "' . $spellCheckerMode . '";';
96  $jsArray[] = 'RTEarea[editornumber].buttons.' . $button . '.enablePersonalDicts = ' . ($enablePersonalDicts ? 'true' : 'false') . ';';
97  $jsArray[] = 'RTEarea[editornumber].buttons.' . $button . '.path = "' . ($this->isFrontend() || $this->isFrontendEditActive() ? ($GLOBALS['TSFE']->absRefPrefix ? $GLOBALS['TSFE']->absRefPrefix : '') . 'index.php?eID=rtehtmlarea_spellchecker' : BackendUtility::getAjaxUrl('rtehtmlarea_spellchecker')) . '";';
98  }
99  return implode(LF, $jsArray);
100  }
101 }
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']