| [ Index ] |
PHP Cross Reference of Joomla 1.5.26 DE |
[Summary view] [Print] [Text view]
1 <?PHP 2 /** 3 * patTemplate modfifier Wordwrapper 4 * 5 * $Id: Wordwrapper.php 10381 2008-06-01 03:35:53Z pasamio $ 6 * 7 * @package patTemplate 8 * @subpackage Modifiers 9 * @author Stephan Schmidt <schst@php.net> 10 */ 11 12 // Check to ensure this file is within the rest of the framework 13 defined('JPATH_BASE') or die(); 14 15 /** 16 * patTemplate modfifier Wordwrapper 17 * 18 * Wraps lines of long texts. 19 * 20 * Possible attributes are: 21 * - width (integer) 22 * - break (string) 23 * - cut (yes|no) 24 * - nl2br (yes|no) 25 * 26 * See the PHP documentation for wordwrap() for 27 * more information. 28 * 29 * @package patTemplate 30 * @subpackage Modifiers 31 * @author Stephan Schmidt <schst@php.net> 32 * @link http://www.php.net/manual/en/function.wordwrap.php 33 */ 34 class patTemplate_Modifier_Wordwrapper extends patTemplate_Modifier 35 { 36 /** 37 * modify the value 38 * 39 * @access public 40 * @param string value 41 * @return string modified value 42 */ 43 function modify( $value, $params = array() ) 44 { 45 /** 46 * width 47 */ 48 if( !isset( $params['width'] ) ) 49 $params['width'] = 72; 50 settype( $params['width'], 'integer' ); 51 52 /** 53 * character used for linebreaks 54 */ 55 if( !isset( $params['break'] ) ) 56 $params['break'] = "\n"; 57 58 /** 59 * cut at the specified width 60 */ 61 if( !isset( $params['cut'] ) ) 62 $params['cut'] = 'no'; 63 64 $params['cut'] = ($params['cut'] === 'yes') ? true : false; 65 66 $value = wordwrap( $value, $params['width'], $params['break'], $params['cut'] ); 67 68 if( isset( $params['nl2br'] ) && $params['nl2br'] === 'yes' ) 69 $value = nl2br( $value ); 70 71 return $value; 72 } 73 } 74 ?>
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Wed Mar 28 15:54:07 2012 | Cross-referenced by PHPXref 0.7.1 |