Fixed bug #103: No Plain-text List Option
[Packages/TYPO3.CMS.git] / typo3 / sysext / statictemplates / 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: plaintextLib.inc 5947 2009-09-16 17:57:09Z ohader $
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                 reset($files);
291                 $lines=array();
292                 if ($this->conf['uploads.']['header'])  {$lines[]=$this->getString($this->conf['uploads.']['header']);}
293                 while(list($k,$file)=each($files))      {
294                         $lines[]=$this->siteUrl.$upload_path.$file;
295                 }
296                 return implode(chr(10),$lines);
297         }
298
299         /**
300          * Creates a list
301          *
302          * @param       string  type of content
303          * @return      string  Content
304          */
305         function getList($CType = 'list') {
306                 $str = $this->cObj->cObjGetSingle($this->conf[$CType], $this->conf[$CType . '.']);
307                 return trim(strip_tags($this->parseBody($str)));
308         }
309
310         /**
311          * Renders a content element header, observing the layout type giving different header formattings
312          *
313          * @param       string          The header string
314          * @param       integer         The layout type of the header (in the content element)
315          * @return      string          Content
316          */
317         function renderHeader($str,$type=0)     {
318                 if ($str)       {
319                         $hConf = $this->conf['header.'];
320                         $defaultType = t3lib_div::intInRange($hConf['defaultType'],1,5);
321                         $type=t3lib_div::intInRange($type,0,6);
322                         if (!$type)     $type=$defaultType;
323                         if ($type!=6)   {       // not hidden
324                                 $tConf = $hConf[$type.'.'];
325
326                                 $lines=array();
327
328                                 $blanks = t3lib_div::intInRange($tConf['preBlanks'],0,1000);
329                                 if ($blanks)    {
330                                         $lines[]=str_pad('', $blanks-1, chr(10));
331                                 }
332
333                                 $lines=$this->pad($lines,$tConf['preLineChar'],$tConf['preLineLen']);
334
335                                 $blanks = t3lib_div::intInRange($tConf['preLineBlanks'],0,1000);
336                                 if ($blanks)    {$lines[]=str_pad('', $blanks-1, chr(10));}
337
338                                 if ($this->cObj->data['date'])  {
339                                         $lines[] = $this->getString($hConf['datePrefix']).date($hConf['date']?$hConf['date']:$GLOBALS['TYPO3_CONF_VARS']['SYS']['ddmmyy'],$this->cObj->data['date']);
340                                 }
341                                 $prefix='';
342                                 $str=$this->getString($tConf['prefix']).$str;
343                                 if ($tConf['autonumber'])       $str=$this->cObj->parentRecordNumber.$str;
344                                 if ($this->cObj->data['header_position']=='right')      {$prefix=str_pad(' ',($this->charWidth-strlen($str)));}
345                                 if ($this->cObj->data['header_position']=='center')     {$prefix=str_pad(' ',floor(($this->charWidth-strlen($str))/2));}
346                                 $lines[]=$this->cObj->stdWrap($prefix.$str,$tConf['stdWrap.']);
347                                 if ($this->cObj->data['header_link'])           {$lines[] = $this->getString($hConf['linkPrefix']).$this->getLink($this->cObj->data['header_link']);}
348
349                                 $blanks = t3lib_div::intInRange($tConf['postLineBlanks'],0,1000);
350                                 if ($blanks)    {$lines[]=str_pad('', $blanks-1, chr(10));}
351
352                                 $lines=$this->pad($lines,$tConf['postLineChar'],$tConf['postLineLen']);
353
354                                 $blanks = t3lib_div::intInRange($tConf['postBlanks'],0,1000);
355                                 if ($blanks)    {$lines[]=str_pad('', $blanks-1, chr(10));}
356                                 return implode(chr(10),$lines);
357                         }
358                 }
359         }
360
361         /**
362          * Function used to repeat a char pattern in head lines (like if you want "********" above/below a header)
363          *
364          * @param       array           Array of existing lines to which the new char-pattern should be added
365          * @param       string          The character pattern to repeat. Default is "-"
366          * @param       integer         The length of the line. $preLineChar will be repeated to fill in this length.
367          * @return      array           The input array with a new line added.
368          * @see renderHeader()
369          */
370         function pad($lines,$preLineChar,$len)  {
371                 $strPad = t3lib_div::intInRange($len,0,1000);
372                 $strPadChar = $preLineChar?$preLineChar:'-';
373                 if ($strPad)    {
374                         $lines[]=str_pad('', $strPad, $strPadChar);
375                 }
376                 return $lines;
377         }
378
379         /**
380          * Function used to wrap the bodytext field content (or image caption) into lines of a max length of
381          *
382          * @param       string          The content to break
383          * @return      string          Processed value.
384          * @see main_plaintext(), breakLines()
385          */
386         function breakContent($str)     {
387                 $cParts = explode(chr(10),$str);
388                 reset($cParts);
389                 $lines=array();
390                 while(list(,$substrs)=each($cParts))    {
391                         $lines[]=$this->breakLines($substrs);
392                 }
393                 return implode(chr(10),$lines);
394         }
395
396         /**
397          * Breaks content lines into a bullet list
398          *
399          * @param       string          Content string to make into a bullet list
400          * @return      string          Processed value
401          */
402         function breakBulletlist($str)  {
403                 $type = $this->cObj->data['layout'];
404                 $type=t3lib_div::intInRange($type,0,3);
405
406                 $tConf = $this->conf['bulletlist.'][$type.'.'];
407
408                 $cParts = explode(chr(10),$str);
409                 reset($cParts);
410                 $lines=array();
411                 $c=0;
412                 while(list(,$substrs)=each($cParts))    {
413                         $c++;
414                         $bullet = $tConf['bullet'] ? $this->getString($tConf['bullet']) : ' - ';
415                         $bLen=strlen($bullet);
416                         $bullet = substr(str_replace('#',$c,$bullet),0,$bLen);
417                         $secondRow = substr($tConf['secondRow']?$this->getString($tConf['secondRow']):str_pad('',strlen($bullet),' '),0,$bLen);
418
419                         $lines[]=$bullet.$this->breakLines($substrs,chr(10).$secondRow,$this->charWidth-$bLen);
420
421                         $blanks = t3lib_div::intInRange($tConf['blanks'],0,1000);
422                         if ($blanks)    {$lines[]=str_pad('', $blanks-1, chr(10));}
423                 }
424                 return implode(chr(10),$lines);
425         }
426
427         /**
428          * Formatting a table in plain text (based on the paradigm of lines being content rows and cells separated by "|")
429          *
430          * @param       string          Content string
431          * @return      string          Processed value
432          */
433         function breakTable($str)       {
434                 $cParts = explode(chr(10),$str);
435                 reset($cParts);
436                 $lines=array();
437                 $cols = intval($this->conf['cols']) ? intval($this->conf['cols']) : 0 ;
438                 $c=0;
439                 while(list(,$substrs)=each($cParts))    {
440                         $c++;
441                         if (trim($substrs))     {
442                                 $lineParts=explode('|',$substrs);
443                                 if (!$cols)     $cols=count($lineParts);
444
445                                 for ($a=0;$a<$cols;$a++)        {
446                                         $jdu = explode(chr(10),$this->breakLines($lineParts[$a],chr(10),ceil($this->charWidth/$cols)));
447                                         $lines[$c][$a]=$jdu;
448                                 }
449                         }
450                 }
451                 $messure = $this->traverseTable($lines);
452
453
454                 $divChar='-';
455                 $joinChar='+';
456                 $colChar='|';
457
458                 // Make table:
459                 $outLines = array();
460                 $outLines[]=$this->addDiv($messure,'',$divChar,$joinChar,$cols);
461
462                 reset($lines);
463                 while(list($k,$v)=each($lines)) {
464                         $top = intval($messure[1][$k]);
465                         for ($aa=0;$aa<$top;$aa++)      {
466                                 $tempArr=array();
467                                 for ($bb=0;$bb<$cols;$bb++)     {
468                                         $tempArr[$bb]=str_pad($v[$bb][$aa],$messure[0][$bb],' ');
469                                 }
470                                 $outLines[]=$colChar.implode($colChar,$tempArr).$colChar;
471                         }
472                         $outLines[]=$this->addDiv($messure,'',$divChar,$joinChar,$cols);
473                 }
474                 return implode(chr(10),$outLines);
475         }
476
477         /**
478          * Subfunction for breakTable(): Adds a divider line between table rows.
479          *
480          * @param       array           Some information about sizes
481          * @param       string          Empty string.
482          * @param       string          Character to use for the divider line, typically "-"
483          * @param       string          Join character, typically "+"
484          * @param       integer         Number of table columns
485          * @return      string          Divider line for the table
486          * @access private
487          * @see breakTable()
488          */
489         function addDiv($messure,$content,$divChar,$joinChar,$cols)     {
490                 $tempArr=array();
491                 for ($a=0;$a<$cols;$a++)        {
492                         $tempArr[$a]=str_pad($content,$messure[0][$a],$divChar);
493                 }
494                 return $joinChar.implode($joinChar,$tempArr).$joinChar;
495         }
496
497         /**
498          * Traverses the table lines/cells and creates arrays with statistics for line numbers and lengths
499          *
500          * @param       array           Array with [table rows] [table cells] [lines in cell]
501          * @return      array           Statistics (max lines/lengths)
502          * @access private
503          * @see breakTable()
504          */
505         function traverseTable($tableLines)     {
506                 $maxLen=array();
507                 $maxLines=array();
508                 reset($tableLines);
509                 while(list($k,$v)=each($tableLines))    {
510                         reset($v);
511                         while(list($kk,$vv)=each($v))   {
512                                 reset($vv);
513                                 while(list($lk,$lv)=each($vv))  {
514                                         if (strlen($lv)>intval($maxLen[$kk]))   $maxLen[$kk]=strlen($lv);
515                                 }
516                                 if (count($vv)>intval($maxLines[$k]))   $maxLines[$k]=count($vv);
517                         }
518                 }
519                 return array($maxLen,$maxLines);
520         }
521
522         /**
523          * Render block of images - which means creating lines with links to the images.
524          *
525          * @param       string          List of image filenames (from "image" field in tt_content records)
526          * @param       string          Link value from the "image_link" field in tt_content records
527          * @param       string          Caption text
528          * @param       string          Alternative relative path for the files listed in $str
529          * @return      string          Content
530          * @see getImages()
531          */
532         function renderImages($str,$links,$caption,$upload_path='uploads/pics/')        {
533                 $images = explode(',',$str);
534                 $linksArr = explode(',',$links);
535                 reset($images);
536                 $lines=array();
537                 if ($this->conf['images.']['header'])   {$lines[]=$this->getString($this->conf['images.']['header']);}
538                 while(list($k,$file)=each($images))     {
539                         $lines[]=$this->siteUrl.$upload_path.$file;
540                         if ($links && count($linksArr)>1)       {
541                                 if (isset($linksArr[$k]))       {
542                                         $ll=$linksArr[$k];
543                                 } else {
544                                         $ll=$linksArr[0];
545                                 }
546
547                                 $theLink = $this->getLink($ll);
548                                 if ($theLink)   {$lines[]=$this->getString($this->conf['images.']['linkPrefix']).$theLink;}
549                         }
550                 }
551                 if ($links && count($linksArr)==1)      {
552                         $theLink = $this->getLink($links);
553                         if ($theLink)   {$lines[]=$this->getString($this->conf['images.']['linkPrefix']).$theLink;}
554                 }
555                 if ($caption)   {
556                         $lines[]='';
557                         $cHeader = trim($this->getString($this->conf['images.']['captionHeader']));
558                         if ($cHeader)           $lines[]=$cHeader;
559                         $lines[]=$this->breakContent($caption);
560                 }
561
562                 return implode(chr(10),$lines);
563         }
564
565         /**
566          * Returns a typolink URL based on input.
567          *
568          * @param       string          Parameter to typolink
569          * @return      string          The URL returned from $this->cObj->getTypoLink_URL(); - possibly it prefixed with the URL of the site if not present already
570          */
571         function getLink($ll)   {
572                 $theLink=$this->cObj->getTypoLink_URL($ll);
573                 if (substr($theLink,0,4)!='http')       {
574                         $theLink=$this->siteUrl.$theLink;
575                 }
576                 return $theLink;
577         }
578
579         /**
580          * Breaking lines into fixed length lines, using t3lib_div::breakLinesForEmail()
581          *
582          * @param       string          The string to break
583          * @param       string          Line break character
584          * @param       integer         Length of lines, default is $this->charWidth
585          * @return      string          Processed string
586          * @see t3lib_div::breakLinesForEmail()
587          */
588         function breakLines($str,$implChar="\n",$charWidth=0)   {
589                 return t3lib_div::breakLinesForEmail($str,$implChar,$charWidth?$charWidth:$this->charWidth);
590         }
591
592         /**
593          * Explodes a string with "|" and if the second part is found it will return this, otherwise the first part.
594          * Used for many TypoScript properties used in this class since they need preceeding whitespace to be preserved.
595          *
596          * @param       string          Input string
597          * @return      string          Output string
598          * @access private
599          */
600         function getString($str)        {
601                 $parts = explode('|',$str);
602                 return strcmp($parts[1],'')?$parts[1]:$parts[0];
603         }
604
605         /**
606          * Calls a user function for processing of data
607          *
608          * @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)
609          * @param       mixed           Variable to process
610          * @return      mixed           The processed $passVar as returned by the function call
611          */
612         function userProcess($mConfKey,$passVar)        {
613                 if ($this->conf[$mConfKey])     {
614                         $funcConf = $this->conf[$mConfKey.'.'];
615                         $funcConf['parentObj'] = $this;
616                         $passVar = $GLOBALS['TSFE']->cObj->callUserFunction($this->conf[$mConfKey], $funcConf, $passVar);
617                 }
618                 return $passVar;
619         }
620
621         /**
622          * Function used by TypoScript "parseFunc" to process links in the bodytext.
623          * 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.
624          *
625          * @param       string          Empty, ignore.
626          * @param       array           TypoScript parameters
627          * @return      string          Processed output.
628          * @see parseBody()
629          */
630         function atag_to_http($content,$conf)   {
631                 $this->conf = $conf;
632                 $this->siteUrl=$conf['siteUrl'];
633                 $theLink  = trim($this->cObj->parameters['href']);
634                 if (strtolower(substr($theLink,0,7))=='mailto:')        {
635                         $theLink=substr($theLink,7);
636                 } elseif (substr($theLink,0,4)!='http') {
637                         $theLink=$this->siteUrl.$theLink;
638                 }
639                 return $this->cObj->getCurrentVal().' (Link: '.$theLink.' )';
640         }
641
642         /**
643          * User function (called from TypoScript) for generating a bullet list (used in parsefunc)
644          *
645          * @param       string          Empty, ignore.
646          * @param       array           TypoScript parameters
647          * @return      string          Processed output.
648          */
649         function typolist($content,$conf)       {
650                 $this->conf = $this->cObj->mergeTSRef($conf,'bulletlist');
651                 $this->siteUrl=$conf['siteUrl'];
652                 $str = trim($this->cObj->getCurrentVal());
653                 $this->cObj->data['layout'] = $this->cObj->parameters['type'];
654                 return $this->breakBulletlist($str);
655         }
656
657         /**
658          * User function (called from TypoScript) for generating a typo header tag (used in parsefunc)
659          *
660          * @param       string          Empty, ignore.
661          * @param       array           TypoScript parameters
662          * @return      string          Processed output.
663          */
664         function typohead($content,$conf)       {
665                 $this->conf = $this->cObj->mergeTSRef($conf,'header');
666
667                 $this->siteUrl=$conf['siteUrl'];
668                 $str = trim($this->cObj->getCurrentVal());
669                 $this->cObj->data['header_layout'] = $this->cObj->parameters['type'];
670                 $this->cObj->data['header_position'] = $this->cObj->parameters['align'];
671                 $this->cObj->data['header']=$str;
672
673                 return $this->getHeader();
674         }
675
676         /**
677          * User function (called from TypoScript) for generating a code listing (used in parsefunc)
678          *
679          * @param       string          Empty, ignore.
680          * @param       array           TypoScript parameters
681          * @return      string          Processed output.
682          */
683         function typocode($content,$conf)       {
684                         // Nothing is really done here...
685                 $this->conf = $conf;
686                 $this->siteUrl=$conf['siteUrl'];
687                 return $this->cObj->getCurrentVal();
688         }
689 }
690
691
692
693
694 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['media/scripts/plaintextLib.inc'])  {
695         include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['media/scripts/plaintextLib.inc']);
696 }
697 ?>