⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 plaintextlib.inc

📁 Typo3, 开源里边最强大的
💻 INC
📖 第 1 页 / 共 2 页
字号:
<?php/****************************************************************  Copyright notice**  (c) 1999-2005 Kasper Skaarhoj (kasperYYYY@typo3.com)*  All rights reserved**  This script is part of the TYPO3 project. The TYPO3 project is*  free software; you can redistribute it and/or modify*  it under the terms of the GNU General Public License as published by*  the Free Software Foundation; either version 2 of the License, or*  (at your option) any later version.**  The GNU General Public License can be found at*  http://www.gnu.org/copyleft/gpl.html.*  A copy is found in the textfile GPL.txt and important notices to the license*  from the author is found in LICENSE.txt distributed with these scripts.***  This script is distributed in the hope that it will be useful,*  but WITHOUT ANY WARRANTY; without even the implied warranty of*  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the*  GNU General Public License for more details.**  This copyright notice MUST APPEAR in all copies of the script!***************************************************************//** * Generating plain text content of content elements for Direct Mails * * $Id: plaintextLib.inc 2000 2007-02-06 07:15:40Z mundaun $ * Revised for TYPO3 3.6 June/2003 by Kasper Skaarhoj * * @author	Kasper Skaarhoj <kasperYYYY@typo3.com> *//** * [CLASS/FUNCTION INDEX of SCRIPT] * * * *  123: class user_plaintext *  137:     function main_plaintext($content,$conf) *  209:     function getMenuSitemap() *  220:     function getShortcut() *  231:     function getHTML($str=array()) *  241:     function getHeader() *  251:     function getImages() *  262:     function parseBody($str) *  284:     function renderUploads($str,$upload_path='uploads/media/') *  302:     function renderHeader($str,$type=0) *  353:     function pad($lines,$preLineChar,$len) *  369:     function breakContent($str) *  385:     function breakBulletlist($str) *  416:     function breakTable($str) *  472:     function addDiv($messure,$content,$divChar,$joinChar,$cols) *  488:     function traverseTable($tableLines) *  515:     function renderImages($str,$links,$caption,$upload_path='uploads/pics/') *  554:     function getLink($ll) *  571:     function breakLines($str,$implChar="\n",$charWidth=0) *  583:     function getString($str) *  595:     function userProcess($mConfKey,$passVar) *  613:     function atag_to_http($content,$conf) *  632:     function typolist($content,$conf) *  647:     function typohead($content,$conf) *  666:     function typocode($content,$conf) * * TOTAL FUNCTIONS: 24 * (This index is automatically created/updated by the extension "extdeveval") * *//** * Alternative rendering of content elements for Plain Text emails. That means text-only output. No HTML at all. Used by the Direct Mail extension. * Normally the plain text output should appear with type=99. * To use this library you can include the static template "plugin.alt.plaintext" * * ## Insert DMailer Boundaries for all elements. * config.insertDmailerBoundaries = 1 * includeLibs.plaintextLib = media/scripts/plaintextLib.inc * * ## Set up page/type number: * alt_plaintext > * alt_plaintext = PAGE * alt_plaintext.typeNum=99 * alt_plaintext.config.disableAllHeaderCode = 1 * alt_plaintext.10 = TEMPLATE * alt_plaintext.10 { *   template = FILE *   template.file = {$plugin.alt.plaintext.file.template} *   marks.CONTENT < styles.content.get *   marks.CONTENT.renderObj = < lib.alt_plaintext.renderObj *   marks.DATE = TEXT *   marks.DATE.data = date:U *   marks.DATE.strftime = %e. %B %Y * } * * (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") * * @author	Kasper Skaarhoj <kasperYYYY@typo3.com> * @package TYPO3 * @subpackage tslib * @link http://typo3.org/doc.0.html?&tx_extrepmgm_pi1[extUid]=270&tx_extrepmgm_pi1[tocEl]=398&cHash=e3024de334 */class user_plaintext {	var $cObj;	var $conf=array();	var $charWidth=76;	/**	 * Main function, called from TypoScript	 * A content object that renders "tt_content" records. See the comment to this class for TypoScript example of how to trigger it.	 * This detects the CType of the current content element and renders it accordingly. Only wellknown types are rendered.	 *	 * @param	string		Empty, ignore.	 * @param	array		TypoScript properties for this content object/function call	 * @return	string		Plain text content	 */	function main_plaintext($content,$conf)	{		$this->conf = $conf;		$this->siteUrl=$conf['siteUrl'];		$lines = array();		$CType= (string)$this->cObj->data['CType'];		switch($CType)	{			case 'header':				$lines[]=$this->getHeader();				if ($this->cObj->data['subheader'])	{					$lines[]=$this->breakContent(strip_tags($this->cObj->data['subheader']));				}			break;			case 'text':			case 'textpic':				$lines[]=$this->getHeader();				if ($CType=='textpic' && !($this->cObj->data['imageorient']&24))	{					$lines[]=$this->getImages();					$lines[]='';				}				$lines[]=$this->breakContent(strip_tags($this->parseBody($this->cObj->data['bodytext'])));				if ($CType=='textpic' && ($this->cObj->data['imageorient']&24))	{					$lines[]='';					$lines[]=$this->getImages();				}			break;			case 'image':				$lines[]=$this->getHeader();				$lines[]=$this->getImages();			break;			case 'uploads':				$lines[]=$this->getHeader();				$lines[]=$this->renderUploads($this->cObj->data['media']);			break;			case 'menu':				$lines[]=$this->getHeader();				$lines[]=$this->getMenuSitemap();			break;			case 'shortcut':				$lines[]=$this->getShortcut();			break;			case 'bullets':				$lines[]=$this->getHeader();				$lines[]=$this->breakBulletlist(strip_tags($this->parseBody($this->cObj->data['bodytext'])));			break;			case 'table':				$lines[]=$this->getHeader();				$lines[]=$this->breakTable(strip_tags($this->parseBody($this->cObj->data['bodytext'])));			break;			case 'html':				$lines[]=$this->getHTML();			break;			default:				$defaultOutput = $this->getString($this->conf['defaultOutput']);				if ($defaultOutput)	{					$lines[]=str_replace('###CType###',$CType,$defaultOutput);				}			break;		}		$lines[]='';	// First break.		$content = implode(chr(10),$lines);			// User processing:		$content=$this->userProcess('userProc',$content);		return $content;	}	/**	 * Creates a menu/sitemap	 *	 * @return	string		Content	 */	function getMenuSitemap()	{		$str = $this->cObj->cObjGetSingle($this->conf['menu'],$this->conf['menu.']);		$str = $this->breakBulletlist(trim(strip_tags(eregi_replace('<br[ /]*>',chr(10),$this->parseBody($str)))));		return $str;	}	/**	 * Creates a shortcut ("Insert Records")	 *	 * @return	string		Content	 */	function getShortcut()	{		$str = $this->cObj->cObjGetSingle($this->conf['shortcut'],$this->conf['shortcut.']);		return $str;	}	/**	 * Creates an HTML element (stripping tags of course)	 *	 * @param	string		HTML content to process. If not passed along, the bodytext field is used.	 * @return	string		Content	 */	function getHTML($str=array())	{		return $this->breakContent(strip_tags(eregi_replace('<br[ /]*>',chr(10),$this->parseBody(is_string($str)?$str:$this->cObj->data['bodytext']))));	}	/**	 * Creates a header (used for most elements)	 *	 * @return	string		Content	 * @see renderHeader()	 */	function getHeader()	{		// links...		return $this->renderHeader($this->cObj->data['header'],$this->cObj->data['header_layout']);	}	/**	 * Get images found in the "image" field of "tt_content"	 *	 * @return	string		Content	 */	function getImages()	{		$images = $this->renderImages($this->cObj->data['image'],!$this->cObj->data['image_zoom']?$this->cObj->data['image_link']:'',$this->cObj->data['imagecaption']);		return $images;	}	/**	 * Parsing the bodytext field content, removing typical entities and <br /> tags.	 *	 * @param	string		Field content from "bodytext"	 * @return	string		Processed content	 */	function parseBody($str)	{			// First, regular parsing:		$str = eregi_replace('<br[ /]*>',' ',$str);		$str = $this->cObj->stdWrap($str,$this->conf['bodytext.']['stdWrap.']);			// Then all a-tags:		$aConf = array();		$aConf['parseFunc.']['tags.']['a']='USER';		$aConf['parseFunc.']['tags.']['a.']['userFunc']='user_plaintext->atag_to_http';		$aConf['parseFunc.']['tags.']['a.']['siteUrl'] = $this->siteUrl;		$str = $this->cObj->stdWrap($str,$aConf);		$str = str_replace('&nbsp;',' ',t3lib_div::htmlspecialchars_decode($str));		return $str;	}	/**	 * Creates a list of links to uploaded files.	 *	 * @param	string		List of uploaded filenames from "uploads/media/" (or $upload_path)	 * @param	string		Alternative path value	 * @return	string		Content	 */	function renderUploads($str,$upload_path='uploads/media/')	{		$files = explode(',',$str);		reset($files);		$lines=array();		if ($this->conf['uploads.']['header'])	{$lines[]=$this->getString($this->conf['uploads.']['header']);}		while(list($k,$file)=each($files))	{			$lines[]=$this->siteUrl.$upload_path.$file;		}		return implode(chr(10),$lines);	}	/**	 * Renders a content element header, observing the layout type giving different header formattings	 *	 * @param	string		The header string	 * @param	integer		The layout type of the header (in the content element)	 * @return	string		Content	 */	function renderHeader($str,$type=0)	{		if ($str)	{			$hConf = $this->conf['header.'];			$defaultType = t3lib_div::intInRange($hConf['defaultType'],1,5);			$type=t3lib_div::intInRange($type,0,6);			if (!$type)	$type=$defaultType;			if ($type!=6)	{	// not hidden				$tConf = $hConf[$type.'.'];				$lines=array();				$blanks = t3lib_div::intInRange($tConf['preBlanks'],0,1000);				if ($blanks)	{					$lines[]=str_pad('', $blanks-1, chr(10));				}				$lines=$this->pad($lines,$tConf['preLineChar'],$tConf['preLineLen']);				$blanks = t3lib_div::intInRange($tConf['preLineBlanks'],0,1000);				if ($blanks)	{$lines[]=str_pad('', $blanks-1, chr(10));}				if ($this->cObj->data['date'])	{					$lines[] = $this->getString($hConf['datePrefix']).date($hConf['date']?$hConf['date']:$GLOBALS['TYPO3_CONF_VARS']['SYS']['ddmmyy'],$this->cObj->data['date']);				}				$prefix='';				$str=$this->getString($tConf['prefix']).$str;				if ($tConf['autonumber'])	$str=$this->cObj->parentRecordNumber.$str;				if ($this->cObj->data['header_position']=='right')	{$prefix=str_pad(' ',($this->charWidth-strlen($str)));}				if ($this->cObj->data['header_position']=='center')	{$prefix=str_pad(' ',floor(($this->charWidth-strlen($str))/2));}				$lines[]=$this->cObj->stdWrap($prefix.$str,$tConf['stdWrap.']);				if ($this->cObj->data['header_link'])		{$lines[] = $this->getString($hConf['linkPrefix']).$this->getLink($this->cObj->data['header_link']);}				$blanks = t3lib_div::intInRange($tConf['postLineBlanks'],0,1000);				if ($blanks)	{$lines[]=str_pad('', $blanks-1, chr(10));}				$lines=$this->pad($lines,$tConf['postLineChar'],$tConf['postLineLen']);				$blanks = t3lib_div::intInRange($tConf['postBlanks'],0,1000);				if ($blanks)	{$lines[]=str_pad('', $blanks-1, chr(10));}				return implode(chr(10),$lines);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -