oxutilsstring.php

Go to the documentation of this file.
00001 <?php
00002 
00006 class oxUtilsString
00007 {
00013     private static $_instance = null;
00014 
00020     public static function getInstance()
00021     {
00022         // disable caching for test modules
00023         if ( defined( 'OXID_PHP_UNIT' ) ) {
00024             static $inst = array();
00025             self::$_instance = $inst[oxClassCacheKey()];
00026         }
00027 
00028         if ( !self::$_instance instanceof oxUtilsString ) {
00029 
00030 
00031             self::$_instance = oxNew( 'oxUtilsString' );
00032 
00033             if ( defined( 'OXID_PHP_UNIT' ) ) {
00034                 $inst[oxClassCacheKey()] = self::$_instance;
00035             }
00036         }
00037         return self::$_instance;
00038     }
00039 
00040 
00048     public function prepareCSVField($sInField)
00049     {
00050         $oStr = getStr();
00051         if ($oStr->strstr($sInField, '"')) {
00052             return '"'.str_replace('"', '""', $sInField).'"';
00053         } elseif ($oStr->strstr($sInField, ';')) {
00054             return '"'.$sInField.'"';
00055         }
00056         return $sInField;
00057     }
00058 
00068     public function minimizeTruncateString( $sString, $iLength )
00069     {
00070         $sString = str_replace( ",", " ", $sString );
00071         //leading and ending whitespaces
00072         $sString = trim( $sString );
00073         //multiple whitespaces
00074         $sString = ereg_replace( "[ \t\n\r]+", " ", $sString );
00075         $oStr = getStr();
00076         if ( $oStr->strlen( $sString ) > $iLength && $iLength != -1 ) {
00077             $sString = $oStr->substr( $sString, 0, $iLength );
00078         }
00079         return $sString;
00080     }
00081 
00089     public function prepareStrForSearch($sSearchStr)
00090     {
00091         $oStr = getStr();
00092         if ( $oStr->hasSpecialChars( $sSearchStr ) ) {
00093             return $oStr->recodeEntities( $sSearchStr, true, array( '&amp;' ), array( '&' ) );
00094         }
00095 
00096         return '';
00097     }
00098 }

Generated on Tue Apr 21 15:45:45 2009 for OXID eShop CE by  doxygen 1.5.5