Changeset 1586
- Timestamp:
- 04/28/08 12:21:34 (7 months ago)
- Files:
-
- 1 modified
-
trunk/htdocs/system/classes/utils.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/htdocs/system/classes/utils.php
r1585 r1586 734 734 public static function glob( $pattern, $flags = 0 ) 735 735 { 736 if ( ! defined( 'GLOB_NOBRACE' ) || ! ( ( $flags & GLOB_BRACE ) == GLOB_BRACE ) ) {737 // this platform supports GLOB_BRACE out of the box 736 if ( ! defined( 'GLOB_NOBRACE' ) || ! ( ( $flags & GLOB_BRACE ) == GLOB_BRACE ) ) { 737 // this platform supports GLOB_BRACE out of the box or GLOB_BRACE wasn't requested 738 738 $results= glob( $pattern, $flags ); 739 739 } 740 740 elseif ( ! preg_match_all( '/\{.*?\}/', $pattern, $m ) ) { 741 // this pattern doesn't even use braces741 // GLOB_BRACE used, but this pattern doesn't even use braces 742 742 $results= glob( $pattern, $flags ^ GLOB_BRACE ); 743 743 } … … 746 746 $braces= array(); 747 747 foreach ( $m[0] as $raw_brace ) { 748 $braces[ preg_quote( $raw_brace ) ] = '( ' . str_replace( ',', '|', preq_quote( substr( $raw_brace, 1, -1 )) ) . ')';748 $braces[ preg_quote( $raw_brace ) ] = '(?:' . str_replace( ',', '|', preg_quote( substr( $raw_brace, 1, -1 ), '/' ) ) . ')'; 749 749 } 750 750 $new_pattern= preg_replace( '/\{.*?\}/', '*', $pattern ); 751 $regex= '/' . str_replace( array_keys( $braces ), array_values( $braces ), preg_quote( $pattern ) ) . '/'; 752 $results= preg_grep( $regex, glob( $new_pattern, $flags ^ GLOB_BRACE) ); 753 } 754 751 $pattern= preg_quote( $pattern, '/' ); 752 $pattern= str_replace( '\\*', '.*', $pattern ); 753 $pattern= str_replace( '\\?', '.', $pattern ); 754 $regex= '/' . str_replace( array_keys( $braces ), array_values( $braces ), $pattern ) . '/'; 755 $results= preg_grep( $regex, Utils::glob( $new_pattern, $flags ^ GLOB_BRACE) ); 756 } 757 755 758 if ( $results === false ) $results= array(); 756 759 return $results;
