This commit is contained in:
Romain Neutron
2012-07-26 12:38:01 +02:00
parent e4dbfbe604
commit 0d90b56c66

View File

@@ -9,8 +9,12 @@
* file that was distributed with this source code. * file that was distributed with this source code.
*/ */
use Monolog\Logger; use Alchemy\Phrasea\Border\File;
use Alchemy\Phrasea\Metadata\Tag\TfFilename;
use Alchemy\Phrasea\Metadata\Tag\TfBasename;
use MediaAlchemyst\Specification\Specification;
use MediaVorus\Media\Media; use MediaVorus\Media\Media;
use Monolog\Logger;
use Symfony\Component\HttpFoundation\File\File as SymfoFile; use Symfony\Component\HttpFoundation\File\File as SymfoFile;
/** /**
@@ -155,7 +159,8 @@ class record_adapter implements record_Interface, cache_cacheableInterface
*/ */
public function __construct($sbas_id, $record_id, $number = null) public function __construct($sbas_id, $record_id, $number = null)
{ {
$this->databox = databox::get_instance((int) $sbas_id); $appbox = \appbox::get_instance(\bootstrap::getCore());
$this->databox = $appbox->get_databox((int) $sbas_id);
$this->number = (int) $number; $this->number = (int) $number;
$this->record_id = (int) $record_id; $this->record_id = (int) $record_id;
@@ -880,9 +885,9 @@ class record_adapter implements record_Interface, cache_cacheableInterface
foreach ($this->get_databox()->get_meta_structure()->get_elements() as $data_field) { foreach ($this->get_databox()->get_meta_structure()->get_elements() as $data_field) {
if ($data_field->get_tag() instanceof \Alchemy\Phrasea\Metadata\Tag\TfFilename) { if ($data_field->get_tag() instanceof TfFilename) {
$original_name = pathinfo($original_name, PATHINFO_FILENAME); $original_name = pathinfo($original_name, PATHINFO_FILENAME);
} elseif ( ! $data_field->get_tag() instanceof \Alchemy\Phrasea\Metadata\Tag\TfBasename) { } elseif ( ! $data_field->get_tag() instanceof TfBasename) {
continue; continue;
} }
@@ -1045,7 +1050,7 @@ class record_adapter implements record_Interface, cache_cacheableInterface
$core['file-system']->copy($media->getFile()->getRealPath(), $pathhd . $filehd, true); $core['file-system']->copy($media->getFile()->getRealPath(), $pathhd . $filehd, true);
$subdefFile = new \Symfony\Component\HttpFoundation\File\File($pathhd . $filehd); $subdefFile = new SymfoFile($pathhd . $filehd);
$meta_writable = true; $meta_writable = true;
} else { } else {
@@ -1071,7 +1076,7 @@ class record_adapter implements record_Interface, cache_cacheableInterface
return $this; return $this;
} }
$subdefFile = new \Symfony\Component\HttpFoundation\File\File($path_file_dest); $subdefFile = new SymfoFile($path_file_dest);
$meta_writable = $subdef_def->meta_writeable(); $meta_writable = $subdef_def->meta_writeable();
} }
@@ -1367,7 +1372,12 @@ class record_adapter implements record_Interface, cache_cacheableInterface
return $story; return $story;
} }
public static function createFromFile(\Alchemy\Phrasea\Border\File $file) /**
*
* @param File $file
* @return \record_adapter
*/
public static function createFromFile(File $file)
{ {
$core = \bootstrap::getCore(); $core = \bootstrap::getCore();
@@ -1424,7 +1434,7 @@ class record_adapter implements record_Interface, cache_cacheableInterface
$media = $core['mediavorus']->guess(new \SplFileInfo($pathhd . $newname)); $media = $core['mediavorus']->guess(new \SplFileInfo($pathhd . $newname));
$subdef = media_subdef::create($record, 'document', $media); $subdef = media_subdef::create($record, 'document', $media);
$record->delete_data_from_cache(record_adapter::CACHE_SUBDEFS); $record->delete_data_from_cache(\record_adapter::CACHE_SUBDEFS);
$record->insertTechnicalDatas(); $record->insertTechnicalDatas();
@@ -1824,27 +1834,27 @@ class record_adapter implements record_Interface, cache_cacheableInterface
/** /**
* Get the extension from MediaAlchemyst specs * Get the extension from MediaAlchemyst specs
* *
* @param MediaAlchemyst\Specification\Specification $spec * @param Specification $spec
* @return string * @return string
*/ */
protected function getExtensionFromSpec(MediaAlchemyst\Specification\Specification $spec) protected function getExtensionFromSpec(Specification $spec)
{ {
$extension = null; $extension = null;
switch (true) { switch (true) {
case $spec->getType() === MediaAlchemyst\Specification\Specification::TYPE_IMAGE: case $spec->getType() === Specification::TYPE_IMAGE:
$extension = 'jpg'; $extension = 'jpg';
break; break;
case $spec->getType() === MediaAlchemyst\Specification\Specification::TYPE_ANIMATION: case $spec->getType() === Specification::TYPE_ANIMATION:
$extension = 'gif'; $extension = 'gif';
break; break;
case $spec->getType() === MediaAlchemyst\Specification\Specification::TYPE_AUDIO: case $spec->getType() === Specification::TYPE_AUDIO:
$extension = $this->getExtensionFromAudioCodec($spec->getAudioCodec()); $extension = $this->getExtensionFromAudioCodec($spec->getAudioCodec());
break; break;
case $spec->getType() === MediaAlchemyst\Specification\Specification::TYPE_VIDEO: case $spec->getType() === Specification::TYPE_VIDEO:
$extension = $this->getExtensionFromVideoCodec($spec->getVideoCodec()); $extension = $this->getExtensionFromVideoCodec($spec->getVideoCodec());
break; break;
case $spec->getType() === MediaAlchemyst\Specification\Specification::TYPE_SWF: case $spec->getType() === Specification::TYPE_SWF:
$extension = 'swf'; $extension = 'swf';
break; break;
} }