Project

General

Profile

Bug #18690 » 8232_v3.diff

Administrator Admin, 2008-08-11 19:08

View differences:

t3lib/class.t3lib_tceforms.php (working copy)
var $additionalJS_pre = array(); // Additional JavaScript, printed before the form
var $additionalJS_post = array(); // Additional JavaScript printed after the form
var $additionalJS_submit = array(); // Additional JavaScript executed on submit; If you set "OK" variable it will raise an error about RTEs not being loaded and offer to block further submission.
var $additionalJS_delete = array(); // Additional JavaScript executed when section element is deleted. This is neceessary, for example, to correctly clean up HTMLArea RTE (bug #8232)
/**
* Instance of t3lib_tceforms_inline
......
// Traversing possible types of new content in the section:
$newElementsLinks = array();
foreach($value['el'] as $nnKey => $nCfg) {
$additionalJS_post_saved = $this->additionalJS_post;
$this->additionalJS_post = array();
$additionalJS_submit_saved = $this->additionalJS_submit;
$this->additionalJS_submit = array();
$newElementTemplate = $this->getSingleField_typeFlex_draw(
array($nnKey => $nCfg),
array(),
......
);
// Makes a "Add new" link:
$onClickInsert = 'new Insertion.Bottom($("'.$idTagPrefix.'"), unescape("'.rawurlencode($newElementTemplate).'").replace(/'.$idTagPrefix.'-/g,"'.$idTagPrefix.'-idx"+Math.floor(Math.random()*100000+1)+"-")); setActionStatus("'.$idTagPrefix.'"); return false;'; // Maybe there is a better way to do this than store the HTML for the new element in rawurlencoded format - maybe it even breaks with certain charsets? But for now this works...
$var = uniqid('idvar');
$replace = 'replace(/' . $idTagPrefix . '-/g,"' . $idTagPrefix . '"+' . $var . '+"-")';
$onClickInsert = 'var ' . $var . ' = "' . $idTagPrefix . '-idx"+(new Date()).getTime();';
// Do not replace $isTagPrefix in setActionStatus() because it needs section id!
$onClickInsert .= 'new Insertion.Bottom($("'.$idTagPrefix.'"), unescape("'.rawurlencode($newElementTemplate).'").' . $replace . '); setActionStatus("'.$idTagPrefix.'");';
$onClickInsert .= 'eval(unescape("' . rawurlencode(implode(';', $this->additionalJS_post)) . '").' . $replace . ');';
$onClickInsert .= 'TBE_EDITOR.addActionChecks("submit", unescape("' . rawurlencode(implode(';', $this->additionalJS_submit)) . '").' . $replace . ');';
$onClickInsert .= 'return false;';
// Kasper's comment (kept for history): Maybe there is a better way to do this than store the HTML for the new element in rawurlencoded format - maybe it even breaks with certain charsets? But for now this works...
$this->additionalJS_post = $additionalJS_post_saved;
$this->additionalJS_submit = $additionalJS_submit_saved;
$newElementsLinks[]= '<a href="#" onclick="'.htmlspecialchars($onClickInsert).'"><img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/new_el.gif','width="11" height="12"').' alt="New" title="New" align="absmiddle" />'.htmlspecialchars(t3lib_div::fixed_lgd_cs($this->sL($nCfg['tx_templavoila']['title']),30)).'</a>';
}
......
<div id="'.$idTagPrefix.'" style="padding-left: 20px;">'.implode('',$tRows).'</div>';
$output.= $mayRestructureFlexforms ? '<div style="padding: 10px 5px 5px 20px;"><b>Add new:</b> '.implode(' | ',$newElementsLinks).'</div>' : '';
// If it's a container:
} else {
// It is a container
$toggleIcon_open = '<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/pil2down.gif','width="12" height="7"').' hspace="2" alt="Open" title="Open" />';
$toggleIcon_close = '<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/pil2right.gif','width="7" height="12"').' hspace="2" alt="Close" title="Close" />';
// Create on-click actions.
# $onClickCopy = 'new Insertion.After($("'.$idTagPrefix.'"), getOuterHTML("'.$idTagPrefix.'").replace(/'.$idTagPrefix.'-/g,"'.$idTagPrefix.'-copy"+Math.floor(Math.random()*100000+1)+"-")); return false;'; // Copied elements doesn't work (well) in Safari while they do in Firefox and MSIE! UPDATE: It turned out that copying doesn't work for any browser, simply because the data from the copied form never gets submitted to the server for some reason! So I decided to simply disable copying for now. If it's requested by customers we can look to enable it again and fix the issue. There is one un-fixable problem though; Copying an element like this will violate integrity if files are attached inside that element because the file reference doesn't get an absolute path prefixed to it which would be required to have TCEmain generate a new copy of the file.
$onClickRemove = 'if (confirm("Are you sure?")){$("'.$idTagPrefix.'").hide();setActionStatus("'.$idPrefix.'");} return false;';
//$onClickCopy = 'new Insertion.After($("'.$idTagPrefix.'"), getOuterHTML("'.$idTagPrefix.'").replace(/'.$idTagPrefix.'-/g,"'.$idTagPrefix.'-copy"+Math.floor(Math.random()*100000+1)+"-")); return false;'; // Copied elements doesn't work (well) in Safari while they do in Firefox and MSIE! UPDATE: It turned out that copying doesn't work for any browser, simply because the data from the copied form never gets submitted to the server for some reason! So I decided to simply disable copying for now. If it's requested by customers we can look to enable it again and fix the issue. There is one un-fixable problem though; Copying an element like this will violate integrity if files are attached inside that element because the file reference doesn't get an absolute path prefixed to it which would be required to have TCEmain generate a new copy of the file.
$onClickRemove = 'if (confirm("Are you sure?")){/*###REMOVE###*/;$("'.$idTagPrefix.'").hide();setActionStatus("'.$idPrefix.'");} return false;';
$onClickToggle = 'flexFormToggle("'.$idTagPrefix.'"); return false;';
$onMove = 'flexFormSortable("'.$idPrefix.'")';
......
$actionFieldName = '_ACTION_FLEX_FORM'.$PA['itemFormElName'].$s[0].'][_ACTION]['.$s[1];
// Putting together the container:
$this->additionalJS_delete = array();
$output.= '
<div id="'.$idTagPrefix.'" class="bgColor2">
<input id="'.$idTagPrefix.'-action" type="hidden" name="'.htmlspecialchars($actionFieldName).'" value=""/>
......
</div>
<input id="'.$idTagPrefix.'-toggleClosed" type="hidden" name="'.htmlspecialchars('data['.$table.']['.$row['uid'].']['.$field.']'.$formPrefix.'[_TOGGLE]').'" value="'.($toggleClosed?1:0).'" />
</div>';
$output = str_replace('/*###REMOVE###*/', t3lib_div::slashJS(htmlspecialchars(implode('', $this->additionalJS_delete))), $output);
// NOTICE: We are saving the toggle-state directly in the flexForm XML and "unauthorized" according to the data structure. It means that flexform XML will report unclean and a cleaning operation will remove the recorded togglestates. This is not a fatal problem. Ideally we should save the toggle states in meta-data but it is much harder to do that. And this implementation was easy to make and with no really harmful impact.
}
typo3/sysext/rtehtmlarea/pi2/class.tx_rtehtmlarea_pi2.php (working copy)
// 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: none;" >' . $TSFE->csConvObj->conv($TSFE->getLLL('Please wait',$this->LOCAL_LANG), $this->charset, $TSFE->renderCharset) . '</div>
<div id="editorWrap' . $$textAreaId . '" class="editorWrap" style="'. 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;
......
*/
function setSaveRTE($RTEcounter, $form, $textarea) {
return '
editornumber = '.$RTEcounter.';
if (RTEarea[editornumber]) {
rteFound = false;
for (editornumber = 1; editornumber < RTEarea.length; editornumber++) {
if (RTEarea[editornumber].textAreaId == "' . $textarea . '") {
if (!RTEarea[editornumber].deleted) {
fields = document.getElementsByName(\'' . $textarea . '\');
field = fields.item(0);
if(field && field.tagName.toLowerCase() == \'textarea\') field.value = RTEarea[editornumber][\'editor\'].getHTML();
}
else {
rteFound = true;
break;
}
}
if (!rteFound) {
OK=0;
}
';
}
}
if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/rtehtmlarea/pi2/class.tx_rtehtmlarea_pi2.php']) {
typo3/sysext/rtehtmlarea/class.tx_rtehtmlarea_base.php (working copy)
$this->TCEform->additionalJS_post[] = $this->setRTEsizeByJS('RTEarea'.$this->TCEform->RTEcounter, $height, $width);
}
$textAreaId = htmlspecialchars($PA['itemFormElName']);
// 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';
$unuqid = uniqid('rte');
$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: none;" >' . $LANG->getLL('Please wait') . '</div>
<div id="editorWrap' . $textAreaId . '" class="editorWrap" style="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>' : '') . '
';
}
......
$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++;
};
function rteHtmlAreaGetElementsByClassName(className) {
var allElements = document.getElementsByTagName("*");
var result = new Array();
for (var i = 0; i < allElements.length; i++) {
var c = " " + allElements[i].className + " ";
if (c.indexOf(" " + className + " ") != -1) {
result[result.length] = allElements[i];
}
}
return result;
}
wait_elements = rteHtmlAreaGetElementsByClassName("pleasewait");
wrap_elements = rteHtmlAreaGetElementsByClassName("editorWrap");
for (i = 0; i < wait_elements.length; i++) {
wait_elements[i].style.display = "block";
wrap_elements[i].style.visibility = "hidden";
}
RTEarea = new Array();
RTEarea[0] = new Object();
RTEarea[0]["version"] = "' . $TYPO3_CONF_VARS['EXTCONF'][$this->ID]['version'] . '";'
......
*
* @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) : '[]') . ';';
editornumber = RTEarea.length;
document.getElementById("pleasewait' . $textAreaId . '").id = "pleasewait" + editornumber;
document.getElementById("editorWrap' . $textAreaId . '").id = "editorWrap" + editornumber;
document.getElementById("RTEarea' . $textAreaId . '").id = "RTEarea" + editornumber;
RTEarea[editornumber] = new Object();
RTEarea[editornumber].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;
......
// Add Javascript configuration for registered plugins
foreach ($this->registeredPlugins as $pluginId => $plugin) {
if ($this->isPluginEnabled($pluginId)) {
$configureRTEInJavascriptString .= $plugin->buildJavascriptConfiguration($RTEcounter);
$configureRTEInJavascriptString .= $plugin->buildJavascriptConfiguration('editornumber');
}
}
$configureRTEInJavascriptString .= '
RTEarea['.$RTEcounter.'].toolbar = '.$this->getJSToolbarArray().';
HTMLArea.initEditor('.$RTEcounter.');' . (!$this->is_FE() ? '' : '
RTEarea[editornumber].toolbar = '.$this->getJSToolbarArray().';
HTMLArea.initEditor(editornumber);' . (!$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;
}
......
*/
function setSaveRTE($RTEcounter, $formName, $textareaId) {
return '
editornumber = '.$RTEcounter.';
if (RTEarea[editornumber]) {
rteFound = false;
for (editornumber = 1; editornumber < RTEarea.length; editornumber++) {
if (RTEarea[editornumber].textAreaId == "' . $textareaId . '") {
if (!RTEarea[editornumber].deleted) {
document.'.$formName.'["'.$textareaId.'"].value = RTEarea[editornumber]["editor"].getHTML();
}
else {
rteFound = true;
break;
}
}
if (!rteFound) {
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 '
for (editornumber = 1; editornumber < RTEarea.length; editornumber++) {
if (RTEarea[editornumber].textAreaId == "' . $textareaId . '") {
if (RTEarea[editornumber]) {
RTEarea[editornumber].deleted = true;
}
}
break;
}
';
}
/**
* Return true if we are in the FE, but not in the FE editing feature of BE.
*
* @return boolean
(6-6/8)