function unserializeContentObjectAttribute( $package, $objectAttribute, $attributeNode ) { $fileNode = $attributeNode->getElementsByTagName( 'binary-file' )->item( 0 ); if ( !is_object( $fileNode ) or !$fileNode->hasAttributes() ) { return; } $binaryFile = eZBinaryFile::create( $objectAttribute->attribute( 'id' ), $objectAttribute->attribute( 'version' ) ); $sourcePath = $package->simpleFilePath( $fileNode->getAttribute( 'filekey' ) ); if ( !file_exists( $sourcePath ) ) { eZDebug::writeError( "The file '$sourcePath' does not exist, cannot initialize file attribute with it", __METHOD__ ); return false; } $ini = eZINI::instance(); $mimeType = $fileNode->getAttribute( 'mime-type' ); list( $mimeTypeCategory, $mimeTypeName ) = explode( '/', $mimeType ); $destinationPath = eZSys::storageDirectory() . '/original/' . $mimeTypeCategory . '/'; if ( !file_exists( $destinationPath ) ) { $oldumask = umask( 0 ); if ( !eZDir::mkdir( $destinationPath, false, true ) ) { umask( $oldumask ); return false; } umask( $oldumask ); } $basename = basename( $fileNode->getAttribute( 'filename' ) ); while ( file_exists( $destinationPath . $basename ) ) { $basename = substr( md5( mt_rand() ), 0, 8 ) . '.' . eZFile::suffix( $fileNode->getAttribute( 'filename' ) ); } eZFileHandler::copy( $sourcePath, $destinationPath . $basename ); eZDebug::writeNotice( 'Copied: ' . $sourcePath . ' to: ' . $destinationPath . $basename, __METHOD__ ); $binaryFile->setAttribute( 'contentobject_attribute_id', $objectAttribute->attribute( 'id' ) ); $binaryFile->setAttribute( 'filename', $basename ); $binaryFile->setAttribute( 'original_filename', $fileNode->getAttribute( 'original-filename' ) ); $binaryFile->setAttribute( 'mime_type', $fileNode->getAttribute( 'mime-type' ) ); $binaryFile->store(); $fileHandler = eZClusterFileHandler::instance(); $fileHandler->fileStore( $destinationPath . $basename, 'binaryfile', true ); }