PageRenderTime 184ms CodeModel.GetById 50ms app.highlight 124ms RepoModel.GetById 1ms app.codeStats 0ms

/typo3/sysext/statictemplates/media/scripts/plaintextLib.inc

https://bitbucket.org/linxpinx/mercurial
PHP | 682 lines | 329 code | 73 blank | 280 comment | 45 complexity | 20757282f7dc832c3cea1515eb8d97e7 MD5 | raw file
  1<?php
  2/***************************************************************
  3*  Copyright notice
  4*
  5*  (c) 1999-2009 Kasper Skaarhoj (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 Skaarhoj
 32 *
 33 * @author	Kasper Skaarhoj <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 Skaarhoj <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 */
123class 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 'table':
182				$lines[]=$this->getHeader();
183				$lines[]=$this->breakTable(strip_tags($this->parseBody($this->cObj->data['bodytext'])));
184			break;
185			case 'html':
186				$lines[]=$this->getHTML();
187			break;
188			default:
189				$defaultOutput = $this->getString($this->conf['defaultOutput']);
190				if ($defaultOutput)	{
191					$lines[]=str_replace('###CType###',$CType,$defaultOutput);
192				}
193			break;
194		}
195
196		$lines[]='';	// First break.
197		$content = implode(chr(10),$lines);
198
199			// User processing:
200		$content=$this->userProcess('userProc',$content);
201		return $content;
202	}
203
204	/**
205	 * Creates a menu/sitemap
206	 *
207	 * @return	string		Content
208	 */
209	function getMenuSitemap()	{
210		$str = $this->cObj->cObjGetSingle($this->conf['menu'],$this->conf['menu.']);
211		$str = $this->breakBulletlist(trim(strip_tags(preg_replace('/<br[ \/]*>/i',chr(10),$this->parseBody($str)))));
212		return $str;
213	}
214
215	/**
216	 * Creates a shortcut ("Insert Records")
217	 *
218	 * @return	string		Content
219	 */
220	function getShortcut()	{
221		$str = $this->cObj->cObjGetSingle($this->conf['shortcut'],$this->conf['shortcut.']);
222		return $str;
223	}
224
225	/**
226	 * Creates an HTML element (stripping tags of course)
227	 *
228	 * @param	string		HTML content to process. If not passed along, the bodytext field is used.
229	 * @return	string		Content
230	 */
231	function getHTML($str=array())	{
232		return $this->breakContent(strip_tags(preg_replace('/<br[ \/]*>/i',chr(10),$this->parseBody(is_string($str)?$str:$this->cObj->data['bodytext']))));
233	}
234
235	/**
236	 * Creates a header (used for most elements)
237	 *
238	 * @return	string		Content
239	 * @see renderHeader()
240	 */
241	function getHeader()	{
242		// links...
243		return $this->renderHeader($this->cObj->data['header'],$this->cObj->data['header_layout']);
244	}
245
246	/**
247	 * Get images found in the "image" field of "tt_content"
248	 *
249	 * @return	string		Content
250	 */
251	function getImages()	{
252		$images = $this->renderImages($this->cObj->data['image'],!$this->cObj->data['image_zoom']?$this->cObj->data['image_link']:'',$this->cObj->data['imagecaption']);
253		return $images;
254	}
255
256	/**
257	 * Parsing the bodytext field content, removing typical entities and <br /> tags.
258	 *
259	 * @param	string		Field content from "bodytext"
260	 * @return	string		Processed content
261	 */
262	function parseBody($str)	{
263			// First, regular parsing:
264		$str = preg_replace('/<br[ \/]*>/i',' ',$str);
265		$str = $this->cObj->stdWrap($str,$this->conf['bodytext.']['stdWrap.']);
266			// Then all a-tags:
267		$aConf = array();
268		$aConf['parseFunc.']['tags.']['a']='USER';
269		$aConf['parseFunc.']['tags.']['a.']['userFunc']='user_plaintext->atag_to_http';
270		$aConf['parseFunc.']['tags.']['a.']['siteUrl'] = $this->siteUrl;
271
272		$str = $this->cObj->stdWrap($str,$aConf);
273		$str = str_replace('&nbsp;',' ',t3lib_div::htmlspecialchars_decode($str));
274		return $str;
275	}
276
277	/**
278	 * Creates a list of links to uploaded files.
279	 *
280	 * @param	string		List of uploaded filenames from "uploads/media/" (or $upload_path)
281	 * @param	string		Alternative path value
282	 * @return	string		Content
283	 */
284	function renderUploads($str,$upload_path='uploads/media/')	{
285		$files = explode(',',$str);
286		reset($files);
287		$lines=array();
288		if ($this->conf['uploads.']['header'])	{$lines[]=$this->getString($this->conf['uploads.']['header']);}
289		while(list($k,$file)=each($files))	{
290			$lines[]=$this->siteUrl.$upload_path.$file;
291		}
292		return implode(chr(10),$lines);
293	}
294
295	/**
296	 * Renders a content element header, observing the layout type giving different header formattings
297	 *
298	 * @param	string		The header string
299	 * @param	integer		The layout type of the header (in the content element)
300	 * @return	string		Content
301	 */
302	function renderHeader($str,$type=0)	{
303		if ($str)	{
304			$hConf = $this->conf['header.'];
305			$defaultType = t3lib_div::intInRange($hConf['defaultType'],1,5);
306			$type=t3lib_div::intInRange($type,0,6);
307			if (!$type)	$type=$defaultType;
308			if ($type!=6)	{	// not hidden
309				$tConf = $hConf[$type.'.'];
310
311				$lines=array();
312
313				$blanks = t3lib_div::intInRange($tConf['preBlanks'],0,1000);
314				if ($blanks)	{
315					$lines[]=str_pad('', $blanks-1, chr(10));
316				}
317
318				$lines=$this->pad($lines,$tConf['preLineChar'],$tConf['preLineLen']);
319
320				$blanks = t3lib_div::intInRange($tConf['preLineBlanks'],0,1000);
321				if ($blanks)	{$lines[]=str_pad('', $blanks-1, chr(10));}
322
323				if ($this->cObj->data['date'])	{
324					$lines[] = $this->getString($hConf['datePrefix']).date($hConf['date']?$hConf['date']:$GLOBALS['TYPO3_CONF_VARS']['SYS']['ddmmyy'],$this->cObj->data['date']);
325				}
326				$prefix='';
327				$str=$this->getString($tConf['prefix']).$str;
328				if ($tConf['autonumber'])	$str=$this->cObj->parentRecordNumber.$str;
329				if ($this->cObj->data['header_position']=='right')	{$prefix=str_pad(' ',($this->charWidth-strlen($str)));}
330				if ($this->cObj->data['header_position']=='center')	{$prefix=str_pad(' ',floor(($this->charWidth-strlen($str))/2));}
331				$lines[]=$this->cObj->stdWrap($prefix.$str,$tConf['stdWrap.']);
332				if ($this->cObj->data['header_link'])		{$lines[] = $this->getString($hConf['linkPrefix']).$this->getLink($this->cObj->data['header_link']);}
333
334				$blanks = t3lib_div::intInRange($tConf['postLineBlanks'],0,1000);
335				if ($blanks)	{$lines[]=str_pad('', $blanks-1, chr(10));}
336
337				$lines=$this->pad($lines,$tConf['postLineChar'],$tConf['postLineLen']);
338
339				$blanks = t3lib_div::intInRange($tConf['postBlanks'],0,1000);
340				if ($blanks)	{$lines[]=str_pad('', $blanks-1, chr(10));}
341				return implode(chr(10),$lines);
342			}
343		}
344	}
345
346	/**
347	 * Function used to repeat a char pattern in head lines (like if you want "********" above/below a header)
348	 *
349	 * @param	array		Array of existing lines to which the new char-pattern should be added
350	 * @param	string		The character pattern to repeat. Default is "-"
351	 * @param	integer		The length of the line. $preLineChar will be repeated to fill in this length.
352	 * @return	array		The input array with a new line added.
353	 * @see renderHeader()
354	 */
355	function pad($lines,$preLineChar,$len)	{
356		$strPad = t3lib_div::intInRange($len,0,1000);
357		$strPadChar = $preLineChar?$preLineChar:'-';
358		if ($strPad)	{
359			$lines[]=str_pad('', $strPad, $strPadChar);
360		}
361		return $lines;
362	}
363
364	/**
365	 * Function used to wrap the bodytext field content (or image caption) into lines of a max length of
366	 *
367	 * @param	string		The content to break
368	 * @return	string		Processed value.
369	 * @see main_plaintext(), breakLines()
370	 */
371	function breakContent($str)	{
372		$cParts = explode(chr(10),$str);
373		reset($cParts);
374		$lines=array();
375		while(list(,$substrs)=each($cParts))	{
376			$lines[]=$this->breakLines($substrs);
377		}
378		return implode(chr(10),$lines);
379	}
380
381	/**
382	 * Breaks content lines into a bullet list
383	 *
384	 * @param	string		Content string to make into a bullet list
385	 * @return	string		Processed value
386	 */
387	function breakBulletlist($str)	{
388		$type = $this->cObj->data['layout'];
389		$type=t3lib_div::intInRange($type,0,3);
390
391		$tConf = $this->conf['bulletlist.'][$type.'.'];
392
393		$cParts = explode(chr(10),$str);
394		reset($cParts);
395		$lines=array();
396		$c=0;
397		while(list(,$substrs)=each($cParts))	{
398			$c++;
399			$bullet = $tConf['bullet'] ? $this->getString($tConf['bullet']) : ' - ';
400			$bLen=strlen($bullet);
401			$bullet = substr(str_replace('#',$c,$bullet),0,$bLen);
402			$secondRow = substr($tConf['secondRow']?$this->getString($tConf['secondRow']):str_pad('',strlen($bullet),' '),0,$bLen);
403
404			$lines[]=$bullet.$this->breakLines($substrs,chr(10).$secondRow,$this->charWidth-$bLen);
405
406			$blanks = t3lib_div::intInRange($tConf['blanks'],0,1000);
407			if ($blanks)	{$lines[]=str_pad('', $blanks-1, chr(10));}
408		}
409		return implode(chr(10),$lines);
410	}
411
412	/**
413	 * Formatting a table in plain text (based on the paradigm of lines being content rows and cells separated by "|")
414	 *
415	 * @param	string		Content string
416	 * @return	string		Processed value
417	 */
418	function breakTable($str)	{
419		$cParts = explode(chr(10),$str);
420		reset($cParts);
421		$lines=array();
422		$cols = intval($this->conf['cols']) ? intval($this->conf['cols']) : 0 ;
423		$c=0;
424		while(list(,$substrs)=each($cParts))	{
425			$c++;
426			if (trim($substrs))	{
427				$lineParts=explode('|',$substrs);
428				if (!$cols)	$cols=count($lineParts);
429
430				for ($a=0;$a<$cols;$a++)	{
431					$jdu = explode(chr(10),$this->breakLines($lineParts[$a],chr(10),ceil($this->charWidth/$cols)));
432					$lines[$c][$a]=$jdu;
433				}
434			}
435		}
436		$messure = $this->traverseTable($lines);
437
438
439		$divChar='-';
440		$joinChar='+';
441		$colChar='|';
442
443		// Make table:
444		$outLines = array();
445		$outLines[]=$this->addDiv($messure,'',$divChar,$joinChar,$cols);
446
447		reset($lines);
448		while(list($k,$v)=each($lines))	{
449			$top = intval($messure[1][$k]);
450			for ($aa=0;$aa<$top;$aa++)	{
451				$tempArr=array();
452				for ($bb=0;$bb<$cols;$bb++)	{
453					$tempArr[$bb]=str_pad($v[$bb][$aa],$messure[0][$bb],' ');
454				}
455				$outLines[]=$colChar.implode($colChar,$tempArr).$colChar;
456			}
457			$outLines[]=$this->addDiv($messure,'',$divChar,$joinChar,$cols);
458		}
459		return implode(chr(10),$outLines);
460	}
461
462	/**
463	 * Subfunction for breakTable(): Adds a divider line between table rows.
464	 *
465	 * @param	array		Some information about sizes
466	 * @param	string		Empty string.
467	 * @param	string		Character to use for the divider line, typically "-"
468	 * @param	string		Join character, typically "+"
469	 * @param	integer		Number of table columns
470	 * @return	string		Divider line for the table
471	 * @access private
472	 * @see breakTable()
473	 */
474	function addDiv($messure,$content,$divChar,$joinChar,$cols)	{
475		$tempArr=array();
476		for ($a=0;$a<$cols;$a++)	{
477			$tempArr[$a]=str_pad($content,$messure[0][$a],$divChar);
478		}
479		return $joinChar.implode($joinChar,$tempArr).$joinChar;
480	}
481
482	/**
483	 * Traverses the table lines/cells and creates arrays with statistics for line numbers and lengths
484	 *
485	 * @param	array		Array with [table rows] [table cells] [lines in cell]
486	 * @return	array		Statistics (max lines/lengths)
487	 * @access private
488	 * @see breakTable()
489	 */
490	function traverseTable($tableLines)	{
491		$maxLen=array();
492		$maxLines=array();
493		reset($tableLines);
494		while(list($k,$v)=each($tableLines))	{
495			reset($v);
496			while(list($kk,$vv)=each($v))	{
497				reset($vv);
498				while(list($lk,$lv)=each($vv))	{
499					if (strlen($lv)>intval($maxLen[$kk]))	$maxLen[$kk]=strlen($lv);
500				}
501				if (count($vv)>intval($maxLines[$k]))	$maxLines[$k]=count($vv);
502			}
503		}
504		return array($maxLen,$maxLines);
505	}
506
507	/**
508	 * Render block of images - which means creating lines with links to the images.
509	 *
510	 * @param	string		List of image filenames (from "image" field in tt_content records)
511	 * @param	string		Link value from the "image_link" field in tt_content records
512	 * @param	string		Caption text
513	 * @param	string		Alternative relative path for the files listed in $str
514	 * @return	string		Content
515	 * @see getImages()
516	 */
517	function renderImages($str,$links,$caption,$upload_path='uploads/pics/')	{
518		$images = explode(',',$str);
519		$linksArr = explode(',',$links);
520		reset($images);
521		$lines=array();
522		if ($this->conf['images.']['header'])	{$lines[]=$this->getString($this->conf['images.']['header']);}
523		while(list($k,$file)=each($images))	{
524			$lines[]=$this->siteUrl.$upload_path.$file;
525			if ($links && count($linksArr)>1)	{
526				if (isset($linksArr[$k]))	{
527					$ll=$linksArr[$k];
528				} else {
529					$ll=$linksArr[0];
530				}
531
532				$theLink = $this->getLink($ll);
533				if ($theLink)	{$lines[]=$this->getString($this->conf['images.']['linkPrefix']).$theLink;}
534			}
535		}
536		if ($links && count($linksArr)==1)	{
537			$theLink = $this->getLink($links);
538			if ($theLink)	{$lines[]=$this->getString($this->conf['images.']['linkPrefix']).$theLink;}
539		}
540		if ($caption)	{
541			$lines[]='';
542			$cHeader = trim($this->getString($this->conf['images.']['captionHeader']));
543			if ($cHeader)		$lines[]=$cHeader;
544			$lines[]=$this->breakContent($caption);
545		}
546
547		return implode(chr(10),$lines);
548	}
549
550	/**
551	 * Returns a typolink URL based on input.
552	 *
553	 * @param	string		Parameter to typolink
554	 * @return	string		The URL returned from $this->cObj->getTypoLink_URL(); - possibly it prefixed with the URL of the site if not present already
555	 */
556	function getLink($ll)	{
557		$theLink=$this->cObj->getTypoLink_URL($ll);
558		if (substr($theLink,0,4)!='http')	{
559			$theLink=$this->siteUrl.$theLink;
560		}
561		return $theLink;
562	}
563
564	/**
565	 * Breaking lines into fixed length lines, using t3lib_div::breakLinesForEmail()
566	 *
567	 * @param	string		The string to break
568	 * @param	string		Line break character
569	 * @param	integer		Length of lines, default is $this->charWidth
570	 * @return	string		Processed string
571	 * @see t3lib_div::breakLinesForEmail()
572	 */
573	function breakLines($str,$implChar="\n",$charWidth=0)	{
574		return t3lib_div::breakLinesForEmail($str,$implChar,$charWidth?$charWidth:$this->charWidth);
575	}
576
577	/**
578	 * Explodes a string with "|" and if the second part is found it will return this, otherwise the first part.
579	 * Used for many TypoScript properties used in this class since they need preceeding whitespace to be preserved.
580	 *
581	 * @param	string		Input string
582	 * @return	string		Output string
583	 * @access private
584	 */
585	function getString($str)	{
586		$parts = explode('|',$str);
587		return strcmp($parts[1],'')?$parts[1]:$parts[0];
588	}
589
590	/**
591	 * Calls a user function for processing of data
592	 *
593	 * @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)
594	 * @param	mixed		Variable to process
595	 * @return	mixed		The processed $passVar as returned by the function call
596	 */
597	function userProcess($mConfKey,$passVar)	{
598		if ($this->conf[$mConfKey])	{
599			$funcConf = $this->conf[$mConfKey.'.'];
600			$funcConf['parentObj'] = $this;
601			$passVar = $GLOBALS['TSFE']->cObj->callUserFunction($this->conf[$mConfKey], $funcConf, $passVar);
602		}
603		return $passVar;
604	}
605
606	/**
607	 * Function used by TypoScript "parseFunc" to process links in the bodytext.
608	 * 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.
609	 *
610	 * @param	string		Empty, ignore.
611	 * @param	array		TypoScript parameters
612	 * @return	string		Processed output.
613	 * @see parseBody()
614	 */
615	function atag_to_http($content,$conf)	{
616		$this->conf = $conf;
617		$this->siteUrl=$conf['siteUrl'];
618		$theLink  = trim($this->cObj->parameters['href']);
619		if (strtolower(substr($theLink,0,7))=='mailto:')	{
620			$theLink=substr($theLink,7);
621		} elseif (substr($theLink,0,4)!='http')	{
622			$theLink=$this->siteUrl.$theLink;
623		}
624		return $this->cObj->getCurrentVal().' (Link: '.$theLink.' )';
625	}
626
627	/**
628	 * User function (called from TypoScript) for generating a bullet list (used in parsefunc)
629	 *
630	 * @param	string		Empty, ignore.
631	 * @param	array		TypoScript parameters
632	 * @return	string		Processed output.
633	 */
634	function typolist($content,$conf)	{
635		$this->conf = $this->cObj->mergeTSRef($conf,'bulletlist');
636		$this->siteUrl=$conf['siteUrl'];
637		$str = trim($this->cObj->getCurrentVal());
638		$this->cObj->data['layout'] = $this->cObj->parameters['type'];
639		return $this->breakBulletlist($str);
640	}
641
642	/**
643	 * User function (called from TypoScript) for generating a typo header tag (used in parsefunc)
644	 *
645	 * @param	string		Empty, ignore.
646	 * @param	array		TypoScript parameters
647	 * @return	string		Processed output.
648	 */
649	function typohead($content,$conf)	{
650		$this->conf = $this->cObj->mergeTSRef($conf,'header');
651
652		$this->siteUrl=$conf['siteUrl'];
653		$str = trim($this->cObj->getCurrentVal());
654		$this->cObj->data['header_layout'] = $this->cObj->parameters['type'];
655		$this->cObj->data['header_position'] = $this->cObj->parameters['align'];
656		$this->cObj->data['header']=$str;
657
658		return $this->getHeader();
659	}
660
661	/**
662	 * User function (called from TypoScript) for generating a code listing (used in parsefunc)
663	 *
664	 * @param	string		Empty, ignore.
665	 * @param	array		TypoScript parameters
666	 * @return	string		Processed output.
667	 */
668	function typocode($content,$conf)	{
669			// Nothing is really done here...
670		$this->conf = $conf;
671		$this->siteUrl=$conf['siteUrl'];
672		return $this->cObj->getCurrentVal();
673	}
674}
675
676
677
678
679if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['media/scripts/plaintextLib.inc'])	{
680	include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['media/scripts/plaintextLib.inc']);
681}
682?>