PageRenderTime 55ms CodeModel.GetById 18ms RepoModel.GetById 0ms app.codeStats 0ms

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

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