|
TYPO3 API
SVNRelease
|
00001 <?php 00002 /*************************************************************** 00003 * Copyright notice 00004 * 00005 * (c) 2008-2011 Stanislas Rolland <typo3(arobas)sjbr.ca> 00006 * All rights reserved 00007 * 00008 * This script is part of the Typo3 project. The Typo3 project is 00009 * free software; you can redistribute it and/or modify 00010 * it under the terms of the GNU General Public License as published by 00011 * the Free Software Foundation; either version 2 of the License, or 00012 * (at your option) any later version. 00013 * 00014 * The GNU General Public License can be found at 00015 * http://www.gnu.org/copyleft/gpl.html. 00016 * 00017 * This script is distributed in the hope that it will be useful, 00018 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00019 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00020 * GNU General Public License for more details. 00021 * 00022 * This copyright notice MUST APPEAR in all copies of the script! 00023 ***************************************************************/ 00024 /** 00025 * Copy Paste plugin for htmlArea RTE 00026 * 00027 * @author Stanislas Rolland <typo3(arobas)sjbr.ca> 00028 * 00029 * TYPO3 SVN ID: $Id: class.tx_rtehtmlarea_copypaste.php 10120 2011-01-18 20:03:36Z ohader $ 00030 * 00031 */ 00032 class tx_rtehtmlarea_copypaste extends tx_rtehtmlarea_api { 00033 00034 protected $extensionKey = 'rtehtmlarea'; // The key of the extension that is extending htmlArea RTE 00035 protected $pluginName = 'CopyPaste'; // The name of the plugin registered by the extension 00036 protected $relativePathToLocallangFile = ''; // Path to this main locallang file of the extension relative to the extension dir. 00037 protected $relativePathToSkin = 'extensions/CopyPaste/skin/htmlarea.css'; // Path to the skin (css) file relative to the extension dir. 00038 protected $htmlAreaRTE; // Reference to the invoking object 00039 protected $thisConfig; // Reference to RTE PageTSConfig 00040 protected $toolbar; // Reference to RTE toolbar array 00041 protected $LOCAL_LANG; // Frontend language array 00042 protected $pluginButtons = 'copy, cut, paste'; 00043 protected $convertToolbarForHtmlAreaArray = array ( 00044 'copy' => 'Copy', 00045 'cut' => 'Cut', 00046 'paste' => 'Paste', 00047 ); 00048 // Hide buttons not implemented in client browsers 00049 protected $hideButtonsFromClient = array ( 00050 'webkit' => array('paste'), 00051 'opera' => array('copy', 'cut', 'paste'), 00052 ); 00053 00054 public function main($parentObject) { 00055 $enabled = parent::main($parentObject); 00056 // Hiding some buttons 00057 if ($enabled && is_array($this->hideButtonsFromClient[$this->htmlAreaRTE->client['browser']])) { 00058 $this->pluginButtons = implode(',', array_diff(t3lib_div::trimExplode(',', $this->pluginButtons, 1), $this->hideButtonsFromClient[$this->htmlAreaRTE->client['browser']])); 00059 } 00060 // Force enabling the plugin even if no button remains in the tool bar, so that hot keys still are enabled 00061 $this->pluginAddsButtons = false; 00062 return $enabled; 00063 } 00064 00065 /** 00066 * Return JS configuration of the htmlArea plugins registered by the extension 00067 * 00068 * @param integer Relative id of the RTE editing area in the form 00069 * 00070 * @return string JS configuration for registered plugins 00071 * 00072 * The returned string will be a set of JS instructions defining the configuration that will be provided to the plugin(s) 00073 * Each of the instructions should be of the form: 00074 * RTEarea['.$RTEcounter.'].buttons.button-id.property = "value"; 00075 */ 00076 public function buildJavascriptConfiguration($RTEcounter) { 00077 $registerRTEinJavascriptString = ''; 00078 $button = 'paste'; 00079 if ($this->htmlAreaRTE->client['browser'] == 'gecko') { 00080 $mozillaAllowClipboardURL = $this->thisConfig['buttons.'][$button.'.']['mozillaAllowClipboardURL'] ? $this->thisConfig['buttons.'][$button.'.']['mozillaAllowClipboardURL'] : $GLOBALS['TYPO3_CONF_VARS']['EXTCONF'][$this->extensionKey]['plugins']['CopyPaste']['mozillaAllowClipboardURL']; 00081 if ($mozillaAllowClipboardURL) { 00082 if (!is_array($this->thisConfig['buttons.']) || !is_array($this->thisConfig['buttons.'][$button.'.'])) { 00083 $registerRTEinJavascriptString .= ' 00084 RTEarea['.$RTEcounter.'].buttons.'. $button .' = new Object();'; 00085 } 00086 $registerRTEinJavascriptString .= ' 00087 RTEarea['.$RTEcounter.'].buttons.'. $button .'.mozillaAllowClipboardURL = "' . $mozillaAllowClipboardURL . '";'; 00088 } 00089 } 00090 return $registerRTEinJavascriptString; 00091 } 00092 00093 /** 00094 * Return an updated array of toolbar enabled buttons 00095 * 00096 * @param array $show: array of toolbar elements that will be enabled, unless modified here 00097 * 00098 * @return array toolbar button array, possibly updated 00099 */ 00100 public function applyToolbarConstraints($show) { 00101 // Remove some buttons 00102 if (is_array($this->hideButtonsFromClient[$this->htmlAreaRTE->client['browser']])) { 00103 return array_diff($show, $this->hideButtonsFromClient[$this->htmlAreaRTE->client['browser']]); 00104 } else { 00105 return $show; 00106 } 00107 } 00108 } 00109 00110 if (defined('TYPO3_MODE') && isset($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['ext/rtehtmlarea/extensions/CopyPaste/class.tx_rtehtmlarea_copypaste.php'])) { 00111 include_once($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['ext/rtehtmlarea/extensions/CopyPaste/class.tx_rtehtmlarea_copypaste.php']); 00112 } 00113 ?>
1.8.0