TYPO3CMS  8
 All Classes Namespaces Files Functions Variables Pages
TableOperations.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 = 'TableOperations';
31 
37  protected $requiredPlugins = 'TYPO3Color,BlockStyle';
38 
44  protected $pluginButtons = 'table, toggleborders, tableproperties, tablerestyle, rowproperties, rowinsertabove, rowinsertunder, rowdelete, rowsplit,
45  columnproperties, columninsertbefore, columninsertafter, columndelete, columnsplit,
46  cellproperties, cellinsertbefore, cellinsertafter, celldelete, cellsplit, cellmerge';
47 
54  'table' => 'InsertTable',
55  'toggleborders' => 'TO-toggle-borders',
56  'tableproperties' => 'TO-table-prop',
57  'tablerestyle' => 'TO-table-restyle',
58  'rowproperties' => 'TO-row-prop',
59  'rowinsertabove' => 'TO-row-insert-above',
60  'rowinsertunder' => 'TO-row-insert-under',
61  'rowdelete' => 'TO-row-delete',
62  'rowsplit' => 'TO-row-split',
63  'columnproperties' => 'TO-col-prop',
64  'columninsertbefore' => 'TO-col-insert-before',
65  'columninsertafter' => 'TO-col-insert-after',
66  'columndelete' => 'TO-col-delete',
67  'columnsplit' => 'TO-col-split',
68  'cellproperties' => 'TO-cell-prop',
69  'cellinsertbefore' => 'TO-cell-insert-before',
70  'cellinsertafter' => 'TO-cell-insert-after',
71  'celldelete' => 'TO-cell-delete',
72  'cellsplit' => 'TO-cell-split',
73  'cellmerge' => 'TO-cell-merge'
74  ];
75 
82  public function main(array $configuration)
83  {
84  $available = parent::main($configuration);
85  if ($this->configuration['client']['browser'] === 'opera') {
86  $this->configuration['thisConfig']['hideTableOperationsInToolbar'] = 0;
87  }
88  return $available;
89  }
90 
96  public function buildJavascriptConfiguration()
97  {
98  $jsArray = [];
99  if (in_array('table', $this->toolbar)) {
100  // Combining fieldset disablers as a list
101  $disabledFieldsets = ['Alignment', 'Borders', 'Color', 'Description', 'Layout', 'RowGroup', 'Spacing', 'Style'];
102  foreach ($disabledFieldsets as $index => $fieldset) {
103  if (!trim($this->configuration['thisConfig']['disable' . $fieldset . 'FieldsetInTableOperations'])) {
104  unset($disabledFieldsets[$index]);
105  }
106  }
107  $disabledFieldsets = strtolower(implode(',', $disabledFieldsets));
108  // Dialogue fieldsets removal configuration
109  if ($disabledFieldsets) {
110  $dialogues = ['table', 'tableproperties', 'rowproperties', 'columnproperties', 'cellproperties'];
111  foreach ($dialogues as $dialogue) {
112  if (in_array($dialogue, $this->toolbar)) {
113  if (!is_array($this->configuration['thisConfig']['buttons.']) || !is_array($this->configuration['thisConfig']['buttons.'][$dialogue . '.'])) {
114  $jsArray[] = 'RTEarea[editornumber].buttons.' . $dialogue . ' = new Object();';
115  $jsArray[] = 'RTEarea[editornumber].buttons.' . $dialogue . '.removeFieldsets = "' . $disabledFieldsets . '";';
116  } elseif ($this->configuration['thisConfig']['buttons.'][$dialogue . '.']['removeFieldsets']) {
117  $jsArray[] = 'RTEarea[editornumber].buttons.' . $dialogue . '.removeFieldsets += ",' . $disabledFieldsets . '";';
118  } else {
119  $jsArray[] = 'RTEarea[editornumber].buttons.' . $dialogue . '.removeFieldsets = ",' . $disabledFieldsets . '";';
120  }
121  }
122  }
123  }
124  $jsArray[] = 'RTEarea[editornumber].hideTableOperationsInToolbar = ' . (trim($this->configuration['thisConfig']['hideTableOperationsInToolbar']) ? 'true' : 'false') . ';';
125  }
126  return implode(LF, $jsArray);
127  }
128 
135  public function applyToolbarConstraints($show)
136  {
137  // We will not allow any table operations button if the table button is not enabled
138  if (!in_array('table', $show)) {
139  return array_diff($show, GeneralUtility::trimExplode(',', $this->pluginButtons));
140  } else {
141  return $show;
142  }
143  }
144 }
static trimExplode($delim, $string, $removeEmptyValues=false, $limit=0)