[ Index ]

PHP Cross Reference of vtigercrm-6.1.0

title

Body

[close]

/kcfinder/lib/ -> helper_text.php (source)

   1  <?php
   2  
   3  /** This file is part of KCFinder project
   4    *
   5    *      @desc Text processing helper class
   6    *   @package KCFinder
   7    *   @version 2.21
   8    *    @author Pavel Tzonkov <[email protected]>
   9    * @copyright 2010 KCFinder Project
  10    *   @license http://www.opensource.org/licenses/gpl-2.0.php GPLv2
  11    *   @license http://www.opensource.org/licenses/lgpl-2.1.php LGPLv2
  12    *      @link http://kcfinder.sunhater.com
  13    */
  14  
  15  class text {
  16  
  17    /** Replace repeated white spaces to single space
  18      * @param string $string
  19      * @return string */
  20  
  21      static function clearWhitespaces($string) {
  22          return trim(preg_replace('/\s+/s', " ", $string));
  23      }
  24  
  25    /** Normalize the string for HTML attribute value
  26      * @param string $string
  27      * @return string */
  28  
  29      static function htmlValue($string) {
  30          return str_replace('"', "&quot;", $string);
  31      }
  32  
  33    /** Normalize the string for JavaScript string value
  34      * @param string $string
  35      * @return string */
  36  
  37      static function jsValue($string) {
  38          return preg_replace('/\r?\n/', "\\n", str_replace('"', "\\\"", str_replace("'", "\\'", $string)));
  39      }
  40  
  41    /** Normalize the string for XML tag content data
  42      * @param string $string
  43      * @param bool $cdata */
  44  
  45      static function xmlData($string, $cdata=false) {
  46          $string = str_replace("]]>", "]]]]><![CDATA[>", $string);
  47          if (!$cdata)
  48              $string = "<![CDATA[$string]]>";
  49          return $string;
  50      }
  51  
  52    /** Returns compressed content of given CSS code
  53      * @param string $code
  54      * @return string */
  55  
  56      static function compressCSS($code) {
  57          $code = self::clearWhitespaces($code);
  58          $code = preg_replace('/ ?\{ ?/', "{", $code);
  59          $code = preg_replace('/ ?\} ?/', "}", $code);
  60          $code = preg_replace('/ ?\; ?/', ";", $code);
  61          $code = preg_replace('/ ?\> ?/', ">", $code);
  62          $code = preg_replace('/ ?\, ?/', ",", $code);
  63          $code = preg_replace('/ ?\: ?/', ":", $code);
  64          $code = str_replace(";}", "}", $code);
  65          return $code;
  66      }
  67  }
  68  
  69  ?>


Generated: Fri Nov 28 20:08:37 2014 Cross-referenced by PHPXref 0.7.1