[ Index ]
 

Code source de Horde 3.1.3

Accédez au Source d'autres logiciels libresSoutenez Angelica Josefina !

title

Body

[fermer]

/lib/Horde/Text/Filter/ -> tabs2spaces.php (source)

   1  <?php
   2  /**
   3   * The Text_Filter_tabs2spaces:: converts tabs into spaces.
   4   *
   5   * $Horde: framework/Text_Filter/Filter/tabs2spaces.php,v 1.3.10.6 2006/01/01 21:28:38 jan Exp $
   6   *
   7   * Copyright 2004-2006 Chuck Hagenbuch <chuck@horde.org>
   8   *
   9   * See the enclosed file COPYING for license information (LGPL). If you did not
  10   * receive this file, see http://www.fsf.org/copyleft/lgpl.html.
  11   *
  12   * @author  Chuck Hagenbuch <chuck@horde.org>
  13   * @package Horde_Text
  14   */
  15  class Text_Filter_tabs2spaces extends Text_Filter {
  16  
  17      /**
  18       * Filter parameters.
  19       *
  20       * @var array
  21       */
  22      var $_params = array('tabstop' => 8, 'breakchar' => "\n");
  23  
  24      /**
  25       * Executes any code necessary before applying the filter patterns.
  26       *
  27       * @param string $text  The text before the filtering.
  28       *
  29       * @return string  The modified text.
  30       */
  31      function preProcess($text)
  32      {
  33          $lines = explode($this->_params['breakchar'], $text);
  34          for ($i = 0; $i < count($lines); $i++) {
  35              while (($pos = strpos($lines[$i], "\t")) !== false) {
  36                  $n_space = $this->_params['tabstop'] - ($pos % $this->_params['tabstop']);
  37                  $new_str = str_repeat(' ', $n_space);
  38                  $lines[$i] = substr_replace($lines[$i], $new_str, $pos, 1);
  39              }
  40          }
  41          return implode("\n", $lines);
  42      }
  43  
  44  }


Généré le : Sun Feb 25 18:01:28 2007 par Balluche grâce à PHPXref 0.7