CompactJavaScript = TRUE ; $this->RenameGlobals = FALSE ; $this->Header = '' ; $this->_OutputPath = $outputPath ; $this->_Files = array() ; } function AddFile( $sourceFilePath ) { $this->_Files[] = $sourceFilePath ; } function CreateFile() { echo 'Packaging file ' . basename( $this->_OutputPath ) . "\n" ; // Extract the directory from the output file path. $destDir = dirname( $this->_OutputPath ); // Create the directory if it doesn't exist. if ( !@is_dir( $destDir ) ) CreateDir( $destDir ) ; // Create the StringBuilder that will hold the output data. $outputData = '' ; $uncompressedSize = 0 ; // Loop through the files. foreach ( $this->_Files as $file ) { // Read the file. $data = file_get_contents( $file ) ; // Strip the UTF-8 BOM, if available. $data = StripUtf8Bom( $data ) ; $dataSize = strlen( $data ) ; $uncompressedSize += $dataSize ; echo ' Adding ' . basename( $file ) . "\n" ; // Compress (if needed) and process its contents. if ( $this->CompactJavaScript ) $outputData .= FCKJavaScriptCompressor::Compress( FCKPreProcessor::Process( $data ), $this->ConstantsProcessor ) ; else $outputData .= FCKPreProcessor::Process( $data ) ; // Each file terminates with a CRLF, even if compressed. $outputData .= "\r\n" ; } // Replace global vars. if ( $this->RenameGlobals ) { $funcProcessor = new FCKFunctionProcessor( $outputData, NULL, true ) ; $outputData = $funcProcessor->Process() ; } // Write the output file. if ( strlen( $this->Header ) > 0 ) $outputData = $this->Header . "\r\n" . $outputData ; if ( !SaveStringToFile( $outputData, $this->_OutputPath, TRUE ) ) ExitError( 'It was not possible to save the file "' . $this->_OutputPath . '".' ) ; echo( "\n" ); echo( ' Number of files processed: ' . count( $this->_Files ) . "\n" ) ; echo( ' Original size............: ' . number_format( $uncompressedSize ) . ' bytes' . "\n" ) ; echo( ' Output file size.........: ' . number_format( strlen( $outputData ) ) . ' bytes (' . round( strlen( $outputData ) / $uncompressedSize * 100, 2 ) . '% of original)' . "\n" ) ; echo( "\n" ); } } ?>