Changeset 2078 for FCKpackager/trunk/fckpackager.php
- Timestamp:
- 2008-06-17 15:48:08 (7 months ago)
- Files:
-
- 1 modified
-
FCKpackager/trunk/fckpackager.php (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
FCKpackager/trunk/fckpackager.php
r2071 r2078 48 48 ?> 49 49 50 <?php50 <?php 51 51 52 52 … … 59 59 function StrEndsWith( $str, $sub ) 60 60 { 61 return ( substr( $str, strlen( $str ) - strlen( $sub ) ) == $sub ) ;61 return ( substr( $str, strlen( $str ) - strlen( $sub ) ) == $sub ) ; 62 62 } 63 63 … … 72 72 function CreateDir($path, $rights = 0777) 73 73 { 74 $folder_path = array( 75 strstr( $path, '.' ) ? dirname( $path ) : $path ) ; 76 77 while ( !@is_dir( dirname( end( $folder_path ) ) ) 78 && dirname( end( $folder_path ) ) != '/' 79 && dirname( end( $folder_path ) ) != '.' 80 && dirname( end( $folder_path ) ) != '' ) 81 { 82 $folder_path[] = dirname( end( $folder_path ) ) ; 83 } 84 85 while ( $parent_folder_path = array_pop( $folder_path ) ) 86 { 87 if ( !@mkdir( $parent_folder_path, $rights ) ) 88 ExitError( "Can't create folder \"$parent_folder_path\"." ) ; 74 $dirParts = explode( '/', $path ) ; 75 76 $currentDir = '' ; 77 78 foreach ( $dirParts as $dirPart ) 79 { 80 $currentDir .= $dirPart . '/' ; 81 82 if ( strlen( $dirPart ) > 0 && !is_dir( $currentDir ) ) 83 mkdir( $currentDir, $rights ) ; 89 84 } 90 85 } … … 100 95 fwrite( $f, "\xEF\xBB\xBF" ) ; // BOM 101 96 102 fwrite( $f, $strData ) ; 103 fclose( $f ) ; 104 105 return TRUE ; 106 } 107 108 function SaveStringToUtf8File( $strData, $filePath, $includeBom = TRUE ) 109 { 110 $f = @fopen( $filePath, 'wb' ) ; 111 112 if ( !$f ) 113 return FALSE ; 114 115 if ( $includeBom ) 116 fwrite( $f, "\xEF\xBB\xBF" ) ; // BOM 117 118 fwrite( $f, ( $strData ) ) ; 119 97 fwrite( $f, StripUtf8Bom( $strData ) ) ; 120 98 fclose( $f ) ; 121 99 … … 359 337 ' ', $script ) ; 360 338 361 // Concatenate lines that end with "}" using a ";" (except for "else" and "catch" cases). 362 $script = preg_replace( 363 '/\s*}\s*[\n\r]+\s*(?!\s*(else|catch|}))/s', 339 // Concatenate lines that end with "}" using a ";", except for "else", 340 // "while", "catch" and "finally" cases, or when followed by, "'", ";", 341 // "}" or ")". 342 $script = preg_replace( 343 '/\s*}\s*[\n\r]+\s*(?!\s*(else|catch|finally|while|[}\),;]))/s', 364 344 '};', $script ) ; 365 345 … … 669 649 function ProcessFile( $sourceFilePath, $destinationFilePath, $onlyHeader = FALSE ) 670 650 { 671 SaveStringTo Utf8File(651 SaveStringToFile( 672 652 FCKPreProcessor::Process( file_get_contents( $sourceFilePath ), $onlyHeader ), 673 653 $destinationFilePath, 674 ( !StrEndsWith( $sourceFilePath, '.asp' ) && !StrEndsWith( $sourceFilePath, '.js' ) ) ) ; // Only ASP and JavaScript files require the BOM.654 ( StrEndsWith( $sourceFilePath, '.asp' ) || StrEndsWith( $sourceFilePath, '.js' ) ) ) ; // Only ASP and JavaScript files require the BOM. 675 655 676 656 // Set the destination file Last Access and Last Write times.