14050_cleaning_t3lib_arraybrowser
[Packages/TYPO3.CMS.git] / t3lib / class.t3lib_parsehtml_proc.php
1 <?php
2 /***************************************************************
3 * Copyright notice
4 *
5 * (c) 1999-2010 Kasper Skårhøj (kasperYYYY@typo3.com)
6 * All rights reserved
7 *
8 * This script is part of the TYPO3 project. The TYPO3 project is
9 * free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
13 *
14 * The GNU General Public License can be found at
15 * http://www.gnu.org/copyleft/gpl.html.
16 * A copy is found in the textfile GPL.txt and important notices to the license
17 * from the author is found in LICENSE.txt distributed with these scripts.
18 *
19 *
20 * This script is distributed in the hope that it will be useful,
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 * GNU General Public License for more details.
24 *
25 * This copyright notice MUST APPEAR in all copies of the script!
26 ***************************************************************/
27 /**
28 * Functions for parsing HTML, specially for TYPO3 processing in relation to TCEmain and Rich Text Editor (RTE)
29 *
30 * $Id$
31 * Revised for TYPO3 3.6 December/2003 by Kasper Skårhøj
32 * XHTML compatible.
33 *
34 * @author Kasper Skårhøj <kasperYYYY@typo3.com>
35 * @internal
36 */
37 /**
38 * [CLASS/FUNCTION INDEX of SCRIPT]
39 *
40 *
41 *
42 * 103: class t3lib_parsehtml_proc extends t3lib_parsehtml
43 * 138: function init($elRef='',$recPid=0)
44 * 150: function setRelPath($path)
45 * 174: function evalWriteFile($pArr,$currentRecord)
46 *
47 * SECTION: Main function
48 * 232: function RTE_transform($value,$specConf,$direction='rte',$thisConfig=array())
49 *
50 * SECTION: Specific RTE TRANSFORMATION functions
51 * 398: function TS_images_db($value)
52 * 550: function TS_images_rte($value)
53 * 589: function TS_reglinks($value,$direction)
54 * 626: function TS_links_db($value)
55 * 675: function TS_links_rte($value)
56 * 760: function TS_preserve_db($value)
57 * 784: function TS_preserve_rte($value)
58 * 805: function TS_transform_db($value,$css=FALSE)
59 * 922: function transformStyledATags($value)
60 * 948: function TS_transform_rte($value,$css=0)
61 * 1019: function TS_strip_db($value)
62 *
63 * SECTION: Generic RTE transformation, analysis and helper functions
64 * 1050: function getURL($url)
65 * 1064: function HTMLcleaner_db($content,$tagList='')
66 * 1091: function getKeepTags($direction='rte',$tagList='')
67 * 1200: function divideIntoLines($value,$count=5,$returnArray=FALSE)
68 * 1304: function setDivTags($value,$dT='p')
69 * 1349: function internalizeFontTags($value)
70 * 1385: function siteUrl()
71 * 1395: function rteImageStorageDir()
72 * 1407: function removeTables($value,$breakChar='<br />')
73 * 1439: function defaultTStagMapping($code,$direction='rte')
74 * 1462: function getWHFromAttribs($attribArray)
75 * 1489: function urlInfoForLinkTags($url)
76 * 1548: function TS_AtagToAbs($value,$dontSetRTEKEEP=FALSE)
77 *
78 * TOTAL FUNCTIONS: 28
79 * (This index is automatically created/updated by the extension "extdeveval")
80 *
81 */
82
83
84
85
86
87
88
89
90
91
92
93
94
95 /**
96 * Class for parsing HTML for the Rich Text Editor. (also called transformations)
97 *
98 * @author Kasper Skårhøj <kasperYYYY@typo3.com>
99 * @package TYPO3
100 * @subpackage t3lib
101 */
102 class t3lib_parsehtml_proc extends t3lib_parsehtml {
103
104 // Static:
105 var $blockElementList = 'PRE,UL,OL,H1,H2,H3,H4,H5,H6,HR,ADDRESS,DL,DD'; // List of tags for these elements
106
107 // Internal, static:
108 var $recPid = 0; // Set this to the pid of the record manipulated by the class.
109 var $elRef = ''; // Element reference [table]:[field], eg. "tt_content:bodytext"
110 var $relPath=''; // Relative path
111 var $relBackPath=''; // Relative back-path
112 public $tsConfig = array(); // Current Page TSConfig
113 var $procOptions = ''; // Set to the TSconfig options coming from Page TSconfig
114
115 // Internal, dynamic
116 var $TS_transform_db_safecounter=100; // Run-away brake for recursive calls.
117 var $rte_p=''; // Parameters from TCA types configuration related to the RTE
118 var $getKeepTags_cache=array(); // Data caching for processing function
119 var $allowedClasses=array(); // Storage of the allowed CSS class names in the RTE
120 var $preserveTags = ''; // Set to tags to preserve from Page TSconfig configuration
121
122
123
124
125
126
127
128
129
130
131 /**
132 * Initialize, setting element reference and record PID
133 *
134 * @param string Element reference, eg "tt_content:bodytext"
135 * @param integer PID of the record (page id)
136 * @return void
137 */
138 function init($elRef='',$recPid=0) {
139 $this->recPid = $recPid;
140 $this->elRef = $elRef;
141 }
142
143 /**
144 * Setting the ->relPath and ->relBackPath to proper values so absolute references to links and images can be converted to relative dittos.
145 * This is used when editing files with the RTE
146 *
147 * @param string The relative path from PATH_site to the place where the file being edited is. Eg. "fileadmin/static".
148 * @return void There is no output, it is set in internal variables. With the above example of "fileadmin/static" as input this will yield ->relPath to be "fileadmin/static/" and ->relBackPath to be "../../"
149 */
150 function setRelPath($path) {
151 $path = trim($path);
152 $path = preg_replace('/^\//','',$path);
153 $path = preg_replace('/\/$/','',$path);
154 if ($path) {
155 $this->relPath = $path;
156 $this->relBackPath = '';
157 $partsC=count(explode('/',$this->relPath));
158 for ($a=0;$a<$partsC;$a++) {
159 $this->relBackPath.='../';
160 }
161 $this->relPath.='/';
162 }
163 }
164
165 /**
166 * Evaluate the environment for editing a staticFileEdit file.
167 * Called for almost all fields being saved in the database. Is called without an instance of the object: t3lib_parsehtml_proc::evalWriteFile()
168 *
169 * @param array Parameters for the current field as found in types-config
170 * @param array Current record we are editing.
171 * @return mixed On success an array with various information is returned, otherwise a string with an error message
172 * @see t3lib_TCEmain, t3lib_transferData
173 */
174 function evalWriteFile($pArr,$currentRecord) {
175
176 // Write file configuration:
177 if (is_array($pArr)) {
178 if ($GLOBALS['TYPO3_CONF_VARS']['BE']['staticFileEditPath']
179 && substr($GLOBALS['TYPO3_CONF_VARS']['BE']['staticFileEditPath'],-1)=='/'
180 && @is_dir(PATH_site.$GLOBALS['TYPO3_CONF_VARS']['BE']['staticFileEditPath'])) {
181
182 $SW_p = $pArr['parameters'];
183 $SW_editFileField = trim($SW_p[0]);
184 $SW_editFile = $currentRecord[$SW_editFileField];
185 if ($SW_editFileField && $SW_editFile && t3lib_div::validPathStr($SW_editFile)) {
186 $SW_relpath = $GLOBALS['TYPO3_CONF_VARS']['BE']['staticFileEditPath'].$SW_editFile;
187 $SW_editFile = PATH_site.$SW_relpath;
188 if (@is_file($SW_editFile)) {
189 return array(
190 'editFile' => $SW_editFile,
191 'relEditFile' => $SW_relpath,
192 'contentField' => trim($SW_p[1]),
193 'markerField' => trim($SW_p[2]),
194 'loadFromFileField' => trim($SW_p[3]),
195 'statusField' => trim($SW_p[4])
196 );
197 } else return "ERROR: Editfile '".$SW_relpath."' did not exist";
198 } else return "ERROR: Edit file name could not be found or was bad.";
199 } else return "ERROR: staticFileEditPath was not set, not set correctly or did not exist!";
200 }
201 }
202
203
204
205
206
207
208
209
210
211
212
213
214
215 /**********************************************
216 *
217 * Main function
218 *
219 **********************************************/
220
221 /**
222 * Transform value for RTE based on specConf in the direction specified by $direction (rte/db)
223 * This is the main function called from tcemain and transfer data classes
224 *
225 * @param string Input value
226 * @param array Special configuration for a field; This is coming from the types-configuration of the field in the TCA. In the types-configuration you can setup features for the field rendering and in particular the RTE takes al its major configuration options from there!
227 * @param string Direction of the transformation. Two keywords are allowed; "db" or "rte". If "db" it means the transformation will clean up content coming from the Rich Text Editor and goes into the database. The other direction, "rte", is of course when content is coming from database and must be transformed to fit the RTE.
228 * @param array Parsed TypoScript content configuring the RTE, probably coming from Page TSconfig.
229 * @return string Output value
230 * @see t3lib_TCEmain::fillInFieldArray(), t3lib_transferData::renderRecord_typesProc()
231 */
232 function RTE_transform($value,$specConf,$direction='rte',$thisConfig=array()) {
233
234 // Init:
235 $this->tsConfig = $thisConfig;
236 $this->procOptions = $thisConfig['proc.'];
237 $this->preserveTags = strtoupper(implode(',',t3lib_div::trimExplode(',',$this->procOptions['preserveTags'])));
238
239 // dynamic configuration of blockElementList
240 if ($this->procOptions['blockElementList']) {
241 $this->blockElementList = $this->procOptions['blockElementList'];
242 }
243
244 // Get parameters for rte_transformation:
245 $p = $this->rte_p = t3lib_BEfunc::getSpecConfParametersFromArray($specConf['rte_transform']['parameters']);
246
247 // Setting modes:
248 if (strcmp($this->procOptions['overruleMode'],'')) {
249 $modes = array_unique(t3lib_div::trimExplode(',',$this->procOptions['overruleMode']));
250 } else {
251 $modes = array_unique(t3lib_div::trimExplode('-',$p['mode']));
252 }
253 $revmodes = array_flip($modes);
254
255 // Find special modes and extract them:
256 if (isset($revmodes['ts'])) {
257 $modes[$revmodes['ts']] = 'ts_transform,ts_preserve,ts_images,ts_links';
258 }
259 // Find special modes and extract them:
260 if (isset($revmodes['ts_css'])) {
261 $modes[$revmodes['ts_css']] = 'css_transform,ts_images,ts_links';
262 }
263
264 // Make list unique
265 $modes = array_unique(t3lib_div::trimExplode(',',implode(',',$modes),1));
266
267 // Reverse order if direction is "rte"
268 if ($direction=='rte') {
269 $modes = array_reverse($modes);
270 }
271
272 // Getting additional HTML cleaner configuration. These are applied either before or after the main transformation is done and is thus totally independant processing options you can set up:
273 $entry_HTMLparser = $this->procOptions['entryHTMLparser_'.$direction] ? $this->HTMLparserConfig($this->procOptions['entryHTMLparser_'.$direction.'.']) : '';
274 $exit_HTMLparser = $this->procOptions['exitHTMLparser_'.$direction] ? $this->HTMLparserConfig($this->procOptions['exitHTMLparser_'.$direction.'.']) : '';
275
276 // Line breaks of content is unified into char-10 only (removing char 13)
277 if (!$this->procOptions['disableUnifyLineBreaks']) {
278 $value = str_replace(CRLF,LF,$value);
279 }
280
281 // In an entry-cleaner was configured, pass value through the HTMLcleaner with that:
282 if (is_array($entry_HTMLparser)) {
283 $value = $this->HTMLcleaner($value,$entry_HTMLparser[0],$entry_HTMLparser[1],$entry_HTMLparser[2],$entry_HTMLparser[3]);
284 }
285
286 // Traverse modes:
287 foreach($modes as $cmd) {
288 // ->DB
289 if ($direction=='db') {
290 // Checking for user defined transformation:
291 if ($_classRef = $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_parsehtml_proc.php']['transformation'][$cmd]) {
292 $_procObj = t3lib_div::getUserObj($_classRef);
293 $_procObj->pObj = $this;
294 $_procObj->transformationKey = $cmd;
295 $value = $_procObj->transform_db($value,$this);
296 } else { // ... else use defaults:
297 switch($cmd) {
298 case 'ts_images':
299 $value = $this->TS_images_db($value);
300 break;
301 case 'ts_reglinks':
302 $value = $this->TS_reglinks($value,'db');
303 break;
304 case 'ts_links':
305 $value = $this->TS_links_db($value);
306 break;
307 case 'ts_preserve':
308 $value = $this->TS_preserve_db($value);
309 break;
310 case 'ts_transform':
311 case 'css_transform':
312 $value = str_replace(CR,'',$value); // Has a very disturbing effect, so just remove all '13' - depend on '10'
313 $this->allowedClasses = t3lib_div::trimExplode(',', $this->procOptions['allowedClasses'], 1);
314 $value = $this->TS_transform_db($value,$cmd=='css_transform');
315 break;
316 case 'ts_strip':
317 $value = $this->TS_strip_db($value);
318 break;
319 default:
320 break;
321 }
322 }
323 }
324 // ->RTE
325 if ($direction=='rte') {
326 // Checking for user defined transformation:
327 if ($_classRef = $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_parsehtml_proc.php']['transformation'][$cmd]) {
328 $_procObj = t3lib_div::getUserObj($_classRef);
329 $_procObj->pObj = $this;
330 $value = $_procObj->transform_rte($value,$this);
331 } else { // ... else use defaults:
332 switch($cmd) {
333 case 'ts_images':
334 $value = $this->TS_images_rte($value);
335 break;
336 case 'ts_reglinks':
337 $value = $this->TS_reglinks($value,'rte');
338 break;
339 case 'ts_links':
340 $value = $this->TS_links_rte($value);
341 break;
342 case 'ts_preserve':
343 $value = $this->TS_preserve_rte($value);
344 break;
345 case 'ts_transform':
346 case 'css_transform':
347 $value = str_replace(CR,'',$value); // Has a very disturbing effect, so just remove all '13' - depend on '10'
348 $value = $this->TS_transform_rte($value,$cmd=='css_transform');
349 break;
350 default:
351 break;
352 }
353 }
354 }
355 }
356
357 // In an exit-cleaner was configured, pass value through the HTMLcleaner with that:
358 if (is_array($exit_HTMLparser)) {
359 $value = $this->HTMLcleaner($value,$exit_HTMLparser[0],$exit_HTMLparser[1],$exit_HTMLparser[2],$exit_HTMLparser[3]);
360 }
361
362 // Final clean up of linebreaks:
363 if (!$this->procOptions['disableUnifyLineBreaks']) {
364 $value = str_replace(CRLF,LF,$value); // Make sure no \r\n sequences has entered in the meantime...
365 $value = str_replace(LF,CRLF,$value); // ... and then change all \n into \r\n
366 }
367
368 // Return value:
369 return $value;
370 }
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387 /************************************
388 *
389 * Specific RTE TRANSFORMATION functions
390 *
391 *************************************/
392
393 /**
394 * Transformation handler: 'ts_images' / direction: "db"
395 * Processing images inserted in the RTE.
396 * This is used when content goes from the RTE to the database.
397 * Images inserted in the RTE has an absolute URL applied to the src attribute. This URL is converted to a relative URL
398 * If it turns out that the URL is from another website than the current the image is read from that external URL and moved to the local server.
399 * Also "magic" images are processed here.
400 *
401 * @param string The content from RTE going to Database
402 * @return string Processed content
403 */
404 function TS_images_db($value) {
405
406 // Split content by <img> tags and traverse the resulting array for processing:
407 $imgSplit = $this->splitTags('img',$value);
408 foreach($imgSplit as $k => $v) {
409 if ($k%2) { // image found, do processing:
410
411 // Init
412 $attribArray = $this->get_tag_attributes_classic($v,1);
413 $siteUrl = $this->siteUrl();
414 $sitePath = str_replace (t3lib_div::getIndpEnv('TYPO3_REQUEST_HOST'), '', $siteUrl);
415
416 $absRef = trim($attribArray['src']); // It's always a absolute URL coming from the RTE into the Database.
417
418 // make path absolute if it is relative and we have a site path wich is not '/'
419 $pI=pathinfo($absRef);
420 if($sitePath AND !$pI['scheme'] && t3lib_div::isFirstPartOfStr($absRef,$sitePath)) {
421 // if site is in a subpath (eg. /~user_jim/) this path needs to be removed because it will be added with $siteUrl
422 $absRef = substr($absRef,strlen($sitePath));
423 $absRef = $siteUrl.$absRef;
424 }
425
426 // External image from another URL? In that case, fetch image (unless disabled feature).
427 if (!t3lib_div::isFirstPartOfStr($absRef,$siteUrl) && !$this->procOptions['dontFetchExtPictures']) {
428 $externalFile = $this->getUrl($absRef); // Get it
429 if ($externalFile) {
430 $pU = parse_url($absRef);
431 $pI=pathinfo($pU['path']);
432
433 if (t3lib_div::inList('gif,png,jpeg,jpg',strtolower($pI['extension']))) {
434 $filename = t3lib_div::shortMD5($absRef).'.'.$pI['extension'];
435 $origFilePath = PATH_site.$this->rteImageStorageDir().'RTEmagicP_'.$filename;
436 $C_origFilePath = PATH_site.$this->rteImageStorageDir().'RTEmagicC_'.$filename.'.'.$pI['extension'];
437 if (!@is_file($origFilePath)) {
438 t3lib_div::writeFile($origFilePath,$externalFile);
439 t3lib_div::writeFile($C_origFilePath,$externalFile);
440 }
441 $absRef = $siteUrl.$this->rteImageStorageDir().'RTEmagicC_'.$filename.'.'.$pI['extension'];
442
443 $attribArray['src']=$absRef;
444 $params = t3lib_div::implodeAttributes($attribArray,1);
445 $imgSplit[$k] = '<img '.$params.' />';
446 }
447 }
448 }
449
450 // Check image as local file (siteURL equals the one of the image)
451 if (t3lib_div::isFirstPartOfStr($absRef,$siteUrl)) {
452 $path = rawurldecode(substr($absRef,strlen($siteUrl))); // Rel-path, rawurldecoded for special characters.
453 $filepath = t3lib_div::getFileAbsFileName($path); // Abs filepath, locked to relative path of this project.
454
455 // Check file existence (in relative dir to this installation!)
456 if ($filepath && @is_file($filepath)) {
457
458 // If "magic image":
459 $pathPre=$this->rteImageStorageDir().'RTEmagicC_';
460 if (t3lib_div::isFirstPartOfStr($path,$pathPre)) {
461 // Find original file:
462 $pI=pathinfo(substr($path,strlen($pathPre)));
463 $filename = substr($pI['basename'],0,-strlen('.'.$pI['extension']));
464 $origFilePath = PATH_site.$this->rteImageStorageDir().'RTEmagicP_'.$filename;
465 if (@is_file($origFilePath)) {
466 $imgObj = t3lib_div::makeInstance('t3lib_stdGraphic');
467 $imgObj->init();
468 $imgObj->mayScaleUp=0;
469 $imgObj->tempPath=PATH_site.$imgObj->tempPath;
470
471 $curInfo = $imgObj->getImageDimensions($filepath); // Image dimensions of the current image
472 $curWH = $this->getWHFromAttribs($attribArray); // Image dimensions as set in the image tag
473 // Compare dimensions:
474 if ($curWH[0]!=$curInfo[0] || $curWH[1]!=$curInfo[1]) {
475 $origImgInfo = $imgObj->getImageDimensions($origFilePath); // Image dimensions of the current image
476 $cW = $curWH[0];
477 $cH = $curWH[1];
478 $cH = 1000; // Make the image based on the width solely...
479 $imgI = $imgObj->imageMagickConvert($origFilePath,$pI['extension'],$cW.'m',$cH.'m');
480 if ($imgI[3]) {
481 $fI=pathinfo($imgI[3]);
482 @copy($imgI[3],$filepath); // Override the child file
483 // Removing width and heigth form style attribute
484 $attribArray['style'] = preg_replace('/((?:^|)\s*(?:width|height)\s*:[^;]*(?:$|;))/si', '', $attribArray['style']);
485 $attribArray['width']=$imgI[0];
486 $attribArray['height']=$imgI[1];
487 $params = t3lib_div::implodeAttributes($attribArray,1);
488 $imgSplit[$k]='<img '.$params.' />';
489 }
490 }
491 }
492
493 } elseif ($this->procOptions['plainImageMode']) { // If "plain image" has been configured:
494
495 // Image dimensions as set in the image tag, if any
496 $curWH = $this->getWHFromAttribs($attribArray);
497 if ($curWH[0]) $attribArray['width'] = $curWH[0];
498 if ($curWH[1]) $attribArray['height'] = $curWH[1];
499
500 // Removing width and heigth form style attribute
501 $attribArray['style'] = preg_replace('/((?:^|)\s*(?:width|height)\s*:[^;]*(?:$|;))/si', '', $attribArray['style']);
502
503 // Finding dimensions of image file:
504 $fI = @getimagesize($filepath);
505
506 // Perform corrections to aspect ratio based on configuration:
507 switch((string)$this->procOptions['plainImageMode']) {
508 case 'lockDimensions':
509 $attribArray['width']=$fI[0];
510 $attribArray['height']=$fI[1];
511 break;
512 case 'lockRatioWhenSmaller': // If the ratio has to be smaller, then first set the width...:
513 if ($attribArray['width']>$fI[0]) $attribArray['width'] = $fI[0];
514 case 'lockRatio':
515 if ($fI[0]>0) {
516 $attribArray['height']=round($attribArray['width']*($fI[1]/$fI[0]));
517 }
518 break;
519 }
520
521 // Compile the image tag again:
522 $params = t3lib_div::implodeAttributes($attribArray,1);
523 $imgSplit[$k]='<img '.$params.' />';
524 }
525 } else { // Remove image if it was not found in a proper position on the server!
526
527 // Commented out; removing the image tag might not be that logical...
528 #$imgSplit[$k]='';
529 }
530 }
531
532 // Convert abs to rel url
533 if ($imgSplit[$k]) {
534 $attribArray=$this->get_tag_attributes_classic($imgSplit[$k],1);
535 $absRef = trim($attribArray['src']);
536 if (t3lib_div::isFirstPartOfStr($absRef,$siteUrl)) {
537 $attribArray['src'] = $this->relBackPath.substr($absRef,strlen($siteUrl));
538 if (!isset($attribArray['alt'])) $attribArray['alt']=''; // Must have alt-attribute for XHTML compliance.
539 $imgSplit[$k]='<img '.t3lib_div::implodeAttributes($attribArray,1,1).' />';
540 }
541 }
542 }
543 }
544 return implode('',$imgSplit);
545 }
546
547 /**
548 * Transformation handler: 'ts_images' / direction: "rte"
549 * Processing images from database content going into the RTE.
550 * Processing includes converting the src attribute to an absolute URL.
551 *
552 * @param string Content input
553 * @return string Content output
554 */
555 function TS_images_rte($value) {
556
557 $siteUrl = $this->siteUrl();
558 $sitePath = str_replace (t3lib_div::getIndpEnv('TYPO3_REQUEST_HOST'), '', $siteUrl);
559
560 // Split content by <img> tags and traverse the resulting array for processing:
561 $imgSplit = $this->splitTags('img',$value);
562 foreach($imgSplit as $k => $v) {
563 if ($k%2) { // image found:
564
565 // Init
566 $attribArray=$this->get_tag_attributes_classic($v,1);
567 $absRef = trim($attribArray['src']);
568
569 // Unless the src attribute is already pointing to an external URL:
570 if (strtolower(substr($absRef,0,4))!='http') {
571 $attribArray['src'] = substr($attribArray['src'],strlen($this->relBackPath));
572 // if site is in a subpath (eg. /~user_jim/) this path needs to be removed because it will be added with $siteUrl
573 $attribArray['src'] = preg_replace('#^'.preg_quote($sitePath,'#').'#','',$attribArray['src']);
574 $attribArray['src'] = $siteUrl.$attribArray['src'];
575 if (!isset($attribArray['alt'])) $attribArray['alt']='';
576 $params = t3lib_div::implodeAttributes($attribArray);
577 $imgSplit[$k]='<img '.$params.' />';
578 }
579 }
580 }
581
582 // return processed content:
583 return implode('',$imgSplit);
584 }
585
586 /**
587 * Transformation handler: 'ts_reglinks' / direction: "db"+"rte" depending on $direction variable.
588 * Converting <A>-tags to/from abs/rel
589 *
590 * @param string Content input
591 * @param string Direction of conversion; "rte" (from database to RTE) or "db" (from RTE to database)
592 * @return string Content output
593 */
594 function TS_reglinks($value,$direction) {
595 $retVal = '';
596
597 switch($direction) {
598 case 'rte':
599 $retVal = $this->TS_AtagToAbs($value,1);
600 break;
601 case 'db':
602 $siteURL = $this->siteUrl();
603 $blockSplit = $this->splitIntoBlock('A',$value);
604 foreach ($blockSplit as $k => $v) {
605 if ($k%2) { // block:
606 $attribArray=$this->get_tag_attributes_classic($this->getFirstTag($v),1);
607 // If the url is local, remove url-prefix
608 if ($siteURL && substr($attribArray['href'],0,strlen($siteURL))==$siteURL) {
609 $attribArray['href']=$this->relBackPath.substr($attribArray['href'],strlen($siteURL));
610 }
611 $bTag='<a '.t3lib_div::implodeAttributes($attribArray,1).'>';
612 $eTag='</a>';
613 $blockSplit[$k] = $bTag.$this->TS_reglinks($this->removeFirstAndLastTag($blockSplit[$k]),$direction).$eTag;
614 }
615 }
616 $retVal = implode('',$blockSplit);
617 break;
618 }
619 return $retVal;
620 }
621
622 /**
623 * Transformation handler: 'ts_links' / direction: "db"
624 * Converting <A>-tags to <link tags>
625 *
626 * @param string Content input
627 * @return string Content output
628 * @see TS_links_rte()
629 */
630 function TS_links_db($value) {
631
632 // Split content into <a> tag blocks and process:
633 $blockSplit = $this->splitIntoBlock('A',$value);
634 foreach($blockSplit as $k => $v) {
635 if ($k%2) { // If an A-tag was found:
636 $attribArray = $this->get_tag_attributes_classic($this->getFirstTag($v),1);
637 $info = $this->urlInfoForLinkTags($attribArray['href']);
638
639 // Check options:
640 $attribArray_copy = $attribArray;
641 unset($attribArray_copy['href']);
642 unset($attribArray_copy['target']);
643 unset($attribArray_copy['class']);
644 unset($attribArray_copy['title']);
645 unset($attribArray_copy['external']);
646 if ($attribArray_copy['rteerror']) { // Unset "rteerror" and "style" attributes if "rteerror" is set!
647 unset($attribArray_copy['style']);
648 unset($attribArray_copy['rteerror']);
649 }
650 if (!count($attribArray_copy)) { // Only if href, target and class are the only attributes, we can alter the link!
651 // Quoting class and title attributes if they contain spaces
652 $attribArray['class'] = preg_match('/ /', $attribArray['class']) ? '"' . $attribArray['class'] . '"' : $attribArray['class'];
653 $attribArray['title'] = preg_match('/ /', $attribArray['title']) ? '"' . $attribArray['title'] . '"' : $attribArray['title'];
654 // Creating the TYPO3 pseudo-tag "<LINK>" for the link (includes href/url, target and class attributes):
655 // If external attribute is set, keep the href unchanged
656 $href = $attribArray['external'] ? $attribArray['href'] : $info['url'].($info['query']?',0,'.$info['query']:'');
657 $bTag='<link '. $href . ($attribArray['target']?' '.$attribArray['target']:(($attribArray['class'] || $attribArray['title'])?' -':'')).($attribArray['class']?' '.$attribArray['class']:($attribArray['title']?' -':'')).($attribArray['title']?' '.$attribArray['title']:'').'>';
658 $eTag='</link>';
659 $blockSplit[$k] = $bTag.$this->TS_links_db($this->removeFirstAndLastTag($blockSplit[$k])).$eTag;
660 } else { // ... otherwise store the link as a-tag.
661 // Unsetting 'rtekeep' attribute if that had been set.
662 unset($attribArray['rtekeep']);
663 if (!$attribArray['external']) {
664 // If the url is local, remove url-prefix
665 $siteURL = $this->siteUrl();
666 if ($siteURL && substr($attribArray['href'],0,strlen($siteURL))==$siteURL) {
667 $attribArray['href']=$this->relBackPath.substr($attribArray['href'],strlen($siteURL));
668 }
669 }
670 unset($attribArray['external']);
671 $bTag='<a '.t3lib_div::implodeAttributes($attribArray,1).'>';
672 $eTag='</a>';
673 $blockSplit[$k] = $bTag.$this->TS_links_db($this->removeFirstAndLastTag($blockSplit[$k])).$eTag;
674 }
675 }
676 }
677 return implode('',$blockSplit);
678 }
679
680 /**
681 * Transformation handler: 'ts_links' / direction: "rte"
682 * Converting <link tags> to <A>-tags
683 *
684 * @param string Content input
685 * @return string Content output
686 * @see TS_links_rte()
687 */
688 function TS_links_rte($value) {
689 $value = $this->TS_AtagToAbs($value);
690
691 // Split content by the TYPO3 pseudo tag "<link>":
692 $blockSplit = $this->splitIntoBlock('link',$value,1);
693 $siteUrl = $this->siteUrl();
694 foreach($blockSplit as $k => $v) {
695 $error = '';
696 if ($k%2) { // block:
697 $tagCode = t3lib_div::unQuoteFilenames(trim(substr($this->getFirstTag($v),0,-1)),true);
698 $link_param = $tagCode[1];
699 $href = '';
700 // Parsing the typolink data. This parsing is roughly done like in tslib_content->typolink()
701 if (strstr($link_param,'@')) { // mailadr
702 $href = 'mailto:'.preg_replace('/^mailto:/i','',$link_param);
703 } elseif (substr($link_param,0,1)=='#') { // check if anchor
704 $href = $siteUrl.$link_param;
705 } else {
706 $fileChar=intval(strpos($link_param, '/'));
707 $urlChar=intval(strpos($link_param, '.'));
708 $external = FALSE;
709 // Parse URL:
710 $pU = parse_url($link_param);
711 // Detects if a file is found in site-root OR is a simulateStaticDocument.
712 list($rootFileDat) = explode('?',$link_param);
713 $rFD_fI = pathinfo($rootFileDat);
714 if (trim($rootFileDat) && !strstr($link_param,'/') && (@is_file(PATH_site.$rootFileDat) || t3lib_div::inList('php,html,htm',strtolower($rFD_fI['extension'])))) {
715 $href = $siteUrl.$link_param;
716 } elseif ($pU['scheme'] || ($urlChar && (!$fileChar || $urlChar < $fileChar))) {
717 // url (external): if has scheme or if a '.' comes before a '/'.
718 $href = $link_param;
719 if (!$pU['scheme']) {
720 $href = 'http://' . $href;
721 }
722 $external = TRUE;
723 } elseif($fileChar) { // file (internal)
724 $href = $siteUrl.$link_param;
725 } else { // integer or alias (alias is without slashes or periods or commas, that is 'nospace,alphanum_x,lower,unique' according to tables.php!!)
726 // Splitting the parameter by ',' and if the array counts more than 1 element it's a id/type/parameters triplet
727 $pairParts = t3lib_div::trimExplode(',', $link_param, TRUE);
728 $idPart = $pairParts[0];
729 $link_params_parts = explode('#', $idPart);
730 $idPart = trim($link_params_parts[0]);
731 $sectionMark = trim($link_params_parts[1]);
732 if (!strcmp($idPart,'')) { $idPart=$this->recPid; } // If no id or alias is given, set it to class record pid
733 // Checking if the id-parameter is an alias.
734 if (!t3lib_div::testInt($idPart)) {
735 list($idPartR) = t3lib_BEfunc::getRecordsByField('pages','alias',$idPart);
736 $idPart = intval($idPartR['uid']);
737 }
738 $page = t3lib_BEfunc::getRecord('pages', $idPart);
739 if (is_array($page)) { // Page must exist...
740 $href = $siteUrl .'?id=' . $idPart . ($pairParts[2] ? $pairParts[2] : '') . ($sectionMark ? '#' . $sectionMark : '');
741 // linkHandler - allowing links to start with registerd linkHandler e.g.. "record:"
742 } elseif (isset($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tslib/class.tslib_content.php']['typolinkLinkHandler'][array_shift(explode(':', $link_param))])) {
743 $href = $link_param;
744 } else {
745 #$href = '';
746 $href = $siteUrl.'?id='.$link_param;
747 $error = 'No page found: '.$idPart;
748 }
749 }
750 }
751
752 // Setting the A-tag:
753 $bTag = '<a href="'.htmlspecialchars($href).'"'.
754 ($tagCode[2]&&$tagCode[2]!='-' ? ' target="'.htmlspecialchars($tagCode[2]).'"' : '').
755 ($tagCode[3]&&$tagCode[3]!='-' ? ' class="'.htmlspecialchars($tagCode[3]).'"' : '').
756 ($tagCode[4] ? ' title="'.htmlspecialchars($tagCode[4]).'"' : '').
757 ($external ? ' external="1"' : '').
758 ($error ? ' rteerror="'.htmlspecialchars($error).'" style="background-color: yellow; border:2px red solid; color: black;"' : ''). // Should be OK to add the style; the transformation back to databsae will remove it...
759 '>';
760 $eTag = '</a>';
761 $blockSplit[$k] = $bTag.$this->TS_links_rte($this->removeFirstAndLastTag($blockSplit[$k])).$eTag;
762 }
763 }
764
765 // Return content:
766 return implode('',$blockSplit);
767 }
768
769 /**
770 * Preserve special tags
771 *
772 * @param string Content input
773 * @return string Content output
774 */
775 function TS_preserve_db($value) {
776 if (!$this->preserveTags) return $value;
777
778 // Splitting into blocks for processing (span-tags are used for special tags)
779 $blockSplit = $this->splitIntoBlock('span',$value);
780 foreach($blockSplit as $k => $v) {
781 if ($k%2) { // block:
782 $attribArray=$this->get_tag_attributes_classic($this->getFirstTag($v));
783 if ($attribArray['specialtag']) {
784 $theTag = rawurldecode($attribArray['specialtag']);
785 $theTagName = $this->getFirstTagName($theTag);
786 $blockSplit[$k] = $theTag.$this->removeFirstAndLastTag($blockSplit[$k]).'</'.$theTagName.'>';
787 }
788 }
789 }
790 return implode('',$blockSplit);
791 }
792
793 /**
794 * Preserve special tags
795 *
796 * @param string Content input
797 * @return string Content output
798 */
799 function TS_preserve_rte($value) {
800 if (!$this->preserveTags) return $value;
801
802 $blockSplit = $this->splitIntoBlock($this->preserveTags,$value);
803 foreach($blockSplit as $k => $v) {
804 if ($k%2) { // block:
805 $blockSplit[$k] = '<span specialtag="'.rawurlencode($this->getFirstTag($v)).'">'.$this->removeFirstAndLastTag($blockSplit[$k]).'</span>';
806 }
807 }
808 return implode('',$blockSplit);
809 }
810
811 /**
812 * Transformation handler: 'ts_transform' + 'css_transform' / direction: "db"
813 * Cleaning (->db) for standard content elements (ts)
814 *
815 * @param string Content input
816 * @param boolean If true, the transformation was "css_transform", otherwise "ts_transform"
817 * @return string Content output
818 * @see TS_transform_rte()
819 */
820 function TS_transform_db($value,$css=FALSE) {
821
822 // safety... so forever loops are avoided (they should not occur, but an error would potentially do this...)
823 $this->TS_transform_db_safecounter--;
824 if ($this->TS_transform_db_safecounter<0) return $value;
825
826 // Split the content from RTE by the occurence of these blocks:
827 $blockSplit = $this->splitIntoBlock('TABLE,BLOCKQUOTE,'.($this->procOptions['preserveDIVSections']?'DIV,':'').$this->blockElementList,$value);
828
829 $cc=0;
830 $aC = count($blockSplit);
831
832 // Avoid superfluous linebreaks by transform_db after ending headListTag
833 while($aC && !strcmp(trim($blockSplit[$aC-1]),'')) {
834 unset($blockSplit[$aC-1]);
835 $aC = count($blockSplit);
836 }
837
838 // Traverse the blocks
839 foreach($blockSplit as $k => $v) {
840 $cc++;
841 $lastBR = $cc==$aC ? '' : LF;
842
843 if ($k%2) { // Inside block:
844
845 // Init:
846 $tag=$this->getFirstTag($v);
847 $tagName=strtolower($this->getFirstTagName($v));
848
849 // Process based on the tag:
850 switch($tagName) {
851 case 'blockquote': // Keep blockquotes, but clean the inside recursively in the same manner as the main code
852 case 'dd' : // Do the same on dd elements
853 case 'div': // Do the same on div sections, if they were splitted
854 $blockSplit[$k]=$tag.$this->TS_transform_db($this->removeFirstAndLastTag($blockSplit[$k]),$css).'</'.$tagName.'>'.$lastBR;
855 break;
856 case 'ol':
857 case 'ul': // Transform lists into <typolist>-tags:
858 if (!$css) {
859 if (!isset($this->procOptions['typolist']) || $this->procOptions['typolist']) {
860 $parts = $this->getAllParts($this->splitIntoBlock('LI',$this->removeFirstAndLastTag($blockSplit[$k])),1,0);
861 foreach ($parts as $k2 => $value) {
862 $parts[$k2]=preg_replace('/['.preg_quote(LF.CR).']+/','',$parts[$k2]); // remove all linesbreaks!
863 $parts[$k2]=$this->defaultTStagMapping($parts[$k2],'db');
864 $parts[$k2]=$this->cleanFontTags($parts[$k2],0,0,0);
865 $parts[$k2] = $this->HTMLcleaner_db($parts[$k2],strtolower($this->procOptions['allowTagsInTypolists']?$this->procOptions['allowTagsInTypolists']:'br,font,b,i,u,a,img,span,strong,em'));
866 }
867 if ($tagName=='ol') { $params=' type="1"'; } else { $params=''; }
868 $blockSplit[$k]='<typolist'.$params.'>'.LF.implode(LF,$parts).LF.'</typolist>'.$lastBR;
869 }
870 } else {
871 $blockSplit[$k]=preg_replace('/['.preg_quote(LF.CR).']+/',' ',$this->transformStyledATags($blockSplit[$k])).$lastBR;
872 }
873 break;
874 case 'table': // Tables are NOT allowed in any form (unless preserveTables is set or CSS is the mode)
875 if (!$this->procOptions['preserveTables'] && !$css) {
876 $blockSplit[$k]=$this->TS_transform_db($this->removeTables($blockSplit[$k]));
877 } else {
878 $blockSplit[$k]=preg_replace('/['.preg_quote(LF.CR).']+/',' ',$this->transformStyledATags($blockSplit[$k])).$lastBR;
879 }
880 break;
881 case 'h1':
882 case 'h2':
883 case 'h3':
884 case 'h4':
885 case 'h5':
886 case 'h6':
887 if (!$css) {
888 $attribArray=$this->get_tag_attributes_classic($tag);
889 // Processing inner content here:
890 $innerContent = $this->HTMLcleaner_db($this->removeFirstAndLastTag($blockSplit[$k]));
891
892 if (!isset($this->procOptions['typohead']) || $this->procOptions['typohead']) {
893 $type = intval(substr($tagName,1));
894 $blockSplit[$k]='<typohead'.
895 ($type!=6?' type="'.$type.'"':'').
896 ($attribArray['align']?' align="'.$attribArray['align'].'"':'').
897 ($attribArray['class']?' class="'.$attribArray['class'].'"':'').
898 '>'.
899 $innerContent.
900 '</typohead>'.
901 $lastBR;
902 } else {
903 $blockSplit[$k]='<'.$tagName.
904 ($attribArray['align']?' align="'.htmlspecialchars($attribArray['align']).'"':'').
905 ($attribArray['class']?' class="'.htmlspecialchars($attribArray['class']).'"':'').
906 '>'.
907 $innerContent.
908 '</'.$tagName.'>'.
909 $lastBR;
910 }
911 } else {
912 // Eliminate true linebreaks inside Hx tags
913 $blockSplit[$k]=preg_replace('/['.preg_quote(LF.CR).']+/',' ',$this->transformStyledATags($blockSplit[$k])).$lastBR;
914 }
915 break;
916 default:
917 // Eliminate true linebreaks inside other headlist tags and after hr tag
918 $blockSplit[$k]=preg_replace('/['.preg_quote(LF.CR).']+/',' ',$this->transformStyledATags($blockSplit[$k])).$lastBR;
919 break;
920 }
921 } else { // NON-block:
922 if (strcmp(trim($blockSplit[$k]),'')) {
923 $blockSplit[$k]=$this->divideIntoLines(preg_replace('/['.preg_quote(LF.CR).']+/',' ',$blockSplit[$k])).$lastBR;
924 $blockSplit[$k]=$this->transformStyledATags($blockSplit[$k]);
925 } else unset($blockSplit[$k]);
926 }
927 }
928 $this->TS_transform_db_safecounter++;
929
930 return implode('',$blockSplit);
931 }
932
933 /**
934 * Wraps a-tags that contain a style attribute with a span-tag
935 *
936 * @param string Content input
937 * @return string Content output
938 */
939 function transformStyledATags($value) {
940 $blockSplit = $this->splitIntoBlock('A',$value);
941 foreach($blockSplit as $k => $v) {
942 if ($k%2) { // If an A-tag was found:
943 $attribArray = $this->get_tag_attributes_classic($this->getFirstTag($v),1);
944 if ($attribArray['style']) { // If "style" attribute is set!
945 $attribArray_copy['style'] = $attribArray['style'];
946 unset($attribArray['style']);
947 $bTag='<span '.t3lib_div::implodeAttributes($attribArray_copy,1).'><a '.t3lib_div::implodeAttributes($attribArray,1).'>';
948 $eTag='</a></span>';
949 $blockSplit[$k] = $bTag.$this->removeFirstAndLastTag($blockSplit[$k]).$eTag;
950 }
951 }
952 }
953 return implode('',$blockSplit);
954 }
955
956 /**
957 * Transformation handler: 'ts_transform' + 'css_transform' / direction: "rte"
958 * Set (->rte) for standard content elements (ts)
959 *
960 * @param string Content input
961 * @param boolean If true, the transformation was "css_transform", otherwise "ts_transform"
962 * @return string Content output
963 * @see TS_transform_db()
964 */
965 function TS_transform_rte($value,$css=0) {
966
967 // Split the content from Database by the occurence of these blocks:
968 $blockSplit = $this->splitIntoBlock('TABLE,BLOCKQUOTE,TYPOLIST,TYPOHEAD,'.($this->procOptions['preserveDIVSections']?'DIV,':'').$this->blockElementList,$value);
969
970 // Traverse the blocks
971 foreach($blockSplit as $k => $v) {
972 if ($k%2) { // Inside one of the blocks:
973
974 // Init:
975 $tag = $this->getFirstTag($v);
976 $tagName = strtolower($this->getFirstTagName($v));
977 $attribArray = $this->get_tag_attributes_classic($tag);
978
979 // Based on tagname, we do transformations:
980 switch($tagName) {
981 case 'blockquote': // Keep blockquotes
982 case 'dd': // Keep definitions
983 case 'div': // Keep div sections, if they were splitted
984 $blockSplit[$k] = $tag.
985 $this->TS_transform_rte($this->removeFirstAndLastTag($blockSplit[$k]),$css).
986 '</'.$tagName.'>';
987 break;
988 case 'typolist': // Transform typolist blocks into OL/UL lists. Type 1 is expected to be numerical block
989 if (!isset($this->procOptions['typolist']) || $this->procOptions['typolist']) {
990 $tListContent = $this->removeFirstAndLastTag($blockSplit[$k]);
991 $tListContent = preg_replace('/^[ ]*'.LF.'/','',$tListContent);
992 $tListContent = preg_replace('/'.LF.'[ ]*$/','',$tListContent);
993 $lines = explode(LF,$tListContent);
994 $typ = $attribArray['type']==1 ? 'ol' : 'ul';
995 $blockSplit[$k] = '<'.$typ.'>'.LF.
996 '<li>'.implode('</li>'.LF.'<li>',$lines).'</li>'.
997 '</'.$typ.'>';
998 }
999 break;
1000 case 'typohead': // Transform typohead into Hx tags.
1001 if (!isset($this->procOptions['typohead']) || $this->procOptions['typohead']) {
1002 $tC = $this->removeFirstAndLastTag($blockSplit[$k]);
1003 $typ = t3lib_div::intInRange($attribArray['type'],0,6);
1004 if (!$typ) $typ=6;
1005 $align = $attribArray['align']?' align="'.$attribArray['align'].'"': '';
1006 $class = $attribArray['class']?' class="'.$attribArray['class'].'"': '';
1007 $blockSplit[$k] = '<h'.$typ.$align.$class.'>'.
1008 $tC.
1009 '</h'.$typ.'>';
1010 }
1011 break;
1012 }
1013 $blockSplit[$k+1] = preg_replace('/^[ ]*'.LF.'/','',$blockSplit[$k+1]); // Removing linebreak if typohead
1014 } else { // NON-block:
1015 $nextFTN = $this->getFirstTagName($blockSplit[$k+1]);
1016 $singleLineBreak = $blockSplit[$k]==LF;
1017 if (t3lib_div::inList('TABLE,BLOCKQUOTE,TYPOLIST,TYPOHEAD,'.($this->procOptions['preserveDIVSections']?'DIV,':'').$this->blockElementList,$nextFTN)) { // Removing linebreak if typolist/typohead
1018 $blockSplit[$k] = preg_replace('/'.LF.'[ ]*$/','',$blockSplit[$k]);
1019 }
1020 // If $blockSplit[$k] is blank then unset the line. UNLESS the line happend to be a single line break.
1021 if (!strcmp($blockSplit[$k],'') && !$singleLineBreak) {
1022 unset($blockSplit[$k]);
1023 } else {
1024 $blockSplit[$k] = $this->setDivTags($blockSplit[$k],($this->procOptions['useDIVasParagraphTagForRTE']?'div':'p'));
1025 }
1026 }
1027 }
1028 return implode(LF,$blockSplit);
1029 }
1030
1031 /**
1032 * Transformation handler: 'ts_strip' / direction: "db"
1033 * Removing all non-allowed tags
1034 *
1035 * @param string Content input
1036 * @return string Content output
1037 */
1038 function TS_strip_db($value) {
1039 $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')).'>');
1040 return $value;
1041 }
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056 /***************************************************************
1057 *
1058 * Generic RTE transformation, analysis and helper functions
1059 *
1060 **************************************************************/
1061
1062 /**
1063 * Reads the file or url $url and returns the content
1064 *
1065 * @param string Filepath/URL to read
1066 * @return string The content from the resource given as input.
1067 * @see t3lib_div::getURL()
1068 */
1069 function getURL($url) {
1070 return t3lib_div::getURL($url);
1071 }
1072
1073 /**
1074 * Function for cleaning content going into the database.
1075 * Content is cleaned eg. by removing unallowed HTML and ds-HSC content
1076 * It is basically calling HTMLcleaner from the parent class with some preset configuration specifically set up for cleaning content going from the RTE into the db
1077 *
1078 * @param string Content to clean up
1079 * @param string Comma list of tags to specifically allow. Default comes from getKeepTags and is ""
1080 * @return string Clean content
1081 * @see getKeepTags()
1082 */
1083 function HTMLcleaner_db($content,$tagList='') {
1084 if (!$tagList) {
1085 $keepTags = $this->getKeepTags('db');
1086 } else {
1087 $keepTags = $this->getKeepTags('db',$tagList);
1088 }
1089 $kUknown = $this->procOptions['dontRemoveUnknownTags_db'] ? 1 : 0; // Default: remove unknown tags.
1090 $hSC = $this->procOptions['dontUndoHSC_db'] ? 0 : -1; // Default: re-convert literals to characters (that is &lt; to <)
1091
1092 // Create additional configuration in order to honor the setting RTE.default.proc.HTMLparser_db.xhtml_cleaning=1
1093 $addConfig=array();
1094 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'])) {
1095 $addConfig['xhtml']=1;
1096 }
1097
1098 return $this->HTMLcleaner($content,$keepTags,$kUknown,$hSC,$addConfig);
1099 }
1100
1101 /**
1102 * Creates an array of configuration for the HTMLcleaner function based on whether content go TO or FROM the Rich Text Editor ($direction)
1103 * Unless "tagList" is given, the function will cache the configuration for next time processing goes on. (In this class that is the case only if we are processing a bulletlist)
1104 *
1105 * @param string The direction of the content being processed by the output configuration; "db" (content going into the database FROM the rte) or "rte" (content going into the form)
1106 * @param string Comma list of tags to keep (overriding default which is to keep all + take notice of internal configuration)
1107 * @return array Configuration array
1108 * @see HTMLcleaner_db()
1109 */
1110 function getKeepTags($direction='rte',$tagList='') {
1111 if (!is_array($this->getKeepTags_cache[$direction]) || $tagList) {
1112
1113 // Setting up allowed tags:
1114 if (strcmp($tagList,'')) { // If the $tagList input var is set, this will take precedence
1115 $keepTags = array_flip(t3lib_div::trimExplode(',',$tagList,1));
1116 } else { // Default is to get allowed/denied tags from internal array of processing options:
1117 // Construct default list of tags to keep:
1118 $typoScript_list = 'b,i,u,a,img,br,div,center,pre,font,hr,sub,sup,p,strong,em,li,ul,ol,blockquote,strike,span';
1119 $keepTags = array_flip(t3lib_div::trimExplode(',',$typoScript_list.','.strtolower($this->procOptions['allowTags']),1));
1120
1121 // For tags to deny, remove them from $keepTags array:
1122 $denyTags = t3lib_div::trimExplode(',',$this->procOptions['denyTags'],1);
1123 foreach($denyTags as $dKe) {
1124 unset($keepTags[$dKe]);
1125 }
1126 }
1127
1128 // Based on the direction of content, set further options:
1129 switch ($direction) {
1130
1131 // GOING from database to Rich Text Editor:
1132 case 'rte':
1133
1134 if (!isset($this->procOptions['transformBoldAndItalicTags']) || $this->procOptions['transformBoldAndItalicTags']) {
1135 // Transform bold/italics tags to strong/em
1136 if (isset($keepTags['b'])) {$keepTags['b']=array('remap'=>'STRONG');}
1137 if (isset($keepTags['i'])) {$keepTags['i']=array('remap'=>'EM');}
1138 }
1139
1140 // Transforming keepTags array so it can be understood by the HTMLcleaner function. This basically converts the format of the array from TypoScript (having .'s) to plain multi-dimensional array.
1141 list($keepTags) = $this->HTMLparserConfig($this->procOptions['HTMLparser_rte.'],$keepTags);
1142 break;
1143
1144 // GOING from RTE to database:
1145 case 'db':
1146
1147 if (!isset($this->procOptions['transformBoldAndItalicTags']) || $this->procOptions['transformBoldAndItalicTags']) {
1148 // Transform strong/em back to bold/italics:
1149 if (isset($keepTags['strong'])) { $keepTags['strong']=array('remap'=>'b'); }
1150 if (isset($keepTags['em'])) { $keepTags['em']=array('remap'=>'i'); }
1151 }
1152
1153 // Setting up span tags if they are allowed:
1154 if (isset($keepTags['span'])) {
1155 $classes=array_merge(array(''),$this->allowedClasses);
1156 $keepTags['span']=array(
1157 'allowedAttribs' => 'id,class,style,title,lang,xml:lang,dir',
1158 'fixAttrib' => Array(
1159 'class' => Array (
1160 'list' => $classes,
1161 'removeIfFalse' => 1
1162 ),
1163 ),
1164 'rmTagIfNoAttrib' => 1
1165 );
1166 if (!$this->procOptions['allowedClasses']) unset($keepTags['span']['fixAttrib']['class']['list']);
1167 }
1168
1169 // Setting up font tags if they are allowed:
1170 if (isset($keepTags['font'])) {
1171 $colors=array_merge(array(''),t3lib_div::trimExplode(',',$this->procOptions['allowedFontColors'],1));
1172 $keepTags['font']=array(
1173 'allowedAttribs'=>'face,color,size',
1174 'fixAttrib' => Array(
1175 'face' => Array (
1176 'removeIfFalse' => 1
1177 ),
1178 'color' => Array (
1179 'removeIfFalse' => 1,
1180 'list'=>$colors
1181 ),
1182 'size' => Array (
1183 'removeIfFalse' => 1,
1184 )
1185 ),
1186 'rmTagIfNoAttrib' => 1
1187 );
1188 if (!$this->procOptions['allowedFontColors']) unset($keepTags['font']['fixAttrib']['color']['list']);
1189 }
1190
1191 // Setting further options, getting them from the processiong options:
1192 $TSc = $this->procOptions['HTMLparser_db.'];
1193 if (!$TSc['globalNesting']) $TSc['globalNesting']='b,i,u,a,center,font,sub,sup,strong,em,strike,span';
1194 if (!$TSc['noAttrib']) $TSc['noAttrib']='b,i,u,br,center,hr,sub,sup,strong,em,li,ul,ol,blockquote,strike';
1195
1196 // Transforming the array from TypoScript to regular array:
1197 list($keepTags) = $this->HTMLparserConfig($TSc,$keepTags);
1198 break;
1199 }
1200
1201 // Caching (internally, in object memory) the result unless tagList is set:
1202 if (!$tagList) {
1203 $this->getKeepTags_cache[$direction] = $keepTags;
1204 } else {
1205 return $keepTags;
1206 }
1207 }
1208
1209 // Return result:
1210 return $this->getKeepTags_cache[$direction];
1211 }
1212
1213 /**
1214 * This resolves the $value into parts based on <div></div>-sections and <p>-sections and <br />-tags. These are returned as lines separated by LF.
1215 * This point is to resolve the HTML-code returned from RTE into ordinary lines so it's 'human-readable'
1216 * The function ->setDivTags does the opposite.
1217 * This function processes content to go into the database.
1218 *
1219 * @param string Value to process.
1220 * @param integer Recursion brake. Decremented on each recursion down to zero. Default is 5 (which equals the allowed nesting levels of p/div tags).
1221 * @param boolean If true, an array with the lines is returned, otherwise a string of the processed input value.
1222 * @return string Processed input value.
1223 * @see setDivTags()
1224 */
1225 function divideIntoLines($value,$count=5,$returnArray=FALSE) {
1226
1227 // Internalize font tags (move them from OUTSIDE p/div to inside it that is the case):
1228 if ($this->procOptions['internalizeFontTags']) {$value = $this->internalizeFontTags($value);}
1229
1230 // Setting configuration for processing:
1231 $allowTagsOutside = t3lib_div::trimExplode(',',strtolower($this->procOptions['allowTagsOutside']?$this->procOptions['allowTagsOutside']:'img'),1);
1232 $remapParagraphTag = strtoupper($this->procOptions['remapParagraphTag']);
1233 $divSplit = $this->splitIntoBlock('div,p',$value,1); // Setting the third param to 1 will eliminate false end-tags. Maybe this is a good thing to do...?
1234
1235 if ($this->procOptions['keepPDIVattribs']) {
1236 $keepAttribListArr = t3lib_div::trimExplode(',',strtolower($this->procOptions['keepPDIVattribs']),1);
1237 } else {
1238 $keepAttribListArr = array();
1239 }
1240
1241 // Returns plainly the value if there was no div/p sections in it
1242 if (count($divSplit)<=1 || $count<=0) {
1243 return $value;
1244 }
1245
1246 // Traverse the splitted sections:
1247 foreach($divSplit as $k => $v) {
1248 if ($k%2) { // Inside
1249 $v=$this->removeFirstAndLastTag($v);
1250
1251 // Fetching 'sub-lines' - which will explode any further p/div nesting...
1252 $subLines = $this->divideIntoLines($v,$count-1,1);
1253 if (is_array($subLines)) { // So, if there happend to be sub-nesting of p/div, this is written directly as the new content of THIS section. (This would be considered 'an error')
1254 // No noting.
1255 } else { //... but if NO subsection was found, we process it as a TRUE line without erronous content:
1256 $subLines = array($subLines);
1257 if (!$this->procOptions['dontConvBRtoParagraph']) { // process break-tags, if configured for. Simply, the breaktags will here be treated like if each was a line of content...
1258 $subLines = preg_split('/<br[[:space:]]*[\/]?>/i', $v);
1259 }
1260
1261 // Traverse sublines (there is typically one, except if <br/> has been converted to lines as well!)
1262 foreach ($subLines as $sk => $value) {
1263
1264 // Clear up the subline for DB.
1265 $subLines[$sk]=$this->HTMLcleaner_db($subLines[$sk]);
1266
1267 // Get first tag, attributes etc:
1268 $fTag = $this->getFirstTag($divSplit[$k]);
1269 $tagName=strtolower($this->getFirstTagName($divSplit[$k]));
1270 $attribs=$this->get_tag_attributes($fTag);
1271
1272 // Keep attributes (lowercase)
1273 $newAttribs=array();
1274 if (count($keepAttribListArr)) {
1275 foreach($keepAttribListArr as $keepA) {
1276 if (isset($attribs[0][$keepA])) { $newAttribs[$keepA] = $attribs[0][$keepA]; }
1277 }
1278 }
1279
1280 // ALIGN attribute:
1281 if (!$this->procOptions['skipAlign'] && strcmp(trim($attribs[0]['align']),'') && strtolower($attribs[0]['align'])!='left') { // Set to value, but not 'left'
1282 $newAttribs['align']=strtolower($attribs[0]['align']);
1283 }
1284
1285 // CLASS attribute:
1286 if (!$this->procOptions['skipClass'] && strcmp(trim($attribs[0]['class']),'')) { // Set to whatever value
1287 if (!count($this->allowedClasses) || in_array($attribs[0]['class'], $this->allowedClasses)) {
1288 $newAttribs['class'] = $attribs[0]['class'];
1289 } else {
1290 $classes = t3lib_div::trimExplode(' ', $attribs[0]['class'], true);
1291 $newClasses = array();
1292 foreach ($classes as $class) {
1293 if (in_array($class, $this->allowedClasses)) {
1294 $newClasses[] = $class;
1295 }
1296 }
1297 if (count($newClasses)) {
1298 $newAttribs['class'] = implode(' ', $newClasses);
1299 }
1300 }
1301 }
1302
1303 // Remove any line break char (10 or 13)
1304 $subLines[$sk]=preg_replace('/'.LF.'|'.CR.'/','',$subLines[$sk]);
1305
1306 // If there are any attributes or if we are supposed to remap the tag, then do so:
1307 if (count($newAttribs) && strcmp($remapParagraphTag,'1')) {
1308 if ($remapParagraphTag=='P') $tagName='p';
1309 if ($remapParagraphTag=='DIV') $tagName='div';
1310 $subLines[$sk]='<'.trim($tagName.' '.$this->compileTagAttribs($newAttribs)).'>'.$subLines[$sk].'</'.$tagName.'>';
1311 }
1312 }
1313 }
1314 // Add the processed line(s)
1315 $divSplit[$k] = implode(LF,$subLines);
1316
1317 // If it turns out the line is just blank (containing a &nbsp; possibly) then just make it pure blank.
1318 // But, prevent filtering of lines that are blank in sense above, but whose tags contain attributes.
1319 // Those attributes should have been filtered before; if they are still there they must be considered as possible content.
1320 if (trim(strip_tags($divSplit[$k]))=='&nbsp;' && !preg_match('/\<(img)(\s[^>]*)?\/?>/si', $divSplit[$k]) && !preg_match('/\<([^>]*)?( align| class| style| id| title| dir| lang| xml:lang)([^>]*)?>/si', trim($divSplit[$k]))) {
1321 $divSplit[$k]='';
1322 }
1323 } else { // outside div:
1324 // Remove positions which are outside div/p tags and without content
1325 $divSplit[$k]=trim(strip_tags($divSplit[$k],'<'.implode('><',$allowTagsOutside).'>'));
1326 if (!strcmp($divSplit[$k],'')) unset($divSplit[$k]); // Remove part if it's empty
1327 }
1328 }
1329
1330 // Return value:
1331 return $returnArray ? $divSplit : implode(LF,$divSplit);
1332 }
1333
1334 /**
1335 * Converts all lines into <div></div>/<p></p>-sections (unless the line is a div-section already)
1336 * For processing of content going FROM database TO RTE.
1337 *
1338 * @param string Value to convert
1339 * @param string Tag to wrap with. Either "p" or "div" should it be. Lowercase preferably.
1340 * @return string Processed value.
1341 * @see divideIntoLines()
1342 */
1343 function setDivTags($value,$dT='p') {
1344
1345 // First, setting configuration for the HTMLcleaner function. This will process each line between the <div>/<p> section on their way to the RTE
1346 $keepTags = $this->getKeepTags('rte');
1347 $kUknown = $this->procOptions['dontProtectUnknownTags_rte'] ? 0 : 'protect'; // Default: remove unknown tags.
1348 $hSC = $this->procOptions['dontHSC_rte'] ? 0 : 1; // Default: re-convert literals to characters (that is &lt; to <)
1349 $convNBSP = !$this->procOptions['dontConvAmpInNBSP_rte']?1:0;
1350
1351 // Divide the content into lines, based on LF:
1352 $parts = explode(LF,$value);
1353 foreach($parts as $k => $v) {
1354
1355 // Processing of line content:
1356 if (!strcmp(trim($parts[$k]),'')) { // If the line is blank, set it to &nbsp;
1357 $parts[$k]='&nbsp;';
1358 } else { // Clean the line content:
1359 $parts[$k]=$this->HTMLcleaner($parts[$k],$keepTags,$kUknown,$hSC);
1360 if ($convNBSP) $parts[$k]=str_replace('&amp;nbsp;','&nbsp;',$parts[$k]);
1361 }
1362
1363 // Wrapping the line in <$dT> is not already wrapped:
1364 $testStr = strtolower(trim($parts[$k]));
1365 if (substr($testStr,0,4)!='<div' || substr($testStr,-6)!='</div>') {
1366 if (substr($testStr,0,2)!='<p' || substr($testStr,-4)!='</p>') {
1367 // Only set p-tags if there is not already div or p tags:
1368 $parts[$k]='<'.$dT.'>'.$parts[$k].'</'.$dT.'>';
1369 }
1370 }
1371 }
1372
1373 // Implode result:
1374 return implode(LF,$parts);
1375 }
1376
1377 /**
1378 * This splits the $value in font-tag chunks.
1379 * If there are any <P>/<DIV> sections inside of them, the font-tag is wrapped AROUND the content INSIDE of the P/DIV sections and the outer font-tag is removed.
1380 * This functions seems to be a good choice for pre-processing content if it has been pasted into the RTE from eg. star-office.
1381 * In that case the font-tags are normally on the OUTSIDE of the sections.
1382 * This function is used by eg. divideIntoLines() if the procesing option 'internalizeFontTags' is set.
1383 *
1384 * @param string Input content
1385 * @return string Output content
1386 * @see divideIntoLines()
1387 */
1388 function internalizeFontTags($value) {
1389
1390 // Splitting into font tag blocks:
1391 $fontSplit = $this->splitIntoBlock('font',$value);
1392
1393 foreach($fontSplit as $k => $v) {
1394 if ($k%2) { // Inside
1395 $fTag = $this->getFirstTag($v); // Fint font-tag
1396
1397 $divSplit_sub = $this->splitIntoBlock('div,p',$this->removeFirstAndLastTag($v),1);
1398 if (count($divSplit_sub)>1) { // If there were div/p sections inside the font-tag, do something about it...
1399 // traverse those sections:
1400 foreach($divSplit_sub as $k2 => $v2) {
1401 if ($k2%2) { // Inside
1402 $div_p = $this->getFirstTag($v2); // Fint font-tag
1403 $div_p_tagname = $this->getFirstTagName($v2); // Fint font-tag
1404 $v2=$this->removeFirstAndLastTag($v2); // ... and remove it from original.
1405 $divSplit_sub[$k2]=$div_p.$fTag.$v2.'</font>'.'</'.$div_p_tagname.'>';
1406 } elseif (trim(strip_tags($v2))) {
1407 $divSplit_sub[$k2]=$fTag.$v2.'</font>';
1408 }
1409 }
1410 $fontSplit[$k]=implode('',$divSplit_sub);
1411 }
1412 }
1413 }
1414
1415 return implode('',$fontSplit);
1416 }
1417
1418 /**
1419 * Returns SiteURL based on thisScript.
1420 *
1421 * @return string Value of t3lib_div::getIndpEnv('TYPO3_SITE_URL');
1422 * @see t3lib_div::getIndpEnv()
1423 */
1424 function siteUrl() {
1425 return t3lib_div::getIndpEnv('TYPO3_SITE_URL');
1426 }
1427
1428 /**
1429 * Return the storage folder of RTE image files.
1430 * Default is $GLOBALS['TYPO3_CONF_VARS']['BE']['RTE_imageStorageDir'] unless something else is configured in the types configuration for the RTE.
1431 *
1432 * @return string
1433 */
1434 function rteImageStorageDir() {
1435 return $this->rte_p['imgpath'] ? $this->rte_p['imgpath'] : $GLOBALS['TYPO3_CONF_VARS']['BE']['RTE_imageStorageDir'];
1436 }
1437
1438 /**
1439 * Remove all tables from incoming code
1440 * The function is trying to to this is some more or less respectfull way. The approach is to resolve each table cells content and implode it all by <br /> chars. Thus at least the content is preserved in some way.
1441 *
1442 * @param string Input value
1443 * @param string Break character to use for linebreaks.
1444 * @return string Output value
1445 */
1446 function removeTables($value,$breakChar='<br />') {
1447
1448 // Splitting value into table blocks:
1449 $tableSplit = $this->splitIntoBlock('table',$value);
1450
1451 // Traverse blocks of tables:
1452 foreach($tableSplit as $k => $v) {
1453 if ($k%2) {
1454 $tableSplit[$k]='';
1455 $rowSplit = $this->splitIntoBlock('tr',$v);
1456 foreach($rowSplit as $k2 => $v2) {
1457 if ($k2%2) {
1458 $cellSplit = $this->getAllParts($this->splitIntoBlock('td',$v2),1,0);
1459 foreach($cellSplit as $k3 => $v3) {
1460 $tableSplit[$k].=$v3.$breakChar;
1461 }
1462 }
1463 }
1464 }
1465 }
1466
1467 // Implode it all again:
1468 return implode($breakChar,$tableSplit);
1469 }
1470
1471 /**
1472 * Default tag mapping for TS
1473 *
1474 * @param string Input code to process
1475 * @param string Direction To databsae (db) or from database to RTE (rte)
1476 * @return string Processed value
1477 */
1478 function defaultTStagMapping($code,$direction='rte') {
1479 if ($direction=='db') {
1480 $code=$this->mapTags($code,array( // Map tags
1481 'strong' => 'b',
1482 'em' => 'i'
1483 ));
1484 }
1485 if ($direction=='rte') {
1486 $code=$this->mapTags($code,array( // Map tags
1487 'b' => 'strong',
1488 'i' => 'em'
1489 ));
1490 }
1491 return $code;
1492 }
1493
1494 /**
1495 * Finds width and height from attrib-array
1496 * If the width and height is found in the style-attribute, use that!
1497 *
1498 * @param array Array of attributes from tag in which to search. More specifically the content of the key "style" is used to extract "width:xxx / height:xxx" information
1499 * @return array Integer w/h in key 0/1. Zero is returned if not found.
1500 */
1501 function getWHFromAttribs($attribArray) {
1502 $style =trim($attribArray['style']);
1503 if ($style) {
1504 $regex='[[:space:]]*:[[:space:]]*([0-9]*)[[:space:]]*px';
1505 // Width
1506 $reg = array();
1507 preg_match('/width'.$regex.'/i',$style,$reg);
1508 $w = intval($reg[1]);
1509 // Height
1510 preg_match('/height'.$regex.'/i',$style,$reg);
1511 $h = intval($reg[1]);
1512 }
1513 if (!$w) {
1514 $w = $attribArray['width'];
1515 }
1516 if (!$h) {
1517 $h = $attribArray['height'];
1518 }
1519 return array(intval($w),intval($h));
1520 }
1521
1522 /**
1523 * Parse <A>-tag href and return status of email,external,file or page
1524 *
1525 * @param string URL to analyse.
1526 * @return array Information in an array about the URL
1527 */
1528 function urlInfoForLinkTags($url) {
1529 $info = array();
1530 $url = trim($url);
1531 if (substr(strtolower($url),0,7)=='mailto:') {
1532 $info['url']=trim(substr($url,7));
1533 $info['type']='email';
1534 } else {
1535 $curURL = $this->siteUrl(); // 100502, removed this: 'http://'.t3lib_div::getThisUrl(); Reason: The url returned had typo3/ in the end - should be only the site's url as far as I see...
1536 for($a=0;$a<strlen($url);$a++) {
1537 if ($url{$a}!=$curURL{$a}) {
1538 break;
1539 }
1540 }
1541
1542 $info['relScriptPath']=substr($curURL,$a);
1543 $info['relUrl']=substr($url,$a);
1544 $info['url']=$url;
1545 $info['type']='ext';
1546
1547 $siteUrl_parts = parse_url($url);
1548 $curUrl_parts = parse_url($curURL);
1549
1550 if ($siteUrl_parts['host']==$curUrl_parts['host'] // Hosts should match
1551 && (!$info['relScriptPath'] || (defined('TYPO3_mainDir') && substr($info['relScriptPath'],0,strlen(TYPO3_mainDir))==TYPO3_mainDir))) { // If the script path seems to match or is empty (FE-EDIT)
1552
1553 // New processing order 100502
1554 $uP=parse_url($info['relUrl']);
1555
1556 if (!strcmp('#'.$siteUrl_parts['fragment'],$info['relUrl'])) {
1557 $info['url']=$info['relUrl'];
1558 $info['type']='anchor';
1559 } elseif (!trim($uP['path']) || !strcmp($uP['path'],'index.php')) {
1560 // URL is a page (id parameter)
1561 $pp = preg_split('/^id=/', $uP['query']);
1562 $pp[1] = preg_replace( '/&id=[^&]*/', '', $pp[1]);
1563 $parameters = explode('&', $pp[1]);
1564 $id = array_shift($parameters);
1565 if ($id) {
1566 $info['pageid']=$id;
1567 $info['cElement']=$uP['fragment'];
1568 $info['url']=$id.($info['cElement']?'#'.$info['cElement']:'');
1569 $info['type']='page';
1570 $info['query'] = $parameters[0]?'&'.implode('&', $parameters):'';
1571 }
1572 } else {
1573 $info['url']=$info['relUrl'];
1574 $info['type']='file';
1575 }
1576 } else {
1577 unset($info['relScriptPath']);
1578 unset($info['relUrl']);
1579 }
1580 }
1581 return $info;
1582 }
1583
1584 /**
1585 * Converting <A>-tags to absolute URLs (+ setting rtekeep attribute)
1586 *
1587 * @param string Content input
1588 * @param boolean If true, then the "rtekeep" attribute will not be set.
1589 * @return string Content output
1590 */
1591 function TS_AtagToAbs($value,$dontSetRTEKEEP=FALSE) {
1592 $blockSplit = $this->splitIntoBlock('A',$value);
1593 foreach ($blockSplit as $k => $v) {
1594 if ($k%2) { // block:
1595 $attribArray = $this->get_tag_attributes_classic($this->getFirstTag($v),1);
1596
1597 // Checking if there is a scheme, and if not, prepend the current url.
1598 if (strlen($attribArray['href'])) { // ONLY do this if href has content - the <a> tag COULD be an anchor and if so, it should be preserved...
1599 $uP = parse_url(strtolower($attribArray['href']));
1600 if (!$uP['scheme']) {
1601 $attribArray['href'] = $this->siteUrl().substr($attribArray['href'],strlen($this->relBackPath));
1602 } elseif ($uP['scheme'] != 'mailto') {
1603 $attribArray['external'] = 1;
1604 }
1605 } else {
1606 $attribArray['rtekeep'] = 1;
1607 }
1608 if (!$dontSetRTEKEEP) $attribArray['rtekeep'] = 1;
1609
1610 $bTag='<a '.t3lib_div::implodeAttributes($attribArray,1).'>';
1611 $eTag='</a>';
1612 $blockSplit[$k] = $bTag.$this->TS_AtagToAbs($this->removeFirstAndLastTag($blockSplit[$k])).$eTag;
1613 }
1614 }
1615 return implode('',$blockSplit);
1616 }
1617 }
1618
1619
1620 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['t3lib/class.t3lib_parsehtml_proc.php']) {
1621 include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['t3lib/class.t3lib_parsehtml_proc.php']);
1622 }
1623
1624 ?>