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 8742 2010-08-30 18:55:32Z 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  * @link http://typo3.org/doc.0.html?&tx_extrepmgm_pi1[extUid]=270&tx_extrepmgm_pi1[tocEl]=398&cHash=e3024de334
00122  */
00123 class user_plaintext {
00124     var $cObj;
00125     var $conf=array();
00126     var $charWidth=76;
00127 
00128     /**
00129      * Main function, called from TypoScript
00130      * A content object that renders "tt_content" records. See the comment to this class for TypoScript example of how to trigger it.
00131      * This detects the CType of the current content element and renders it accordingly. Only wellknown types are rendered.
00132      *
00133      * @param   string      Empty, ignore.
00134      * @param   array       TypoScript properties for this content object/function call
00135      * @return  string      Plain text content
00136      */
00137     function main_plaintext($content,$conf) {
00138         $this->conf = $conf;
00139         $this->siteUrl=$conf['siteUrl'];
00140         $lines = array();
00141         $CType= (string)$this->cObj->data['CType'];
00142         switch($CType)  {
00143             case 'header':
00144                 $lines[]=$this->getHeader();
00145                 if ($this->cObj->data['subheader']) {
00146                     $lines[]=$this->breakContent(strip_tags($this->cObj->data['subheader']));
00147                 }
00148             break;
00149             case 'text':
00150             case 'textpic':
00151                 $lines[]=$this->getHeader();
00152                 if ($CType=='textpic' && !($this->cObj->data['imageorient']&24))    {
00153                     $lines[]=$this->getImages();
00154                     $lines[]='';
00155                 }
00156                 $lines[]=$this->breakContent(strip_tags($this->parseBody($this->cObj->data['bodytext'])));
00157                 if ($CType=='textpic' && ($this->cObj->data['imageorient']&24)) {
00158                     $lines[]='';
00159                     $lines[]=$this->getImages();
00160                 }
00161             break;
00162             case 'image':
00163                 $lines[]=$this->getHeader();
00164                 $lines[]=$this->getImages();
00165             break;
00166             case 'uploads':
00167                 $lines[]=$this->getHeader();
00168                 $lines[]=$this->renderUploads($this->cObj->data['media']);
00169             break;
00170             case 'menu':
00171                 $lines[]=$this->getHeader();
00172                 $lines[]=$this->getMenuSitemap();
00173             break;
00174             case 'shortcut':
00175                 $lines[]=$this->getShortcut();
00176             break;
00177             case 'bullets':
00178                 $lines[]=$this->getHeader();
00179                 $lines[]=$this->breakBulletlist(strip_tags($this->parseBody($this->cObj->data['bodytext'])));
00180             break;
00181             case 'table':
00182                 $lines[]=$this->getHeader();
00183                 $lines[]=$this->breakTable(strip_tags($this->parseBody($this->cObj->data['bodytext'])));
00184             break;
00185             case 'html':
00186                 $lines[]=$this->getHTML();
00187             break;
00188             default:
00189                 $defaultOutput = $this->getString($this->conf['defaultOutput']);
00190                 if ($defaultOutput) {
00191                     $lines[]=str_replace('###CType###',$CType,$defaultOutput);
00192                 }
00193             break;
00194         }
00195 
00196         $lines[]='';    // First break.
00197         $content = implode(chr(10),$lines);
00198 
00199             // User processing:
00200         $content=$this->userProcess('userProc',$content);
00201         return $content;
00202     }
00203 
00204     /**
00205      * Creates a menu/sitemap
00206      *
00207      * @return  string      Content
00208      */
00209     function getMenuSitemap()   {
00210         $str = $this->cObj->cObjGetSingle($this->conf['menu'],$this->conf['menu.']);
00211         $str = $this->breakBulletlist(trim(strip_tags(preg_replace('/<br[ \/]*>/i',chr(10),$this->parseBody($str)))));
00212         return $str;
00213     }
00214 
00215     /**
00216      * Creates a shortcut ("Insert Records")
00217      *
00218      * @return  string      Content
00219      */
00220     function getShortcut()  {
00221         $str = $this->cObj->cObjGetSingle($this->conf['shortcut'],$this->conf['shortcut.']);
00222         return $str;
00223     }
00224 
00225     /**
00226      * Creates an HTML element (stripping tags of course)
00227      *
00228      * @param   string      HTML content to process. If not passed along, the bodytext field is used.
00229      * @return  string      Content
00230      */
00231     function getHTML($str=array())  {
00232         return $this->breakContent(strip_tags(preg_replace('/<br[ \/]*>/i',chr(10),$this->parseBody(is_string($str)?$str:$this->cObj->data['bodytext']))));
00233     }
00234 
00235     /**
00236      * Creates a header (used for most elements)
00237      *
00238      * @return  string      Content
00239      * @see renderHeader()
00240      */
00241     function getHeader()    {
00242         // links...
00243         return $this->renderHeader($this->cObj->data['header'],$this->cObj->data['header_layout']);
00244     }
00245 
00246     /**
00247      * Get images found in the "image" field of "tt_content"
00248      *
00249      * @return  string      Content
00250      */
00251     function getImages()    {
00252         $images = $this->renderImages($this->cObj->data['image'],!$this->cObj->data['image_zoom']?$this->cObj->data['image_link']:'',$this->cObj->data['imagecaption']);
00253         return $images;
00254     }
00255 
00256     /**
00257      * Parsing the bodytext field content, removing typical entities and <br /> tags.
00258      *
00259      * @param   string      Field content from "bodytext"
00260      * @return  string      Processed content
00261      */
00262     function parseBody($str)    {
00263             // First, regular parsing:
00264         $str = preg_replace('/<br[ \/]*>/i',' ',$str);
00265         $str = $this->cObj->stdWrap($str,$this->conf['bodytext.']['stdWrap.']);
00266             // Then all a-tags:
00267         $aConf = array();
00268         $aConf['parseFunc.']['tags.']['a']='USER';
00269         $aConf['parseFunc.']['tags.']['a.']['userFunc']='user_plaintext->atag_to_http';
00270         $aConf['parseFunc.']['tags.']['a.']['siteUrl'] = $this->siteUrl;
00271 
00272         $str = $this->cObj->stdWrap($str,$aConf);
00273         $str = str_replace('&nbsp;',' ',t3lib_div::htmlspecialchars_decode($str));
00274         return $str;
00275     }
00276 
00277     /**
00278      * Creates a list of links to uploaded files.
00279      *
00280      * @param   string      List of uploaded filenames from "uploads/media/" (or $upload_path)
00281      * @param   string      Alternative path value
00282      * @return  string      Content
00283      */
00284     function renderUploads($str,$upload_path='uploads/media/')  {
00285         $files = explode(',',$str);
00286         $lines=array();
00287         if ($this->conf['uploads.']['header'])  {$lines[]=$this->getString($this->conf['uploads.']['header']);}
00288         foreach ($files as $k => $file) {
00289             $lines[]=$this->siteUrl.$upload_path.$file;
00290         }
00291         return implode(chr(10),$lines);
00292     }
00293 
00294     /**
00295      * Renders a content element header, observing the layout type giving different header formattings
00296      *
00297      * @param   string      The header string
00298      * @param   integer     The layout type of the header (in the content element)
00299      * @return  string      Content
00300      */
00301     function renderHeader($str,$type=0) {
00302         if ($str)   {
00303             $hConf = $this->conf['header.'];
00304             $defaultType = t3lib_div::intInRange($hConf['defaultType'],1,5);
00305             $type=t3lib_div::intInRange($type,0,6);
00306             if (!$type) $type=$defaultType;
00307             if ($type!=6)   {   // not hidden
00308                 $tConf = $hConf[$type.'.'];
00309 
00310                 $lines=array();
00311 
00312                 $blanks = t3lib_div::intInRange($tConf['preBlanks'],0,1000);
00313                 if ($blanks)    {
00314                     $lines[]=str_pad('', $blanks-1, chr(10));
00315                 }
00316 
00317                 $lines=$this->pad($lines,$tConf['preLineChar'],$tConf['preLineLen']);
00318 
00319                 $blanks = t3lib_div::intInRange($tConf['preLineBlanks'],0,1000);
00320                 if ($blanks)    {$lines[]=str_pad('', $blanks-1, chr(10));}
00321 
00322                 if ($this->cObj->data['date'])  {
00323                     $lines[] = $this->getString($hConf['datePrefix']).date($hConf['date']?$hConf['date']:$GLOBALS['TYPO3_CONF_VARS']['SYS']['ddmmyy'],$this->cObj->data['date']);
00324                 }
00325                 $prefix='';
00326                 $str=$this->getString($tConf['prefix']).$str;
00327                 if ($tConf['autonumber'])   $str=$this->cObj->parentRecordNumber.$str;
00328                 if ($this->cObj->data['header_position']=='right')  {$prefix=str_pad(' ',($this->charWidth-strlen($str)));}
00329                 if ($this->cObj->data['header_position']=='center') {$prefix=str_pad(' ',floor(($this->charWidth-strlen($str))/2));}
00330                 $lines[]=$this->cObj->stdWrap($prefix.$str,$tConf['stdWrap.']);
00331                 if ($this->cObj->data['header_link'])       {$lines[] = $this->getString($hConf['linkPrefix']).$this->getLink($this->cObj->data['header_link']);}
00332 
00333                 $blanks = t3lib_div::intInRange($tConf['postLineBlanks'],0,1000);
00334                 if ($blanks)    {$lines[]=str_pad('', $blanks-1, chr(10));}
00335 
00336                 $lines=$this->pad($lines,$tConf['postLineChar'],$tConf['postLineLen']);
00337 
00338                 $blanks = t3lib_div::intInRange($tConf['postBlanks'],0,1000);
00339                 if ($blanks)    {$lines[]=str_pad('', $blanks-1, chr(10));}
00340                 return implode(chr(10),$lines);
00341             }
00342         }
00343     }
00344 
00345     /**
00346      * Function used to repeat a char pattern in head lines (like if you want "********" above/below a header)
00347      *
00348      * @param   array       Array of existing lines to which the new char-pattern should be added
00349      * @param   string      The character pattern to repeat. Default is "-"
00350      * @param   integer     The length of the line. $preLineChar will be repeated to fill in this length.
00351      * @return  array       The input array with a new line added.
00352      * @see renderHeader()
00353      */
00354     function pad($lines,$preLineChar,$len)  {
00355         $strPad = t3lib_div::intInRange($len,0,1000);
00356         $strPadChar = $preLineChar?$preLineChar:'-';
00357         if ($strPad)    {
00358             $lines[]=str_pad('', $strPad, $strPadChar);
00359         }
00360         return $lines;
00361     }
00362 
00363     /**
00364      * Function used to wrap the bodytext field content (or image caption) into lines of a max length of
00365      *
00366      * @param   string      The content to break
00367      * @return  string      Processed value.
00368      * @see main_plaintext(), breakLines()
00369      */
00370     function breakContent($str) {
00371         $cParts = explode(chr(10),$str);
00372         $lines=array();
00373         foreach ($cParts as $substrs) {
00374             $lines[]=$this->breakLines($substrs);
00375         }
00376         return implode(chr(10),$lines);
00377     }
00378 
00379     /**
00380      * Breaks content lines into a bullet list
00381      *
00382      * @param   string      Content string to make into a bullet list
00383      * @return  string      Processed value
00384      */
00385     function breakBulletlist($str)  {
00386         $type = $this->cObj->data['layout'];
00387         $type=t3lib_div::intInRange($type,0,3);
00388 
00389         $tConf = $this->conf['bulletlist.'][$type.'.'];
00390 
00391         $cParts = explode(chr(10),$str);
00392         $lines=array();
00393         $c=0;
00394         foreach ($cParts as $substrs) {
00395             $c++;
00396             $bullet = $tConf['bullet'] ? $this->getString($tConf['bullet']) : ' - ';
00397             $bLen=strlen($bullet);
00398             $bullet = substr(str_replace('#',$c,$bullet),0,$bLen);
00399             $secondRow = substr($tConf['secondRow']?$this->getString($tConf['secondRow']):str_pad('',strlen($bullet),' '),0,$bLen);
00400 
00401             $lines[]=$bullet.$this->breakLines($substrs,chr(10).$secondRow,$this->charWidth-$bLen);
00402 
00403             $blanks = t3lib_div::intInRange($tConf['blanks'],0,1000);
00404             if ($blanks)    {$lines[]=str_pad('', $blanks-1, chr(10));}
00405         }
00406         return implode(chr(10),$lines);
00407     }
00408 
00409     /**
00410      * Formatting a table in plain text (based on the paradigm of lines being content rows and cells separated by "|")
00411      *
00412      * @param   string      Content string
00413      * @return  string      Processed value
00414      */
00415     function breakTable($str)   {
00416         $cParts = explode(chr(10),$str);
00417         $lines=array();
00418         $cols = intval($this->conf['cols']) ? intval($this->conf['cols']) : 0 ;
00419         $c=0;
00420         foreach ($cParts as $substrs) {
00421             $c++;
00422             if (trim($substrs)) {
00423                 $lineParts=explode('|',$substrs);
00424                 if (!$cols) $cols=count($lineParts);
00425 
00426                 for ($a=0;$a<$cols;$a++)    {
00427                     $jdu = explode(chr(10),$this->breakLines($lineParts[$a],chr(10),ceil($this->charWidth/$cols)));
00428                     $lines[$c][$a]=$jdu;
00429                 }
00430             }
00431         }
00432         $messure = $this->traverseTable($lines);
00433 
00434 
00435         $divChar='-';
00436         $joinChar='+';
00437         $colChar='|';
00438 
00439         // Make table:
00440         $outLines = array();
00441         $outLines[]=$this->addDiv($messure,'',$divChar,$joinChar,$cols);
00442 
00443         foreach ($lines as $k => $v) {
00444             $top = intval($messure[1][$k]);
00445             for ($aa=0;$aa<$top;$aa++)  {
00446                 $tempArr=array();
00447                 for ($bb=0;$bb<$cols;$bb++) {
00448                     $tempArr[$bb]=str_pad($v[$bb][$aa],$messure[0][$bb],' ');
00449                 }
00450                 $outLines[]=$colChar.implode($colChar,$tempArr).$colChar;
00451             }
00452             $outLines[]=$this->addDiv($messure,'',$divChar,$joinChar,$cols);
00453         }
00454         return implode(chr(10),$outLines);
00455     }
00456 
00457     /**
00458      * Subfunction for breakTable(): Adds a divider line between table rows.
00459      *
00460      * @param   array       Some information about sizes
00461      * @param   string      Empty string.
00462      * @param   string      Character to use for the divider line, typically "-"
00463      * @param   string      Join character, typically "+"
00464      * @param   integer     Number of table columns
00465      * @return  string      Divider line for the table
00466      * @access private
00467      * @see breakTable()
00468      */
00469     function addDiv($messure,$content,$divChar,$joinChar,$cols) {
00470         $tempArr=array();
00471         for ($a=0;$a<$cols;$a++)    {
00472             $tempArr[$a]=str_pad($content,$messure[0][$a],$divChar);
00473         }
00474         return $joinChar.implode($joinChar,$tempArr).$joinChar;
00475     }
00476 
00477     /**
00478      * Traverses the table lines/cells and creates arrays with statistics for line numbers and lengths
00479      *
00480      * @param   array       Array with [table rows] [table cells] [lines in cell]
00481      * @return  array       Statistics (max lines/lengths)
00482      * @access private
00483      * @see breakTable()
00484      */
00485     function traverseTable($tableLines) {
00486         $maxLen=array();
00487         $maxLines=array();
00488         foreach ($tableLines as $k => $v) {
00489             foreach ($v as $kk => $vv) {
00490                 foreach ($vv as $lk => $lv) {
00491                     if (strlen($lv)>intval($maxLen[$kk]))   $maxLen[$kk]=strlen($lv);
00492                 }
00493                 if (count($vv)>intval($maxLines[$k]))   $maxLines[$k]=count($vv);
00494             }
00495         }
00496         return array($maxLen,$maxLines);
00497     }
00498 
00499     /**
00500      * Render block of images - which means creating lines with links to the images.
00501      *
00502      * @param   string      List of image filenames (from "image" field in tt_content records)
00503      * @param   string      Link value from the "image_link" field in tt_content records
00504      * @param   string      Caption text
00505      * @param   string      Alternative relative path for the files listed in $str
00506      * @return  string      Content
00507      * @see getImages()
00508      */
00509     function renderImages($str,$links,$caption,$upload_path='uploads/pics/')    {
00510         $images = explode(',',$str);
00511         $linksArr = explode(',',$links);
00512         $lines=array();
00513         if ($this->conf['images.']['header'])   {$lines[]=$this->getString($this->conf['images.']['header']);}
00514         foreach ($images as $k => $file) {
00515             $lines[]=$this->siteUrl.$upload_path.$file;
00516             if ($links && count($linksArr)>1)   {
00517                 if (isset($linksArr[$k]))   {
00518                     $ll=$linksArr[$k];
00519                 } else {
00520                     $ll=$linksArr[0];
00521                 }
00522 
00523                 $theLink = $this->getLink($ll);
00524                 if ($theLink)   {$lines[]=$this->getString($this->conf['images.']['linkPrefix']).$theLink;}
00525             }
00526         }
00527         if ($links && count($linksArr)==1)  {
00528             $theLink = $this->getLink($links);
00529             if ($theLink)   {$lines[]=$this->getString($this->conf['images.']['linkPrefix']).$theLink;}
00530         }
00531         if ($caption)   {
00532             $lines[]='';
00533             $cHeader = trim($this->getString($this->conf['images.']['captionHeader']));
00534             if ($cHeader)       $lines[]=$cHeader;
00535             $lines[]=$this->breakContent($caption);
00536         }
00537 
00538         return implode(chr(10),$lines);
00539     }
00540 
00541     /**
00542      * Returns a typolink URL based on input.
00543      *
00544      * @param   string      Parameter to typolink
00545      * @return  string      The URL returned from $this->cObj->getTypoLink_URL(); - possibly it prefixed with the URL of the site if not present already
00546      */
00547     function getLink($ll)   {
00548         $theLink=$this->cObj->getTypoLink_URL($ll);
00549         if (substr($theLink,0,4)!='http')   {
00550             $theLink=$this->siteUrl.$theLink;
00551         }
00552         return $theLink;
00553     }
00554 
00555     /**
00556      * Breaking lines into fixed length lines, using t3lib_div::breakLinesForEmail()
00557      *
00558      * @param   string      The string to break
00559      * @param   string      Line break character
00560      * @param   integer     Length of lines, default is $this->charWidth
00561      * @return  string      Processed string
00562      * @see t3lib_div::breakLinesForEmail()
00563      */
00564     function breakLines($str,$implChar="\n",$charWidth=0)   {
00565         return t3lib_div::breakLinesForEmail($str,$implChar,$charWidth?$charWidth:$this->charWidth);
00566     }
00567 
00568     /**
00569      * Explodes a string with "|" and if the second part is found it will return this, otherwise the first part.
00570      * Used for many TypoScript properties used in this class since they need preceeding whitespace to be preserved.
00571      *
00572      * @param   string      Input string
00573      * @return  string      Output string
00574      * @access private
00575      */
00576     function getString($str)    {
00577         $parts = explode('|',$str);
00578         return strcmp($parts[1],'')?$parts[1]:$parts[0];
00579     }
00580 
00581     /**
00582      * Calls a user function for processing of data
00583      *
00584      * @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)
00585      * @param   mixed       Variable to process
00586      * @return  mixed       The processed $passVar as returned by the function call
00587      */
00588     function userProcess($mConfKey,$passVar)    {
00589         if ($this->conf[$mConfKey]) {
00590             $funcConf = $this->conf[$mConfKey.'.'];
00591             $funcConf['parentObj'] = $this;
00592             $passVar = $GLOBALS['TSFE']->cObj->callUserFunction($this->conf[$mConfKey], $funcConf, $passVar);
00593         }
00594         return $passVar;
00595     }
00596 
00597     /**
00598      * Function used by TypoScript "parseFunc" to process links in the bodytext.
00599      * 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.
00600      *
00601      * @param   string      Empty, ignore.
00602      * @param   array       TypoScript parameters
00603      * @return  string      Processed output.
00604      * @see parseBody()
00605      */
00606     function atag_to_http($content,$conf)   {
00607         $this->conf = $conf;
00608         $this->siteUrl=$conf['siteUrl'];
00609         $theLink  = trim($this->cObj->parameters['href']);
00610         if (strtolower(substr($theLink,0,7))=='mailto:')    {
00611             $theLink=substr($theLink,7);
00612         } elseif (substr($theLink,0,4)!='http') {
00613             $theLink=$this->siteUrl.$theLink;
00614         }
00615         return $this->cObj->getCurrentVal().' (Link: '.$theLink.' )';
00616     }
00617 
00618     /**
00619      * User function (called from TypoScript) for generating a bullet list (used in parsefunc)
00620      *
00621      * @param   string      Empty, ignore.
00622      * @param   array       TypoScript parameters
00623      * @return  string      Processed output.
00624      */
00625     function typolist($content,$conf)   {
00626         $this->conf = $this->cObj->mergeTSRef($conf,'bulletlist');
00627         $this->siteUrl=$conf['siteUrl'];
00628         $str = trim($this->cObj->getCurrentVal());
00629         $this->cObj->data['layout'] = $this->cObj->parameters['type'];
00630         return $this->breakBulletlist($str);
00631     }
00632 
00633     /**
00634      * User function (called from TypoScript) for generating a typo header tag (used in parsefunc)
00635      *
00636      * @param   string      Empty, ignore.
00637      * @param   array       TypoScript parameters
00638      * @return  string      Processed output.
00639      */
00640     function typohead($content,$conf)   {
00641         $this->conf = $this->cObj->mergeTSRef($conf,'header');
00642 
00643         $this->siteUrl=$conf['siteUrl'];
00644         $str = trim($this->cObj->getCurrentVal());
00645         $this->cObj->data['header_layout'] = $this->cObj->parameters['type'];
00646         $this->cObj->data['header_position'] = $this->cObj->parameters['align'];
00647         $this->cObj->data['header']=$str;
00648 
00649         return $this->getHeader();
00650     }
00651 
00652     /**
00653      * User function (called from TypoScript) for generating a code listing (used in parsefunc)
00654      *
00655      * @param   string      Empty, ignore.
00656      * @param   array       TypoScript parameters
00657      * @return  string      Processed output.
00658      */
00659     function typocode($content,$conf)   {
00660             // Nothing is really done here...
00661         $this->conf = $conf;
00662         $this->siteUrl=$conf['siteUrl'];
00663         return $this->cObj->getCurrentVal();
00664     }
00665 }
00666 
00667 
00668 
00669 
00670 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['media/scripts/plaintextLib.inc'])  {
00671     include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['media/scripts/plaintextLib.inc']);
00672 }
00673 ?>

Generated on Sat Sep 4 04:17:15 2010 for TYPO3 API by  doxygen 1.4.7