rtgx

Použitie RTE htmlarea vo FE extensions

Pripojenie súboru s RTE class:

// Include the htmlArea RTE frontend plugin
require_once( t3lib_extMgm::extPath( 'rtehtmlarea' ).'pi2/class.tx_rtehtmlarea_pi2.php' );

Deklarácia premenných:

	// Declare the following class variables for the RTE API:
var $RTEObj;
var $docLarge = 0;
var $RTEcounter = 0;
var $formName;
var $additionalJS_initial = '';// Initial JavaScript to be printed before the form (should be in head, but cannot due to IE6 timing bug)
var $additionalJS_pre = array();// Additional JavaScript to be printed before the form (works in Mozilla/Firefox when included in head, but not in IE6)
var $additionalJS_post = array();// Additional JavaScript to be printed after the form
var $additionalJS_submit = array();// Additional JavaScript to be executed on submit
var $PA = array( 'itemFormElName' => '', 'itemFormElValue' => '', );
var $specConf = array(
'rte_transform' => array(
'parameters' => array(
'mode' => 'ts_css',
)
)
);
var $thisConfig = array();
var $RTEtypeVal = 'text';
var $thePidValue;

Funkcia pre samotné vytvorenie triedy RTE editora aj s napolnením príslušných šablónových značiek (riadok vyznačený červenou je dôležitý pre správnu funkciu RTE editora v Mozille, konkrétne pri vkladaní textu do RTE zo schránky):

	/**
* Parse marks for RTE htmlarea editor in frontend
*
* @param array $markerArray: template markers
* @return array return: RTE marks
*/
function parseMarksRtetextarea( &$markerArray ) {

// My settings
$myFormName = 'formCreate';
$myTableName = 'tx_extname_cv';
$myFieldName = 'cv';
$this->postvars = t3lib_div::_POST( $this->prefixId );
$this->postvars[$myTableName] = preg_replace( '`[\r\n]`', ' ', $this->postvars[$myTableName] );

// RTE settings
if( !$this->RTEObj )
$this->RTEObj = t3lib_div::makeInstance( 'tx_rtehtmlarea_pi2' );
if( $this->RTEObj->isAvailable() ) {
$this->RTEcounter++;
$this->table = $myTableName;
$this->field = $myFieldName;
$this->formName = $myFormName;
$this->PA['itemFormElName'] = $this->prefixId.'['.$myTableName.']';
$this->PA['itemFormElValue'] = $this->postvars[$myTableName];
$this->thePidValue = $GLOBALS['TSFE']->id;
$RTEItem = $this->RTEObj->drawRTE( $this, $myTableName, $myFieldName, $row=array(), $this->PA, $this->specConf, $this->thisConfig, $this->RTEtypeVal, '', $this->thePidValue );
$markerArray['###ADDITIONALJS_PRE###'] = $this->additionalJS_initial.'
<script type="text/javascript">'. implode(chr(10), $this->additionalJS_pre).'</script>';
$markerArray['###ADDITIONALJS_POST###'] = '
<script type="text/javascript">'. implode(chr(10), $this->additionalJS_post).'</script>';
$markerArray['###ADDITIONALJS_SUBMIT###'] = implode(';', $this->additionalJS_submit);
$markerArray['###FORM_RTE_ENTRY###'] = $RTEItem;
return $markerArray;
}
}

Použitie predchádzajúcej funkcie vo FE module (parameter $marks je pole značiek HTML šablóny):

$this->parseMarksRtetextarea( $marks );

HTML šablóna, červenou sú vyznačené značky RTE editora:

###ADDITIONALJS_PRE###
<form action="###URL###" id="regForm" namwe="formCreate" method="post" onsubmit="###ADDITIONALJS_SUBMIT###" enctype="multipart/form-data">
<fieldset>
<label for="idCV">###CV_CV_TITLE### *</label>
<div class="rteareablock">###FORM_RTE_ENTRY###</div>
###CV_CV_ERROR###
<br />
<label> </label>
<input type="submit" name="submit" value="###CV_SUBMIT_TITLE###" />
</fieldset>
</form>
###ADDITIONALJS_POST###

Konfigurácia RTE htmlarea pre FE extension

TSconfig
RTE.default.FE {
hidePStyleItems = ADDRESS, H1, H2, H5, H6, PRE
hideButtons => blockstylelabel, blockstyle, textstylelabel, textstyle, fontstyle, fontsize, underline, strikethrough, subscript, superscript, lefttoright, righttoleft, left, center, right, justifyfull, outdent, indent, textcolor, bgcolor, textindicator, emoticon, insertcharacter, line, link, image, table, user, acronym, findreplace, spellcheck, inserttag, removeformat, copy, cut, paste, about, toggleborders, tableproperties, rowproperties, rowinsertabove, rowinsertunder, rowdelete, rowsplit, columninsertbefore, columninsertafter, columndelete, columnsplit, cellproperties, cellinsertbefore, cellinsertafter, celldelete, cellsplit, cellmerge
contentCSS = fileadmin/sitename/css/rte.css
useCSS = 0
}
 
Žiadne dokumenty ani odkazy k tejto stránke.