TYPO3CMS  8
 All Classes Namespaces Files Functions Variables Pages
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 = [
56  'gecko' => ['copy', 'cut', 'paste'],
57  'webkit' => ['copy', 'cut', 'paste'],
58  'opera' => ['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 }
static trimExplode($delim, $string, $removeEmptyValues=false, $limit=0)