Support Joomla!

Joomla! 1.5 Documentation

Packages

Package: patTemplate

Developer Network License

The Joomla! Developer Network content is © copyright 2006 by the individual contributors and can be used in accordance with the Creative Commons License, Attribution- NonCommercial- ShareAlike 2.5
Source code for file /pattemplate/patTemplate/Modifier/Wordwrapper.php

Documentation is available at Wordwrapper.php

  1. <?PHP
  2. /**
  3.  * patTemplate modfifier Wordwrapper
  4.  *
  5.  * $Id: Wordwrapper.php 104 2004-04-09 17:59:36Z schst $
  6.  *
  7.  * @package        patTemplate
  8.  * @subpackage    Modifiers
  9.  * @author        Stephan Schmidt <[email protected]>
  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 <[email protected]>
  32.  * @link        http://www.php.net/manual/en/function.wordwrap.php
  33.  */
  34. {
  35.    /**
  36.     * modify the value
  37.     *
  38.     * @access    public
  39.     * @param    string        value
  40.     * @return    string        modified value
  41.     */
  42.     function modify$value$params array() )
  43.     {
  44.         /**
  45.          * width
  46.          */
  47.         if!isset$params['width') )
  48.             $params['width']    =    72;
  49.         settype$params['width']'integer' );
  50.  
  51.         /**
  52.          * character used for linebreaks
  53.          */
  54.         if!isset$params['break') )
  55.             $params['break']    =    "\n";
  56.  
  57.         /**
  58.          * cut at the specified width
  59.          */
  60.         if!isset$params['cut') )
  61.             $params['cut']    =    'no';
  62.  
  63.         $params['cut'($params['cut'=== 'yes'true false;
  64.  
  65.         $value wordwrap$value$params['width']$params['break']$params['cut');
  66.  
  67.         ifisset$params['nl2br'&& $params['nl2br'=== 'yes' )
  68.             $value    =    nl2br$value );
  69.  
  70.         return $value;
  71.     }
  72. }
  73. ?>

Documentation generated on Mon, 05 Mar 2007 21:31:40 +0000 by phpDocumentor 1.3.1