Cleanup: Updated copyright comments
[Packages/TYPO3.CMS.git] / typo3 / sysext / rtehtmlarea / extensions / TableOperations / class.tx_rtehtmlarea_tableoperations.php
1 <?php
2 /***************************************************************
3 * Copyright notice
4 *
5 * (c) 2008-2011 Stanislas Rolland <typo3(arobas)sjbr.ca>
6 * All rights reserved
7 *
8 * This script is part of the Typo3 project. The Typo3 project is
9 * free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
13 *
14 * The GNU General Public License can be found at
15 * http://www.gnu.org/copyleft/gpl.html.
16 *
17 * This script is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
21 *
22 * This copyright notice MUST APPEAR in all copies of the script!
23 ***************************************************************/
24 /**
25 * Table Operations extension for htmlArea RTE
26 *
27 * @author Stanislas Rolland <typo3(arobas)sjbr.ca>
28 *
29 * TYPO3 SVN ID: $Id$
30 *
31 */
32 class tx_rtehtmlarea_tableoperations extends tx_rtehtmlarea_api {
33
34 protected $extensionKey = 'rtehtmlarea'; // The key of the extension that is extending htmlArea RTE
35 protected $pluginName = 'TableOperations'; // The name of the plugin registered by the extension
36 protected $relativePathToLocallangFile = ''; // Path to this main locallang file of the extension relative to the extension dir.
37 protected $relativePathToSkin = 'extensions/TableOperations/skin/htmlarea.css'; // Path to the skin (css) file relative to the extension dir
38 protected $htmlAreaRTE; // Reference to the invoking object
39 protected $thisConfig; // Reference to RTE PageTSConfig
40 protected $toolbar; // Reference to RTE toolbar array
41 protected $LOCAL_LANG; // Frontend language array
42 protected $requiresClassesConfiguration = true; // True if the registered plugin requires the PageTSConfig Classes configuration
43 protected $requiredPlugins = 'TYPO3Color,BlockStyle'; // The comma-separated list of names of prerequisite plugins
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 protected $convertToolbarForHtmlAreaArray = array (
48 'table' => 'InsertTable',
49 'toggleborders' => 'TO-toggle-borders',
50 'tableproperties' => 'TO-table-prop',
51 'tablerestyle' => 'TO-table-restyle',
52 'rowproperties' => 'TO-row-prop',
53 'rowinsertabove' => 'TO-row-insert-above',
54 'rowinsertunder' => 'TO-row-insert-under',
55 'rowdelete' => 'TO-row-delete',
56 'rowsplit' => 'TO-row-split',
57 'columnproperties' => 'TO-col-prop',
58 'columninsertbefore' => 'TO-col-insert-before',
59 'columninsertafter' => 'TO-col-insert-after',
60 'columndelete' => 'TO-col-delete',
61 'columnsplit' => 'TO-col-split',
62 'cellproperties' => 'TO-cell-prop',
63 'cellinsertbefore' => 'TO-cell-insert-before',
64 'cellinsertafter' => 'TO-cell-insert-after',
65 'celldelete' => 'TO-cell-delete',
66 'cellsplit' => 'TO-cell-split',
67 'cellmerge' => 'TO-cell-merge',
68 );
69 public function main($parentObject) {
70 $available = parent::main($parentObject);
71 if ($this->htmlAreaRTE->client['browser'] == 'opera') {
72 $this->thisConfig['hideTableOperationsInToolbar'] = 0;
73 }
74 return $available;
75 }
76 /**
77 * Return JS configuration of the htmlArea plugins registered by the extension
78 *
79 * @param integer Relative id of the RTE editing area in the form
80 *
81 * @return string JS configuration for registered plugins, in this case, JS configuration of block elements
82 *
83 * The returned string will be a set of JS instructions defining the configuration that will be provided to the plugin(s)
84 * Each of the instructions should be of the form:
85 * RTEarea['.$RTEcounter.']["buttons"]["button-id"]["property"] = "value";
86 */
87 public function buildJavascriptConfiguration($RTEcounter) {
88 global $TSFE, $LANG;
89
90 $registerRTEinJavascriptString = '';
91 if (in_array('table', $this->toolbar)) {
92
93 // Combining fieldset disablers as a list
94 $disabledFieldsets = array('Alignment', 'Borders', 'Color', 'Description', 'Layout', 'RowGroup', 'Spacing', 'Style');
95 foreach ($disabledFieldsets as $index => $fieldset) {
96 if (!trim($this->thisConfig['disable'.$fieldset.'FieldsetInTableOperations'])) {
97 unset($disabledFieldsets[$index]);
98 }
99 }
100 $disabledFieldsets = strtolower(implode(',', $disabledFieldsets));
101
102 // Dialogue fieldsets removal configuration
103 if ($disabledFieldsets) {
104 $dialogues = array('table', 'tableproperties', 'rowproperties', 'columnproperties', 'cellproperties');
105 foreach ($dialogues as $dialogue) {
106 if (in_array($dialogue, $this->toolbar)) {
107 if (!is_array( $this->thisConfig['buttons.']) || !is_array( $this->thisConfig['buttons.'][$dialogue.'.'])) {
108 $registerRTEinJavascriptString .= '
109 RTEarea['.$RTEcounter.'].buttons.'.$dialogue.' = new Object();
110 RTEarea['.$RTEcounter.'].buttons.'.$dialogue.'.removeFieldsets = "' . $disabledFieldsets . '";';
111 } else if ($this->thisConfig['buttons.'][$dialogue.'.']['removeFieldsets']) {
112 $registerRTEinJavascriptString .= '
113 RTEarea['.$RTEcounter.'].buttons.'.$dialogue.'.removeFieldsets += ",' . $disabledFieldsets . '";';
114 } else {
115 $registerRTEinJavascriptString .= '
116 RTEarea['.$RTEcounter.'].buttons.'.$dialogue.'.removeFieldsets = ",' . $disabledFieldsets . '";';
117 }
118 }
119 }
120 }
121
122 $registerRTEinJavascriptString .= '
123 RTEarea['.$RTEcounter.'].hideTableOperationsInToolbar = ' . (trim($this->thisConfig['hideTableOperationsInToolbar']) ? 'true' : 'false') . ';';
124
125 // Deprecated toggleborders button configuration
126 if (in_array('toggleborders',$this->toolbar) && $this->thisConfig['keepToggleBordersInToolbar']) {
127 if (!is_array($this->thisConfig['buttons.']['toggleborders.'])) {
128 $registerRTEinJavascriptString .= '
129 RTEarea['.$RTEcounter.'].buttons.toggleborders = new Object();
130 RTEarea['.$RTEcounter.'].buttons.toggleborders.keepInToolbar = true;';
131 } elseif (!$this->thisConfig['buttons.']['toggleborders.']['keepInToolbar']) {
132 $registerRTEinJavascriptString .= '
133 RTEarea['.$RTEcounter.'].buttons.toggleborders.keepInToolbar = true;';
134 }
135 }
136 }
137 return $registerRTEinJavascriptString;
138 }
139 /**
140 * Return an updated array of toolbar enabled buttons
141 *
142 * @param array $show: array of toolbar elements that will be enabled, unless modified here
143 *
144 * @return array toolbar button array, possibly updated
145 */
146 public function applyToolbarConstraints($show) {
147 // We will not allow any table operations button if the table button is not enabled
148 if (!in_array('table', $show)) {
149 return array_diff($show, t3lib_div::trimExplode(',', $this->pluginButtons));
150 } else {
151 return $show;
152 }
153 }
154 }
155 if (defined('TYPO3_MODE') && isset($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['ext/rtehtmlarea/extensions/TableOperations/class.tx_rtehtmlarea_tableoperations.php'])) {
156 include_once($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['ext/rtehtmlarea/extensions/TableOperations/class.tx_rtehtmlarea_tableoperations.php']);
157 }
158 ?>