00001 <?php
00002
00007 class oxStrRegular
00008 {
00014 protected $_sEncoding = 'ISO8859-15';
00015
00021 protected $_aUmls = array( "\344", "\366", "\374", "\304", "\326", "\334", "\337" );
00022
00027 protected $_aUmlEntities = array('ä', 'ö', 'ü', 'Ä', 'Ö', 'Ü', 'ß' );
00028
00036 public function strlen($sStr)
00037 {
00038 return strlen($sStr);
00039 }
00040
00050 public function substr($sStr, $iStart, $iLength = null)
00051 {
00052 if (is_null($iLength)) {
00053 return substr($sStr, $iStart);
00054 } else {
00055 return substr($sStr, $iStart, $iLength);
00056 }
00057 }
00058
00068 public function strpos($sHaystack, $sNeedle, $iOffset = null)
00069 {
00070 if (is_null($iOffset)) {
00071 return strpos($sHaystack, $sNeedle);
00072 } else {
00073 return strpos($sHaystack, $sNeedle, $iOffset);
00074 }
00075 }
00076
00085 public function strstr($sHaystack, $sNeedle)
00086 {
00087 return strstr($sHaystack, $sNeedle);
00088 }
00089
00097 public function strtolower($sString)
00098 {
00099 return strtolower($sString);
00100 }
00101
00109 public function strtoupper($sString)
00110 {
00111 return strtoupper($sString);
00112 }
00113
00122 public function htmlspecialchars($sString, $blDoubleEncode = true)
00123 {
00124 return htmlspecialchars( $sString, ENT_QUOTES, $this->_sEncoding, $blDoubleEncode );
00125 }
00126
00134 public function htmlentities($sString)
00135 {
00136 return htmlentities( $sString, ENT_QUOTES, $this->_sEncoding );
00137 }
00138
00146 public function html_entity_decode($sString)
00147 {
00148 return html_entity_decode( $sString, ENT_QUOTES, $this->_sEncoding );
00149 }
00150
00161 public function preg_split($sPattern, $sString, $iLimit = -1, $iFlag = 0)
00162 {
00163 return preg_split( $sPattern, $sString, $iLimit, $iFlag );
00164 }
00165
00177 public function preg_replace($sPattern, $sString, $sSubject, $sLimit = -1, $iCount = null)
00178 {
00179 return preg_replace( $sPattern, $sString, $sSubject, $sLimit, $iCount);
00180 }
00181
00193 public function preg_match($sPattern, $sSubject, &$aMatches = null, $iFlags = null, $iOffset = null)
00194 {
00195 return preg_match( $sPattern, $sSubject, $aMatches, $iFlags, $iOffset);
00196 }
00197
00205 public function ucfirst($sSubject)
00206 {
00207 $sString = $this->strtoupper($this->substr($sSubject, 0, 1));
00208 return $sString . $this->substr($sSubject, 1);
00209 }
00210
00221 public function wordwrap($sString, $iLength = 75, $sBreak = "\n", $blCut = null )
00222 {
00223 return wordwrap($sString, $iLength, $sBreak, $blCut);
00224 }
00225
00238 public function recodeEntities( $sInput, $blToHtmlEntities = false, $aUmls = array(), $aUmlEntities = array() )
00239 {
00240 $aUmls = ( count( $aUmls ) > 0 ) ? array_merge( $this->_aUmls, $aUmls) : $this->_aUmls;
00241 $aUmlEntities = ( count( $aUmlEntities ) > 0 ) ? array_merge( $this->_aUmlEntities, $aUmlEntities) : $this->_aUmlEntities;
00242 return $blToHtmlEntities ? str_replace( $aUmls, $aUmlEntities, $sInput ) : str_replace( $aUmlEntities, $aUmls, $sInput );
00243 }
00244
00252 public function hasSpecialChars( $sStr )
00253 {
00254 return $this->preg_match( "/(".implode( "|", $this->_aUmls )."|(&))/", $sStr );
00255 }
00256
00266 public function cleanStr( $sStr, $sCleanChr = ' ' )
00267 {
00268 return $this->preg_replace( "/\"|\'|\.|\:|\!|\?|\n|\r|\t|\x95|\xa0|;/", $sCleanChr, $sStr );
00269 }
00270 }