PackageFiles = array() ; $this->RemoveDeclaration = true ; $this->_ConstantProcessor = new FCKConstantProcessor() ; $this->_TotalFiles = 0 ; } function LoadDefinitionFile( $packageDefinitionXmlPath ) { $XML = new FCKXmlDocument() ; if ( !$XML->LoadFile( $packageDefinitionXmlPath ) ) ExitError( 'Could not load XML definition file "' . $packageDefinitionXmlPath . '"' ) ; $this->LoadDefinitionFileXmlDocument( $XML ) ; } function LoadDefinitionXml( $packageDefinitionXml ) { $XML = new FCKXmlDocument() ; if ( !$XML->LoadXml( $packageDefinitionXml ) ) ExitError( 'Could not load XML data' ) ; $this->RunXmlDocument( $XML ) ; } function LoadDefinitionFileXmlDocument( $packageDefinitionXmlDocument ) { // Get the root "Package" element. $packageNode = &$packageDefinitionXmlDocument->Children[ 'PACKAGE' ][0] ; // Get the Header text. if ( isset( $packageNode->Children[ 'HEADER' ] ) ) $header = $packageNode->Children[ 'HEADER' ][0]->Value ; else $header = 0 ; // Get the constants (if defined). $constantsNode = &$packageNode->Children[ 'CONSTANTS' ][0] ; if ( isset( $constantsNode ) ) { $this->_ConstantProcessor->RemoveDeclaration = ( GetXmlAttribute( $constantsNode, 'REMOVEDECLARATION', 'true' ) == 'true' ) ; $constantNodes = &$constantsNode->Children[ 'CONSTANT' ] ; // Add the constants to the constants processor. foreach ( $constantNodes as $constantNode ) { $this->_ConstantProcessor->AddConstant( $constantNode->Attributes[ 'NAME' ], $constantNode->Attributes[ 'VALUE' ] ) ; } } // Get the Package Files definitions. $packageFileNodes = $packageNode->Children[ 'PACKAGEFILE' ] ; if ( isset( $packageFileNodes ) ) { $this->_TotalFiles += count( $packageFileNodes ) ; // Loop through the package files. foreach ( $packageFileNodes as $packageFileNode ) { // Create the package file instance. $file = new FCKPackageFile( $packageFileNode->Attributes[ 'PATH' ] ) ; $file->CompactJavaScript = ( GetXmlAttribute( $packageFileNode, 'COMPACTJAVASCRIPT', 'true' ) == 'true' ) ; $file->RenameGlobals = ( GetXmlAttribute( $packageFileNode, 'RENAMEGLOBALS', 'false' ) == 'true' ) ; $file->Header = $header ; $file->ConstantsProcessor = &$this->_ConstantProcessor ; // Get all files defined for that package file. $fileNodes = $packageFileNode->Children[ 'FILE' ] ; if ( isset( $fileNodes ) ) { // Loop throwgh the files. foreach ( $fileNodes as $fileNode ) { $file->AddFile( $fileNode->Attributes[ 'PATH' ] ) ; } } $this->PackageFiles[] = $file ; } } } function Run() { $startTime = GetMicrotime() ; foreach ( $this->PackageFiles as $packageFile ) { $packageFile->CreateFile() ; } $execTime = GetMicrotime() - $startTime ; $execTime = number_format( $execTime, 10 ) ; switch ( $this->_TotalFiles ) { case 0 : echo( 'No files defined' ) ; break; case 1 : echo( 'The generation of the package file has been completed in ' . $execTime . ' seconds.' ) ; break; default : echo( 'The generation of ' . $this->_TotalFiles . ' files has been completed in ' . $execTime . ' seconds.' ) ; break; } } } ?>