oxstrregular.php

Go to the documentation of this file.
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('&auml;', '&ouml;', '&uuml;', '&Auml;', '&Ouml;', '&Uuml;', '&szlig;' );
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         $iPos = false;
00079         if ( $sHaystack && $sNeedle ) {
00080             if ( is_null( $iOffset ) ) {
00081                 $iPos = strpos( $sHaystack, $sNeedle );
00082             } else {
00083                 $iPos = strpos( $sHaystack, $sNeedle, $iOffset );
00084             }
00085         }
00086         return $iPos;
00087     }
00088 
00097     public function strstr($sHaystack, $sNeedle)
00098     {
00099         return strstr($sHaystack, $sNeedle);
00100     }
00101 
00109     public function strtolower($sString)
00110     {
00111         return strtolower($sString);
00112     }
00113 
00121     public function strtoupper($sString)
00122     {
00123         return strtoupper($sString);
00124     }
00125 
00133     public function htmlspecialchars($sString)
00134     {
00135         return htmlspecialchars( $sString, ENT_QUOTES, $this->_sEncoding );
00136     }
00137 
00145     public function htmlentities($sString)
00146     {
00147         return htmlentities( $sString, ENT_QUOTES, $this->_sEncoding );
00148     }
00149 
00157     public function html_entity_decode($sString)
00158     {
00159         return html_entity_decode( $sString, ENT_QUOTES, $this->_sEncoding );
00160     }
00161 
00172     public function preg_split($sPattern, $sString, $iLimit = -1, $iFlag = 0)
00173     {
00174         return preg_split( $sPattern, $sString, $iLimit, $iFlag );
00175     }
00176 
00188     public function preg_replace($sPattern, $sString, $sSubject, $iLimit = -1, $iCount = null)
00189     {
00190         return preg_replace( $sPattern, $sString, $sSubject, $iLimit, $iCount);
00191     }
00192 
00204     public function preg_match($sPattern, $sSubject, &$aMatches = null, $iFlags = null, $iOffset = null)
00205     {
00206         return preg_match( $sPattern, $sSubject, $aMatches, $iFlags, $iOffset);
00207     }
00208 
00220     public function preg_match_all($sPattern, $sSubject, &$aMatches = null, $iFlags = null, $iOffset = null)
00221     {
00222         return preg_match_all( $sPattern, $sSubject, $aMatches, $iFlags, $iOffset);
00223     }
00224 
00232     public function ucfirst($sSubject)
00233     {
00234         $sString = $this->strtoupper($this->substr($sSubject, 0, 1));
00235         return $sString . $this->substr($sSubject, 1);
00236     }
00237 
00248     public function wordwrap($sString, $iLength = 75, $sBreak = "\n", $blCut = null )
00249     {
00250         return wordwrap($sString, $iLength, $sBreak, $blCut);
00251     }
00252 
00265     public function recodeEntities( $sInput, $blToHtmlEntities = false, $aUmls = array(), $aUmlEntities = array() )
00266     {
00267         $aUmls = ( count( $aUmls ) > 0 ) ? array_merge( $this->_aUmls, $aUmls) : $this->_aUmls;
00268         $aUmlEntities = ( count( $aUmlEntities ) > 0 ) ? array_merge( $this->_aUmlEntities, $aUmlEntities) : $this->_aUmlEntities;
00269         return $blToHtmlEntities ? str_replace( $aUmls, $aUmlEntities, $sInput ) : str_replace( $aUmlEntities, $aUmls, $sInput );
00270     }
00271 
00279     public function hasSpecialChars( $sStr )
00280     {
00281         return $this->preg_match( "/(".implode( "|", $this->_aUmls  )."|(&amp;))/", $sStr );
00282     }
00283 
00293     public function cleanStr( $sStr, $sCleanChr = ' ')
00294     {
00295         return $this->preg_replace( "/\"|\'|\:|\!|\?|\n|\r|\t|\x95|\xa0|;/", $sCleanChr, $sStr );
00296     }
00297 }