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/Surround.php

Documentation is available at Surround.php

  1. <?PHP
  2. /**
  3.  * patTemplate modfifier Surround
  4.  *
  5.  * $Id: Surround.php 297 2004-10-03 11:35:57Z gerd $
  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 Surround
  17.  *
  18.  * splits a text and surrunds each part by custom start and end strings
  19.  *
  20.  * Possible attributes are:
  21.  * - delimiter (string)
  22.  * - start (string)
  23.  * - end (string)
  24.  * - keepdelimiter (yes|no) default: no
  25.  * - withfirst (yes|no) default: yes
  26.  * - withlast (yes|no) default: yes
  27.  *
  28.  *
  29.  * @package        patTemplate
  30.  * @subpackage    Modifiers
  31.  * @author        gERD Schaufelberger <[email protected]>
  32.  * @version        0.2
  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.         // set default values
  45.         $delimiter    =    "\n";
  46.         $start        =    '';
  47.         $end        =    '';
  48.  
  49.         // where to split
  50.         ifisset$params['delimiter') )
  51.         {
  52.             $delimiter    =    $params['delimiter'];
  53.         }
  54.  
  55.         ifisset$params['start') )
  56.         {
  57.             $start    =    $params['start'];
  58.         }
  59.  
  60.         ifisset$params['end') )
  61.         {
  62.             $end    =    $params['end'];
  63.         }
  64.  
  65.         // append the delimiter?
  66.         ifisset$params['keepdelimiter'&& $params['keepdelimiter'=== 'yes' )
  67.         {
  68.             $end    .=    $delimiter;
  69.         }
  70.  
  71.         $split    =    explode$delimiter$value );
  72.         $value    =    implode$end $start$split );
  73.  
  74.         // add first?
  75.         if!isset$params['withfirst'|| $params['withfirst'!== 'no' )
  76.         {
  77.             $value    =    $start $value;
  78.         }
  79.  
  80.         // add last?
  81.         if!isset$params['withlast'|| $params['withlast'!== 'no' )
  82.         {
  83.             $value    .=    $end;
  84.         }
  85.  
  86.         return $value;
  87.     }
  88. }
  89. ?>

Documentation generated on Mon, 05 Mar 2007 21:27:23 +0000 by phpDocumentor 1.3.1