home *** CD-ROM | disk | FTP | other *** search
/ Cricao de Sites - 650 Layouts Prontos / WebMasters.iso / Servidores / xampp-win32-1.6.7-installer.exe / phpMyAdmin / libraries / transformations / text_plain__substr.inc.php < prev   
Encoding:
PHP Script  |  2008-06-23  |  1.2 KB  |  51 lines

  1. <?php
  2. /* vim: set expandtab sw=4 ts=4 sts=4: */
  3. /**
  4.  *
  5.  * @version $Id: text_plain__substr.inc.php 10239 2007-04-01 09:51:41Z cybot_tm $
  6.  */
  7.  
  8. /**
  9.  *
  10.  */
  11. function PMA_transformation_text_plain__substr($buffer, $options = array(), $meta = '') {
  12.     // possibly use a global transform and feed it with special options:
  13.     // include './libraries/transformations/global.inc.php';
  14.  
  15.     // further operations on $buffer using the $options[] array.
  16.     if (!isset($options[0]) ||  $options[0] == '') {
  17.         $options[0] = 0;
  18.     }
  19.  
  20.     if (!isset($options[1]) ||  $options[1] == '') {
  21.         $options[1] = 'all';
  22.     }
  23.  
  24.     if (!isset($options[2]) || $options[2] == '') {
  25.         $options[2] = '...';
  26.     }
  27.  
  28.     $newtext = '';
  29.     if ($options[1] != 'all') {
  30.         $newtext = PMA_substr($buffer, $options[0], $options[1]);
  31.     } else {
  32.         $newtext = PMA_substr($buffer, $options[0]);
  33.     }
  34.  
  35.     $length = strlen($newtext);
  36.     $baselength = strlen($buffer);
  37.     if ($length != $baselength) {
  38.         if ($options[0] != 0) {
  39.             $newtext = $options[2] . $newtext;
  40.         }
  41.  
  42.         if (($length + $options[0]) != $baselength) {
  43.             $newtext .= $options[2];
  44.         }
  45.     }
  46.  
  47.     return $newtext;
  48. }
  49.  
  50. ?>
  51.