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