mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-15 22:13:13 +00:00
PHRAS-3717 Wrong extension on subdef upload w. adapt=0 (#4107)
* fix substitute adapt 0 * fix path file dest
This commit is contained in:
@@ -99,18 +99,20 @@ class FilesystemService
|
||||
* @param \record_adapter $record
|
||||
* @param \databox_subdef $subdef
|
||||
* @param string $marker
|
||||
* @param string $extension if not set,get from subdef spec
|
||||
* @return string
|
||||
*/
|
||||
public function generateSubdefFilename(\record_adapter $record, \databox_subdef $subdef, $marker = '')
|
||||
public function generateSubdefFilename(\record_adapter $record, \databox_subdef $subdef, $marker = '', $extension = null)
|
||||
{
|
||||
return $record->getRecordId() . '_' . $marker . $subdef->get_name() . '.' . $this->getExtensionFromSpec($subdef->getSpecs());
|
||||
$extension = empty($extension) ? $this->getExtensionFromSpec($subdef->getSpecs()) : $extension;
|
||||
return $record->getRecordId() . '_' . $marker . $subdef->get_name() . '.' . $extension;
|
||||
}
|
||||
|
||||
public function generateSubdefSubstitutionPathname(\record_adapter $record, \databox_subdef $subdef)
|
||||
public function generateSubdefSubstitutionPathname(\record_adapter $record, \databox_subdef $subdef, $extension = null)
|
||||
{
|
||||
$pathdest = $this->directorySpread($subdef->get_path());
|
||||
|
||||
return $pathdest . $this->generateSubdefFilename($record, $subdef, '0_');
|
||||
return $pathdest . $this->generateSubdefFilename($record, $subdef, '0_', $extension);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -102,15 +102,13 @@ class SubdefSubstituer
|
||||
$databox_subdef = $record->getDatabox()->get_subdef_structure()->get_subdef($type, $name);
|
||||
|
||||
if ($this->isOldSubdefPresent($record, $name)) {
|
||||
$path_file_dest = $record->get_subdef($name)->getRealPath();
|
||||
$record->get_subdef($name)->remove_file();
|
||||
$record->clearSubdefCache($name);
|
||||
} else {
|
||||
$path_file_dest = $this->fs->generateSubdefSubstitutionPathname($record, $databox_subdef);
|
||||
}
|
||||
|
||||
if($adapt) {
|
||||
try {
|
||||
$path_file_dest = $this->fs->generateSubdefSubstitutionPathname($record, $databox_subdef);
|
||||
$this->alchemyst->turnInto(
|
||||
$media->getFile()->getRealPath(),
|
||||
$path_file_dest,
|
||||
@@ -120,6 +118,7 @@ class SubdefSubstituer
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
$path_file_dest = $this->fs->generateSubdefSubstitutionPathname($record, $databox_subdef, pathinfo($media->getFile()->getRealPath(), PATHINFO_EXTENSION));
|
||||
$this->fs->copy($media->getFile()->getRealPath(), $path_file_dest);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user