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