edfb6cedeccd42247a07fef3d6872bbc43fa651f
[Packages/TYPO3.CMS.git] / typo3 / sysext / rtehtmlarea / extensions / TableOperations / class.tx_rtehtmlarea_tableoperations.php
1 <?php
2 /***************************************************************
3 * Copyright notice
4 *
5 * (c) 2008 Stanislas Rolland <stanislas.rolland(arobas)fructifor.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 <stanislas.rolland(arobas)fructifor.ca>
28 *
29 * TYPO3 SVN ID: $Id$
30 *
31 */
32
33 require_once(t3lib_extMgm::extPath('rtehtmlarea').'class.tx_rtehtmlareaapi.php');
34
35 class tx_rtehtmlarea_tableoperations extends tx_rtehtmlareaapi {
36
37 protected $extensionKey = 'rtehtmlarea'; // The key of the extension that is extending htmlArea RTE
38 protected $pluginName = 'TableOperations'; // The name of the plugin registered by the extension
39 protected $relativePathToLocallangFile = ''; // Path to this main locallang file of the extension relative to the extension dir.
40 protected $relativePathToSkin = 'extensions/TableOperations/skin/htmlarea.css'; // Path to the skin (css) file relative to the extension dir
41 protected $htmlAreaRTE; // Reference to the invoking object
42 protected $thisConfig; // Reference to RTE PageTSConfig
43 protected $toolbar; // Reference to RTE toolbar array
44 protected $LOCAL_LANG; // Frontend language array
45
46 protected $pluginButtons = 'table, toggleborders, tableproperties, rowproperties, rowinsertabove, rowinsertunder, rowdelete, rowsplit,
47 columninsertbefore, columninsertafter, columndelete, columnsplit,
48 cellproperties, cellinsertbefore, cellinsertafter, celldelete, cellsplit, cellmerge';
49 protected $convertToolbarForHtmlAreaArray = array (
50 'table' => 'InsertTable',
51 'toggleborders' => 'TO-toggle-borders',
52 'tableproperties' => 'TO-table-prop',
53 'rowproperties' => 'TO-row-prop',
54 'rowinsertabove' => 'TO-row-insert-above',
55 'rowinsertunder' => 'TO-row-insert-under',
56 'rowdelete' => 'TO-row-delete',
57 'rowsplit' => 'TO-row-split',
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
70 public function main($parentObject) {
71 global $TYPO3_CONF_VARS;
72
73 $available = parent::main($parentObject);
74
75 if ($this->htmlAreaRTE->client['BROWSER'] == 'opera') {
76 $this->thisConfig['hideTableOperationsInToolbar'] = 0;
77 }
78
79 return $available;
80 }
81
82 /**
83 * Return JS configuration of the htmlArea plugins registered by the extension
84 *
85 * @param integer Relative id of the RTE editing area in the form
86 *
87 * @return string JS configuration for registered plugins, in this case, JS configuration of block elements
88 *
89 * The returned string will be a set of JS instructions defining the configuration that will be provided to the plugin(s)
90 * Each of the instructions should be of the form:
91 * RTEarea['.$RTEcounter.']["buttons"]["button-id"]["property"] = "value";
92 */
93 public function buildJavascriptConfiguration($RTEcounter) {
94 global $TSFE, $LANG;
95
96 $registerRTEinJavascriptString = '';
97 if (in_array('table', $this->toolbar)) {
98
99 $registerRTEinJavascriptString .= '
100 RTEarea['.$RTEcounter.'].hideTableOperationsInToolbar = ' . (trim($this->thisConfig['hideTableOperationsInToolbar']) ? 'true' : 'false') . ';
101 RTEarea['.$RTEcounter.'].disableLayoutFieldsetInTableOperations = ' . (trim($this->thisConfig['disableLayoutFieldsetInTableOperations'])?'true':'false') . ';
102 RTEarea['.$RTEcounter.'].disableAlignmentFieldsetInTableOperations = ' . (trim($this->thisConfig['disableAlignmentFieldsetInTableOperations'])?'true':'false') . ';
103 RTEarea['.$RTEcounter.'].disableSpacingFieldsetInTableOperations = ' . (trim($this->thisConfig['disableSpacingFieldsetInTableOperations'])?'true':'false') . ';
104 RTEarea['.$RTEcounter.'].disableBordersFieldsetInTableOperations = ' . (trim($this->thisConfig['disableBordersFieldsetInTableOperations'])?'true':'false') . ';
105 RTEarea['.$RTEcounter.'].disableColorFieldsetInTableOperations = ' . (trim($this->thisConfig['disableColorFieldsetInTableOperations'])?'true':'false') . ';';
106
107 // Deprecated toggleborders button configuration
108 if (in_array('toggleborders',$this->toolbar) && $this->thisConfig['keepToggleBordersInToolbar']) {
109 if (!is_array($this->thisConfig['buttons.']['toggleborders.'])) {
110 $registerRTEinJavascriptString .= '
111 RTEarea['.$RTEcounter.'].buttons.toggleborders = new Object();
112 RTEarea['.$RTEcounter.'].buttons.toggleborders.keepInToolbar = true;';
113 } elseif (!$this->thisConfig['buttons.']['toggleborders.']['keepInToolbar']) {
114 $registerRTEinJavascriptString .= '
115 RTEarea['.$RTEcounter.'].buttons.toggleborders.keepInToolbar = true;';
116 }
117 }
118 }
119 return $registerRTEinJavascriptString;
120 }
121
122 } // end of class
123
124 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/rtehtmlarea/extensions/TableOperations/class.tx_rtehtmlarea_tableoperations.php']) {
125 include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/rtehtmlarea/extensions/TableOperations/class.tx_rtehtmlarea_tableoperations.php']);
126 }
127
128 ?>