TYPO3  7.6
CopyPaste.php
Go to the documentation of this file.
1 <?php
2 namespace TYPO3\CMS\Rtehtmlarea\Extension;
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 = 'CopyPaste';
31 
37  protected $pluginButtons = 'copy, cut, paste';
38 
45  'copy' => 'Copy',
46  'cut' => 'Cut',
47  'paste' => 'Paste'
48  );
49 
55  protected $hideButtonsFromClient = array(
56  'gecko' => array('copy', 'cut', 'paste'),
57  'webkit' => array('copy', 'cut', 'paste'),
58  'opera' => array('copy', 'cut', 'paste')
59  );
60 
67  public function main(array $configuration)
68  {
69  $enabled = parent::main($configuration);
70  // Hiding some buttons
71  if ($enabled && is_array($this->hideButtonsFromClient[$this->configuration['client']['browser']])) {
72  $this->pluginButtons = implode(',', array_diff(GeneralUtility::trimExplode(',', $this->pluginButtons, true), $this->hideButtonsFromClient[$this->configuration['client']['browser']]));
73  }
74  // Force enabling the plugin even if no button remains in the tool bar, so that hot keys still are enabled
75  $this->pluginAddsButtons = false;
76  return $enabled;
77  }
78 
85  public function applyToolbarConstraints($show)
86  {
87  // Remove some buttons
88  if (is_array($this->hideButtonsFromClient[$this->configuration['client']['browser']])) {
89  return array_diff($show, $this->hideButtonsFromClient[$this->configuration['client']['browser']]);
90  } else {
91  return $show;
92  }
93  }
94 }