TYPO3 CMS  TYPO3_6-2
RteHtmlAreaApi.php
Go to the documentation of this file.
1 <?php
2 namespace TYPO3\CMS\Rtehtmlarea;
3 
21 abstract class RteHtmlAreaApi {
22 
23  protected $extensionKey;
24 
25  // The key of the extension that is extending htmlArea RTE
26  protected $pluginName;
27 
28  // The name of the plugin registered by the extension
30 
31  // Path to the localization file for this script, relative to the extension dir
33 
34  // Path to the skin (css) file that should be added to the RTE skin when the registered plugin is enabled, relative to the extension dir
36 
37  // Path to the directory containing the plugin, relative to the extension dir (should end with slash /)
38  protected $htmlAreaRTE;
39 
40  // Reference to the invoking object
41  protected $rteExtensionKey;
42 
43  // The extension key of the RTE
44  protected $thisConfig;
45 
46  // Reference to RTE PageTSConfig
47  protected $toolbar;
48 
49  // Refrence to RTE toolbar array
50  protected $LOCAL_LANG;
51 
52  // Frontend language array
53  protected $pluginButtons = '';
54 
55  // The comma-separated list of button names that the registered plugin is adding to the htmlArea RTE toolbar
56  protected $pluginLabels = '';
57 
58  // The comma-separated list of label names that the registered plugin is adding to the htmlArea RTE toolbar
59  protected $pluginAddsButtons = TRUE;
60 
61  // Boolean indicating whether the plugin is adding buttons or not
62  protected $convertToolbarForHtmlAreaArray = array();
63 
64  // The name-converting array, converting the button names used in the RTE PageTSConfing to the button id's used by the JS scripts
65  protected $requiresClassesConfiguration = FALSE;
66 
67  // TRUE if the registered plugin requires the PageTSConfig Classes configuration
68  protected $requiresSynchronousLoad = FALSE;
69 
70  // TRUE if the plugin must be loaded synchronously
71  protected $requiredPlugins = '';
72 
73  // The comma-separated list of names of prerequisite plugins
80  public function main($parentObject) {
81  global $TYPO3_CONF_VARS, $LANG, $TSFE;
82  $this->htmlAreaRTE = $parentObject;
83  $this->rteExtensionKey = &$this->htmlAreaRTE->ID;
84  $this->thisConfig = &$this->htmlAreaRTE->thisConfig;
85  $this->toolbar = &$this->htmlAreaRTE->toolbar;
86  $this->LOCAL_LANG = &$this->htmlAreaRTE->LOCAL_LANG;
87  // Set the value of this boolean based on the initial value of $this->pluginButtons
88  $this->pluginAddsButtons = !empty($this->pluginButtons);
89  // Check if the plugin should be disabled in frontend
90  if ($this->htmlAreaRTE->is_FE() && $TYPO3_CONF_VARS['EXTCONF'][$this->rteExtensionKey]['plugins'][$this->pluginName]['disableInFE']) {
91  return FALSE;
92  }
93  // Localization array must be initialized here
94  if ($this->relativePathToLocallangFile) {
95  if ($this->htmlAreaRTE->is_FE()) {
97  $this->LOCAL_LANG,
98  \TYPO3\CMS\Core\Utility\GeneralUtility::readLLfile(
99  'EXT:' . $this->extensionKey . '/' . $this->relativePathToLocallangFile,
100  $this->htmlAreaRTE->language
101  )
102  );
103  } else {
104  $LANG->includeLLFile('EXT:' . $this->extensionKey . '/' . $this->relativePathToLocallangFile);
105  }
106  }
107  return TRUE;
108  }
109 
115  public function addButtonsToToolbar() {
116  //Add only buttons not yet in the default toolbar order
117  $addButtons = implode(',', array_diff(\TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode(',', $this->pluginButtons, TRUE), \TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode(',', $this->htmlAreaRTE->defaultToolbarOrder, TRUE)));
118  return ($addButtons ? 'bar,' . $addButtons . ',linebreak,' : '') . $this->htmlAreaRTE->defaultToolbarOrder;
119  }
120 
126  public function getPathToSkin() {
127  global $TYPO3_CONF_VARS;
128  if ($TYPO3_CONF_VARS['EXTCONF'][$this->rteExtensionKey]['plugins'][$this->pluginName]['addIconsToSkin']) {
130  } else {
131  return '';
132  }
133  }
134 
141  public function buildJavascriptConfiguration($RTEcounter) {
142  global $TSFE, $LANG;
143  $registerRTEinJavascriptString = '';
144  $pluginButtons = \TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode(',', $this->pluginButtons, TRUE);
145  foreach ($pluginButtons as $button) {
146  if (in_array($button, $this->toolbar)) {
147  if (!is_array($this->thisConfig['buttons.']) || !is_array($this->thisConfig['buttons.'][($button . '.')])) {
148  $registerRTEinJavascriptString .= '
149  RTEarea[' . $RTEcounter . '].buttons.' . $button . ' = new Object();';
150  }
151  }
152  }
153  return $registerRTEinJavascriptString;
154  }
155 
161  public function getExtensionKey() {
162  return $this->extensionKey;
163  }
164 
170  public function getPathToPluginDirectory() {
171  return $this->relativePathToPluginDirectory ? $this->htmlAreaRTE->httpTypo3Path . \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::siteRelPath($this->extensionKey) . $this->relativePathToPluginDirectory : '';
172  }
173 
179  public function addsButtons() {
181  }
182 
188  public function getPluginButtons() {
189  return $this->pluginButtons;
190  }
191 
197  public function getPluginLabels() {
198  return $this->pluginLabels;
199  }
200 
208  }
209 
215  public function requiresClassesConfiguration() {
217  }
218 
224  public function requiresSynchronousLoad() {
226  }
227 
234  public function setSynchronousLoad($value = TRUE) {
235  $this->requiresSynchronousLoad = $value;
236  }
237 
243  public function getRequiredPlugins() {
244  return $this->requiredPlugins;
245  }
246 
247 }
static mergeRecursiveWithOverrule(array &$original, array $overrule, $addKeys=TRUE, $includeEmptyValues=TRUE, $enableUnsetFeature=TRUE)
$TYPO3_CONF_VARS['SYS']['contentTable']
static trimExplode($delim, $string, $removeEmptyValues=FALSE, $limit=0)
$TSFE
Definition: index_ts.php:72