00001 <?php
00002
00006 class oxStrRegular
00007 {
00013 protected $_sEncoding = 'ISO8859-15';
00014
00020 protected $_aUmls = array( "\344", "\366", "\374", "\304", "\326", "\334", "\337" );
00021
00026 protected $_aUmlEntities = array('ä', 'ö', 'ü', 'Ä', 'Ö', 'Ü', 'ß' );
00027
00033 public function __construct()
00034 {
00035 }
00036
00044 public function strlen($sStr)
00045 {
00046 return strlen($sStr);
00047 }
00048
00058 public function substr($sStr, $iStart, $iLength = null)
00059 {
00060 if (is_null($iLength)) {
00061 return substr($sStr, $iStart);
00062 } else {
00063 return substr($sStr, $iStart, $iLength);
00064 }
00065 }
00066
00076 public function strpos($sHaystack, $sNeedle, $iOffset = null)
00077 {
00078 if (is_null($iOffset)) {
00079 return strpos($sHaystack, $sNeedle);
00080 } else {
00081 return strpos($sHaystack, $sNeedle, $iOffset);
00082 }
00083 }
00084
00093 public function strstr($sHaystack, $sNeedle)
00094 {
00095 return strstr($sHaystack, $sNeedle);
00096 }
00097
00105 public function strtolower($sString)
00106 {
00107 return strtolower($sString);
00108 }
00109
00117 public function strtoupper($sString)
00118 {
00119 return strtoupper($sString);
00120 }
00121
00129 public function htmlspecialchars($sString)
00130 {
00131 return htmlspecialchars( $sString, ENT_QUOTES, $this->_sEncoding );
00132 }
00133
00141 public function htmlentities($sString)
00142 {
00143 return htmlentities( $sString, ENT_QUOTES, $this->_sEncoding );
00144 }
00145
00153 public function html_entity_decode($sString)
00154 {
00155 return html_entity_decode( $sString, ENT_QUOTES, $this->_sEncoding );
00156 }
00157
00168 public function preg_split($sPattern, $sString, $iLimit = -1, $iFlag = 0)
00169 {
00170 return preg_split( $sPattern, $sString, $iLimit, $iFlag );
00171 }
00172
00184 public function preg_replace($sPattern, $sString, $sSubject, $iLimit = -1, $iCount = null)
00185 {
00186 return preg_replace( $sPattern, $sString, $sSubject, $iLimit, $iCount);
00187 }
00188
00200 public function preg_match($sPattern, $sSubject, &$aMatches = null, $iFlags = null, $iOffset = null)
00201 {
00202 return preg_match( $sPattern, $sSubject, $aMatches, $iFlags, $iOffset);
00203 }
00204
00212 public function ucfirst($sSubject)
00213 {
00214 $sString = $this->strtoupper($this->substr($sSubject, 0, 1));
00215 return $sString . $this->substr($sSubject, 1);
00216 }
00217
00228 public function wordwrap($sString, $iLength = 75, $sBreak = "\n", $blCut = null )
00229 {
00230 return wordwrap($sString, $iLength, $sBreak, $blCut);
00231 }
00232
00245 public function recodeEntities( $sInput, $blToHtmlEntities = false, $aUmls = array(), $aUmlEntities = array() )
00246 {
00247 $aUmls = ( count( $aUmls ) > 0 ) ? array_merge( $this->_aUmls, $aUmls) : $this->_aUmls;
00248 $aUmlEntities = ( count( $aUmlEntities ) > 0 ) ? array_merge( $this->_aUmlEntities, $aUmlEntities) : $this->_aUmlEntities;
00249 return $blToHtmlEntities ? str_replace( $aUmls, $aUmlEntities, $sInput ) : str_replace( $aUmlEntities, $aUmls, $sInput );
00250 }
00251
00259 public function hasSpecialChars( $sStr )
00260 {
00261 return $this->preg_match( "/(".implode( "|", $this->_aUmls )."|(&))/", $sStr );
00262 }
00263
00273 public function cleanStr( $sStr, $sCleanChr = ' ')
00274 {
00275 return $this->preg_replace( "/\"|\'|\:|\!|\?|\n|\r|\t|\x95|\xa0|;/", $sCleanChr, $sStr );
00276 }
00277 }