TYPO3 API  SVNRelease
plaintextLib.inc
Go to the documentation of this file.
00001 <?php
00002 /***************************************************************
00003 *  Copyright notice
00004 *
00005 *  (c) 1999-2009 Kasper Skårhøj (kasperYYYY@typo3.com)
00006 *  All rights reserved
00007 *
00008 *  This script is part of the TYPO3 project. The TYPO3 project is
00009 *  free software; you can redistribute it and/or modify
00010 *  it under the terms of the GNU General Public License as published by
00011 *  the Free Software Foundation; either version 2 of the License, or
00012 *  (at your option) any later version.
00013 *
00014 *  The GNU General Public License can be found at
00015 *  http://www.gnu.org/copyleft/gpl.html.
00016 *  A copy is found in the textfile GPL.txt and important notices to the license
00017 *  from the author is found in LICENSE.txt distributed with these scripts.
00018 *
00019 *
00020 *  This script is distributed in the hope that it will be useful,
00021 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00022 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00023 *  GNU General Public License for more details.
00024 *
00025 *  This copyright notice MUST APPEAR in all copies of the script!
00026 ***************************************************************/
00027 /**
00028  * Generating plain text content of content elements for Direct Mails
00029  *
00030  * $Id: plaintextLib.inc 10317 2011-01-26 00:56:49Z baschny $
00031  * Revised for TYPO3 3.6 June/2003 by Kasper Skårhøj
00032  *
00033  * @author  Kasper Skårhøj <kasperYYYY@typo3.com>
00034  */
00035 /**
00036  * [CLASS/FUNCTION INDEX of SCRIPT]
00037  *
00038  *
00039  *
00040  *  123: class user_plaintext
00041  *  137:     function main_plaintext($content,$conf)
00042  *  209:     function getMenuSitemap()
00043  *  220:     function getShortcut()
00044  *  231:     function getHTML($str=array())
00045  *  241:     function getHeader()
00046  *  251:     function getImages()
00047  *  262:     function parseBody($str)
00048  *  284:     function renderUploads($str,$upload_path='uploads/media/')
00049  *  302:     function renderHeader($str,$type=0)
00050  *  353:     function pad($lines,$preLineChar,$len)
00051  *  369:     function breakContent($str)
00052  *  385:     function breakBulletlist($str)
00053  *  416:     function breakTable($str)
00054  *  472:     function addDiv($messure,$content,$divChar,$joinChar,$cols)
00055  *  488:     function traverseTable($tableLines)
00056  *  515:     function renderImages($str,$links,$caption,$upload_path='uploads/pics/')
00057  *  554:     function getLink($ll)
00058  *  571:     function breakLines($str,$implChar="\n",$charWidth=0)
00059  *  583:     function getString($str)
00060  *  595:     function userProcess($mConfKey,$passVar)
00061  *  613:     function atag_to_http($content,$conf)
00062  *  632:     function typolist($content,$conf)
00063  *  647:     function typohead($content,$conf)
00064  *  666:     function typocode($content,$conf)
00065  *
00066  * TOTAL FUNCTIONS: 24
00067  * (This index is automatically created/updated by the extension "extdeveval")
00068  *
00069  */
00070 
00071 
00072 
00073 
00074 
00075 
00076 
00077 
00078 
00079 
00080 
00081 
00082 
00083 
00084 
00085 
00086 
00087 
00088 
00089 
00090 
00091 /**
00092  * Alternative rendering of content elements for Plain Text emails. That means text-only output. No HTML at all. Used by the Direct Mail extension.
00093  * Normally the plain text output should appear with type=99.
00094  * To use this library you can include the static template "plugin.alt.plaintext"
00095  *
00096  * ## Insert DMailer Boundaries for all elements.
00097  * config.insertDmailerBoundaries = 1
00098  * includeLibs.plaintextLib = media/scripts/plaintextLib.inc
00099  *
00100  * ## Set up page/type number:
00101  * alt_plaintext >
00102  * alt_plaintext = PAGE
00103  * alt_plaintext.typeNum=99
00104  * alt_plaintext.config.disableAllHeaderCode = 1
00105  * alt_plaintext.10 = TEMPLATE
00106  * alt_plaintext.10 {
00107  *   template = FILE
00108  *   template.file = {$plugin.alt.plaintext.file.template}
00109  *   marks.CONTENT < styles.content.get
00110  *   marks.CONTENT.renderObj = < lib.alt_plaintext.renderObj
00111  *   marks.DATE = TEXT
00112  *   marks.DATE.data = date:U
00113  *   marks.DATE.strftime = %e. %B %Y
00114  * }
00115  *
00116  * (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")
00117  *
00118  * @author  Kasper Skårhøj <kasperYYYY@typo3.com>
00119  * @package TYPO3
00120  * @subpackage tslib
00121  */
00122 class user_plaintext {
00123     var $cObj;
00124     var $conf=array();
00125     var $charWidth=76;
00126 
00127     /**
00128      * Main function, called from TypoScript
00129      * A content object that renders "tt_content" records. See the comment to this class for TypoScript example of how to trigger it.
00130      * This detects the CType of the current content element and renders it accordingly. Only wellknown types are rendered.
00131      *
00132      * @param   string      Empty, ignore.
00133      * @param   array       TypoScript properties for this content object/function call
00134      * @return  string      Plain text content
00135      */
00136     function main_plaintext($content,$conf) {
00137         $this->conf = $conf;
00138         $this->siteUrl=$conf['siteUrl'];
00139         $lines = array();
00140         $CType= (string)$this->cObj->data['CType'];
00141         switch($CType)  {
00142             case 'header':
00143                 $lines[]=$this->getHeader();
00144                 if ($this->cObj->data['subheader']) {
00145                     $lines[]=$this->breakContent(strip_tags($this->cObj->data['subheader']));
00146                 }
00147             break;
00148             case 'text':
00149             case 'textpic':
00150                 $lines[]=$this->getHeader();
00151                 if ($CType=='textpic' && !($this->cObj->data['imageorient']&24))    {
00152                     $lines[]=$this->getImages();
00153                     $lines[]='';
00154                 }
00155                 $lines[]=$this->breakContent(strip_tags($this->parseBody($this->cObj->data['bodytext'])));
00156                 if ($CType=='textpic' && ($this->cObj->data['imageorient']&24)) {
00157                     $lines[]='';
00158                     $lines[]=$this->getImages();
00159                 }
00160             break;
00161             case 'image':
00162                 $lines[]=$this->getHeader();
00163                 $lines[]=$this->getImages();
00164             break;
00165             case 'uploads':
00166                 $lines[]=$this->getHeader();
00167                 $lines[]=$this->renderUploads($this->cObj->data['media']);
00168             break;
00169             case 'menu':
00170                 $lines[]=$this->getHeader();
00171                 $lines[]=$this->getMenuSitemap();
00172             break;
00173             case 'shortcut':
00174                 $lines[]=$this->getShortcut();
00175             break;
00176             case 'bullets':
00177                 $lines[]=$this->getHeader();
00178                 $lines[]=$this->breakBulletlist(strip_tags($this->parseBody($this->cObj->data['bodytext'])));
00179             break;
00180             case 'list':
00181                 $lines[]=$this->getHeader();
00182                 $lines[]=$this->getList();
00183             break;
00184             case 'table':
00185                 $lines[]=$this->getHeader();
00186                 $lines[]=$this->breakTable(strip_tags($this->parseBody($this->cObj->data['bodytext'])));
00187             break;
00188             case 'html':
00189                 $lines[]=$this->getHTML();
00190             break;
00191             default:
00192                 $defaultOutput = $this->getString($this->conf['defaultOutput']);
00193                 if ($defaultOutput) {
00194                     $lines[]=str_replace('###CType###',$CType,$defaultOutput);
00195                 }
00196             break;
00197         }
00198 
00199         $lines[]='';    // First break.
00200         $content = implode(chr(10),$lines);
00201 
00202             // User processing:
00203         $content=$this->userProcess('userProc',$content);
00204         return $content;
00205     }
00206 
00207     /**
00208      * Creates a menu/sitemap
00209      *
00210      * @return  string      Content
00211      */
00212     function getMenuSitemap()   {
00213         $str = $this->cObj->cObjGetSingle($this->conf['menu'],$this->conf['menu.']);
00214         $str = $this->breakBulletlist(trim(strip_tags(preg_replace('/<br[ \/]*>/i',chr(10),$this->parseBody($str)))));
00215         return $str;
00216     }
00217 
00218     /**
00219      * Creates a shortcut ("Insert Records")
00220      *
00221      * @return  string      Content
00222      */
00223     function getShortcut()  {
00224         $str = $this->cObj->cObjGetSingle($this->conf['shortcut'],$this->conf['shortcut.']);
00225         return $str;
00226     }
00227 
00228     /**
00229      * Creates an HTML element (stripping tags of course)
00230      *
00231      * @param   string      HTML content to process. If not passed along, the bodytext field is used.
00232      * @return  string      Content
00233      */
00234     function getHTML($str=array())  {
00235         return $this->breakContent(strip_tags(preg_replace('/<br[ \/]*>/i',chr(10),$this->parseBody(is_string($str)?$str:$this->cObj->data['bodytext']))));
00236     }
00237 
00238     /**
00239      * Creates a header (used for most elements)
00240      *
00241      * @return  string      Content
00242      * @see renderHeader()
00243      */
00244     function getHeader()    {
00245         // links...
00246         return $this->renderHeader($this->cObj->data['header'],$this->cObj->data['header_layout']);
00247     }
00248 
00249     /**
00250      * Get images found in the "image" field of "tt_content"
00251      *
00252      * @return  string      Content
00253      */
00254     function getImages()    {
00255         $images = $this->renderImages($this->cObj->data['image'],!$this->cObj->data['image_zoom']?$this->cObj->data['image_link']:'',$this->cObj->data['imagecaption']);
00256         return $images;
00257     }
00258 
00259     /**
00260      * Parsing the bodytext field content, removing typical entities and <br /> tags.
00261      *
00262      * @param   string      Field content from "bodytext"
00263      * @return  string      Processed content
00264      */
00265     function parseBody($str)    {
00266             // First, regular parsing:
00267         $str = preg_replace('/<br[ \/]*>/i',' ',$str);
00268         $str = $this->cObj->stdWrap($str,$this->conf['bodytext.']['stdWrap.']);
00269             // Then all a-tags:
00270         $aConf = array();
00271         $aConf['parseFunc.']['tags.']['a']='USER';
00272         $aConf['parseFunc.']['tags.']['a.']['userFunc']='user_plaintext->atag_to_http';
00273         $aConf['parseFunc.']['tags.']['a.']['siteUrl'] = $this->siteUrl;
00274 
00275         $str = $this->cObj->stdWrap($str,$aConf);
00276         $str = str_replace('&nbsp;',' ',t3lib_div::htmlspecialchars_decode($str));
00277         return $str;
00278     }
00279 
00280     /**
00281      * Creates a list of links to uploaded files.
00282      *
00283      * @param   string      List of uploaded filenames from "uploads/media/" (or $upload_path)
00284      * @param   string      Alternative path value
00285      * @return  string      Content
00286      */
00287     function renderUploads($str,$upload_path='uploads/media/')  {
00288         $files = explode(',',$str);
00289         $lines=array();
00290         if ($this->conf['uploads.']['header'])  {$lines[]=$this->getString($this->conf['uploads.']['header']);}
00291         foreach ($files as $k => $file) {
00292             $lines[]=$this->siteUrl.$upload_path.$file;
00293         }
00294         return implode(chr(10),$lines);
00295     }
00296 
00297     /**
00298      * Creates a list
00299      *
00300      * @param   string  type of content
00301      * @return  string  Content
00302      */
00303     function getList($CType = 'list') {
00304         $str = $this->cObj->cObjGetSingle($this->conf[$CType], $this->conf[$CType . '.']);
00305         return trim(strip_tags($this->parseBody($str)));
00306     }
00307 
00308     /**
00309      * Renders a content element header, observing the layout type giving different header formattings
00310      *
00311      * @param   string      The header string
00312      * @param   integer     The layout type of the header (in the content element)
00313      * @return  string      Content
00314      */
00315     function renderHeader($str,$type=0) {
00316         if ($str)   {
00317             $hConf = $this->conf['header.'];
00318             $defaultType = t3lib_div::intInRange($hConf['defaultType'],1,5);
00319             $type=t3lib_div::intInRange($type,0,6);
00320             if (!$type) $type=$defaultType;
00321             if ($type!=6)   {   // not hidden
00322                 $tConf = $hConf[$type.'.'];
00323 
00324                 $lines=array();
00325 
00326                 $blanks = t3lib_div::intInRange($tConf['preBlanks'],0,1000);
00327                 if ($blanks)    {
00328                     $lines[]=str_pad('', $blanks-1, chr(10));
00329                 }
00330 
00331                 $lines=$this->pad($lines,$tConf['preLineChar'],$tConf['preLineLen']);
00332 
00333                 $blanks = t3lib_div::intInRange($tConf['preLineBlanks'],0,1000);
00334                 if ($blanks)    {$lines[]=str_pad('', $blanks-1, chr(10));}
00335 
00336                 if ($this->cObj->data['date'])  {
00337                     $lines[] = $this->getString($hConf['datePrefix']).date($hConf['date']?$hConf['date']:$GLOBALS['TYPO3_CONF_VARS']['SYS']['ddmmyy'],$this->cObj->data['date']);
00338                 }
00339                 $prefix='';
00340                 $str=$this->getString($tConf['prefix']).$str;
00341                 if ($tConf['autonumber'])   $str=$this->cObj->parentRecordNumber.$str;
00342                 if ($this->cObj->data['header_position']=='right')  {$prefix=str_pad(' ',($this->charWidth-strlen($str)));}
00343                 if ($this->cObj->data['header_position']=='center') {$prefix=str_pad(' ',floor(($this->charWidth-strlen($str))/2));}
00344                 $lines[]=$this->cObj->stdWrap($prefix.$str,$tConf['stdWrap.']);
00345                 if ($this->cObj->data['header_link'])       {$lines[] = $this->getString($hConf['linkPrefix']).$this->getLink($this->cObj->data['header_link']);}
00346 
00347                 $blanks = t3lib_div::intInRange($tConf['postLineBlanks'],0,1000);
00348                 if ($blanks)    {$lines[]=str_pad('', $blanks-1, chr(10));}
00349 
00350                 $lines=$this->pad($lines,$tConf['postLineChar'],$tConf['postLineLen']);
00351 
00352                 $blanks = t3lib_div::intInRange($tConf['postBlanks'],0,1000);
00353                 if ($blanks)    {$lines[]=str_pad('', $blanks-1, chr(10));}
00354                 return implode(chr(10),$lines);
00355             }
00356         }
00357     }
00358 
00359     /**
00360      * Function used to repeat a char pattern in head lines (like if you want "********" above/below a header)
00361      *
00362      * @param   array       Array of existing lines to which the new char-pattern should be added
00363      * @param   string      The character pattern to repeat. Default is "-"
00364      * @param   integer     The length of the line. $preLineChar will be repeated to fill in this length.
00365      * @return  array       The input array with a new line added.
00366      * @see renderHeader()
00367      */
00368     function pad($lines,$preLineChar,$len)  {
00369         $strPad = t3lib_div::intInRange($len,0,1000);
00370         $strPadChar = $preLineChar?$preLineChar:'-';
00371         if ($strPad)    {
00372             $lines[]=str_pad('', $strPad, $strPadChar);
00373         }
00374         return $lines;
00375     }
00376 
00377     /**
00378      * Function used to wrap the bodytext field content (or image caption) into lines of a max length of
00379      *
00380      * @param   string      The content to break
00381      * @return  string      Processed value.
00382      * @see main_plaintext(), breakLines()
00383      */
00384     function breakContent($str) {
00385         $cParts = explode(chr(10),$str);
00386         $lines=array();
00387         foreach ($cParts as $substrs) {
00388             $lines[]=$this->breakLines($substrs);
00389         }
00390         return implode(chr(10),$lines);
00391     }
00392 
00393     /**
00394      * Breaks content lines into a bullet list
00395      *
00396      * @param   string      Content string to make into a bullet list
00397      * @return  string      Processed value
00398      */
00399     function breakBulletlist($str)  {
00400         $type = $this->cObj->data['layout'];
00401         $type=t3lib_div::intInRange($type,0,3);
00402 
00403         $tConf = $this->conf['bulletlist.'][$type.'.'];
00404 
00405         $cParts = explode(chr(10),$str);
00406         $lines=array();
00407         $c=0;
00408         foreach ($cParts as $substrs) {
00409             $c++;
00410             $bullet = $tConf['bullet'] ? $this->getString($tConf['bullet']) : ' - ';
00411             $bLen=strlen($bullet);
00412             $bullet = substr(str_replace('#',$c,$bullet),0,$bLen);
00413             $secondRow = substr($tConf['secondRow']?$this->getString($tConf['secondRow']):str_pad('',strlen($bullet),' '),0,$bLen);
00414 
00415             $lines[]=$bullet.$this->breakLines($substrs,chr(10).$secondRow,$this->charWidth-$bLen);
00416 
00417             $blanks = t3lib_div::intInRange($tConf['blanks'],0,1000);
00418             if ($blanks)    {$lines[]=str_pad('', $blanks-1, chr(10));}
00419         }
00420         return implode(chr(10),$lines);
00421     }
00422 
00423     /**
00424      * Formatting a table in plain text (based on the paradigm of lines being content rows and cells separated by "|")
00425      *
00426      * @param   string      Content string
00427      * @return  string      Processed value
00428      */
00429     function breakTable($str)   {
00430         $cParts = explode(chr(10),$str);
00431         $lines=array();
00432         $cols = intval($this->conf['cols']) ? intval($this->conf['cols']) : 0 ;
00433         $c=0;
00434         foreach ($cParts as $substrs) {
00435             $c++;
00436             if (trim($substrs)) {
00437                 $lineParts=explode('|',$substrs);
00438                 if (!$cols) $cols=count($lineParts);
00439 
00440                 for ($a=0;$a<$cols;$a++)    {
00441                     $jdu = explode(chr(10),$this->breakLines($lineParts[$a],chr(10),ceil($this->charWidth/$cols)));
00442                     $lines[$c][$a]=$jdu;
00443                 }
00444             }
00445         }
00446         $messure = $this->traverseTable($lines);
00447 
00448 
00449         $divChar='-';
00450         $joinChar='+';
00451         $colChar='|';
00452 
00453         // Make table:
00454         $outLines = array();
00455         $outLines[]=$this->addDiv($messure,'',$divChar,$joinChar,$cols);
00456 
00457         foreach ($lines as $k => $v) {
00458             $top = intval($messure[1][$k]);
00459             for ($aa=0;$aa<$top;$aa++)  {
00460                 $tempArr=array();
00461                 for ($bb=0;$bb<$cols;$bb++) {
00462                     $tempArr[$bb]=str_pad($v[$bb][$aa],$messure[0][$bb],' ');
00463                 }
00464                 $outLines[]=$colChar.implode($colChar,$tempArr).$colChar;
00465             }
00466             $outLines[]=$this->addDiv($messure,'',$divChar,$joinChar,$cols);
00467         }
00468         return implode(chr(10),$outLines);
00469     }
00470 
00471     /**
00472      * Subfunction for breakTable(): Adds a divider line between table rows.
00473      *
00474      * @param   array       Some information about sizes
00475      * @param   string      Empty string.
00476      * @param   string      Character to use for the divider line, typically "-"
00477      * @param   string      Join character, typically "+"
00478      * @param   integer     Number of table columns
00479      * @return  string      Divider line for the table
00480      * @access private
00481      * @see breakTable()
00482      */
00483     function addDiv($messure,$content,$divChar,$joinChar,$cols) {
00484         $tempArr=array();
00485         for ($a=0;$a<$cols;$a++)    {
00486             $tempArr[$a]=str_pad($content,$messure[0][$a],$divChar);
00487         }
00488         return $joinChar.implode($joinChar,$tempArr).$joinChar;
00489     }
00490 
00491     /**
00492      * Traverses the table lines/cells and creates arrays with statistics for line numbers and lengths
00493      *
00494      * @param   array       Array with [table rows] [table cells] [lines in cell]
00495      * @return  array       Statistics (max lines/lengths)
00496      * @access private
00497      * @see breakTable()
00498      */
00499     function traverseTable($tableLines) {
00500         $maxLen=array();
00501         $maxLines=array();
00502         foreach ($tableLines as $k => $v) {
00503             foreach ($v as $kk => $vv) {
00504                 foreach ($vv as $lk => $lv) {
00505                     if (strlen($lv)>intval($maxLen[$kk]))   $maxLen[$kk]=strlen($lv);
00506                 }
00507                 if (count($vv)>intval($maxLines[$k]))   $maxLines[$k]=count($vv);
00508             }
00509         }
00510         return array($maxLen,$maxLines);
00511     }
00512 
00513     /**
00514      * Render block of images - which means creating lines with links to the images.
00515      *
00516      * @param   string      List of image filenames (from "image" field in tt_content records)
00517      * @param   string      Link value from the "image_link" field in tt_content records
00518      * @param   string      Caption text
00519      * @param   string      Alternative relative path for the files listed in $str
00520      * @return  string      Content
00521      * @see getImages()
00522      */
00523     function renderImages($str,$links,$caption,$upload_path='uploads/pics/')    {
00524         $images = explode(',',$str);
00525         $linksArr = explode(',',$links);
00526         $lines=array();
00527         if ($this->conf['images.']['header'])   {$lines[]=$this->getString($this->conf['images.']['header']);}
00528         foreach ($images as $k => $file) {
00529             $lines[]=$this->siteUrl.$upload_path.$file;
00530             if ($links && count($linksArr)>1)   {
00531                 if (isset($linksArr[$k]))   {
00532                     $ll=$linksArr[$k];
00533                 } else {
00534                     $ll=$linksArr[0];
00535                 }
00536 
00537                 $theLink = $this->getLink($ll);
00538                 if ($theLink)   {$lines[]=$this->getString($this->conf['images.']['linkPrefix']).$theLink;}
00539             }
00540         }
00541         if ($links && count($linksArr)==1)  {
00542             $theLink = $this->getLink($links);
00543             if ($theLink)   {$lines[]=$this->getString($this->conf['images.']['linkPrefix']).$theLink;}
00544         }
00545         if ($caption)   {
00546             $lines[]='';
00547             $cHeader = trim($this->getString($this->conf['images.']['captionHeader']));
00548             if ($cHeader)       $lines[]=$cHeader;
00549             $lines[]=$this->breakContent($caption);
00550         }
00551 
00552         return implode(chr(10),$lines);
00553     }
00554 
00555     /**
00556      * Returns a typolink URL based on input.
00557      *
00558      * @param   string      Parameter to typolink
00559      * @return  string      The URL returned from $this->cObj->getTypoLink_URL(); - possibly it prefixed with the URL of the site if not present already
00560      */
00561     function getLink($ll)   {
00562         $theLink=$this->cObj->getTypoLink_URL($ll);
00563         if (substr($theLink,0,4)!='http')   {
00564             $theLink=$this->siteUrl.$theLink;
00565         }
00566         return $theLink;
00567     }
00568 
00569     /**
00570      * Breaking lines into fixed length lines, using t3lib_div::breakLinesForEmail()
00571      *
00572      * @param   string      The string to break
00573      * @param   string      Line break character
00574      * @param   integer     Length of lines, default is $this->charWidth
00575      * @return  string      Processed string
00576      * @see t3lib_div::breakLinesForEmail()
00577      */
00578     function breakLines($str,$implChar="\n",$charWidth=0)   {
00579         return t3lib_div::breakLinesForEmail($str,$implChar,$charWidth?$charWidth:$this->charWidth);
00580     }
00581 
00582     /**
00583      * Explodes a string with "|" and if the second part is found it will return this, otherwise the first part.
00584      * Used for many TypoScript properties used in this class since they need preceeding whitespace to be preserved.
00585      *
00586      * @param   string      Input string
00587      * @return  string      Output string
00588      * @access private
00589      */
00590     function getString($str)    {
00591         $parts = explode('|',$str);
00592         return strcmp($parts[1],'')?$parts[1]:$parts[0];
00593     }
00594 
00595     /**
00596      * Calls a user function for processing of data
00597      *
00598      * @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)
00599      * @param   mixed       Variable to process
00600      * @return  mixed       The processed $passVar as returned by the function call
00601      */
00602     function userProcess($mConfKey,$passVar)    {
00603         if ($this->conf[$mConfKey]) {
00604             $funcConf = $this->conf[$mConfKey.'.'];
00605             $funcConf['parentObj'] = $this;
00606             $passVar = $GLOBALS['TSFE']->cObj->callUserFunction($this->conf[$mConfKey], $funcConf, $passVar);
00607         }
00608         return $passVar;
00609     }
00610 
00611     /**
00612      * Function used by TypoScript "parseFunc" to process links in the bodytext.
00613      * 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.
00614      *
00615      * @param   string      Empty, ignore.
00616      * @param   array       TypoScript parameters
00617      * @return  string      Processed output.
00618      * @see parseBody()
00619      */
00620     function atag_to_http($content,$conf)   {
00621         $this->conf = $conf;
00622         $this->siteUrl=$conf['siteUrl'];
00623         $theLink  = trim($this->cObj->parameters['href']);
00624         if (strtolower(substr($theLink,0,7))=='mailto:')    {
00625             $theLink=substr($theLink,7);
00626         } elseif (substr($theLink,0,4)!='http') {
00627             $theLink=$this->siteUrl.$theLink;
00628         }
00629         return $this->cObj->getCurrentVal().' (Link: '.$theLink.' )';
00630     }
00631 
00632     /**
00633      * User function (called from TypoScript) for generating a bullet list (used in parsefunc)
00634      *
00635      * @param   string      Empty, ignore.
00636      * @param   array       TypoScript parameters
00637      * @return  string      Processed output.
00638      */
00639     function typolist($content,$conf)   {
00640         $this->conf = $this->cObj->mergeTSRef($conf,'bulletlist');
00641         $this->siteUrl=$conf['siteUrl'];
00642         $str = trim($this->cObj->getCurrentVal());
00643         $this->cObj->data['layout'] = $this->cObj->parameters['type'];
00644         return $this->breakBulletlist($str);
00645     }
00646 
00647     /**
00648      * User function (called from TypoScript) for generating a typo header tag (used in parsefunc)
00649      *
00650      * @param   string      Empty, ignore.
00651      * @param   array       TypoScript parameters
00652      * @return  string      Processed output.
00653      */
00654     function typohead($content,$conf)   {
00655         $this->conf = $this->cObj->mergeTSRef($conf,'header');
00656 
00657         $this->siteUrl=$conf['siteUrl'];
00658         $str = trim($this->cObj->getCurrentVal());
00659         $this->cObj->data['header_layout'] = $this->cObj->parameters['type'];
00660         $this->cObj->data['header_position'] = $this->cObj->parameters['align'];
00661         $this->cObj->data['header']=$str;
00662 
00663         return $this->getHeader();
00664     }
00665 
00666     /**
00667      * User function (called from TypoScript) for generating a code listing (used in parsefunc)
00668      *
00669      * @param   string      Empty, ignore.
00670      * @param   array       TypoScript parameters
00671      * @return  string      Processed output.
00672      */
00673     function typocode($content,$conf)   {
00674             // Nothing is really done here...
00675         $this->conf = $conf;
00676         $this->siteUrl=$conf['siteUrl'];
00677         return $this->cObj->getCurrentVal();
00678     }
00679 }
00680 
00681 
00682 
00683 
00684 if (defined('TYPO3_MODE') && isset($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['media/scripts/plaintextLib.inc'])) {
00685     include_once($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['media/scripts/plaintextLib.inc']);
00686 }
00687 ?>