|
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 * InlineElements plugin for htmlArea RTE 00026 * 00027 * @author Stanislas Rolland <typo3(arobas)sjbr.ca> 00028 * 00029 * TYPO3 SVN ID: $Id: class.tx_rtehtmlarea_inlineelements.php 10120 2011-01-18 20:03:36Z ohader $ 00030 * 00031 */ 00032 class tx_rtehtmlarea_inlineelements extends tx_rtehtmlarea_api { 00033 00034 protected $extensionKey = 'rtehtmlarea'; // The key of the extension that is extending htmlArea RTE 00035 protected $pluginName = 'InlineElements'; // The name of the plugin registered by the extension 00036 protected $relativePathToLocallangFile = 'extensions/InlineElements/locallang.xml'; // Path to this main locallang file of the extension relative to the extension dir. 00037 protected $relativePathToSkin = 'extensions/InlineElements/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 00043 protected $pluginButtons = 'formattext, bidioverride, big, bold, citation, code, definition, deletedtext, emphasis, insertedtext, italic, keyboard, quotation, sample, small, span, strikethrough, strong, subscript, superscript, underline, variable'; 00044 00045 protected $convertToolbarForHtmlAreaArray = array ( 00046 'formattext' => 'FormatText', 00047 'bidioverride' => 'BiDiOverride', 00048 'big' => 'Big', 00049 'bold' => 'Bold', 00050 'citation' => 'Citation', 00051 'code' => 'Code', 00052 'definition' => 'Definition', 00053 'deletedtext' => 'DeletedText', 00054 'emphasis' => 'Emphasis', 00055 'insertedtext' => 'InsertedText', 00056 'italic' => 'Italic', 00057 'keyboard' => 'Keyboard', 00058 'monospaced' => 'MonoSpaced', 00059 'quotation' => 'Quotation', 00060 'sample' => 'Sample', 00061 'small' => 'Small', 00062 'span' => 'Span', 00063 'strikethrough' => 'StrikeThrough', 00064 'strong' => 'Strong', 00065 'subscript' => 'Subscript', 00066 'superscript' => 'Superscript', 00067 'underline' => 'Underline', 00068 'variable' => 'Variable', 00069 ); 00070 00071 protected $defaultInlineElements = array( 00072 'none' => 'No markup', 00073 'b' => 'Bold', 00074 'bdo' => 'BiDi override', 00075 'big' => 'Large text', 00076 'cite' => 'Citation', 00077 'code' => 'Code', 00078 'del' => 'Deleted text', 00079 'dfn' => 'Definition', 00080 'em' => 'Emphasis', 00081 'i' => 'Italic', 00082 'ins' => 'Inserted text', 00083 'kbd' => 'Keyboard', 00084 'q' => 'Quotation', 00085 'samp' => 'Sample', 00086 'small' => 'Small text', 00087 'span' => 'Style container', 00088 'strike' => 'Strike-through', 00089 'strong' => 'Strong emphasis', 00090 'sub' => 'Subscript', 00091 'sup' => 'Superscript', 00092 'tt' => 'Monospaced text', 00093 'u' => 'Underline', 00094 'var' => 'Variable', 00095 ); 00096 00097 protected $defaultInlineElementsOrder = 'none, bidioverride, big, bold, citation, code, definition, deletedtext, emphasis, insertedtext, italic, keyboard, 00098 monospaced, quotation, sample, small, span, strikethrough, strong, subscript, superscript, underline, variable'; 00099 00100 protected $buttonToInlineElement = array( 00101 'none' => 'none', 00102 'bidioverride' => 'bdo', 00103 'big' => 'big', 00104 'bold' => 'b', 00105 'citation' => 'cite', 00106 'code' => 'code', 00107 'definition' => 'dfn', 00108 'deletedtext' => 'del', 00109 'emphasis' => 'em', 00110 'insertedtext' => 'ins', 00111 'italic' => 'i', 00112 'keyboard' => 'kbd', 00113 'monospaced' => 'tt', 00114 'quotation' => 'q', 00115 'sample' => 'samp', 00116 'small' => 'small', 00117 'span' => 'span', 00118 'strikethrough' => 'strike', 00119 'strong' => 'strong', 00120 'subscript' => 'sub', 00121 'superscript' => 'sup', 00122 'underline' => 'u', 00123 'variable' => 'var', 00124 ); 00125 00126 /** 00127 * Return JS configuration of the htmlArea plugins registered by the extension 00128 * 00129 * @param integer Relative id of the RTE editing area in the form 00130 * 00131 * @return string JS configuration for registered plugins 00132 * 00133 * The returned string will be a set of JS instructions defining the configuration that will be provided to the plugin(s) 00134 * Each of the instructions should be of the form: 00135 * RTEarea['.$RTEcounter.']["buttons"]["button-id"]["property"] = "value"; 00136 */ 00137 public function buildJavascriptConfiguration($RTEcounter) { 00138 global $TSFE, $LANG; 00139 00140 $registerRTEinJavascriptString = ''; 00141 if (in_array('formattext', $this->toolbar)) { 00142 if (!is_array( $this->thisConfig['buttons.']) || !is_array( $this->thisConfig['buttons.']['formattext.'])) { 00143 $registerRTEinJavascriptString .= ' 00144 RTEarea['.$RTEcounter.'].buttons.formattext = new Object();'; 00145 } 00146 00147 // Default inline elements 00148 $hideItems = array(); 00149 $restrictTo = array('*'); 00150 $inlineElementsOrder = $this->defaultInlineElementsOrder; 00151 $prefixLabelWithTag = false; 00152 $postfixLabelWithTag = false; 00153 00154 // Processing PageTSConfig 00155 if (is_array($this->thisConfig['buttons.']) && is_array($this->thisConfig['buttons.']['formattext.'])) { 00156 // Removing elements 00157 if ($this->thisConfig['buttons.']['formattext.']['removeItems']) { 00158 $hideItems = t3lib_div::trimExplode(',', $this->htmlAreaRTE->cleanList($this->thisConfig['buttons.']['formattext.']['removeItems']), 1); 00159 } 00160 // Restriction clause 00161 if ($this->thisConfig['buttons.']['formattext.']['restrictTo']) { 00162 $restrictTo = t3lib_div::trimExplode(',', $this->htmlAreaRTE->cleanList('none,'.$this->thisConfig['buttons.']['formattext.']['restrictTo']), 1); 00163 } else if ($this->thisConfig['buttons.']['formattext.']['restrictToItems']) { 00164 $restrictTo = t3lib_div::trimExplode(',', $this->htmlAreaRTE->cleanList('none,'.$this->thisConfig['buttons.']['formattext.']['restrictToItems']), 1); 00165 } 00166 // Elements order 00167 if ($this->thisConfig['buttons.']['formattext.']['orderItems']) { 00168 $inlineElementsOrder = 'none,'.$this->thisConfig['buttons.']['formattext.']['orderItems']; 00169 } 00170 $prefixLabelWithTag = ($this->thisConfig['buttons.']['formattext.']['prefixLabelWithTag'])?true:$prefixLabelWithTag; 00171 $postfixLabelWithTag = ($this->thisConfig['buttons.']['formattext.']['postfixLabelWithTag'])?true:$postfixLabelWithTag; 00172 } 00173 00174 $inlineElementsOrder = array_diff(t3lib_div::trimExplode(',', $this->htmlAreaRTE->cleanList($inlineElementsOrder), 1), $hideItems); 00175 if (!in_array('*', $restrictTo)) { 00176 $inlineElementsOrder = array_intersect($inlineElementsOrder, $restrictTo); 00177 } 00178 00179 // Localizing the options 00180 $inlineElementsOptions = array(); 00181 foreach ($inlineElementsOrder as $item) { 00182 if ($this->htmlAreaRTE->is_FE()) { 00183 $inlineElementsOptions[$this->buttonToInlineElement[$item]] = $TSFE->getLLL($this->defaultInlineElements[$this->buttonToInlineElement[$item]], $this->LOCAL_LANG); 00184 } else { 00185 $inlineElementsOptions[$this->buttonToInlineElement[$item]] = $LANG->getLL($this->defaultInlineElements[$this->buttonToInlineElement[$item]]); 00186 } 00187 $inlineElementsOptions[$this->buttonToInlineElement[$item]] = (($prefixLabelWithTag && $item != 'none')?($this->buttonToInlineElement[$item].' - '):'') . $inlineElementsOptions[$this->buttonToInlineElement[$item]] . (($postfixLabelWithTag && $item != 'none')?(' - '.$this->buttonToInlineElement[$item]):''); 00188 } 00189 00190 $first = array_shift($inlineElementsOptions); 00191 // Sorting the options 00192 if (!is_array($this->thisConfig['buttons.']) || !is_array($this->thisConfig['buttons.']['formattext.']) || !$this->thisConfig['buttons.']['formattext.']['orderItems']) { 00193 asort($inlineElementsOptions); 00194 } 00195 // Generating the javascript options 00196 $JSInlineElements = array(); 00197 $JSInlineElements[] = array($first, 'none'); 00198 foreach ($inlineElementsOptions as $item => $label) { 00199 $JSInlineElements[] = array($label, $item); 00200 } 00201 if ($this->htmlAreaRTE->is_FE()) { 00202 $GLOBALS['TSFE']->csConvObj->convArray($JSInlineElements, $this->htmlAreaRTE->OutputCharset, 'utf-8'); 00203 } else { 00204 $GLOBALS['LANG']->csConvObj->convArray($JSInlineElements, $GLOBALS['LANG']->charSet, 'utf-8'); 00205 } 00206 $registerRTEinJavascriptString .= ' 00207 RTEarea['.$RTEcounter.'].buttons.formattext.options = ' . json_encode($JSInlineElements) . ';'; 00208 } 00209 return $registerRTEinJavascriptString; 00210 } 00211 } 00212 if (defined('TYPO3_MODE') && isset($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['ext/rtehtmlarea/extensions/InlineElements/class.tx_rtehtmlarea_inlineelements.php'])) { 00213 include_once($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['ext/rtehtmlarea/extensions/InlineElements/class.tx_rtehtmlarea_inlineelements.php']); 00214 } 00215 ?>
1.8.0