/** * Tests the static strrpos * @return void */ public function test_strrpos() { $str = "Žluťoučký koníček"; $this->assertSame(textlib::strrpos($str, 'o'), 11); }
/** * Generate the name of the mod instance from the name of the file * (remove the extension and convert underscore => space * * @param string $filename the filename of the uploaded file * @return string the display name to use */ protected function display_name_from_file($filename) { $pos = textlib::strrpos($filename, '.'); if ($pos) { // Want to skip if $pos === 0 OR $pos === false. $filename = textlib::substr($filename, 0, $pos); } return str_replace('_', ' ', $filename); }
/** * Filter out "." and ".." segments from a URL's path and return * the result. * * This function implements the "remove_dot_segments" algorithm from * the RFC3986 specification for URLs. * * This function supports multi-byte characters with the UTF-8 encoding, * per the URL specification. * * Parameters: * path the path to filter * * Return values: * The filtered path with "." and ".." removed. */ function url_remove_dot_segments( $path ) { // multi-byte character explode $inSegs = preg_split( '!/!u', $path ); $outSegs = array( ); foreach ( $inSegs as $seg ) { if ( $seg == '' || $seg == '.') continue; if ( $seg == '..' ) array_pop( $outSegs ); else array_push( $outSegs, $seg ); } $outPath = implode( '/', $outSegs ); if ($path[0] == '/') { $outPath = '/' . $outPath; } // Compare last multi-byte character against '/'. if ($outPath != '/' && (textlib::strlen($path) - 1) == textlib::strrpos($path, '/', 'UTF-8')) { $outPath .= '/'; } return $outPath; }