|
TYPO3 API
SVNRelease
|
00001 <?php 00002 /*************************************************************** 00003 * Copyright notice 00004 * 00005 * (c) 2007-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 * API for extending htmlArea RTE 00026 * 00027 * @author Stanislas Rolland <typo3(arobas)sjbr.ca> 00028 * 00029 * TYPO3 SVN ID: $Id: class.tx_rtehtmlareaapi.php 10120 2011-01-18 20:03:36Z ohader $ 00030 * 00031 */ 00032 00033 abstract class tx_rtehtmlarea_api { 00034 00035 protected $extensionKey; // The key of the extension that is extending htmlArea RTE 00036 protected $pluginName; // The name of the plugin registered by the extension 00037 protected $relativePathToLocallangFile; // Path to the localization file for this script, relative to the extension dir 00038 protected $relativePathToSkin; // Path to the skin (css) file that should be added to the RTE skin when the registered plugin is enabled, relative to the extension dir 00039 protected $relativePathToPluginDirectory; // Path to the directory containing the plugin, relative to the extension dir (should end with slash /) 00040 protected $htmlAreaRTE; // Reference to the invoking object 00041 protected $rteExtensionKey; // The extension key of the RTE 00042 protected $thisConfig; // Reference to RTE PageTSConfig 00043 protected $toolbar; // Refrence to RTE toolbar array 00044 protected $LOCAL_LANG; // Frontend language array 00045 protected $pluginButtons = ''; // The comma-separated list of button names that the registered plugin is adding to the htmlArea RTE toolbar 00046 protected $pluginLabels = ''; // The comma-separated list of label names that the registered plugin is adding to the htmlArea RTE toolbar 00047 protected $pluginAddsButtons = true; // Boolean indicating whether the plugin is adding buttons or not 00048 protected $convertToolbarForHtmlAreaArray = array(); // The name-converting array, converting the button names used in the RTE PageTSConfing to the button id's used by the JS scripts 00049 protected $requiresClassesConfiguration = false; // True if the registered plugin requires the PageTSConfig Classes configuration 00050 protected $requiresSynchronousLoad = false; // True if the plugin must be loaded synchronously 00051 protected $requiredPlugins = ''; // The comma-separated list of names of prerequisite plugins 00052 00053 /** 00054 * Returns true if the plugin is available and correctly initialized 00055 * 00056 * @param object Reference to parent object, which is an instance of the htmlArea RTE 00057 * 00058 * @return boolean true if this plugin object should be made available in the current environment and is correctly initialized 00059 */ 00060 public function main($parentObject) { 00061 global $TYPO3_CONF_VARS, $LANG, $TSFE; 00062 00063 $this->htmlAreaRTE = $parentObject; 00064 $this->rteExtensionKey =& $this->htmlAreaRTE->ID; 00065 $this->thisConfig =& $this->htmlAreaRTE->thisConfig; 00066 $this->toolbar =& $this->htmlAreaRTE->toolbar; 00067 $this->LOCAL_LANG =& $this->htmlAreaRTE->LOCAL_LANG; 00068 00069 // Set the value of this boolean based on the initial value of $this->pluginButtons 00070 $this->pluginAddsButtons = !empty($this->pluginButtons); 00071 00072 // Check if the plugin should be disabled in frontend 00073 if ($this->htmlAreaRTE->is_FE() && $TYPO3_CONF_VARS['EXTCONF'][$this->rteExtensionKey]['plugins'][$this->pluginName]['disableInFE']) { 00074 return false; 00075 } 00076 00077 // Localization array must be initialized here 00078 if ($this->relativePathToLocallangFile) { 00079 if ($this->htmlAreaRTE->is_FE()) { 00080 $this->LOCAL_LANG = t3lib_div::array_merge_recursive_overrule($this->LOCAL_LANG, t3lib_div::readLLfile('EXT:' . $this->extensionKey . '/' . $this->relativePathToLocallangFile, $this->htmlAreaRTE->language)); 00081 } else { 00082 $LANG->includeLLFile('EXT:' . $this->extensionKey . '/' . $this->relativePathToLocallangFile); 00083 } 00084 } 00085 return true; 00086 } 00087 00088 /** 00089 * Returns a modified toolbar order string 00090 * 00091 * @return string a modified tollbar order list 00092 */ 00093 public function addButtonsToToolbar() { 00094 //Add only buttons not yet in the default toolbar order 00095 $addButtons = implode(',', array_diff(t3lib_div::trimExplode(',', $this->pluginButtons, 1), t3lib_div::trimExplode(',', $this->htmlAreaRTE->defaultToolbarOrder, 1))); 00096 return (($addButtons ? ('bar,' . $addButtons . ',linebreak,') : '') . $this->htmlAreaRTE->defaultToolbarOrder); 00097 } 00098 00099 /** 00100 * Returns the path to the skin component (button icons) that should be added to linked stylesheets 00101 * 00102 * @return string path to the skin (css) file 00103 */ 00104 public function getPathToSkin() { 00105 global $TYPO3_CONF_VARS; 00106 if ($TYPO3_CONF_VARS['EXTCONF'][$this->rteExtensionKey]['plugins'][$this->pluginName]['addIconsToSkin']) { 00107 return $this->relativePathToSkin; 00108 } else { 00109 return ''; 00110 } 00111 } 00112 00113 /** 00114 * Return JS configuration of the htmlArea plugins registered by the extension 00115 * 00116 * @param integer Relative id of the RTE editing area in the form 00117 * 00118 * @return string JS configuration for registered plugins 00119 * 00120 * The returned string will be a set of JS instructions defining the configuration that will be provided to the plugin(s) 00121 * Each of the instructions should be of the form: 00122 * RTEarea['.$RTEcounter.']["buttons"]["button-id"]["property"] = "value"; 00123 */ 00124 public function buildJavascriptConfiguration($RTEcounter) { 00125 global $TSFE, $LANG; 00126 00127 $registerRTEinJavascriptString = ''; 00128 $pluginButtons = t3lib_div::trimExplode(',', $this->pluginButtons, 1); 00129 foreach ($pluginButtons as $button) { 00130 if (in_array($button, $this->toolbar)) { 00131 if (!is_array( $this->thisConfig['buttons.']) || !is_array( $this->thisConfig['buttons.'][$button.'.'])) { 00132 $registerRTEinJavascriptString .= ' 00133 RTEarea['.$RTEcounter.'].buttons.'. $button .' = new Object();'; 00134 } 00135 } 00136 } 00137 return $registerRTEinJavascriptString; 00138 } 00139 00140 /** 00141 * Returns the extension key 00142 * 00143 * @return string the extension key 00144 */ 00145 public function getExtensionKey() { 00146 return $this->extensionKey; 00147 } 00148 00149 /** 00150 * Returns the path to the plugin directory, if any 00151 * 00152 * @return string the full path to the plugin directory 00153 */ 00154 public function getPathToPluginDirectory() { 00155 return ($this->relativePathToPluginDirectory ? $this->htmlAreaRTE->httpTypo3Path . t3lib_extMgm::siteRelPath($this->extensionKey) . $this->relativePathToPluginDirectory : ''); 00156 } 00157 00158 /** 00159 * Returns a boolean indicating whether the plugin adds buttons or not to the toolbar 00160 * 00161 * @return boolean 00162 */ 00163 public function addsButtons() { 00164 return $this->pluginAddsButtons; 00165 } 00166 00167 /** 00168 * Returns the list of buttons implemented by the plugin 00169 * 00170 * @return string the list of buttons implemented by the plugin 00171 */ 00172 public function getPluginButtons() { 00173 return $this->pluginButtons; 00174 } 00175 00176 /** 00177 * Returns the list of toolbar labels implemented by the plugin 00178 * 00179 * @return string the list of labels implemented by the plugin 00180 */ 00181 public function getPluginLabels() { 00182 return $this->pluginLabels; 00183 } 00184 00185 /** 00186 * Returns the conversion array from TYPO3 button names to htmlArea button names 00187 * 00188 * @return array the conversion array from TYPO3 button names to htmlArea button names 00189 */ 00190 public function getConvertToolbarForHtmlAreaArray() { 00191 return $this->convertToolbarForHtmlAreaArray; 00192 } 00193 00194 /** 00195 * Returns true if the extension requires the PageTSConfig Classes configuration 00196 * 00197 * @return boolean true if the extension requires the PageTSConfig Classes configuration 00198 */ 00199 public function requiresClassesConfiguration() { 00200 return $this->requiresClassesConfiguration; 00201 } 00202 00203 /** 00204 * Returns true if the plugin requires synchronous load 00205 * 00206 * @return boolean true if the plugin requires synchronous load 00207 */ 00208 public function requiresSynchronousLoad() { 00209 return $this->requiresSynchronousLoad; 00210 } 00211 00212 /** 00213 * Sets the plugin to require synchronous load or not 00214 * 00215 * @param boolean $value: the boolean value to set 00216 * 00217 * @return void 00218 */ 00219 public function setSynchronousLoad($value = true) { 00220 $this->requiresSynchronousLoad = $value; 00221 } 00222 00223 /** 00224 * Returns the list of plugins required by the plugin 00225 * 00226 * @return string the list of plugins required by the plugin 00227 */ 00228 public function getRequiredPlugins() { 00229 return $this->requiredPlugins; 00230 } 00231 } 00232 /* 00233 * Class alias for backward compatibility (TYPO3 4.5) 00234 */ 00235 abstract class tx_rtehtmlareaapi extends tx_rtehtmlarea_api { 00236 } 00237 ?>
1.8.0