function unserializeContentObjectAttribute($package, $objectAttribute, $attributeNode)
 {
     $mediaNode = $attributeNode->getElementsByTagName('media-file')->item(0);
     if (!$mediaNode) {
         // No media type data found.
         return;
     }
     $mediaFile = ezflowMedia::create($objectAttribute->attribute('id'), $objectAttribute->attribute('version'));
     $sourcePath = $package->simpleFilePath($mediaNode->getAttribute('filekey'));
     $ini = eZINI::instance();
     $mimeType = $mediaNode->getAttribute('mime-type');
     list($mimeTypeCategory, $mimeTypeName) = explode('/', $mimeType);
     $destinationPath = eZSys::storageDirectory() . '/original/' . $mimeTypeCategory . '/';
     if (!file_exists($destinationPath)) {
         if (!eZDir::mkdir($destinationPath, false, true)) {
             return false;
         }
     }
     $basename = basename($mediaNode->getAttribute('filename'));
     while (file_exists($destinationPath . $basename)) {
         $basename = substr(md5(mt_rand()), 0, 8) . '.' . eZFile::suffix($mediaNode->getAttribute('filename'));
     }
     eZFileHandler::copy($sourcePath, $destinationPath . $basename);
     eZDebug::writeNotice('Copied: ' . $sourcePath . ' to: ' . $destinationPath . $basename, 'ezflowMediaType::unserializeContentObjectAttribute()');
     $mediaFile->setAttribute('contentobject_attribute_id', $objectAttribute->attribute('id'));
     $mediaFile->setAttribute('filename', $basename);
     $mediaFile->setAttribute('original_filename', $mediaNode->getAttribute('original-filename'));
     $mediaFile->setAttribute('mime_type', $mediaNode->getAttribute('mime-type'));
     $mediaFile->setAttribute('streaming', $mediaNode->getAttribute('streaming'));
     $mediaFile->setAttribute('url', $mediaNode->getAttribute('url'));
     $mediaFile->setAttribute('movie', $mediaNode->getAttribute('movie'));
     $mediaFile->setAttribute('width', $mediaNode->getAttribute('width'));
     $mediaFile->setAttribute('height', $mediaNode->getAttribute('height'));
     $mediaFile->setAttribute('has_controller', $mediaNode->getAttribute('has-controller'));
     $mediaFile->setAttribute('controls', $mediaNode->getAttribute('controls'));
     $mediaFile->setAttribute('is_autoplay', $mediaNode->getAttribute('is-autoplay'));
     // $mediaFile->setAttribute( 'pluginspage', $mediaNode->getAttribute( 'plugins-page' ) );
     // $mediaFile->setAttribute( 'quality', $mediaNode->getAttribute( 'quality' ) );
     $mediaFile->setAttribute('is_loop', $mediaNode->getAttribute('is-loop'));
     $fileHandler = eZClusterFileHandler::instance();
     $fileHandler->fileStore($destinationPath . $basename, 'mediafile', true);
     $mediaFile->store();
 }
Example #2
0
 static function removeByID($id, $version)
 {
     if ($version == null) {
         eZPersistentObject::removeObject(ezflowMedia::definition(), array("contentobject_attribute_id" => $id));
     } else {
         eZPersistentObject::removeObject(ezflowMedia::definition(), array("contentobject_attribute_id" => $id, "version" => $version));
     }
 }