3f84ca50fd313bc0b9d2c498619c60364f066de3
[Packages/TYPO3.CMS.git] / typo3 / sysext / cms / tslib / media / scripts / plaintextLib.inc
1 <?php
2 /***************************************************************
3 *  Copyright notice
4 *
5 *  (c) 1999-2009 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  * Generating plain text content of content elements for Direct Mails
29  *
30  * Revised for TYPO3 3.6 June/2003 by Kasper Skårhøj
31  *
32  * @author Kasper Skårhøj <kasperYYYY@typo3.com>
33  */
34
35 /**
36  * Alternative rendering of content elements for Plain Text emails. That means text-only output. No HTML at all. Used by the Direct Mail extension.
37  * Normally the plain text output should appear with type=99.
38  * To use this library you can include the static template "plugin.alt.plaintext"
39  *
40  * ## Insert DMailer Boundaries for all elements.
41  * config.insertDmailerBoundaries = 1
42  * includeLibs.plaintextLib = media/scripts/plaintextLib.inc
43  *
44  * ## Set up page/type number:
45  * alt_plaintext >
46  * alt_plaintext = PAGE
47  * alt_plaintext.typeNum=99
48  * alt_plaintext.config.disableAllHeaderCode = 1
49  * alt_plaintext.10 = TEMPLATE
50  * alt_plaintext.10 {
51  *   template = FILE
52  *   template.file = {$plugin.alt.plaintext.file.template}
53  *   marks.CONTENT < styles.content.get
54  *   marks.CONTENT.renderObj = < lib.alt_plaintext.renderObj
55  *   marks.DATE = TEXT
56  *   marks.DATE.data = date:U
57  *   marks.DATE.strftime = %e. %B %Y
58  * }
59  *
60  * (And then also "lib.alt_plaintext.renderObj" is configured extensively - basically with the TypoScript options passed to this class. See the static template "plugin.alt.plaintext")
61  *
62  * @author Kasper Skårhøj <kasperYYYY@typo3.com>
63  * @package TYPO3
64  * @subpackage tslib
65  */
66 class user_plaintext {
67         var $cObj;
68         var $conf = array();
69         var $charWidth = 76;
70
71         /**
72          * Main function, called from TypoScript
73          * A content object that renders "tt_content" records. See the comment to this class for TypoScript example of how to trigger it.
74          * This detects the CType of the current content element and renders it accordingly. Only wellknown types are rendered.
75          *
76          * @param string $content Empty, ignore.
77          * @param array $conf TypoScript properties for this content object/function call
78          * @return string Plain text content
79          */
80         function main_plaintext($content, $conf) {
81                 $this->conf = $conf;
82                 $this->siteUrl=$conf['siteUrl'];
83                 $lines = array();
84                 $CType= (string)$this->cObj->data['CType'];
85                 switch($CType) {
86                         case 'header':
87                                 $lines[]=$this->getHeader();
88                                 if ($this->cObj->data['subheader']) {
89                                         $lines[]=$this->breakContent(strip_tags($this->cObj->data['subheader']));
90                                 }
91                         break;
92                         case 'text':
93                         case 'textpic':
94                                 $lines[]=$this->getHeader();
95                                 if ($CType=='textpic' && !($this->cObj->data['imageorient']&24)) {
96                                         $lines[]=$this->getImages();
97                                         $lines[]='';
98                                 }
99                                 $lines[]=$this->breakContent(strip_tags($this->parseBody($this->cObj->data['bodytext'])));
100                                 if ($CType=='textpic' && ($this->cObj->data['imageorient']&24)) {
101                                         $lines[]='';
102                                         $lines[]=$this->getImages();
103                                 }
104                         break;
105                         case 'image':
106                                 $lines[]=$this->getHeader();
107                                 $lines[]=$this->getImages();
108                         break;
109                         case 'uploads':
110                                 $lines[]=$this->getHeader();
111                                 $lines[]=$this->renderUploads($this->cObj->data['media']);
112                         break;
113                         case 'menu':
114                                 $lines[]=$this->getHeader();
115                                 $lines[]=$this->getMenuSitemap();
116                         break;
117                         case 'shortcut':
118                                 $lines[]=$this->getShortcut();
119                         break;
120                         case 'bullets':
121                                 $lines[]=$this->getHeader();
122                                 $lines[]=$this->breakBulletlist(strip_tags($this->parseBody($this->cObj->data['bodytext'])));
123                         break;
124                         case 'list':
125                                 $lines[]=$this->getHeader();
126                                 $lines[]=$this->getList();
127                         break;
128                         case 'table':
129                                 $lines[]=$this->getHeader();
130                                 $lines[]=$this->breakTable(strip_tags($this->parseBody($this->cObj->data['bodytext'])));
131                         break;
132                         case 'html':
133                                 $lines[]=$this->getHTML();
134                         break;
135                         default:
136                                 $defaultOutput = $this->getString($this->conf['defaultOutput']);
137                                 if ($defaultOutput) {
138                                         $lines[]=str_replace('###CType###', $CType, $defaultOutput);
139                                 }
140                         break;
141                 }
142
143                         // First break.
144                 $lines[] = '';
145                 $content = implode(chr(10), $lines);
146
147                         // User processing:
148                 $content=$this->userProcess('userProc', $content);
149                 return $content;
150         }
151
152         /**
153          * Creates a menu/sitemap
154          *
155          * @return string Content
156          */
157         function getMenuSitemap() {
158                 $str = $this->cObj->cObjGetSingle($this->conf['menu'], $this->conf['menu.']);
159                 $str = $this->breakBulletlist(trim(strip_tags(preg_replace('/<br[ \/]*>/i', chr(10), $this->parseBody($str)))));
160                 return $str;
161         }
162
163         /**
164          * Creates a shortcut ("Insert Records")
165          *
166          * @return string Content
167          */
168         function getShortcut() {
169                 $str = $this->cObj->cObjGetSingle($this->conf['shortcut'], $this->conf['shortcut.']);
170                 return $str;
171         }
172
173         /**
174          * Creates an HTML element (stripping tags of course)
175          *
176          * @param string $str HTML content to process. If not passed along, the bodytext field is used.
177          * @return string Content
178          */
179         function getHTML($str = array()) {
180                 return $this->breakContent(strip_tags(preg_replace('/<br[ \/]*>/i', chr(10), $this->parseBody(is_string($str) ? $str : $this->cObj->data['bodytext']))));
181         }
182
183         /**
184          * Creates a header (used for most elements)
185          *
186          * @return string Content
187          * @see renderHeader()
188          */
189         function getHeader() {
190                         // links...
191                 return $this->renderHeader($this->cObj->data['header'], $this->cObj->data['header_layout']);
192         }
193
194         /**
195          * Get images found in the "image" field of "tt_content"
196          *
197          * @return string Content
198          */
199         function getImages() {
200                 $images = $this->renderImages($this->cObj->data['image'], !$this->cObj->data['image_zoom'] ? $this->cObj->data['image_link'] : '', $this->cObj->data['imagecaption']);
201                 return $images;
202         }
203
204         /**
205          * Parsing the bodytext field content, removing typical entities and <br /> tags.
206          *
207          * @param string $str Field content from "bodytext"
208          * @return string Processed content
209          */
210         function parseBody($str) {
211                         // First, regular parsing:
212                 $str = preg_replace('/<br[ \/]*>/i', ' ', $str);
213                 $str = $this->cObj->stdWrap($str, $this->conf['bodytext.']['stdWrap.']);
214                         // Then all a-tags:
215                 $aConf = array();
216                 $aConf['parseFunc.']['tags.']['a']='USER';
217                 $aConf['parseFunc.']['tags.']['a.']['userFunc'] = 'user_plaintext->atag_to_http';
218                 $aConf['parseFunc.']['tags.']['a.']['siteUrl'] = $this->siteUrl;
219
220                 $str = $this->cObj->stdWrap($str, $aConf);
221                 $str = str_replace('&nbsp;', ' ', t3lib_div::htmlspecialchars_decode($str));
222                 return $str;
223         }
224
225         /**
226          * Creates a list of links to uploaded files.
227          *
228          * @param string $str List of uploaded filenames from "uploads/media/" (or $upload_path)
229          * @param string $upload_path Alternative path value
230          * @return string Content
231          */
232         function renderUploads($str, $upload_path = 'uploads/media/') {
233                 $files = explode(',', $str);
234                 $lines = array();
235                 if ($this->conf['uploads.']['header']) {
236                         $lines[] = $this->getString($this->conf['uploads.']['header']);
237                 }
238                 foreach ($files as $k => $file) {
239                         $lines[] = $this->siteUrl.$upload_path.$file;
240                 }
241                 return implode(chr(10), $lines);
242         }
243
244         /**
245          * Creates a list
246          *
247          * @param string $CType Type of content
248          * @return string Content
249          */
250         function getList($CType = 'list') {
251                 $str = $this->cObj->cObjGetSingle($this->conf[$CType], $this->conf[$CType . '.']);
252                 return trim(strip_tags($this->parseBody($str)));
253         }
254
255         /**
256          * Renders a content element header, observing the layout type giving different header formattings
257          *
258          * @param string $str The header string
259          * @param integer $type The layout type of the header (in the content element)
260          * @return string Content
261          */
262         function renderHeader($str, $type = 0) {
263                 if ($str) {
264                         $hConf = $this->conf['header.'];
265                         $defaultType = t3lib_utility_Math::forceIntegerInRange($hConf['defaultType'], 1, 5);
266                         $type=t3lib_utility_Math::forceIntegerInRange($type, 0, 6);
267                         if (!$type)     $type = $defaultType;
268                                 // not hidden
269                         if ($type != 6) {
270                                 $tConf = $hConf[$type.'.'];
271
272                                 $lines=array();
273
274                                 $blanks = t3lib_utility_Math::forceIntegerInRange($tConf['preBlanks'], 0, 1000);
275                                 if ($blanks) {
276                                         $lines[]=str_pad('', $blanks-1, chr(10));
277                                 }
278
279                                 $lines=$this->pad($lines, $tConf['preLineChar'], $tConf['preLineLen']);
280
281                                 $blanks = t3lib_utility_Math::forceIntegerInRange($tConf['preLineBlanks'], 0, 1000);
282                                 if ($blanks)    {$lines[]=str_pad('', $blanks-1, chr(10));}
283
284                                 if ($this->cObj->data['date']) {
285                                         $lines[] = $this->getString($hConf['datePrefix']) . date($hConf['date'] ? $hConf['date'] : $GLOBALS['TYPO3_CONF_VARS']['SYS']['ddmmyy'], $this->cObj->data['date']);
286                                 }
287                                 $prefix = '';
288                                 $str = $this->getString($tConf['prefix']).$str;
289                                 if ($tConf['autonumber'])       $str=$this->cObj->parentRecordNumber.$str;
290                                 if ($this->cObj->data['header_position']=='right')      {$prefix=str_pad(' ', ($this->charWidth-strlen($str)));}
291                                 if ($this->cObj->data['header_position']=='center')     {$prefix=str_pad(' ', floor(($this->charWidth-strlen($str))/2));}
292                                 $lines[]=$this->cObj->stdWrap($prefix.$str, $tConf['stdWrap.']);
293                                 if ($this->cObj->data['header_link'])           {$lines[] = $this->getString($hConf['linkPrefix']).$this->getLink($this->cObj->data['header_link']);}
294
295                                 $blanks = t3lib_utility_Math::forceIntegerInRange($tConf['postLineBlanks'], 0, 1000);
296                                 if ($blanks) {
297                                         $lines[] = str_pad('', $blanks-1, chr(10));
298                                 }
299
300                                 $lines=$this->pad($lines, $tConf['postLineChar'], $tConf['postLineLen']);
301
302                                 $blanks = t3lib_utility_Math::forceIntegerInRange($tConf['postBlanks'], 0, 1000);
303                                 if ($blanks) {
304                                         $lines[] = str_pad('', $blanks-1, chr(10));
305                                 }
306                                 return implode(chr(10), $lines);
307                         }
308                 }
309         }
310
311         /**
312          * Function used to repeat a char pattern in head lines (like if you want "********" above/below a header)
313          *
314          * @param array $lines Array of existing lines to which the new char-pattern should be added
315          * @param string $preLineChar The character pattern to repeat. Default is "-"
316          * @param integer $len The length of the line. $preLineChar will be repeated to fill in this length.
317          * @return array The input array with a new line added.
318          * @see renderHeader()
319          */
320         function pad($lines, $preLineChar, $len) {
321                 $strPad = t3lib_utility_Math::forceIntegerInRange($len, 0, 1000);
322                 $strPadChar = $preLineChar?$preLineChar:'-';
323                 if ($strPad) {
324                         $lines[]=str_pad('', $strPad, $strPadChar);
325                 }
326                 return $lines;
327         }
328
329         /**
330          * Function used to wrap the bodytext field content (or image caption) into lines of a max length of
331          *
332          * @param string The content to break
333          * @return string Processed value.
334          * @see main_plaintext(), breakLines()
335          */
336         function breakContent($str) {
337                 $cParts = explode(chr(10), $str);
338                 $lines = array();
339                 foreach ($cParts as $substrs) {
340                         $lines[] = $this->breakLines($substrs);
341                 }
342                 return implode(chr(10), $lines);
343         }
344
345         /**
346          * Breaks content lines into a bullet list
347          *
348          * @param string $str Content string to make into a bullet list
349          * @return string Processed value
350          */
351         function breakBulletlist($str) {
352                 $type = $this->cObj->data['layout'];
353                 $type=t3lib_utility_Math::forceIntegerInRange($type, 0, 3);
354
355                 $tConf = $this->conf['bulletlist.'][$type.'.'];
356
357                 $cParts = explode(chr(10), $str);
358                 $lines = array();
359                 $c = 0;
360                 foreach ($cParts as $substrs) {
361                         $c++;
362                         $bullet = $tConf['bullet'] ? $this->getString($tConf['bullet']) : ' - ';
363                         $bLen = strlen($bullet);
364                         $bullet = substr(str_replace('#', $c, $bullet), 0, $bLen);
365                         $secondRow = substr($tConf['secondRow'] ? $this->getString($tConf['secondRow']) : str_pad('', strlen($bullet), ' '), 0, $bLen);
366
367                         $lines[] = $bullet . $this->breakLines($substrs, chr(10) . $secondRow, $this->charWidth-$bLen);
368
369                         $blanks = t3lib_utility_Math::forceIntegerInRange($tConf['blanks'], 0, 1000);
370                         if ($blanks) {
371                                 $lines[]=str_pad('', $blanks-1, chr(10));
372                         }
373                 }
374                 return implode(chr(10), $lines);
375         }
376
377         /**
378          * Formatting a table in plain text (based on the paradigm of lines being content rows and cells separated by "|")
379          *
380          * @param string $str Content string
381          * @return string Processed value
382          */
383         function breakTable($str) {
384                 $cParts = explode(chr(10), $str);
385                 $lines = array();
386                 $cols = intval($this->conf['cols']) ? intval($this->conf['cols']) : 0;
387                 $c = 0;
388                 foreach ($cParts as $substrs) {
389                         $c++;
390                         if (trim($substrs)) {
391                                 $lineParts=explode('|', $substrs);
392                                 if (!$cols)     $cols=count($lineParts);
393
394                                 for ($a=0;$a<$cols;$a++) {
395                                         $jdu = explode(chr(10), $this->breakLines($lineParts[$a], chr(10), ceil($this->charWidth/$cols)));
396                                         $lines[$c][$a]=$jdu;
397                                 }
398                         }
399                 }
400                 $messure = $this->traverseTable($lines);
401
402                 $divChar = '-';
403                 $joinChar = '+';
404                 $colChar = '|';
405
406                         // Make table:
407                 $outLines = array();
408                 $outLines[] = $this->addDiv($messure, '', $divChar, $joinChar, $cols);
409
410                 foreach ($lines as $k => $v) {
411                         $top = intval($messure[1][$k]);
412                         for ($aa = 0; $aa < $top; $aa++) {
413                                 $tempArr = array();
414                                 for ($bb = 0; $bb < $cols; $bb++) {
415                                         $tempArr[$bb]=str_pad($v[$bb][$aa], $messure[0][$bb], ' ');
416                                 }
417                                 $outLines[] = $colChar . implode($colChar, $tempArr) . $colChar;
418                         }
419                         $outLines[] = $this->addDiv($messure, '', $divChar, $joinChar, $cols);
420                 }
421                 return implode(chr(10), $outLines);
422         }
423
424         /**
425          * Subfunction for breakTable(): Adds a divider line between table rows.
426          *
427          * @param array $messure Some information about sizes
428          * @param string $content Empty string.
429          * @param string $divChar Character to use for the divider line, typically "-"
430          * @param string $joinChar Join character, typically "+"
431          * @param integer $colsNumber of table columns
432          * @return string Divider line for the table
433          * @access private
434          * @see breakTable()
435          */
436         function addDiv($messure, $content, $divChar, $joinChar, $cols) {
437                 $tempArr=array();
438                 for ($a=0;$a<$cols;$a++) {
439                         $tempArr[$a]=str_pad($content, $messure[0][$a], $divChar);
440                 }
441                 return $joinChar . implode($joinChar, $tempArr) . $joinChar;
442         }
443
444         /**
445          * Traverses the table lines/cells and creates arrays with statistics for line numbers and lengths
446          *
447          * @param array $tableLines Array with [table rows] [table cells] [lines in cell]
448          * @return array Statistics (max lines/lengths)
449          * @access private
450          * @see breakTable()
451          */
452         function traverseTable($tableLines) {
453                 $maxLen=array();
454                 $maxLines=array();
455                 foreach ($tableLines as $k => $v) {
456                         foreach ($v as $kk => $vv) {
457                                 foreach ($vv as $lk => $lv) {
458                                         if (strlen($lv)>intval($maxLen[$kk]))   $maxLen[$kk]=strlen($lv);
459                                 }
460                                 if (count($vv)>intval($maxLines[$k]))   $maxLines[$k]=count($vv);
461                         }
462                 }
463                 return array($maxLen, $maxLines);
464         }
465
466         /**
467          * Render block of images - which means creating lines with links to the images.
468          *
469          * @param string $str List of image filenames (from "image" field in tt_content records)
470          * @param string $links Link value from the "image_link" field in tt_content records
471          * @param string $caption Caption text
472          * @param string $upload_path Alternative relative path for the files listed in $str
473          * @return string Content
474          * @see getImages()
475          */
476         function renderImages($str, $links, $caption, $upload_path = 'uploads/pics/') {
477                 $images = explode(',', $str);
478                 $linksArr = explode(LF, $links);
479                 $lines = array();
480                 if ($this->conf['images.']['header'])   {
481                         $lines[] = $this->getString($this->conf['images.']['header']);
482                 }
483                 foreach ($images as $k => $file) {
484                         $lines[]=$this->siteUrl.$upload_path.$file;
485                         if ($links && count($linksArr)>1) {
486                                 if (isset($linksArr[$k])) {
487                                         $ll=$linksArr[$k];
488                                 } else {
489                                         $ll=$linksArr[0];
490                                 }
491
492                                 $theLink = $this->getLink($ll);
493                                 if ($theLink)   {$lines[]=$this->getString($this->conf['images.']['linkPrefix']).$theLink;}
494                         }
495                 }
496                 if ($links && count($linksArr) == 1) {
497                         $theLink = $this->getLink($links);
498                         if ($theLink)   {$lines[]=$this->getString($this->conf['images.']['linkPrefix']).$theLink;}
499                 }
500                 if ($caption) {
501                         $lines[] = '';
502                         $cHeader = trim($this->getString($this->conf['images.']['captionHeader']));
503                         if ($cHeader)           $lines[] = $cHeader;
504                         $lines[] = $this->breakContent($caption);
505                 }
506
507                 return implode(chr(10), $lines);
508         }
509
510         /**
511          * Returns a typolink URL based on input.
512          *
513          * @param string $ll Parameter to typolink
514          * @return string The URL returned from $this->cObj->getTypoLink_URL(); - possibly it prefixed with the URL of the site if not present already
515          */
516         function getLink($ll) {
517                 $theLink=$this->cObj->getTypoLink_URL($ll);
518                 if (substr($theLink, 0, 4) != 'http') {
519                         $theLink=$this->siteUrl.$theLink;
520                 }
521                 return $theLink;
522         }
523
524         /**
525          * Breaking lines into fixed length lines, using t3lib_div::breakLinesForEmail()
526          *
527          * @param string $str The string to break
528          * @param string $implChar Line break character
529          * @param integer $charWidth Length of lines, default is $this->charWidth
530          * @return string Processed string
531          * @see t3lib_div::breakLinesForEmail()
532          */
533         function breakLines($str, $implChar = "\n", $charWidth = 0) {
534                 return t3lib_div::breakLinesForEmail($str, $implChar, $charWidth ? $charWidth : $this->charWidth);
535         }
536
537         /**
538          * Explodes a string with "|" and if the second part is found it will return this, otherwise the first part.
539          * Used for many TypoScript properties used in this class since they need preceeding whitespace to be preserved.
540          *
541          * @param string $str Input string
542          * @return string Output string
543          * @access private
544          */
545         function getString($str) {
546                 $parts = explode('|', $str);
547                 return strcmp($parts[1], '') ? $parts[1] : $parts[0];
548         }
549
550         /**
551          * Calls a user function for processing of data
552          *
553          * @param string $mConfKey TypoScript property name, pointing to the definition of the user function to call (from the TypoScript array internally in this class). This array is passed to the user function. Notice that "parentObj" property is a reference to this class ($this)
554          * @param mixed $passVar Variable to process
555          * @return mixed The processed $passVar as returned by the function call
556          */
557         function userProcess($mConfKey, $passVar) {
558                 if ($this->conf[$mConfKey]) {
559                         $funcConf = $this->conf[$mConfKey.'.'];
560                         $funcConf['parentObj'] = $this;
561                         $passVar = $GLOBALS['TSFE']->cObj->callUserFunction($this->conf[$mConfKey], $funcConf, $passVar);
562                 }
563                 return $passVar;
564         }
565
566         /**
567          * Function used by TypoScript "parseFunc" to process links in the bodytext.
568          * Extracts the link and shows it in plain text in a parathesis next to the link text. If link was relative the site URL was prepended.
569          *
570          * @param string $content Empty, ignore.
571          * @param array $conf TypoScript parameters
572          * @return string Processed output.
573          * @see parseBody()
574          */
575         function atag_to_http($content, $conf) {
576                 $this->conf = $conf;
577                 $this->siteUrl=$conf['siteUrl'];
578                 $theLink  = trim($this->cObj->parameters['href']);
579                 if (strtolower(substr($theLink, 0, 7)) == 'mailto:') {
580                         $theLink = substr($theLink, 7);
581                 } elseif (substr($theLink, 0, 4) != 'http') {
582                         $theLink=$this->siteUrl.$theLink;
583                 }
584                 return $this->cObj->getCurrentVal().' (Link: '.$theLink.' )';
585         }
586
587         /**
588          * User function (called from TypoScript) for generating a bullet list (used in parsefunc)
589          *
590          * @param string $content Empty, ignore.
591          * @param array $conf TypoScript parameters
592          * @return string Processed output.
593          */
594         function typolist($content, $conf) {
595                 $this->conf = $this->cObj->mergeTSRef($conf, 'bulletlist');
596                 $this->siteUrl=$conf['siteUrl'];
597                 $str = trim($this->cObj->getCurrentVal());
598                 $this->cObj->data['layout'] = $this->cObj->parameters['type'];
599                 return $this->breakBulletlist($str);
600         }
601
602         /**
603          * User function (called from TypoScript) for generating a typo header tag (used in parsefunc)
604          *
605          * @param string $content Empty, ignore.
606          * @param array $conf TypoScript parameters
607          * @return string Processed output.
608          */
609         function typohead($content, $conf) {
610                 $this->conf = $this->cObj->mergeTSRef($conf, 'header');
611
612                 $this->siteUrl=$conf['siteUrl'];
613                 $str = trim($this->cObj->getCurrentVal());
614                 $this->cObj->data['header_layout'] = $this->cObj->parameters['type'];
615                 $this->cObj->data['header_position'] = $this->cObj->parameters['align'];
616                 $this->cObj->data['header'] = $str;
617
618                 return $this->getHeader();
619         }
620
621         /**
622          * User function (called from TypoScript) for generating a code listing (used in parsefunc)
623          *
624          * @param string $content Empty, ignore.
625          * @param array $conf TypoScript parameters
626          * @return string Processed output.
627          */
628         function typocode($content, $conf) {
629                         // Nothing is really done here...
630                 $this->conf = $conf;
631                 $this->siteUrl = $conf['siteUrl'];
632                 return $this->cObj->getCurrentVal();
633         }
634 }
635
636 if (defined('TYPO3_MODE') && isset($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['media/scripts/plaintextLib.inc'])) {
637         include_once($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['media/scripts/plaintextLib.inc']);
638 }
639 ?>