mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-23 18:03:17 +00:00
Better checking TechnicalDataSet return type.
This commit is contained in:
@@ -897,14 +897,20 @@ class Bridge_Api_Dailymotion extends Bridge_Api_Abstract implements Bridge_Api_I
|
||||
private function check_record_constraints(record_adapter $record)
|
||||
{
|
||||
$errors = [];
|
||||
if ( ! $record->get_hd_file() instanceof \SplFileInfo)
|
||||
$errors["file_size"] = $this->translator->trans("Le record n'a pas de fichier physique"); //Record must rely on real file
|
||||
//Record must rely on real file
|
||||
if (!$record->get_hd_file() instanceof \SplFileInfo) {
|
||||
$errors["file_size"] = $this->translator->trans("Le record n'a pas de fichier physique");
|
||||
}
|
||||
|
||||
if ($record->get_duration() > self::AUTH_VIDEO_DURATION)
|
||||
if ($record->get_duration() > self::AUTH_VIDEO_DURATION) {
|
||||
$errors["duration"] = $this->translator->trans("La taille maximale d'une video est de %duration% minutes.", ['%duration%' => self::AUTH_VIDEO_DURATION / 60]);
|
||||
}
|
||||
|
||||
if ($record->get_technical_infos('size')->getValue() > self::AUTH_VIDEO_SIZE)
|
||||
$size = $record->get_technical_infos('size');
|
||||
$size = $size ? $size->getValue() : PHP_INT_MAX;
|
||||
if ($size > self::AUTH_VIDEO_SIZE) {
|
||||
$errors["size"] = $this->translator->trans("Le poids maximum d'un fichier est de %size%", ['%size%' => p4string::format_octets(self::AUTH_VIDEO_SIZE)]);
|
||||
}
|
||||
|
||||
return $errors;
|
||||
}
|
||||
|
@@ -805,10 +805,16 @@ class Bridge_Api_Flickr extends Bridge_Api_Abstract implements Bridge_Api_Interf
|
||||
private function check_record_constraints(record_adapter $record)
|
||||
{
|
||||
$errors = [];
|
||||
if ( ! $record->get_hd_file() instanceof \SplFileInfo)
|
||||
$errors["file_size"] = $this->translator->trans("Le record n'a pas de fichier physique"); //Record must rely on real file
|
||||
if ($record->get_technical_infos('size')->getValue() > self::AUTH_PHOTO_SIZE)
|
||||
//Record must rely on real file
|
||||
if ( ! $record->get_hd_file() instanceof \SplFileInfo) {
|
||||
$errors["file_size"] = $this->translator->trans("Le record n'a pas de fichier physique");
|
||||
}
|
||||
|
||||
$size = $record->get_technical_infos('size');
|
||||
$size = $size ? $size->getValue() : PHP_INT_MAX;
|
||||
if ($size > self::AUTH_PHOTO_SIZE) {
|
||||
$errors["size"] = $this->translator->trans("Le poids maximum d'un fichier est de %size%", ['%size%' => p4string::format_octets(self::AUTH_VIDEO_SIZE)]);
|
||||
}
|
||||
|
||||
return $errors;
|
||||
}
|
||||
|
@@ -1013,14 +1013,20 @@ class Bridge_Api_Youtube extends Bridge_Api_Abstract implements Bridge_Api_Inter
|
||||
{
|
||||
$errors = [];
|
||||
$key = $record->get_serialize_key();
|
||||
if ( ! $record->get_hd_file() instanceof SplFileInfo)
|
||||
$errors["file_size_" . $key] = $this->translator->trans("Le record n'a pas de fichier physique"); //Record must rely on real file
|
||||
//Record must rely on real file
|
||||
if ( ! $record->get_hd_file() instanceof SplFileInfo) {
|
||||
$errors["file_size_" . $key] = $this->translator->trans("Le record n'a pas de fichier physique");
|
||||
}
|
||||
|
||||
if ($record->get_duration() > self::AUTH_VIDEO_DURATION)
|
||||
if ($record->get_duration() > self::AUTH_VIDEO_DURATION) {
|
||||
$errors["duration_" . $key] = $this->translator->trans("La taille maximale d'une video est de %duration% minutes.", ['%duration%' => self::AUTH_VIDEO_DURATION / 60]);
|
||||
}
|
||||
|
||||
if ($record->get_technical_infos('size')->getValue() > self::AUTH_VIDEO_SIZE)
|
||||
$size = $record->get_technical_infos('size');
|
||||
$size = $size ? $size->getValue() : PHP_INT_MAX;
|
||||
if ($size > self::AUTH_VIDEO_SIZE) {
|
||||
$errors["size_" . $key] = $this->translator->trans("Le poids maximum d'un fichier est de %size%", ['%size%' => p4string::format_octets(self::AUTH_VIDEO_SIZE)]);
|
||||
}
|
||||
|
||||
return $errors;
|
||||
}
|
||||
|
@@ -320,7 +320,8 @@ class record_adapter implements RecordInterface, cache_cacheableInterface
|
||||
public function get_duration()
|
||||
{
|
||||
if (!$this->duration) {
|
||||
$this->duration = round($this->get_technical_infos(media_subdef::TC_DATA_DURATION)->getValue());
|
||||
$duration = $this->get_technical_infos(media_subdef::TC_DATA_DURATION);
|
||||
$this->duration = $duration ? round($duration->getValue()) : 0;
|
||||
}
|
||||
|
||||
return $this->duration;
|
||||
|
@@ -110,8 +110,9 @@
|
||||
{% set dataW = constant('media_subdef::TC_DATA_WIDTH') %}
|
||||
{% set dataH = constant('media_subdef::TC_DATA_HEIGHT') %}
|
||||
|
||||
{% set width = record.get_technical_infos(dataW).value %}
|
||||
{% set height = record.get_technical_infos(dataH).value %}
|
||||
{% set technical_info = record.get_technical_infos %}
|
||||
{% set width = technical_info[dataW].value %}
|
||||
{% set height = technical_infos[dataH].value %}
|
||||
|
||||
{% if width and height %}
|
||||
{% set ratio = (width / height)|number_format(2, '.') %}
|
||||
|
Reference in New Issue
Block a user