TYPO3 CMS  TYPO3_6-2
AbstractRte.php
Go to the documentation of this file.
1 <?php
3 
18 
26 class AbstractRte {
27 
28  // Internal, dynamic:
29  // Error messages regarding non-availability is collected here.
33  public $errorLog = array();
34 
35  // Internal, static:
36  // Set this to the extension key of the RTE so it can identify itself.
40  public $ID = '';
41 
42  /***********************************
43  *
44  * Main API functions;
45  * When you create alternative RTEs, simply override these functions in your parent class.
46  * See the "rte" or "rtehtmlarea" extension as an example!
47  *
48  **********************************/
56  public function isAvailable() {
57  return TRUE;
58  }
59 
77  public function drawRTE(&$pObj, $table, $field, $row, $PA, $specConf, $thisConfig, $RTEtypeVal, $RTErelPath, $thePidValue) {
78  // Transform value:
79  $value = $this->transformContent('rte', $PA['itemFormElValue'], $table, $field, $row, $specConf, $thisConfig, $RTErelPath, $thePidValue);
80  // Create item:
81  $item = '
82  ' . $this->triggerField($PA['itemFormElName']) . '
83  <textarea name="' . htmlspecialchars($PA['itemFormElName']) . '"' . $pObj->formWidthText('48', 'off') . ' rows="20" wrap="off" style="background-color: #99eebb;">' . GeneralUtility::formatForTextarea($value) . '</textarea>';
84  // Return form item:
85  return $item;
86  }
87 
106  public function transformContent($dirRTE, $value, $table, $field, $row, $specConf, $thisConfig, $RTErelPath, $pid) {
107  if ($specConf['rte_transform']) {
108  $p = \TYPO3\CMS\Backend\Utility\BackendUtility::getSpecConfParametersFromArray($specConf['rte_transform']['parameters']);
109  // There must be a mode set for transformation
110  if ($p['mode']) {
111  // Initialize transformation:
112  $parseHTML = GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Html\\RteHtmlParser');
113  $parseHTML->init($table . ':' . $field, $pid);
114  $parseHTML->setRelPath($RTErelPath);
115  // Perform transformation:
116  $value = $parseHTML->RTE_transform($value, $specConf, $dirRTE, $thisConfig);
117  }
118  }
119  return $value;
120  }
121 
122  /***********************************
123  *
124  * Helper functions
125  *
126  **********************************/
134  public function triggerField($fieldName) {
135  $triggerFieldName = preg_replace('/\\[([^]]+)\\]$/', '[_TRANSFORM_\\1]', $fieldName);
136  return '<input type="hidden" name="' . htmlspecialchars($triggerFieldName) . '" value="RTE" />';
137  }
138 
139 }
drawRTE(&$pObj, $table, $field, $row, $PA, $specConf, $thisConfig, $RTEtypeVal, $RTErelPath, $thePidValue)
Definition: AbstractRte.php:77
transformContent($dirRTE, $value, $table, $field, $row, $specConf, $thisConfig, $RTErelPath, $pid)