2 namespace TYPO3\CMS\Core\Html;
20 use TYPO3\CMS\Core\Resource;
31 public $blockElementList =
'PRE,UL,OL,H1,H2,H3,H4,H5,H6,ADDRESS,DL,DD,HEADER,SECTION,FOOTER,NAV,ARTICLE,ASIDE';
134 $path = preg_replace(
'/^\\//',
'', $path);
135 $path = preg_replace(
'/\\/$/',
'', $path);
137 $this->relPath = $path;
138 $this->relBackPath =
'';
139 $partsC = count(explode(
'/', $this->relPath));
140 for ($a = 0; $a < $partsC; $a++) {
141 $this->relBackPath .=
'../';
143 $this->relPath .=
'/';
177 public function RTE_transform($value, $specConf, $direction =
'rte', $thisConfig = array())
180 $this->tsConfig = $thisConfig;
181 $this->procOptions = (array)$thisConfig[
'proc.'];
184 if ($this->procOptions[
'blockElementList']) {
185 $this->blockElementList = $this->procOptions[
'blockElementList'];
190 if ((
string)$this->procOptions[
'overruleMode'] !==
'') {
195 $revmodes = array_flip($modes);
197 if (isset($revmodes[
'ts'])) {
198 $modes[$revmodes[
'ts']] =
'ts_transform,ts_preserve,ts_images,ts_links';
201 if (isset($revmodes[
'ts_css'])) {
202 $modes[$revmodes[
'ts_css']] =
'css_transform,ts_images,ts_links';
207 if ($direction ==
'rte') {
208 $modes = array_reverse($modes);
211 $entry_HTMLparser = $this->procOptions[
'entryHTMLparser_' . $direction] ? $this->
HTMLparserConfig($this->procOptions[
'entryHTMLparser_' . $direction .
'.']) :
'';
212 $exit_HTMLparser = $this->procOptions[
'exitHTMLparser_' . $direction] ? $this->
HTMLparserConfig($this->procOptions[
'exitHTMLparser_' . $direction .
'.']) :
'';
214 if (!$this->procOptions[
'disableUnifyLineBreaks']) {
215 $value = str_replace(CRLF, LF, $value);
218 if (is_array($entry_HTMLparser)) {
219 $value = $this->HTMLcleaner($value, $entry_HTMLparser[0], $entry_HTMLparser[1], $entry_HTMLparser[2], $entry_HTMLparser[3]);
222 foreach ($modes as $cmd) {
224 if ($direction ==
'db') {
226 if ($_classRef =
$GLOBALS[
'TYPO3_CONF_VARS'][
'SC_OPTIONS'][
't3lib/class.t3lib_parsehtml_proc.php'][
'transformation'][$cmd]) {
228 $_procObj->pObj = $this;
229 $_procObj->transformationKey = $cmd;
230 $value = $_procObj->transform_db($value, $this);
235 $value = $this->TS_images_db($value);
248 case 'css_transform':
251 $value = str_replace(CR,
'', $value);
253 $value = str_replace(
'<p></p>',
'<p> </p>', $value);
255 $value = preg_replace(
'/<p> <\/p>$/',
'<p> </p>' .
'<p> </p>', $value);
267 if ($direction ==
'rte') {
269 if ($_classRef =
$GLOBALS[
'TYPO3_CONF_VARS'][
'SC_OPTIONS'][
't3lib/class.t3lib_parsehtml_proc.php'][
'transformation'][$cmd]) {
271 $_procObj->pObj = $this;
272 $value = $_procObj->transform_rte($value, $this);
290 case 'css_transform':
292 $value = str_replace(CR,
'', $value);
302 if (is_array($exit_HTMLparser)) {
303 $value = $this->HTMLcleaner($value, $exit_HTMLparser[0], $exit_HTMLparser[1], $exit_HTMLparser[2], $exit_HTMLparser[3]);
306 if (!$this->procOptions[
'disableUnifyLineBreaks']) {
308 $value = str_replace(CRLF, LF, $value);
310 $value = str_replace(LF, CRLF, $value);
332 public function TS_images_db($value)
335 $imgSplit = $this->
splitTags(
'img', $value);
336 if (count($imgSplit) > 1) {
340 $resourceFactory = Resource\ResourceFactory::getInstance();
343 $magicImageService->setMagicImageMaximumDimensions($this->tsConfig);
344 foreach ($imgSplit as $k => $v) {
350 $absoluteUrl = trim($attribArray[
'src']);
352 $pI = pathinfo($absoluteUrl);
355 $absoluteUrl = substr($absoluteUrl, strlen($sitePath));
356 $absoluteUrl = $siteUrl . $absoluteUrl;
360 if ($imgTagDimensions[0]) {
361 $attribArray[
'width'] = $imgTagDimensions[0];
363 if ($imgTagDimensions[1]) {
364 $attribArray[
'height'] = $imgTagDimensions[1];
366 $originalImageFile = null;
367 if ($attribArray[
'data-htmlarea-file-uid']) {
371 $originalImageFile = $resourceFactory->getFileObject(intval($attribArray[
'data-htmlarea-file-uid']));
372 }
catch (Resource\Exception\FileDoesNotExistException $fileDoesNotExistException) {
374 $message = sprintf(
'Could not find file with uid "%s"', $attribArray[
'data-htmlarea-file-uid']);
375 $this->getLogger()->error($message);
378 if ($originalImageFile instanceof Resource\File) {
380 if ($absoluteUrl == $originalImageFile->getPublicUrl() || $absoluteUrl == $siteUrl . $originalImageFile->getPublicUrl()) {
382 if ($this->procOptions[
'plainImageMode']) {
386 $originalImageFile->getProperty(
'width'),
387 $originalImageFile->getProperty(
'height')
389 if (!$imageInfo[0] || !$imageInfo[1]) {
390 $filePath = $originalImageFile->getForLocalProcessing(
false);
391 $imageInfo = @getimagesize($filePath);
397 $imageConfiguration = array(
398 'width' => $imgTagDimensions[0],
399 'height' => $imgTagDimensions[1]
401 $magicImage = $magicImageService->createMagicImage($originalImageFile, $imageConfiguration);
402 $attribArray[
'width'] = $magicImage->getProperty(
'width');
403 $attribArray[
'height'] = $magicImage->getProperty(
'height');
404 $attribArray[
'src'] = $magicImage->getPublicUrl();
409 $externalFile = $this->
getUrl($absoluteUrl);
411 $pU = parse_url($absoluteUrl);
412 $pI = pathinfo($pU[
'path']);
416 list($table, $field) = explode(
':', $this->elRef);
417 $folder =
$GLOBALS[
'BE_USER']->getDefaultUploadFolder($this->recPid, $table, $field);
418 $fileObject = $folder->createFile($fileName)->setContents($externalFile);
419 $imageConfiguration = array(
420 'width' => $attribArray[
'width'],
421 'height' => $attribArray[
'height']
423 $magicImage = $magicImageService->createMagicImage($fileObject, $imageConfiguration);
424 $attribArray[
'width'] = $magicImage->getProperty(
'width');
425 $attribArray[
'height'] = $magicImage->getProperty(
'height');
426 $attribArray[
'data-htmlarea-file-uid'] = $fileObject->getUid();
427 $attribArray[
'src'] = $magicImage->getPublicUrl();
434 $path = rawurldecode(substr($absoluteUrl, strlen($siteUrl)));
438 if ($filepath && @is_file($filepath)) {
440 if ($this->procOptions[
'plainImageMode']) {
443 $imageInfo = @getimagesize($filepath);
448 $fileOrFolderObject = $resourceFactory->retrieveFileOrFolderObject($path);
449 if ($fileOrFolderObject instanceof Resource\FileInterface) {
450 $fileIdentifier = $fileOrFolderObject->getIdentifier();
451 $fileObject = $fileOrFolderObject->getStorage()->getFile($fileIdentifier);
453 $attribArray[
'data-htmlarea-file-uid'] = $fileObject->getUid();
455 }
catch (Resource\Exception\ResourceDoesNotExistException $resourceDoesNotExistException) {
461 $attribArray[
'style'] = preg_replace(
'/((?:^|)\\s*(?:width|height)\\s*:[^;]*(?:$|;))/si',
'', $attribArray[
'style']);
463 if (!isset($attribArray[
'alt'])) {
464 $attribArray[
'alt'] =
'';
468 $attribArray[
'src'] = $this->relBackPath . substr($attribArray[
'src'], strlen($siteUrl));
474 return implode(
'', $imgSplit);
488 $imgSplit = $this->
splitTags(
'img', $value);
489 if (count($imgSplit) > 1) {
492 foreach ($imgSplit as $k => $v) {
497 $absoluteUrl = trim($attribArray[
'src']);
499 if (strtolower(substr($absoluteUrl, 0, 4)) !==
'http') {
500 $attribArray[
'src'] = substr($attribArray[
'src'], strlen($this->relBackPath));
502 $attribArray[
'src'] = preg_replace(
'#^' . preg_quote($sitePath,
'#') .
'#',
'', $attribArray[
'src']);
503 $attribArray[
'src'] = $siteUrl . $attribArray[
'src'];
506 if (!isset($attribArray[
'alt'])) {
507 $attribArray[
'alt'] =
'';
514 return implode(
'', $imgSplit);
528 switch ($direction) {
535 foreach ($blockSplit as $k => $v) {
540 if ($siteURL && substr($attribArray[
'href'], 0, strlen($siteURL)) == $siteURL) {
541 $attribArray[
'href'] = $this->relBackPath . substr($attribArray[
'href'], strlen($siteURL));
548 $retVal = implode(
'', $blockSplit);
567 foreach ($blockSplit as $k => $v) {
573 $attribArray_copy = $attribArray;
574 unset($attribArray_copy[
'href']);
575 unset($attribArray_copy[
'target']);
576 unset($attribArray_copy[
'class']);
577 unset($attribArray_copy[
'title']);
578 unset($attribArray_copy[
'data-htmlarea-external']);
580 if ($attribArray_copy[
'rteerror']) {
581 unset($attribArray_copy[
'style']);
582 unset($attribArray_copy[
'rteerror']);
585 if (isset(
$GLOBALS[
'TYPO3_CONF_VARS'][
'SC_OPTIONS'][
't3lib/class.t3lib_parsehtml_proc.php'][
'removeParams_PostProc']) && is_array(
$GLOBALS[
'TYPO3_CONF_VARS'][
'SC_OPTIONS'][
't3lib/class.t3lib_parsehtml_proc.php'][
'removeParams_PostProc'])) {
588 'aTagParams' => &$attribArray_copy
590 foreach (
$GLOBALS[
'TYPO3_CONF_VARS'][
'SC_OPTIONS'][
't3lib/class.t3lib_parsehtml_proc.php'][
'removeParams_PostProc'] as $objRef) {
592 $attribArray_copy = $processor->removeParams($parameters, $this);
596 if (empty($attribArray_copy)) {
598 $attribArray[
'class'] = preg_match(
'/ /', $attribArray[
'class']) ?
'"' . $attribArray[
'class'] .
'"' : $attribArray[
'class'];
599 $attribArray[
'title'] = preg_match(
'/ /', $attribArray[
'title']) ?
'"' . $attribArray[
'title'] .
'"' : $attribArray[
'title'];
602 if ($attribArray[
'data-htmlarea-external']) {
603 $href = $attribArray[
'href'];
605 $href = $info[
'url'] . ($info[
'query'] ?
',0,' . $info[
'query'] :
'');
607 $bTag =
'<link ' . $href . ($attribArray[
'target'] ?
' ' . $attribArray[
'target'] : ($attribArray[
'class'] || $attribArray[
'title'] ?
' -' :
'')) . ($attribArray[
'class'] ?
' ' . $attribArray[
'class'] : ($attribArray[
'title'] ?
' -' :
'')) . ($attribArray[
'title'] ?
' ' . $attribArray[
'title'] :
'') .
'>';
610 if (isset(
$GLOBALS[
'TYPO3_CONF_VARS'][
'SC_OPTIONS'][
't3lib/class.t3lib_parsehtml_proc.php'][
'modifyParams_LinksDb_PostProc']) && is_array(
$GLOBALS[
'TYPO3_CONF_VARS'][
'SC_OPTIONS'][
't3lib/class.t3lib_parsehtml_proc.php'][
'modifyParams_LinksDb_PostProc'])) {
613 'currentBlock' => $v,
615 'attributes' => $attribArray
617 foreach (
$GLOBALS[
'TYPO3_CONF_VARS'][
'SC_OPTIONS'][
't3lib/class.t3lib_parsehtml_proc.php'][
'modifyParams_LinksDb_PostProc'] as $objRef) {
619 $blockSplit[$k] = $processor->modifyParamsLinksDb($parameters, $this);
627 unset($attribArray[
'rtekeep']);
628 if (!$attribArray[
'data-htmlarea-external']) {
631 if ($siteURL && substr($attribArray[
'href'], 0, strlen($siteURL)) == $siteURL) {
632 $attribArray[
'href'] = $this->relBackPath . substr($attribArray[
'href'], strlen($siteURL));
635 list($linkHandlerKeyword, $linkHandlerValue) = explode(
':', $attribArray[
'href'], 2);
636 if ($linkHandlerKeyword ===
'?file') {
638 $fileOrFolderObject = \TYPO3\CMS\Core\Resource\ResourceFactory::getInstance()->retrieveFileOrFolderObject(rawurldecode($linkHandlerValue));
639 if ($fileOrFolderObject instanceof \TYPO3\CMS\Core\Resource\FileInterface || $fileOrFolderObject instanceof \TYPO3\CMS\Core\Resource\
Folder) {
640 $attribArray[
'href'] = $fileOrFolderObject->getPublicUrl();
647 unset($attribArray[
'data-htmlarea-external']);
654 return implode(
'', $blockSplit);
672 foreach ($blockSplit as $k => $v) {
678 $typolink = explode(
' ', substr($this->
getFirstTag($v), 0, -1), 2)[1];
681 $link_param = $tagCode[
'url'];
684 $pU = parse_url($link_param);
685 if (strstr($link_param,
'@') && (!$pU[
'scheme'] || $pU[
'scheme'] ==
'mailto')) {
687 $href =
'mailto:' . preg_replace(
'/^mailto:/i',
'', $link_param);
688 }
elseif ($link_param[0] ===
'#') {
690 $href = $siteUrl . $link_param;
693 list($linkHandlerKeyword, $linkHandlerValue) = explode(
':', trim($link_param), 2);
695 $href = $siteUrl .
'?' . $linkHandlerKeyword .
':' . rawurlencode($linkHandlerValue);
697 $fileChar = (int)strpos($link_param,
'/');
698 $urlChar = (int)strpos($link_param,
'.');
700 list($rootFileDat) = explode(
'?', $link_param);
701 $rFD_fI = pathinfo($rootFileDat);
702 if (trim($rootFileDat) && !strstr($link_param,
'/') && (@is_file((PATH_site . $rootFileDat)) ||
GeneralUtility::inList(
'php,html,htm', strtolower($rFD_fI[
'extension'])))) {
703 $href = $siteUrl . $link_param;
707 && !isset(
$GLOBALS[
'TYPO3_CONF_VARS'][
'SC_OPTIONS'][
'tslib/class.tslib_content.php'][
'typolinkLinkHandler'][$pU[
'scheme']])
709 || $urlChar && (!$fileChar || $urlChar < $fileChar)
713 if (!$pU[
'scheme']) {
714 $href =
'http://' . $href;
721 $fileOrFolderObject = \TYPO3\CMS\Core\Resource\ResourceFactory::getInstance()->retrieveFileOrFolderObject($link_param);
722 }
catch (\TYPO3\CMS\Core\Resource\
Exception $exception) {
724 $fileOrFolderObject = null;
726 if ($fileOrFolderObject instanceof \TYPO3\CMS\Core\Resource\
Folder) {
728 $folderIdentifier = $fileOrFolderObject->getIdentifier();
729 $href = $siteUrl .
'?file:' . rawurlencode($folderIdentifier);
730 }
elseif ($fileOrFolderObject instanceof \TYPO3\CMS\Core\Resource\FileInterface) {
732 $fileIdentifier = $fileOrFolderObject->getIdentifier();
733 $fileObject = $fileOrFolderObject->getStorage()->getFile($fileIdentifier);
734 $href = $siteUrl .
'?file:' . $fileObject->getUid();
736 $href = $siteUrl . $link_param;
742 $idPart = $pairParts[0];
743 $link_params_parts = explode(
'#', $idPart);
744 $idPart = trim($link_params_parts[0]);
745 $sectionMark = trim($link_params_parts[1]);
746 if ((
string)$idPart ===
'') {
753 $idPart = (int)$idPartR[
'uid'];
756 if (is_array($page)) {
758 $href = $siteUrl .
'?id=' . $idPart . ($pairParts[2] ? $pairParts[2] :
'') . ($sectionMark ?
'#' . $sectionMark :
'');
759 }
elseif (isset(
$GLOBALS[
'TYPO3_CONF_VARS'][
'SC_OPTIONS'][
'tslib/class.tslib_content.php'][
'typolinkLinkHandler'][array_shift(explode(
':', $link_param))])) {
762 $href = $siteUrl .
'?id=' . $link_param;
763 $error =
'No page found: ' . $idPart;
769 $bTag =
'<a href="' . htmlspecialchars($href) .
'"'
770 . ($tagCode[
'target'] ?
' target="' . htmlspecialchars($tagCode[
'target']) .
'"' :
'')
771 . ($tagCode[
'class'] ?
' class="' . htmlspecialchars($tagCode[
'class']) .
'"' :
'')
772 . ($tagCode[
'title'] ?
' title="' . htmlspecialchars($tagCode[
'title']) .
'"' :
'')
773 . ($external ?
' data-htmlarea-external="1"' :
'')
774 . ($error ?
' rteerror="' . htmlspecialchars($error) .
'" style="background-color: yellow; border:2px red solid; color: black;"' :
'') .
'>';
777 if (isset(
$GLOBALS[
'TYPO3_CONF_VARS'][
'SC_OPTIONS'][
't3lib/class.t3lib_parsehtml_proc.php'][
'modifyParams_LinksRte_PostProc']) && is_array(
$GLOBALS[
'TYPO3_CONF_VARS'][
'SC_OPTIONS'][
't3lib/class.t3lib_parsehtml_proc.php'][
'modifyParams_LinksRte_PostProc'])) {
780 'currentBlock' => $v,
782 'tagCode' => $tagCode,
783 'external' => $external,
786 foreach (
$GLOBALS[
'TYPO3_CONF_VARS'][
'SC_OPTIONS'][
't3lib/class.t3lib_parsehtml_proc.php'][
'modifyParams_LinksRte_PostProc'] as $objRef) {
788 $blockSplit[$k] = $processor->modifyParamsLinksRte($parameters, $this);
796 return implode(
'', $blockSplit);
807 if (!$this->preserveTags) {
812 foreach ($blockSplit as $k => $v) {
816 if ($attribArray[
'specialtag']) {
817 $theTag = rawurldecode($attribArray[
'specialtag']);
819 $blockSplit[$k] = $theTag . $this->
removeFirstAndLastTag($blockSplit[$k]) .
'</' . $theTagName .
'>';
823 return implode(
'', $blockSplit);
834 if (!$this->preserveTags) {
838 foreach ($blockSplit as $k => $v) {
844 return implode(
'', $blockSplit);
859 $this->TS_transform_db_safecounter--;
860 if ($this->TS_transform_db_safecounter < 0) {
864 $blockSplit = $this->
splitIntoBlock(
'TABLE,BLOCKQUOTE,' . ($this->procOptions[
'preserveDIVSections'] ?
'DIV,' :
'') . $this->blockElementList, $value);
866 $aC = count($blockSplit);
868 while ($aC && trim($blockSplit[($aC - 1)]) ===
'') {
869 unset($blockSplit[$aC - 1]);
870 $aC = count($blockSplit);
873 foreach ($blockSplit as $k => $v) {
875 $lastBR = $cc == $aC ?
'' : LF;
906 $blockSplit[$k] = preg_replace((
'/[' . LF . CR .
']+/'),
' ', $this->
transformStyledATags($blockSplit[$k])) . $lastBR;
911 if (!$this->procOptions[
'preserveTables'] && !$css) {
914 $blockSplit[$k] = preg_replace((
'/[' . LF . CR .
']+/'),
' ', $this->
transformStyledATags($blockSplit[$k])) . $lastBR;
932 $blockSplit[$k] =
'<' . $tagName . ($attribArray[
'align'] ?
' align="' . htmlspecialchars($attribArray[
'align']) .
'"' :
'') . ($attribArray[
'class'] ?
' class="' . htmlspecialchars($attribArray[
'class']) .
'"' :
'') .
'>' . $innerContent .
'</' . $tagName .
'>' . $lastBR;
935 $blockSplit[$k] = preg_replace((
'/[' . LF . CR .
']+/'),
' ', $this->
transformStyledATags($blockSplit[$k])) . $lastBR;
940 $blockSplit[$k] = preg_replace((
'/[' . LF . CR .
']+/'),
' ', $this->
transformStyledATags($blockSplit[$k])) . $lastBR;
944 if (trim($blockSplit[$k]) !==
'') {
945 $blockSplit[$k] = preg_replace(
'/<hr\\/>/',
'<hr />', $blockSplit[$k]);
947 $blockSplit[$k] = preg_replace(
'/[' . LF . CR .
']+<(hr)(\\s[^>\\/]*)?[[:space:]]*\\/?>/',
'<$1$2/>', $blockSplit[$k]);
949 $blockSplit[$k] = preg_replace(
'/<(hr)(\\s[^>\\/]*)?[[:space:]]*\\/?>[' . LF . CR .
']+/',
'<$1$2/>', $blockSplit[$k]);
951 $blockSplit[$k] = preg_replace(
'/[' . LF . CR .
']+/',
' ', $blockSplit[$k]);
955 unset($blockSplit[$k]);
959 $this->TS_transform_db_safecounter++;
960 return implode(
'', $blockSplit);
972 foreach ($blockSplit as $k => $v) {
977 if ($attribArray[
'style'] && !$attribArray[
'rteerror']) {
978 $attribArray_copy[
'style'] = $attribArray[
'style'];
979 unset($attribArray[
'style']);
981 $eTag =
'</a></span>';
986 return implode(
'', $blockSplit);
1001 $blockElementList =
'TABLE,BLOCKQUOTE,' . ($this->procOptions[
'preserveDIVSections'] ?
'DIV,' :
'') . $this->blockElementList;
1004 foreach ($blockSplit as $k => $v) {
1033 $blockSplit[$k + 1] = preg_replace(
'/^[ ]*' . LF .
'/',
'', $blockSplit[$k + 1]);
1037 $onlyLineBreaks = (preg_match(
'/^[ ]*' . LF .
'+[ ]*$/', $blockSplit[$k]) == 1);
1041 if (!$onlyLineBreaks) {
1042 $blockSplit[$k] = preg_replace(
'/(' . LF .
'*)' . LF .
'[ ]*$/',
'$1', $blockSplit[$k]);
1045 $blockSplit[$k] = preg_replace(
'/^[ ]*' . LF .
'/',
'', $blockSplit[$k]);
1049 if ((
string)$blockSplit[$k] ===
'' && !$onlyLineBreaks) {
1050 unset($blockSplit[$k]);
1052 $blockSplit[$k] = $this->
setDivTags($blockSplit[$k], $this->procOptions[
'useDIVasParagraphTagForRTE'] ?
'div' :
'p');
1056 return implode(LF, $blockSplit);
1068 $value = strip_tags($value,
'<' . implode(
'><', explode(
',',
'b,i,u,a,img,br,div,center,pre,font,hr,sub,sup,p,strong,em,li,ul,ol,blockquote')) .
'>');
1107 $kUknown = $this->procOptions[
'dontRemoveUnknownTags_db'] ? 1 : 0;
1109 $hSC = $this->procOptions[
'dontUndoHSC_db'] ? 0 : -1;
1111 $addConfig = array();
1112 if (is_array($this->procOptions[
'HTMLparser_db.']) && $this->procOptions[
'HTMLparser_db.'][
'xhtml_cleaning'] || is_array($this->procOptions[
'entryHTMLparser_db.']) && $this->procOptions[
'entryHTMLparser_db.'][
'xhtml_cleaning'] || is_array($this->procOptions[
'exitHTMLparser_db.']) && $this->procOptions[
'exitHTMLparser_db.'][
'xhtml_cleaning']) {
1113 $addConfig[
'xhtml'] = 1;
1115 return $this->HTMLcleaner($content, $keepTags, $kUknown, $hSC, $addConfig);
1129 if (!is_array($this->getKeepTags_cache[$direction]) || $tagList) {
1132 if ((
string)$tagList !==
'') {
1137 $typoScript_list =
'b,i,u,a,img,br,div,center,pre,font,hr,sub,sup,p,strong,em,li,ul,ol,blockquote,strike,span';
1138 $keepTags = array_flip(
GeneralUtility::trimExplode(
',', $typoScript_list .
',' . strtolower($this->procOptions[
'allowTags']),
true));
1141 foreach ($denyTags as $dKe) {
1142 unset($keepTags[$dKe]);
1146 switch ($direction) {
1148 if (!isset($this->procOptions[
'transformBoldAndItalicTags']) || $this->procOptions[
'transformBoldAndItalicTags']) {
1150 if (isset($keepTags[
'b'])) {
1151 $keepTags[
'b'] = array(
'remap' =>
'STRONG');
1153 if (isset($keepTags[
'i'])) {
1154 $keepTags[
'i'] = array(
'remap' =>
'EM');
1158 list($keepTags) = $this->
HTMLparserConfig($this->procOptions[
'HTMLparser_rte.'], $keepTags);
1161 if (!isset($this->procOptions[
'transformBoldAndItalicTags']) || $this->procOptions[
'transformBoldAndItalicTags']) {
1163 if (isset($keepTags[
'strong'])) {
1164 $keepTags[
'strong'] = array(
'remap' =>
'b');
1166 if (isset($keepTags[
'em'])) {
1167 $keepTags[
'em'] = array(
'remap' =>
'i');
1171 if (isset($keepTags[
'span'])) {
1172 $classes = array_merge(array(
''), $this->allowedClasses);
1173 $keepTags[
'span'] = array(
1174 'allowedAttribs' =>
'id,class,style,title,lang,xml:lang,dir,itemscope,itemtype,itemprop',
1175 'fixAttrib' => array(
1178 'removeIfFalse' => 1
1181 'rmTagIfNoAttrib' => 1
1183 if (!$this->procOptions[
'allowedClasses']) {
1184 unset($keepTags[
'span'][
'fixAttrib'][
'class'][
'list']);
1188 if (isset($keepTags[
'font'])) {
1190 $keepTags[
'font'] = array(
1191 'allowedAttribs' =>
'face,color,size',
1192 'fixAttrib' => array(
1194 'removeIfFalse' => 1
1197 'removeIfFalse' => 1,
1201 'removeIfFalse' => 1
1204 'rmTagIfNoAttrib' => 1
1206 if (!$this->procOptions[
'allowedFontColors']) {
1207 unset($keepTags[
'font'][
'fixAttrib'][
'color'][
'list']);
1211 $TSc = $this->procOptions[
'HTMLparser_db.'];
1212 if (!$TSc[
'globalNesting']) {
1213 $TSc[
'globalNesting'] =
'b,i,u,a,center,font,sub,sup,strong,em,strike,span';
1215 if (!$TSc[
'noAttrib']) {
1216 $TSc[
'noAttrib'] =
'b,i,u,br,center,hr,sub,sup,strong,em,li,ul,ol,blockquote,strike';
1224 $this->getKeepTags_cache[$direction] = $keepTags;
1230 return $this->getKeepTags_cache[$direction];
1248 $allowTagsOutside =
GeneralUtility::trimExplode(
',', strtolower($this->procOptions[
'allowTagsOutside'] ?
'hr,' . $this->procOptions[
'allowTagsOutside'] :
'hr,img'),
true);
1249 $remapParagraphTag = strtoupper($this->procOptions[
'remapParagraphTag']);
1252 if ($this->procOptions[
'keepPDIVattribs']) {
1255 $keepAttribListArr = array();
1258 if (count($divSplit) <= 1 || $count <= 0) {
1260 $newValue = preg_replace(
'/<(hr)(\\s[^>\\/]*)?[[:space:]]*\\/?>/i', LF .
'<$1$2/>' . LF, $value);
1261 $newValue = preg_replace(
'/' . LF . LF .
'/i', LF, $newValue);
1262 $newValue = preg_replace(
'/(^' . LF .
')|(' . LF .
'$)/i',
'', $newValue);
1266 foreach ($divSplit as $k => $v) {
1273 if (is_array($subLines)) {
1276 $subLines = array($subLines);
1278 if (!$this->procOptions[
'dontConvBRtoParagraph']) {
1279 $subLines = preg_split(
'/<br[[:space:]]*[\\/]?>/i', $v);
1282 foreach ($subLines as $sk => $value) {
1290 $newAttribs = array();
1291 if (!empty($keepAttribListArr)) {
1292 foreach ($keepAttribListArr as $keepA) {
1293 if (isset($attribs[0][$keepA])) {
1294 $newAttribs[$keepA] = $attribs[0][$keepA];
1299 if (!$this->procOptions[
'skipAlign'] && trim($attribs[0][
'align']) !==
'' && strtolower($attribs[0][
'align']) !=
'left') {
1301 $newAttribs[
'align'] = strtolower($attribs[0][
'align']);
1305 if (!$this->procOptions[
'skipClass'] && trim($attribs[0][
'class']) !==
'') {
1306 if (empty($this->allowedClasses) || in_array($attribs[0][
'class'], $this->allowedClasses)) {
1307 $newAttribs[
'class'] = $attribs[0][
'class'];
1310 $newClasses = array();
1311 foreach ($classes as $class) {
1312 if (in_array($class, $this->allowedClasses)) {
1313 $newClasses[] = $class;
1316 if (!empty($newClasses)) {
1317 $newAttribs[
'class'] = implode(
' ', $newClasses);
1322 $subLines[$sk] = preg_replace(
'/' . LF .
'|' . CR .
'/',
'', $subLines[$sk]);
1324 if (!empty($newAttribs) && $remapParagraphTag !==
'1') {
1325 if ($remapParagraphTag ===
'P') {
1328 if ($remapParagraphTag ===
'DIV') {
1331 $subLines[$sk] =
'<' . trim($tagName .
' ' . $this->
compileTagAttribs($newAttribs)) .
'>' . $subLines[$sk] .
'</' . $tagName .
'>';
1336 $divSplit[$k] = implode(LF, $subLines);
1340 if (trim(strip_tags($divSplit[$k])) ==
' ' && !preg_match(
'/\\<(img)(\\s[^>]*)?\\/?>/si', $divSplit[$k]) && !preg_match(
'/\\<([^>]*)?( align| class| style| id| title| dir| lang| xml:lang)([^>]*)?>/si', trim($divSplit[$k]))) {
1346 $divSplit[$k] = trim(strip_tags($divSplit[$k],
'<' . implode(
'><', $allowTagsOutside) .
'>'));
1348 $divSplit[$k] = preg_replace(
'/<(hr)(\\s[^>\\/]*)?[[:space:]]*\\/?>/i', LF .
'<$1$2/>' . LF, $divSplit[$k]);
1349 $divSplit[$k] = preg_replace(
'/' . LF . LF .
'/i', LF, $divSplit[$k]);
1350 $divSplit[$k] = preg_replace(
'/(^' . LF .
')|(' . LF .
'$)/i',
'', $divSplit[$k]);
1351 if ((
string)$divSplit[$k] ===
'') {
1352 unset($divSplit[$k]);
1357 return $returnArray ? $divSplit : implode(LF, $divSplit);
1374 $kUknown = $this->procOptions[
'dontProtectUnknownTags_rte'] ? 0 :
'protect';
1376 $hSC = $this->procOptions[
'dontHSC_rte'] ? 0 : 1;
1377 $convNBSP = !$this->procOptions[
'dontConvAmpInNBSP_rte'] ? 1 : 0;
1379 $parts = explode(LF, $value);
1380 foreach ($parts as $k => $v) {
1383 if (trim($parts[$k]) ===
'') {
1384 $parts[$k] =
' ';
1387 $parts[$k] = $this->HTMLcleaner($parts[$k], $keepTags, $kUknown, $hSC);
1389 $parts[$k] = str_replace(
'&nbsp;',
' ', $parts[$k]);
1393 if (!preg_match(
'/<(hr)(\\s[^>\\/]*)?[[:space:]]*\\/?>/i', $parts[$k])) {
1394 $testStr = strtolower(trim($parts[$k]));
1395 if (substr($testStr, 0, 4) !=
'<div' || substr($testStr, -6) !=
'</div>') {
1396 if (substr($testStr, 0, 2) !=
'<p' || substr($testStr, -4) !=
'</p>') {
1398 $parts[$k] =
'<' . $dT .
'>' . $parts[$k] .
'</' . $dT .
'>';
1404 return implode(LF, $parts);
1432 foreach ($tableSplit as $k => $v) {
1434 $tableSplit[$k] =
'';
1436 foreach ($rowSplit as $k2 => $v2) {
1439 foreach ($cellSplit as $k3 => $v3) {
1440 $tableSplit[$k] .= $v3 . $breakChar;
1447 return implode($breakChar, $tableSplit);
1459 if ($direction ==
'db') {
1460 $code = $this->
mapTags($code, array(
1466 if ($direction ==
'rte') {
1467 $code = $this->
mapTags($code, array(
1485 $style = trim($attribArray[
'style']);
1487 $regex =
'[[:space:]]*:[[:space:]]*([0-9]*)[[:space:]]*px';
1490 preg_match(
'/width' . $regex .
'/i', $style, $reg);
1493 preg_match(
'/height' . $regex .
'/i', $style, $reg);
1497 $w = $attribArray[
'width'];
1500 $h = $attribArray[
'height'];
1502 return array((
int)$w, (
int)$h);
1515 if (substr(strtolower(
$url), 0, 7) ==
'mailto:') {
1516 $info[
'url'] = trim(substr(
$url, 7));
1517 $info[
'type'] =
'email';
1518 }
elseif (strpos(
$url,
'?file:') !==
false) {
1519 $info[
'type'] =
'file';
1520 $info[
'url'] = rawurldecode(substr(
$url, strpos(
$url,
'?file:') + 1));
1523 $urlLength = strlen(
$url);
1524 for ($a = 0; $a < $urlLength; $a++) {
1525 if (
$url[$a] != $curURL[$a]) {
1529 $info[
'relScriptPath'] = substr($curURL, $a);
1530 $info[
'relUrl'] = substr(
$url, $a);
1531 $info[
'url'] =
$url;
1532 $info[
'type'] =
'ext';
1533 $siteUrl_parts = parse_url(
$url);
1534 $curUrl_parts = parse_url($curURL);
1536 if ($siteUrl_parts[
'host'] == $curUrl_parts[
'host'] && (!$info[
'relScriptPath'] || defined(
'TYPO3_mainDir') && substr($info[
'relScriptPath'], 0, strlen(TYPO3_mainDir)) == TYPO3_mainDir)) {
1539 $uP = parse_url($info[
'relUrl']);
1540 if ($info[
'relUrl'] ===
'#' . $siteUrl_parts[
'fragment']) {
1541 $info[
'url'] = $info[
'relUrl'];
1542 $info[
'type'] =
'anchor';
1543 }
elseif (!trim($uP[
'path']) || $uP[
'path'] ===
'index.php') {
1545 $pp = preg_split(
'/^id=/', $uP[
'query']);
1546 $pp[1] = preg_replace(
'/&id=[^&]*/',
'', $pp[1]);
1547 $parameters = explode(
'&', $pp[1]);
1548 $id = array_shift($parameters);
1550 $info[
'pageid'] = $id;
1551 $info[
'cElement'] = $uP[
'fragment'];
1552 $info[
'url'] = $id . ($info[
'cElement'] ?
'#' . $info[
'cElement'] :
'');
1553 $info[
'type'] =
'page';
1554 $info[
'query'] = $parameters[0] ?
'&' . implode(
'&', $parameters) :
'';
1557 $info[
'url'] = $info[
'relUrl'];
1558 $info[
'type'] =
'file';
1561 unset($info[
'relScriptPath']);
1562 unset($info[
'relUrl']);
1578 foreach ($blockSplit as $k => $v) {
1584 if ($attribArray[
'href'] !==
'') {
1585 $uP = parse_url(strtolower($attribArray[
'href']));
1586 if (!$uP[
'scheme']) {
1587 $attribArray[
'href'] = $this->
siteUrl() . substr($attribArray[
'href'], strlen($this->relBackPath));
1588 }
elseif ($uP[
'scheme'] !=
'mailto') {
1589 $attribArray[
'data-htmlarea-external'] = 1;
1592 $attribArray[
'rtekeep'] = 1;
1594 if (!$dontSetRTEKEEP) {
1595 $attribArray[
'rtekeep'] = 1;
1602 return implode(
'', $blockSplit);
1615 if ($this->procOptions[
'plainImageMode']) {
1617 switch ((
string)$this->procOptions[
'plainImageMode']) {
1618 case 'lockDimensions':
1619 $attribArray[
'width'] = $imageInfo[0];
1620 $attribArray[
'height'] = $imageInfo[1];
1622 case 'lockRatioWhenSmaller':
1623 if ($attribArray[
'width'] > $imageInfo[0]) {
1624 $attribArray[
'width'] = $imageInfo[0];
1627 if ($imageInfo[0] > 0) {
1628 $attribArray[
'height'] = round($attribArray[
'width'] * ($imageInfo[1] / $imageInfo[0]));
1633 return $attribArray;
1639 protected function getLogger()
1644 return $logManager->getLogger(get_class($this));