Project

General

Profile

Bug #19477 » rtehtmlarea_bugfix_9596_typo3_4-2_v2.patch

Administrator Admin, 2008-12-03 06:02

View differences:

typo3/sysext/rtehtmlarea/class.tx_rtehtmlarea_base.php (copie de travail)
$GLOBALS['TSFE']->additionalHeaderData['rtehtmlarea-contentCSS'] = $this->getPageStyle();
$GLOBALS['TSFE']->additionalHeaderData['rtehtmlarea-skin'] = $this->getSkin();
} else {
$GLOBALS['SOBE']->doc->additionalHeaderData['rtehtmlarea-contentCSS'] = $this->getPageStyle();
$GLOBALS['SOBE']->doc->additionalHeaderData['rtehtmlarea-skin'] = $this->getSkin();
// If it was not known that an RTE-enabled field would be created when the page was first created, the css would not have been added to head
if (is_object($this->TCEform->inline) && $this->TCEform->inline->isAjaxCall) {
$this->TCEform->additionalCode_pre['rtehtmlarea-contentCSS'] = $this->getPageStyle();
$this->TCEform->additionalCode_pre['rtehtmlarea-skin'] = $this->getSkin();
} else {
$GLOBALS['SOBE']->doc->additionalHeaderData['rtehtmlarea-contentCSS'] = $this->getPageStyle();
$GLOBALS['SOBE']->doc->additionalHeaderData['rtehtmlarea-skin'] = $this->getSkin();
}
}
// Loading JavaScript files and code
$this->TCEform->additionalCode_pre['rtehtmlarea-loadJSfiles'] = $this->loadJSfiles($this->TCEform->RTEcounter);
$this->TCEform->additionalJS_pre['rtehtmlarea-loadJScode'] = $this->loadJScode($this->TCEform->RTEcounter);
// Trying to avoid re-loading after initial load, although on IRRE Ajax call a different TCEform instance will be used.
if ($this->TCEform->RTEcounter == 1) {
$this->TCEform->additionalCode_pre['rtehtmlarea-loadJSfiles'] = $this->loadJSfiles($this->TCEform->RTEcounter);
$this->TCEform->additionalJS_pre['rtehtmlarea-loadJScode'] = $this->loadJScode($this->TCEform->RTEcounter);
}
/* =======================================
* DRAW THE EDITOR
......
}
// Register RTE windows
$this->TCEform->RTEwindows[] = $PA['itemFormElName'];
$textAreaId = htmlspecialchars($PA['itemFormElName']);
// Check if wizard_rte called this for fullscreen edtition; if so, change the size of the RTE to fullscreen using JS
if (basename(PATH_thisScript) == 'wizard_rte.php') {
......
$editorWrapWidth = '100%';
$editorWrapHeight = '100%';
$this->RTEdivStyle = 'position:relative; left:0px; top:0px; height:100%; width:100%; border: 1px solid black; padding: 2px 0px 2px 2px;';
$this->TCEform->additionalJS_post[] = $this->setRTEsizeByJS('RTEarea'.$this->TCEform->RTEcounter, $height, $width);
$this->TCEform->additionalJS_post[] = $this->setRTEsizeByJS('RTEarea' . $textAreaId, $height, $width);
}
// Register RTE in JS:
$this->TCEform->additionalJS_post[] = $this->registerRTEinJS($this->TCEform->RTEcounter, $table, $row['uid'], $field);
$this->TCEform->additionalJS_post[] = $this->registerRTEinJS($this->TCEform->RTEcounter, $table, $row['uid'], $field, $textAreaId);
// Set the save option for the RTE:
$this->TCEform->additionalJS_submit[] = $this->setSaveRTE($this->TCEform->RTEcounter, $this->TCEform->formName, htmlspecialchars($PA['itemFormElName']));
$this->TCEform->additionalJS_submit[] = $this->setSaveRTE($this->TCEform->RTEcounter, $this->TCEform->formName, $textAreaId);
$this->TCEform->additionalJS_delete[] = $this->setDeleteRTE($this->TCEform->RTEcounter, $this->TCEform->formName, $textAreaId);
// Draw the textarea
$visibility = 'hidden';
$item = $this->triggerField($PA['itemFormElName']).'
<div id="pleasewait' . $this->TCEform->RTEcounter . '" class="pleasewait" style="display: none;" >' . $LANG->getLL('Please wait') . '</div>
<div id="editorWrap' . $this->TCEform->RTEcounter . '" class="editorWrap" style="width:' . $editorWrapWidth . '; height:' . $editorWrapHeight . ';">
<textarea id="RTEarea'.$this->TCEform->RTEcounter.'" name="'.htmlspecialchars($PA['itemFormElName']).'" style="'.t3lib_div::deHSCentities(htmlspecialchars($this->RTEdivStyle)).'">'.t3lib_div::formatForTextarea($value).'</textarea>
<div id="pleasewait' . $textAreaId . '" class="pleasewait" style="display: block;" >' . $LANG->getLL('Please wait') . '</div>
<div id="editorWrap' . $textAreaId . '" class="editorWrap" style="visibility: hidden; width:' . $editorWrapWidth . '; height:' . $editorWrapHeight . ';">
<textarea id="RTEarea' . $textAreaId . '" name="'.htmlspecialchars($PA['itemFormElName']).'" style="'.t3lib_div::deHSCentities(htmlspecialchars($this->RTEdivStyle)).'">'.t3lib_div::formatForTextarea($value).'</textarea>
</div>' . ($TYPO3_CONF_VARS['EXTCONF'][$this->ID]['enableDebugMode'] ? '<div id="HTMLAreaLog"></div>' : '') . '
';
}
......
function loadJSfiles($RTEcounter) {
global $TYPO3_CONF_VARS;
$loadPluginCode = '
HTMLArea_plugins = new Array();';
foreach ($this->pluginEnabledCumulativeArray[$RTEcounter] as $pluginId) {
$extensionKey = is_object($this->registeredPlugins[$pluginId]) ? $this->registeredPlugins[$pluginId]->getExtensionKey() : $this->ID;
$loadPluginCode .= '
HTMLArea_plugins.push("' . $this->writeTemporaryFile('EXT:' . $extensionKey . '/htmlarea/plugins/' . $pluginId . '/' . strtolower(preg_replace('/([a-z])([A-Z])([a-z])/', "$1".'-'."$2"."$3", $pluginId)) . '.js', $pluginId) . '");';
}
// Avoid re-initialization on AJax call when RTEarea object was already initialized
$loadJavascriptCode = '
<script type="text/javascript">
/*<![CDATA[*/
i=1;
while (document.getElementById("pleasewait" + i)) {
document.getElementById("pleasewait" + i).style.display = "block";
document.getElementById("editorWrap" + i).style.visibility = "hidden";
i++;
};
RTEarea = new Array();
RTEarea[0] = new Object();
RTEarea[0]["version"] = "' . $TYPO3_CONF_VARS['EXTCONF'][$this->ID]['version'] . '";'
. (($this->client['BROWSER'] == 'msie') ? ('
RTEarea[0]["htmlarea-ie"] = "' . $this->writeTemporaryFile('EXT:' . $this->ID . '/htmlarea/htmlarea-ie.js', "htmlarea-ie") . '";')
: ('
RTEarea[0]["htmlarea-gecko"] = "' . $this->writeTemporaryFile('EXT:' . $this->ID . '/htmlarea/htmlarea-gecko.js', "htmlarea-gecko") . '";')) . '
_editor_url = "' . $this->extHttpPath . 'htmlarea";
_editor_lang = "' . $this->language . '";
_editor_CSS = "' . $this->editorCSS . '";
_editor_skin = "' . dirname($this->editorCSS) . '";
_editor_edited_content_CSS = "' . $this->editedContentCSS . '";
_typo3_host_url = "' . $this->hostURL . '";
_editor_debug_mode = ' . ($TYPO3_CONF_VARS['EXTCONF'][$this->ID]['enableDebugMode'] ? 'true' : 'false') . ';
_editor_compressed_scripts = ' . ($TYPO3_CONF_VARS['EXTCONF'][$this->ID]['enableCompressedScripts'] ? 'true' : 'false') . ';'
. (($this->client['BROWSER'] == 'gecko') ? ('
_editor_mozAllowClipboard_url = "' . ($TYPO3_CONF_VARS['EXTCONF'][$this->ID]['mozAllowClipboardURL'] ? $TYPO3_CONF_VARS['EXTCONF'][$this->ID]['mozAllowClipboardURL'] : '') . '";')
: '') . '
if (typeof(RTEarea) == "undefined") {
RTEarea = new Object();
RTEarea.init = function() {
if (typeof(HTMLArea) == "undefined") {
window.setTimeout("RTEarea.init();", 40);
} else {'
. $loadPluginCode . '
HTMLArea.init();
}
};
RTEarea.initEditor = function(editorNumber) {
if (typeof(HTMLArea) == "undefined") {
window.setTimeout("RTEarea.initEditor(\'" + editorNumber + "\');", 40);
} else {
HTMLArea.initEditor(editorNumber);
}
};
RTEarea[0] = new Object();
RTEarea[0].version = "' . $TYPO3_CONF_VARS['EXTCONF'][$this->ID]['version'] . '";'
. (($this->client['BROWSER'] == 'msie') ? ('
RTEarea[0]["htmlarea-ie"] = "' . $this->writeTemporaryFile('EXT:' . $this->ID . '/htmlarea/htmlarea-ie.js', "htmlarea-ie") . '";')
: ('
RTEarea[0]["htmlarea-gecko"] = "' . $this->writeTemporaryFile('EXT:' . $this->ID . '/htmlarea/htmlarea-gecko.js', "htmlarea-gecko") . '";')) . '
_editor_url = "' . $this->extHttpPath . 'htmlarea";
_editor_lang = "' . $this->language . '";
_editor_CSS = "' . $this->editorCSS . '";
_editor_skin = "' . dirname($this->editorCSS) . '";
_editor_edited_content_CSS = "' . $this->editedContentCSS . '";
_typo3_host_url = "' . $this->hostURL . '";
_editor_debug_mode = ' . ($TYPO3_CONF_VARS['EXTCONF'][$this->ID]['enableDebugMode'] ? 'true' : 'false') . ';
_editor_compressed_scripts = ' . ($TYPO3_CONF_VARS['EXTCONF'][$this->ID]['enableCompressedScripts'] ? 'true' : 'false') . ';'
. (($this->client['BROWSER'] == 'gecko') ? ('
_editor_mozAllowClipboard_url = "' . ($TYPO3_CONF_VARS['EXTCONF'][$this->ID]['mozAllowClipboardURL'] ? $TYPO3_CONF_VARS['EXTCONF'][$this->ID]['mozAllowClipboardURL'] : '') . '";')
: '') . '
}
/*]]>*/
</script>';
$loadJavascriptCode .= '
......
*/
function loadJScode($RTEcounter) {
$loadPluginCode = '';
foreach ($this->pluginEnabledCumulativeArray[$RTEcounter] as $pluginId) {
$extensionKey = is_object($this->registeredPlugins[$pluginId]) ? $this->registeredPlugins[$pluginId]->getExtensionKey() : $this->ID;
$loadPluginCode .= '
HTMLArea.loadPlugin("' . $pluginId . '", true, "' . $this->writeTemporaryFile('EXT:' . $extensionKey . '/htmlarea/plugins/' . $pluginId . '/' . strtolower(preg_replace('/([a-z])([A-Z])([a-z])/', "$1".'-'."$2"."$3", $pluginId)) . '.js', $pluginId) . '");';
}
return (!$this->is_FE() ? '' : '
' . '/*<![CDATA[*/') . ($this->is_FE() ? '' : '
RTEarea[0]["RTEtsConfigParams"] = "&RTEtsConfigParams=' . rawurlencode($this->RTEtsConfigParams()) . '";')
. $loadPluginCode . '
HTMLArea.init();' . (!$this->is_FE() ? '' : '
' . '/*<![CDATA[*/') . '
RTEarea.init();' . (!$this->is_FE() ? '' : '
/*]]>*/
');
}
......
*
* @return string the Javascript code for configuring the RTE
*/
function registerRTEinJS($RTEcounter, $table='', $uid='', $field='') {
function registerRTEinJS($RTEcounter, $table='', $uid='', $field='', $textAreaId = '') {
global $TYPO3_CONF_VARS;
$configureRTEInJavascriptString = (!$this->is_FE() ? '' : '
' . '/*<![CDATA[*/') . '
RTEarea['.$RTEcounter.'] = new Object();
RTEarea['.$RTEcounter.'].RTEtsConfigParams = "&RTEtsConfigParams=' . rawurlencode($this->RTEtsConfigParams()) . '";
RTEarea['.$RTEcounter.'].number = '.$RTEcounter.';
RTEarea['.$RTEcounter.'].id = "RTEarea'.$RTEcounter.'";
RTEarea['.$RTEcounter.'].enableWordClean = ' . (trim($this->thisConfig['enableWordClean'])?'true':'false') . ';
RTEarea['.$RTEcounter.']["htmlRemoveComments"] = ' . (trim($this->thisConfig['removeComments'])?'true':'false') . ';
RTEarea['.$RTEcounter.'].disableEnterParagraphs = ' . (trim($this->thisConfig['disableEnterParagraphs'])?'true':'false') . ';
RTEarea['.$RTEcounter.'].disableObjectResizing = ' . (trim($this->thisConfig['disableObjectResizing'])?'true':'false') . ';
RTEarea['.$RTEcounter.']["removeTrailingBR"] = ' . (trim($this->thisConfig['removeTrailingBR'])?'true':'false') . ';
RTEarea['.$RTEcounter.']["useCSS"] = ' . (trim($this->thisConfig['useCSS'])?'true':'false') . ';
RTEarea['.$RTEcounter.']["keepButtonGroupTogether"] = ' . (trim($this->thisConfig['keepButtonGroupTogether'])?'true':'false') . ';
RTEarea['.$RTEcounter.']["disablePCexamples"] = ' . (trim($this->thisConfig['disablePCexamples'])?'true':'false') . ';
RTEarea['.$RTEcounter.']["statusBar"] = ' . (trim($this->thisConfig['showStatusBar'])?'true':'false') . ';
RTEarea['.$RTEcounter.']["showTagFreeClasses"] = ' . (trim($this->thisConfig['showTagFreeClasses'])?'true':'false') . ';
RTEarea['.$RTEcounter.']["useHTTPS"] = ' . ((trim(stristr($this->siteURL, 'https')) || $this->thisConfig['forceHTTPS'])?'true':'false') . ';
RTEarea['.$RTEcounter.']["enableMozillaExtension"] = ' . (($this->client['BROWSER'] == 'gecko' && $TYPO3_CONF_VARS['EXTCONF'][$this->ID]['enableMozillaExtension'])?'true':'false') . ';
RTEarea['.$RTEcounter.']["tceformsNested"] = ' . (is_object($this->TCEform) && method_exists($this->TCEform, 'getDynNestedStack') ? $this->TCEform->getDynNestedStack(true) : '[]') . ';';
if (typeof(configureEditorInstance) == "undefined") {
configureEditorInstance = new Object();
}
configureEditorInstance["' . $textAreaId . '"] = function() {
if (typeof(RTEarea) == "undefined" || typeof(HTMLArea) == "undefined") {
window.setTimeout("configureEditorInstance[\'' . $textAreaId . '\']();", 40);
} else {
editornumber = "' . $textAreaId . '";
RTEarea[editornumber] = new Object();
RTEarea[editornumber].RTEtsConfigParams = "&RTEtsConfigParams=' . rawurlencode($this->RTEtsConfigParams()) . '";'
. ($RTEcounter ? 'RTEarea[0].RTEtsConfigParams = "&RTEtsConfigParams=' . rawurlencode($this->RTEtsConfigParams()) . '";' : '') . '
RTEarea[editornumber].number = editornumber;
RTEarea[editornumber].deleted = false;
RTEarea[editornumber].textAreaId = "' . $textAreaId . '";
RTEarea[editornumber].id = "RTEarea" + editornumber;
RTEarea[editornumber].enableWordClean = ' . (trim($this->thisConfig['enableWordClean'])?'true':'false') . ';
RTEarea[editornumber]["htmlRemoveComments"] = ' . (trim($this->thisConfig['removeComments'])?'true':'false') . ';
RTEarea[editornumber].disableEnterParagraphs = ' . (trim($this->thisConfig['disableEnterParagraphs'])?'true':'false') . ';
RTEarea[editornumber].disableObjectResizing = ' . (trim($this->thisConfig['disableObjectResizing'])?'true':'false') . ';
RTEarea[editornumber]["removeTrailingBR"] = ' . (trim($this->thisConfig['removeTrailingBR'])?'true':'false') . ';
RTEarea[editornumber]["useCSS"] = ' . (trim($this->thisConfig['useCSS'])?'true':'false') . ';
RTEarea[editornumber]["keepButtonGroupTogether"] = ' . (trim($this->thisConfig['keepButtonGroupTogether'])?'true':'false') . ';
RTEarea[editornumber]["disablePCexamples"] = ' . (trim($this->thisConfig['disablePCexamples'])?'true':'false') . ';
RTEarea[editornumber]["statusBar"] = ' . (trim($this->thisConfig['showStatusBar'])?'true':'false') . ';
RTEarea[editornumber]["showTagFreeClasses"] = ' . (trim($this->thisConfig['showTagFreeClasses'])?'true':'false') . ';
RTEarea[editornumber]["useHTTPS"] = ' . ((trim(stristr($this->siteURL, 'https')) || $this->thisConfig['forceHTTPS'])?'true':'false') . ';
RTEarea[editornumber]["enableMozillaExtension"] = ' . (($this->client['BROWSER'] == 'gecko' && $TYPO3_CONF_VARS['EXTCONF'][$this->ID]['enableMozillaExtension'])?'true':'false') . ';
RTEarea[editornumber].tceformsNested = ' . (is_object($this->TCEform) && method_exists($this->TCEform, 'getDynNestedStack') ? $this->TCEform->getDynNestedStack(true) : '[]') . ';';
// The following properties apply only to the backend
if (!$this->is_FE()) {
$configureRTEInJavascriptString .= '
RTEarea['.$RTEcounter.'].sys_language_content = "' . $this->contentLanguageUid . '";
RTEarea['.$RTEcounter.'].typo3ContentLanguage = "' . $this->contentTypo3Language . '";
RTEarea['.$RTEcounter.'].typo3ContentCharset = "' . $this->contentCharset . '";
RTEarea['.$RTEcounter.'].userUid = "' . $this->userUid . '";';
RTEarea[editornumber].sys_language_content = "' . $this->contentLanguageUid . '";
RTEarea[editornumber].typo3ContentLanguage = "' . $this->contentTypo3Language . '";
RTEarea[editornumber].typo3ContentCharset = "' . $this->contentCharset . '";
RTEarea[editornumber].userUid = "' . $this->userUid . '";';
}
// Setting the plugin flags
$configureRTEInJavascriptString .= '
RTEarea['.$RTEcounter.'].plugin = new Object();
RTEarea['.$RTEcounter.'].pathToPluginDirectory = new Object();';
RTEarea[editornumber].plugin = new Object();
RTEarea[editornumber].pathToPluginDirectory = new Object();';
foreach ($this->pluginEnabledArray as $pluginId) {
$configureRTEInJavascriptString .= '
RTEarea['.$RTEcounter.'].plugin.'.$pluginId.' = true;';
RTEarea[editornumber].plugin.'.$pluginId.' = true;';
if (is_object($this->registeredPlugins[$pluginId])) {
$pathToPluginDirectory = $this->registeredPlugins[$pluginId]->getPathToPluginDirectory();
if ($pathToPluginDirectory) {
$configureRTEInJavascriptString .= '
RTEarea['.$RTEcounter.'].pathToPluginDirectory.'.$pluginId.' = "' . $pathToPluginDirectory . '";';
RTEarea[editornumber].pathToPluginDirectory.'.$pluginId.' = "' . $pathToPluginDirectory . '";';
}
}
}
// Setting the buttons configuration
$configureRTEInJavascriptString .= '
RTEarea['.$RTEcounter.'].buttons = new Object();';
RTEarea[editornumber].buttons = new Object();';
if (is_array($this->thisConfig['buttons.'])) {
foreach ($this->thisConfig['buttons.'] as $buttonIndex => $conf) {
$button = substr($buttonIndex, 0, -1);
if (in_array($button,$this->toolbar)) {
$configureRTEInJavascriptString .= '
RTEarea['.$RTEcounter.'].buttons.'.$button.' = ' . $this->buildNestedJSArray($conf) . ';';
RTEarea[editornumber].buttons.'.$button.' = ' . $this->buildNestedJSArray($conf) . ';';
}
}
}
......
// Setting the list of tags to be removed if specified in the RTE config
if (trim($this->thisConfig['removeTags'])) {
$configureRTEInJavascriptString .= '
RTEarea['.$RTEcounter.']["htmlRemoveTags"] = /^(' . implode('|', t3lib_div::trimExplode(',', $this->thisConfig['removeTags'], 1)) . ')$/i;';
RTEarea[editornumber]["htmlRemoveTags"] = /^(' . implode('|', t3lib_div::trimExplode(',', $this->thisConfig['removeTags'], 1)) . ')$/i;';
}
// Setting the list of tags to be removed with their contents if specified in the RTE config
if (trim($this->thisConfig['removeTagsAndContents'])) {
$configureRTEInJavascriptString .= '
RTEarea['.$RTEcounter.']["htmlRemoveTagsAndContents"] = /^(' . implode('|', t3lib_div::trimExplode(',', $this->thisConfig['removeTagsAndContents'], 1)) . ')$/i;';
RTEarea[editornumber]["htmlRemoveTagsAndContents"] = /^(' . implode('|', t3lib_div::trimExplode(',', $this->thisConfig['removeTagsAndContents'], 1)) . ')$/i;';
}
// Process default style configuration
$configureRTEInJavascriptString .= '
RTEarea['.$RTEcounter.'].defaultPageStyle = "' . $this->hostURL . $this->writeTemporaryFile('', 'defaultPageStyle', 'css', $this->buildStyleSheet()) . '";';
RTEarea[editornumber].defaultPageStyle = "' . $this->hostURL . $this->writeTemporaryFile('', 'defaultPageStyle', 'css', $this->buildStyleSheet()) . '";';
// Setting the pageStyle
$filename = trim($this->thisConfig['contentCSS']) ? trim($this->thisConfig['contentCSS']) : 'EXT:' . $this->ID . '/res/contentcss/default.css';
$configureRTEInJavascriptString .= '
RTEarea['.$RTEcounter.'].pageStyle = "' . $this->getFullFileName($filename) .'";';
RTEarea[editornumber].pageStyle = "' . $this->getFullFileName($filename) .'";';
// Process classes configuration
$classesConfigurationRequired = false;
foreach ($this->registeredPlugins as $pluginId => $plugin) {
......
// Add Javascript configuration for registered plugins
foreach ($this->registeredPlugins as $pluginId => $plugin) {
if ($this->isPluginEnabled($pluginId)) {
$configureRTEInJavascriptString .= $plugin->buildJavascriptConfiguration($RTEcounter);
$configureRTEInJavascriptString .= $plugin->buildJavascriptConfiguration('editornumber');
}
}
// Avoid premature reference to HTMLArea when being initially loaded by IRRE Ajax call
$configureRTEInJavascriptString .= '
RTEarea['.$RTEcounter.'].toolbar = '.$this->getJSToolbarArray().';
HTMLArea.initEditor('.$RTEcounter.');' . (!$this->is_FE() ? '' : '
RTEarea[editornumber].toolbar = '.$this->getJSToolbarArray().';
RTEarea.initEditor(editornumber);
}
};
configureEditorInstance["' . $textAreaId . '"]();'. (!$this->is_FE() ? '' : '
/*]]>*/');
return $configureRTEInJavascriptString;
}
......
$classesTagConvert = array( 'classesCharacter' => 'span', 'classesParagraph' => 'div', 'classesImage' => 'img', 'classesTable' => 'table', 'classesLinks' => 'a', 'classesTD' => 'td');
$classesTagArray = t3lib_div::trimExplode(',' , $classesTagList);
$configureRTEInJavascriptString = '
RTEarea['.$RTEcounter.']["classesTag"] = new Object();';
RTEarea[editornumber]["classesTag"] = new Object();';
foreach ($classesTagArray as $classesTagName) {
$HTMLAreaJSClasses = ($this->thisConfig[$classesTagName])?('"' . $this->cleanList($this->thisConfig[$classesTagName]) . '";'):'null;';
$configureRTEInJavascriptString .= '
RTEarea['.$RTEcounter.']["classesTag"]["'. $classesTagConvert[$classesTagName] .'"] = '. $HTMLAreaJSClasses;
RTEarea[editornumber]["classesTag"]["'. $classesTagConvert[$classesTagName] .'"] = '. $HTMLAreaJSClasses;
}
// Include JS arrays of configured classes
$configureRTEInJavascriptString .= '
RTEarea['.$RTEcounter.']["classesUrl"] = "' . $this->hostURL . $this->writeTemporaryFile('', 'classes_'.$LANG->lang, 'js', $this->buildJSClassesArray()) . '";';
RTEarea[editornumber]["classesUrl"] = "' . $this->hostURL . $this->writeTemporaryFile('', 'classes_'.$LANG->lang, 'js', $this->buildJSClassesArray()) . '";';
return $configureRTEInJavascriptString;
}
......
* @return string Javascript code
*/
function setSaveRTE($RTEcounter, $formName, $textareaId) {
return '
editornumber = '.$RTEcounter.';
if (RTEarea[editornumber]) {
document.'.$formName.'["'.$textareaId.'"].value = RTEarea[editornumber]["editor"].getHTML();
}
else {
OK=0;
}
';
return 'if (RTEarea[\'' . $textareaId . '\']) { document.' . $formName . '[\'' . $textareaId . '\'].value = RTEarea[\'' . $textareaId . '\'][\'editor\'].getHTML(); } else { OK = 0; };';
}
/**
* Return the Javascript code for copying the HTML code from the editor into the hidden input field.
* This is for submit function of the form.
*
* @param integer $RTEcounter: The index number of the current RTE editing area within the form.
* @param string $formName: the name of the form
* @param string $textareaId: the id of the textarea
*
* @return string Javascript code
*/
function setDeleteRTE($RTEcounter, $formName, $textareaId) {
return 'if (RTEarea[\'' . $textareaId . '\']) { RTEarea[\'' . $textareaId . '\'].deleted = true;}';
}
/**
* Return true if we are in the FE, but not in the FE editing feature of BE.
*
* @return boolean
typo3/sysext/rtehtmlarea/htmlarea/htmlarea-gecko.js (copie de travail)
*
* (c) 2002-2004, interactivetools.com, inc.
* (c) 2003-2004 dynarch.com
* (c) 2004-2008 Stanislas Rolland <stanislas.rolland(arobas)fructifor.ca>
* (c) 2004-2008 Stanislas Rolland <typo3(arobas)sjbr.ca>
* All rights reserved
*
* This script is part of the TYPO3 project. The TYPO3 project is
......
if (HTMLArea.is_wamcom) {
this._doc.open();
this._doc.close();
this._initIframeTimer = window.setTimeout("HTMLArea.initIframe(" + this._editorNumber + ");", 500);
this._initIframeTimer = window.setTimeout("HTMLArea.initIframe(\'" + this._editorNumber + "\');", 500);
return false;
}
}
typo3/sysext/rtehtmlarea/htmlarea/htmlarea.js (copie de travail)
/***************************************************
* EDITOR INITIALIZATION AND CONFIGURATION
***************************************************/
// Avoid re-starting on Ajax call
if (typeof(HTMLArea) != "function") {
/*
* Set some basic paths
*/
if (typeof(_editor_url) == "string") {
// Leave exactly one backslash at the end of _editor_url
_editor_url = _editor_url.replace(/\x2f*$/, '/');
} else {
alert("WARNING: _editor_url is not set!");
var _editor_url = '';
}
if (typeof(_editor_skin) == "string") _editor_skin = _editor_skin.replace(/\x2f*$/, '/');
else var _editor_skin = _editor_url + "skins/default/";
if (typeof(_editor_CSS) != "string") var _editor_CSS = _editor_url + "skins/default/htmlarea.css";
if (typeof(_editor_edited_content_CSS) != "string") var _editor_edited_content_CSS = _editor_skin + "htmlarea-edited-content.css";
if (typeof(_editor_lang) == "string") _editor_lang = _editor_lang ? _editor_lang.toLowerCase() : "en";
/*
* HTMLArea object constructor.
*/
var HTMLArea = function(textarea, config) {
HTMLArea = function(textarea, config) {
if (HTMLArea.checkSupportedBrowser()) {
if (typeof(config) == "undefined") this.config = new HTMLArea.Config();
else this.config = config;
......
}
};
HTMLArea.editorCSS = _editor_CSS;
/*
* Browser identification
*/
......
/*
* A log for troubleshooting
*/
HTMLArea._debugMode = false;
if (typeof(_editor_debug_mode) != "undefined") HTMLArea._debugMode = _editor_debug_mode;
HTMLArea._appendToLog = function(str){
if(HTMLArea._debugMode) {
var log = document.getElementById("HTMLAreaLog");
......
};
/*
* Using compressed scripts
*/
HTMLArea._compressedScripts = false;
if (typeof(_editor_compressed_scripts) != "undefined") HTMLArea._compressedScripts = _editor_compressed_scripts;
/*
* Localization of core script
*/
HTMLArea.I18N = HTMLArea_langArray;
/*
* Build array of scripts to be loaded
*/
HTMLArea.is_loaded = false;
HTMLArea.onload = function(){
HTMLArea.is_loaded = true;
HTMLArea._appendToLog("All scripts successfully loaded.");
};
HTMLArea.loadTimer;
HTMLArea._scripts = [];
HTMLArea._scriptLoaded = [];
HTMLArea._request = [];
HTMLArea.loadScript = function(url, plugin) {
if (plugin) url = _editor_url + "/plugins/" + plugin + '/' + url;
if (HTMLArea.is_opera) url = _typo3_host_url + url;
if (HTMLArea._compressedScripts && url.indexOf("compressed") == -1) url = url.replace(/\.js$/gi, "_compressed.js");
HTMLArea._scripts.push(url);
};
if(HTMLArea.is_gecko) HTMLArea.loadScript(RTEarea[0]["htmlarea-gecko"] ? RTEarea[0]["htmlarea-gecko"] : _editor_url + "htmlarea-gecko.js");
if(HTMLArea.is_ie) HTMLArea.loadScript(RTEarea[0]["htmlarea-ie"] ? RTEarea[0]["htmlarea-ie"] : _editor_url + "htmlarea-ie.js");
/*
* Get a script using asynchronous XMLHttpRequest
*/
HTMLArea.MSXML_XMLHTTP_PROGIDS = new Array("Msxml2.XMLHTTP.5.0", "Msxml2.XMLHTTP.4.0", "Msxml2.XMLHTTP.3.0", "Msxml2.XMLHTTP", "Microsoft.XMLHTTP");
......
}
var request = HTMLArea._request[i];
if (request) {
HTMLArea._appendToLog("[HTMLArea::getScript]: Requesting script " + url);
request.open("GET", url, asynchronous);
if (asynchronous) request.onreadystatechange = HTMLArea.XMLHTTPResponseHandler(i);
if (window.XMLHttpRequest) request.send(null);
......
return false;
}
};
/*
* Get all the scripts
* Build stack of scripts to be loaded
*/
HTMLArea.loadScript = function(url, plugin) {
if (plugin) url = _editor_url + "/plugins/" + plugin + '/' + url;
if (HTMLArea.is_opera) url = _typo3_host_url + url;
if (HTMLArea._compressedScripts && url.indexOf("compressed") == -1) url = url.replace(/\.js$/gi, "_compressed.js");
HTMLArea._scripts.push(url);
};
/*
* Initial load
*/
HTMLArea.init = function() {
HTMLArea._eventCache = HTMLArea._eventCacheConstructor();
if (window.XMLHttpRequest || window.ActiveXObject) {
try {
var success = true;
for (var i = 0, n = HTMLArea._scripts.length; i < n && success; i++) {
success = success && HTMLArea._getScript(i);
}
} catch (e) {
HTMLArea._appendToLog("ERROR [HTMLArea::init]: Unable to use XMLHttpRequest: "+ e);
if (typeof(_editor_url) != "string") {
window.setTimeout("HTMLArea.init();", 50);
} else {
// Set some basic paths
// Leave exactly one backslash at the end of _editor_url
_editor_url = _editor_url.replace(/\x2f*$/, '/');
if (typeof(_editor_skin) == "string") _editor_skin = _editor_skin.replace(/\x2f*$/, '/');
else _editor_skin = _editor_url + "skins/default/";
if (typeof(_editor_CSS) != "string") _editor_CSS = _editor_url + "skins/default/htmlarea.css";
if (typeof(_editor_edited_content_CSS) != "string") _editor_edited_content_CSS = _editor_skin + "htmlarea-edited-content.css";
if (typeof(_editor_lang) == "string") _editor_lang = _editor_lang ? _editor_lang.toLowerCase() : "en";
HTMLArea.editorCSS = _editor_CSS;
// Initialize event cache
HTMLArea._eventCache = HTMLArea._eventCacheConstructor();
// Set troubleshooting mode
HTMLArea._debugMode = false;
if (typeof(_editor_debug_mode) != "undefined") HTMLArea._debugMode = _editor_debug_mode;
// Using compressed scripts
HTMLArea._compressedScripts = false;
if (typeof(_editor_compressed_scripts) != "undefined") HTMLArea._compressedScripts = _editor_compressed_scripts;
// Localization of core script
HTMLArea.I18N = HTMLArea_langArray;
// Build array of scripts to be loaded
HTMLArea.is_loaded = false;
HTMLArea.loadTimer;
HTMLArea._scripts = [];
HTMLArea._scriptLoaded = [];
HTMLArea._request = [];
if (HTMLArea.is_gecko) HTMLArea.loadScript(RTEarea[0]["htmlarea-gecko"] ? RTEarea[0]["htmlarea-gecko"] : _editor_url + "htmlarea-gecko.js");
if (HTMLArea.is_ie) HTMLArea.loadScript(RTEarea[0]["htmlarea-ie"] ? RTEarea[0]["htmlarea-ie"] : _editor_url + "htmlarea-ie.js");
for (var i = 0, n = HTMLArea_plugins.length; i < n; i++) {
HTMLArea.loadScript(HTMLArea_plugins[i]);
}
if (success) {
HTMLArea.checkInitialLoad();
// Get all the scripts
if (window.XMLHttpRequest || window.ActiveXObject) {
try {
var success = true;
for (var i = 0, n = HTMLArea._scripts.length; i < n && success; i++) {
success = success && HTMLArea._getScript(i);
}
} catch (e) {
HTMLArea._appendToLog("ERROR [HTMLArea::init]: Unable to use XMLHttpRequest: "+ e);
}
if (success) {
HTMLArea.checkInitialLoad();
} else {
if (HTMLArea.is_ie) window.setTimeout('alert(HTMLArea.I18N.msg["ActiveX-required"]);', 200);
}
} else {
if (HTMLArea.is_ie) window.setTimeout('if (window.document.getElementById("pleasewait1")) { window.document.getElementById("pleasewait1").innerHTML = HTMLArea.I18N.msg["ActiveX-required"]; } else { alert(HTMLArea.I18N.msg["ActiveX-required"]); };', 200);
if (HTMLArea.is_ie) alert(HTMLArea.I18N.msg["ActiveX-required"]);
}
} else {
if (HTMLArea.is_ie) alert(HTMLArea.I18N.msg["ActiveX-required"]);
}
};
......
/*
* Editor configuration object constructor
*/
HTMLArea.Config = function () {
this.width = "auto";
this.height = "auto";
......
HTMLArea.prototype.initIframe = function() {
if (this._initIframeTimer) window.clearTimeout(this._initIframeTimer);
if (!this._iframe || (!this._iframe.contentWindow && !this._iframe.contentDocument)) {
this._initIframeTimer = window.setTimeout("HTMLArea.initIframe(" + this._editorNumber + ");", 50);
this._initIframeTimer = window.setTimeout("HTMLArea.initIframe(\'" + this._editorNumber + "\');", 50);
return false;
} else if (this._iframe.contentWindow && !HTMLArea.is_safari) {
if (!this._iframe.contentWindow.document || !this._iframe.contentWindow.document.documentElement) {
this._initIframeTimer = window.setTimeout("HTMLArea.initIframe(" + this._editorNumber + ");", 50);
this._initIframeTimer = window.setTimeout("HTMLArea.initIframe(\'" + this._editorNumber + "\');", 50);
return false;
}
} else if (!this._iframe.contentDocument.documentElement || !this._iframe.contentDocument.body) {
this._initIframeTimer = window.setTimeout("HTMLArea.initIframe(" + this._editorNumber + ");", 50);
this._initIframeTimer = window.setTimeout("HTMLArea.initIframe(\'" + this._editorNumber + "\');", 50);
return false;
}
var doc = this._iframe.contentWindow ? this._iframe.contentWindow.document : this._iframe.contentDocument;
......
}
if (!stylesAreLoaded && !HTMLArea.is_wamcom) {
HTMLArea._appendToLog("[HTMLArea::initIframe]: Failed attempt at loading stylesheets: " + errorText + " Retrying...");
this._stylesLoadedTimer = window.setTimeout("HTMLArea.stylesLoaded(" + this._editorNumber + ");", 100);
this._stylesLoadedTimer = window.setTimeout("HTMLArea.stylesLoaded(\'" + this._editorNumber + "\');", 100);
return false;
}
HTMLArea._appendToLog("[HTMLArea::initIframe]: Stylesheets successfully loaded.");
......
if (HTMLArea.is_ie) doc.documentElement._editorNo = this._editorNumber;
// Start undo snapshots
if (this._customUndo) this._timerUndo = window.setInterval("HTMLArea.undoTakeSnapshot(" + this._editorNumber + ");", this.config.undoTimeout);
if (this._customUndo) this._timerUndo = window.setInterval("HTMLArea.undoTakeSnapshot(\'" + this._editorNumber + "\');", this.config.undoTimeout);
// intercept events for updating the toolbar & for keyboard handlers
HTMLArea._addEvents((HTMLArea.is_ie ? doc.body : doc), ["keydown","keypress","mousedown","mouseup","drag"], HTMLArea._editorEvent, true);
......
HTMLArea._addEvent((this._iframe.contentWindow ? this._iframe.contentWindow : this._iframe.contentDocument), "unload", HTMLArea.removeEditorEvents);
}
// set enableWordClean and intercept paste, dragdrop and drop events for wordClean
//if (this.config.enableWordClean) HTMLArea._addEvents((HTMLArea.is_ie ? doc.body : doc), ["paste","dragdrop","drop"], HTMLArea.wordClean, true);
window.setTimeout("HTMLArea.generatePlugins(" + this._editorNumber + ");", 100);
window.setTimeout("HTMLArea.generatePlugins(\'" + this._editorNumber + "\');", 100);
};
HTMLArea.generatePlugins = function(editorNumber) {
......
if (HTMLArea._eventCache) {
HTMLArea._eventCache.flush();
}
for (var editorNumber = RTEarea.length; --editorNumber > 0 ;) {
var editor = RTEarea[editorNumber].editor;
if (editor) {
RTEarea[editorNumber].editor = null;
// save the HTML content into the original textarea for submit, back/forward, etc.
editor._textArea.value = editor.getHTML();
// release undo/redo snapshots
window.clearInterval(editor._timerUndo);
editor._undoQueue = null;
// do final cleanup
HTMLArea.cleanup(editor);
for (var editorNumber in RTEarea) {
if (RTEarea.hasOwnProperty(editorNumber)) {
var editor = RTEarea[editorNumber].editor;
if (editor) {
RTEarea[editorNumber].editor = null;
// save the HTML content into the original textarea for submit, back/forward, etc.
editor._textArea.value = editor.getHTML();
// release undo/redo snapshots
window.clearInterval(editor._timerUndo);
editor._undoQueue = null;
// do final cleanup
HTMLArea.cleanup(editor);
}
}
}
};
......
var obj = editor._toolbarObjects[txt];
obj.state = null;
obj.cmd = null;
document.getElementById(obj.elementId)._obj = null;
var element = document.getElementById(obj.elementId);
if (element) {
element._obj = null;
}
editor._toolbarObjects[txt] = null;
}
}
......
}
// update the toolbar state after some time
if (editor._timerToolbar) window.clearTimeout(editor._timerToolbar);
editor._timerToolbar = window.setTimeout("HTMLArea.updateToolbar(" + editor._editorNumber + ");", 100);
editor._timerToolbar = window.setTimeout("HTMLArea.updateToolbar(\'" + editor._editorNumber + "\');", 100);
return false;
}
break;
......
}
// update the toolbar state after some time
if (editor._timerToolbar) window.clearTimeout(editor._timerToolbar);
editor._timerToolbar = window.setTimeout("HTMLArea.updateToolbar(" + editor._editorNumber + ");", 50);
editor._timerToolbar = window.setTimeout("HTMLArea.updateToolbar(\'" + editor._editorNumber + "\');", 50);
break;
case 9: // KEY horizontal tab
var newkey = (ev.shiftKey ? "SHIFT-" : "") + "TAB";
......
case 40: // DOWN arrow key
if (HTMLArea.is_ie) {
if (editor._timerToolbar) window.clearTimeout(editor._timerToolbar);
editor._timerToolbar = window.setTimeout("HTMLArea.updateToolbar(" + editor._editorNumber + ");", 10);
editor._timerToolbar = window.setTimeout("HTMLArea.updateToolbar(\'" + editor._editorNumber + "\');", 10);
return true;
}
}
......
// mouse event
if (editor._timerToolbar) window.clearTimeout(editor._timerToolbar);
if (ev.type == "mouseup") editor.updateToolbar();
else editor._timerToolbar = window.setTimeout("HTMLArea.updateToolbar(" + editor._editorNumber + ");", 50);
else editor._timerToolbar = window.setTimeout("HTMLArea.updateToolbar(\'" + editor._editorNumber + "\');", 50);
}
};
......
*/
var lorem_ipsum = function(element,text) {
if (element.tagName.toLowerCase() == "textarea" && element.id && element.id.substr(0,7) == "RTEarea") {
var editor = RTEarea[element.id.substr(7,8)]["editor"];
var editor = RTEarea[element.id.substr(7, element.id.length)]["editor"];
editor.insertHTML(text);
editor.updateToolbar();
}
......
/*
* Initialize the editor, configure the toolbar, setup the plugins, etc.
*/
HTMLArea.initTimer = [];
HTMLArea.initTimer = new Object();
HTMLArea.onGenerateHandler = function(editorNumber) {
return (function() {
......
document.getElementById('editorWrap' + editorNumber).style.visibility = 'hidden';
if(HTMLArea.initTimer[editorNumber]) window.clearTimeout(HTMLArea.initTimer[editorNumber]);
if(!HTMLArea.is_loaded) {
HTMLArea.initTimer[editorNumber] = window.setTimeout( "HTMLArea.initEditor(" + editorNumber + ");", 150);
HTMLArea.initTimer[editorNumber] = window.setTimeout("HTMLArea.initEditor(\'" + editorNumber + "\');", 150);
} else {
var RTE = RTEarea[editorNumber];
HTMLArea._appendToLog("[HTMLArea::initEditor]: Initializing editor with editor Id: " + editorNumber + ".");
// Get the configuration properties
var config = new HTMLArea.Config();
......
}
}
});
};
typo3/sysext/rtehtmlarea/htmlarea/plugins/TYPO3HtmlParser/typo3html-parser.js (copie de travail)
if (typeof(HTMLArea.Dialog) != "undefined" && HTMLArea.Dialog.TYPO3Image) {
HTMLArea.Dialog.TYPO3Image.close();
} else {
window.setTimeout("TYPO3HtmlParser.cleanLater(" + editor._editorNumber + ");", 250);
window.setTimeout("TYPO3HtmlParser.cleanLater(\'" + editor._editorNumber + "\');", 250);
}
};
typo3/sysext/rtehtmlarea/pi2/class.tx_rtehtmlarea_pi2.php (copie de travail)
// Loading RTE skin style sheets
$GLOBALS['TSFE']->additionalHeaderData['rtehtmlarea-skin'] = $this->getSkin();
// Loading JavaScript files and code
$this->TCEform->additionalJS_initial = $this->loadJSfiles($this->TCEform->RTEcounter);
$this->TCEform->additionalJS_pre['rtehtmlarea-loadJScode'] = $this->loadJScode($this->TCEform->RTEcounter);
if ($this->TCEform->RTEcounter == 1) {
$this->TCEform->additionalJS_initial = $this->loadJSfiles($this->TCEform->RTEcounter);
$this->TCEform->additionalJS_pre['rtehtmlarea-loadJScode'] = $this->loadJScode($this->TCEform->RTEcounter);
}
/* =======================================
* DRAW THE EDITOR
......
// Register RTE windows:
$this->TCEform->RTEwindows[] = $PA['itemFormElName'];
$textAreaId = htmlspecialchars($PA['itemFormElName']);
// Register RTE in JS:
$this->TCEform->additionalJS_post[] = $this->registerRTEinJS($this->TCEform->RTEcounter);
$this->TCEform->additionalJS_post[] = $this->registerRTEinJS($this->TCEform->RTEcounter, '', '', '',$textAreaId);
// Set the save option for the RTE:
$this->TCEform->additionalJS_submit[] = $this->setSaveRTE($this->TCEform->RTEcounter, $this->TCEform->formName, htmlspecialchars($PA['itemFormElName']));
$this->TCEform->additionalJS_submit[] = $this->setSaveRTE($this->TCEform->RTEcounter, $this->TCEform->formName, $textAreaId);
// draw the textarea
$visibility = 'hidden';
$item = $this->triggerField($PA['itemFormElName']).'
<div id="pleasewait' . $this->TCEform->RTEcounter . '" class="pleasewait" style="display: none;" >' . $TSFE->csConvObj->conv($TSFE->getLLL('Please wait',$this->LOCAL_LANG), $this->charset, $TSFE->renderCharset) . '</div>
<div id="editorWrap' . $this->TCEform->RTEcounter . '" class="editorWrap" style="'. htmlspecialchars($this->RTEWrapStyle). '">
<textarea id="RTEarea'.$this->TCEform->RTEcounter.'" name="'.htmlspecialchars($PA['itemFormElName']).'" style="'.htmlspecialchars($this->RTEdivStyle).'">'.t3lib_div::formatForTextarea($value).'</textarea>
<div id="pleasewait' . $textAreaId . '" class="pleasewait" style="display: block;" >' . $TSFE->csConvObj->conv($TSFE->getLLL('Please wait',$this->LOCAL_LANG), $this->charset, $TSFE->renderCharset) . '</div>
<div id="editorWrap' . $textAreaId . '" class="editorWrap" style="visibility: hidden; '. htmlspecialchars($this->RTEWrapStyle). '">
<textarea id="RTEarea' . $textAreaId . '" name="'.htmlspecialchars($PA['itemFormElName']).'" style="'.htmlspecialchars($this->RTEdivStyle).'">'.t3lib_div::formatForTextarea($value).'</textarea>
</div>' . ($TYPO3_CONF_VARS['EXTCONF'][$this->ID]['enableDebugMode'] ? '<div id="HTMLAreaLog"></div>' : '') . '
';
return $item;
......
*
* @param integer $RTEcounter: The index number of the RTE editing area.
* @param string $form: the name of the form
* @param string $textarea: the name of the textarea
* @param string $textareaId: the id of the textarea
*
* @return string the JS-Code
*/
function setSaveRTE($RTEcounter, $form, $textarea) {
function setSaveRTE($RTEcounter, $form, $textareaId) {
return '
editornumber = '.$RTEcounter.';
if (RTEarea[editornumber]) {
fields = document.getElementsByName(\'' . $textarea . '\');
if (RTEarea[\'' . $textareaId . '\'] && !RTEarea[\'' . $textareaId . '\'].deleted) {
fields = document.getElementsByName(\'' . $textareaId . '\');
field = fields.item(0);
if(field && field.tagName.toLowerCase() == \'textarea\') field.value = RTEarea[editornumber][\'editor\'].getHTML();
}
else {
OK=0;
}
';
if (field && field.nodeName.toLowerCase() == \'textarea\') {
field.value = RTEarea[\'' . $textareaId . '\'][\'editor\'].getHTML();
}
} else {
OK = 0;
}';
}
}
if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/rtehtmlarea/pi2/class.tx_rtehtmlarea_pi2.php']) {
(2-2/4)