|
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 * TYPO3Link plugin for htmlArea RTE 00026 * 00027 * @author Stanislas Rolland <typo3(arobas)sjbr.ca> 00028 * 00029 * TYPO3 SVN ID: $Id: class.tx_rtehtmlarea_typo3link.php 10502 2011-02-20 04:18:31Z stan $ 00030 * 00031 */ 00032 class tx_rtehtmlarea_typo3link extends tx_rtehtmlarea_api { 00033 00034 protected $extensionKey = 'rtehtmlarea'; // The key of the extension that is extending htmlArea RTE 00035 protected $pluginName = 'TYPO3Link'; // 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/TYPO3Link/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 = 'link, unlink'; 00044 protected $convertToolbarForHtmlAreaArray = array ( 00045 'link' => 'CreateLink', 00046 'unlink' => 'UnLink', 00047 ); 00048 00049 public function main($parentObject) { 00050 // Check if this should be enabled based on Page TSConfig 00051 return parent::main($parentObject) && !$this->thisConfig['disableTYPO3Browsers'] 00052 && !(is_array( $this->thisConfig['buttons.']) && is_array($this->thisConfig['buttons.']['link.']) && is_array($this->thisConfig['buttons.']['link.']['TYPO3Browser.']) && $this->thisConfig['buttons.']['link.']['TYPO3Browser.']['disabled']); 00053 } 00054 00055 /** 00056 * Return JS configuration of the htmlArea plugins registered by the extension 00057 * 00058 * @param integer Relative id of the RTE editing area in the form 00059 * 00060 * @return string JS configuration for registered plugins, in this case, JS configuration of block elements 00061 * 00062 * The returned string will be a set of JS instructions defining the configuration that will be provided to the plugin(s) 00063 * Each of the instructions should be of the form: 00064 * RTEarea['.$RTEcounter.']["buttons"]["button-id"]["property"] = "value"; 00065 */ 00066 public function buildJavascriptConfiguration($RTEcounter) { 00067 00068 $registerRTEinJavascriptString = ''; 00069 $button = 'link'; 00070 if (in_array($button, $this->toolbar)) { 00071 if (!is_array( $this->thisConfig['buttons.']) || !is_array( $this->thisConfig['buttons.'][$button.'.'])) { 00072 $registerRTEinJavascriptString .= ' 00073 RTEarea['.$RTEcounter.'].buttons.'. $button .' = new Object();'; 00074 } 00075 $registerRTEinJavascriptString .= ' 00076 RTEarea['.$RTEcounter.'].buttons.'. $button .'.pathLinkModule = "' . $this->htmlAreaRTE->extHttpPath . 'mod3/browse_links.php";'; 00077 00078 if ($this->htmlAreaRTE->is_FE()) { 00079 $RTEProperties = $this->htmlAreaRTE->RTEsetup; 00080 } else { 00081 $RTEProperties = $this->htmlAreaRTE->RTEsetup['properties']; 00082 } 00083 if (is_array($RTEProperties['classesAnchor.'])) { 00084 $registerRTEinJavascriptString .= ' 00085 RTEarea['.$RTEcounter.'].buttons.'. $button .'.classesAnchorUrl = "' . $this->htmlAreaRTE->writeTemporaryFile('', 'classesAnchor_'.$this->htmlAreaRTE->contentLanguageUid, 'js', $this->buildJSClassesAnchorArray(), TRUE) . '";'; 00086 } 00087 $registerRTEinJavascriptString .= ' 00088 RTEarea['.$RTEcounter.'].buttons.'. $button .'.additionalAttributes = "external' . ($GLOBALS['TYPO3_CONF_VARS']['EXTCONF'][$this->extensionKey]['plugins'][$this->pluginName]['additionalAttributes'] ? (',' . $GLOBALS['TYPO3_CONF_VARS']['EXTCONF'][$this->extensionKey]['plugins'][$this->pluginName]['additionalAttributes']) : '') . '";'; 00089 } 00090 return $registerRTEinJavascriptString; 00091 } 00092 00093 /** 00094 * Return a JS array for special anchor classes 00095 * 00096 * @return string classesAnchor array definition 00097 */ 00098 public function buildJSClassesAnchorArray() { 00099 global $LANG, $TYPO3_CONF_VARS; 00100 00101 $linebreak = $TYPO3_CONF_VARS['EXTCONF'][$this->htmlAreaRTE->ID]['enableCompressedScripts'] ? '' : LF; 00102 $JSClassesAnchorArray .= 'HTMLArea.classesAnchorSetup = [ ' . $linebreak; 00103 $classesAnchorIndex = 0; 00104 foreach ($this->htmlAreaRTE->RTEsetup['properties']['classesAnchor.'] as $label => $conf) { 00105 if (is_array($conf) && $conf['class']) { 00106 $JSClassesAnchorArray .= (($classesAnchorIndex++)?',':'') . ' { ' . $linebreak; 00107 $index = 0; 00108 $JSClassesAnchorArray .= (($index++)?',':'') . 'name : "' . str_replace('"', '', str_replace('\'', '', $conf['class'])) . '"' . $linebreak; 00109 if ($conf['type']) { 00110 $JSClassesAnchorArray .= (($index++)?',':'') . 'type : "' . str_replace('"', '', str_replace('\'', '', $conf['type'])) . '"' . $linebreak; 00111 } 00112 if (trim(str_replace('\'', '', str_replace('"', '', $conf['image'])))) { 00113 $JSClassesAnchorArray .= (($index++)?',':'') . 'image : "' . $this->htmlAreaRTE->siteURL . t3lib_div::resolveBackPath(TYPO3_mainDir . $this->htmlAreaRTE->getFullFileName(trim(str_replace('\'', '', str_replace('"', '', $conf['image']))))) . '"' . $linebreak; 00114 } 00115 $JSClassesAnchorArray .= (($index++)?',':'') . 'addIconAfterLink : ' . ($conf['addIconAfterLink']?'true':'false') . $linebreak; 00116 if (trim($conf['altText'])) { 00117 $string = $this->htmlAreaRTE->getLLContent(trim($conf['altText'])); 00118 $JSClassesAnchorArray .= (($index++)?',':'') . 'altText : ' . str_replace('"', '\"', str_replace('\\\'', '\'', $string)) . $linebreak; 00119 } 00120 if (trim($conf['titleText'])) { 00121 $string = $this->htmlAreaRTE->getLLContent(trim($conf['titleText'])); 00122 $JSClassesAnchorArray .= (($index++)?',':'') . 'titleText : ' . str_replace('"', '\"', str_replace('\\\'', '\'', $string)) . $linebreak; 00123 } 00124 if (trim($conf['target'])) { 00125 $JSClassesAnchorArray .= (($index++)?',':'') . 'target : "' . trim($conf['target']) . '"' . $linebreak; 00126 } 00127 $JSClassesAnchorArray .= '}' . $linebreak; 00128 } 00129 } 00130 $JSClassesAnchorArray .= '];' . $linebreak; 00131 return $JSClassesAnchorArray; 00132 } 00133 00134 /** 00135 * Return an updated array of toolbar enabled buttons 00136 * 00137 * @param array $show: array of toolbar elements that will be enabled, unless modified here 00138 * 00139 * @return array toolbar button array, possibly updated 00140 */ 00141 public function applyToolbarConstraints($show) { 00142 // We will not allow unlink if link is not enabled 00143 if (!in_array('link', $show)) { 00144 return array_diff($show, t3lib_div::trimExplode(',', $this->pluginButtons)); 00145 } else { 00146 return $show; 00147 } 00148 } 00149 } 00150 if (defined('TYPO3_MODE') && isset($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['ext/rtehtmlarea/extensions/TYPO3Link/class.tx_rtehtmlarea_typo3link.php'])) { 00151 include_once($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['ext/rtehtmlarea/extensions/TYPO3Link/class.tx_rtehtmlarea_typo3link.php']); 00152 } 00153 ?>
1.8.0