TYPO3 CMS  TYPO3_6-2
ContentParser.php
Go to the documentation of this file.
1 <?php
2 namespace TYPO3\CMS\Rtehtmlarea;
3 
18 
25 
29  public $content;
30 
34  public $modData;
35 
42  public $doc;
43 
47  public $extKey = 'rtehtmlarea';
48 
52  public $prefixId = 'TYPO3HtmlParser';
53 
58  public function init() {
59  $this->doc = GeneralUtility::makeInstance('TYPO3\\CMS\\Backend\\Template\\DocumentTemplate');
60  $this->doc->backPath = $GLOBALS['BACK_PATH'];
61  $this->doc->JScode = '';
62  $this->modData = $GLOBALS['BE_USER']->getModuleData($GLOBALS['MCONF']['name'], 'ses');
63  if (GeneralUtility::_GP('OC_key')) {
64  $parts = explode('|', GeneralUtility::_GP('OC_key'));
65  $this->modData['openKeys'][$parts[1]] = $parts[0] == 'O' ? 1 : 0;
66  $GLOBALS['BE_USER']->pushModuleData($GLOBALS['MCONF']['name'], $this->modData);
67  }
68  }
69 
76  public function main() {
77  $this->content .= $this->main_parse_html($this->modData['openKeys']);
78  header('Content-Type: text/plain; charset=utf-8');
79  }
80 
87  public function printContent() {
88  echo $this->content;
89  }
90 
98  public function main_parse_html($openKeys) {
99  global $TYPO3_CONF_VARS;
100  $editorNo = GeneralUtility::_GP('editorNo');
101  $html = GeneralUtility::_GP('content');
102  $RTEtsConfigParts = explode(':', GeneralUtility::_GP('RTEtsConfigParams'));
103  $RTEsetup = $GLOBALS['BE_USER']->getTSConfig('RTE', \TYPO3\CMS\Backend\Utility\BackendUtility::getPagesTSconfig($RTEtsConfigParts[5]));
104  $thisConfig = \TYPO3\CMS\Backend\Utility\BackendUtility::RTEsetup($RTEsetup['properties'], $RTEtsConfigParts[0], $RTEtsConfigParts[2], $RTEtsConfigParts[4]);
105  $HTMLParser = GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Html\\HtmlParser');
106  if (is_array($thisConfig['enableWordClean.'])) {
107  $HTMLparserConfig = $thisConfig['enableWordClean.']['HTMLparser.'];
108  if (is_array($HTMLparserConfig)) {
109  $this->keepSpanTagsWithId($HTMLparserConfig);
110  $HTMLparserConfig = $HTMLParser->HTMLparserConfig($HTMLparserConfig);
111  }
112  }
113  if (is_array($HTMLparserConfig)) {
114  $html = $HTMLParser->HTMLcleaner($html, $HTMLparserConfig[0], $HTMLparserConfig[1], $HTMLparserConfig[2], $HTMLparserConfig[3]);
115  }
116  if (is_array($TYPO3_CONF_VARS['EXTCONF'][$this->extKey][$this->prefixId]['cleanPastedContent'])) {
117  foreach ($TYPO3_CONF_VARS['EXTCONF'][$this->extKey][$this->prefixId]['cleanPastedContent'] as $classRef) {
118  $hookObj = GeneralUtility::getUserObj($classRef);
119  if (method_exists($hookObj, 'cleanPastedContent_afterCleanWord')) {
120  $html = $hookObj->cleanPastedContent_afterCleanWord($html, $thisConfig);
121  }
122  }
123  }
124  return $html;
125  }
126 
134  protected function keepSpanTagsWithId(&$HTMLparserConfig) {
135  // Allow span tag
136  if (isset($HTMLparserConfig['allowTags'])) {
137  if (!GeneralUtility::inList($HTMLparserConfig['allowTags'], 'span')) {
138  $HTMLparserConfig['allowTags'] .= ',span';
139  }
140  } else {
141  $HTMLparserConfig['allowTags'] = 'span';
142  }
143  // Allow attributes on span tags
144  if (isset($HTMLparserConfig['noAttrib']) && GeneralUtility::inList($HTMLparserConfig['noAttrib'], 'span')) {
145  $HTMLparserConfig['noAttrib'] = GeneralUtility::rmFromList('span', $HTMLparserConfig['noAttrib']);
146  }
147  // Do not remove span tags
148  if (isset($HTMLparserConfig['removeTags']) && GeneralUtility::inList($HTMLparserConfig['removeTags'], 'span')) {
149  $HTMLparserConfig['removeTags'] = GeneralUtility::rmFromList('span', $HTMLparserConfig['removeTags']);
150  }
151  // Review the tags array
152  if (is_array($HTMLparserConfig['tags.'])) {
153  // Allow span tag
154  if (isset($HTMLparserConfig['tags.']['span']) && !$HTMLparserConfig['tags.']['span']) {
155  $HTMLparserConfig['tags.']['span'] = 1;
156  }
157  if (is_array($HTMLparserConfig['tags.']['span.'])) {
158  if (isset($HTMLparserConfig['tags.']['span.']['allowedAttribs'])) {
159  if (!$HTMLparserConfig['tags.']['span.']['allowedAttribs']) {
160  $HTMLparserConfig['tags.']['span.']['allowedAttribs'] = 'id';
161  } elseif (!GeneralUtility::inList($HTMLparserConfig['tags.']['span.']['allowedAttribs'], 'id')) {
162  $HTMLparserConfig['tags.']['span.']['allowedAttribs'] .= ',id';
163  }
164  }
165  if (isset($HTMLparserConfig['tags.']['span.']['fixAttrib.']['id.']['unset'])) {
166  unset($HTMLparserConfig['tags.']['span.']['fixAttrib.']['id.']['unset']);
167  }
168  }
169  }
170  }
171 
172 }
$TYPO3_CONF_VARS['SYS']['contentTable']
static getUserObj($classRef, $checkPrefix='', $silent=FALSE)
static RTEsetup($RTEprop, $table, $field, $type='')
keepSpanTagsWithId(&$HTMLparserConfig)
if(!defined('TYPO3_MODE')) $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_userauth.php']['logoff_pre_processing'][]
static getPagesTSconfig($id, $rootLine=NULL, $returnPartArray=FALSE)