-
Notifications
You must be signed in to change notification settings - Fork 44
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[FINNA-2579] & [FINNA-2875] Add file size to LIDO resource and fix resource play buttons for sr #3118
base: dev
Are you sure you want to change the base?
[FINNA-2579] & [FINNA-2875] Add file size to LIDO resource and fix resource play buttons for sr #3118
Changes from 7 commits
2c15b79
78916bf
2dd5483
20fe5f0
a14dd13
bc9c073
cbd3a95
f0a2a83
c972f16
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -384,7 +384,7 @@ public function getAllImages($language = null) | |
* | ||
* @return array | ||
*/ | ||
protected function formatImageMeasurements( | ||
protected function formatResourceMeasurements( | ||
\SimpleXmlElement $measurements | ||
): array { | ||
$results = []; | ||
|
@@ -639,14 +639,28 @@ protected function getRepresentations(string $language): array | |
|
||
// Representation is a 3d model | ||
if (in_array($type, $modelTypeKeys)) { | ||
if ($model = $this->getModel($url, $format, $type)) { | ||
if ( | ||
$model = $this->getModel( | ||
$url, | ||
$format, | ||
$type, | ||
$representation->resourceMeasurementsSet | ||
) | ||
) { | ||
$modelUrls[] = $model; | ||
} | ||
continue; | ||
} | ||
// Representation is an audio | ||
if (in_array($type, $audioTypeKeys)) { | ||
if ($audio = $this->getAudio($url, $format, $description)) { | ||
if ( | ||
$audio = $this->getAudio( | ||
$url, | ||
$format, | ||
$description, | ||
$representation->resourceMeasurementsSet | ||
) | ||
) { | ||
$audioUrls = array_merge($audioUrls, $audio); | ||
if ($extraDetails = $this->getExtraDetails($resourceSet, $language)) { | ||
$audioUrls = array_merge($audioUrls, $extraDetails); | ||
|
@@ -656,7 +670,14 @@ protected function getRepresentations(string $language): array | |
} | ||
// Representation is a video | ||
if (in_array($type, $videoTypeKeys)) { | ||
if ($video = $this->getVideo($url, $format, $description)) { | ||
if ( | ||
$video = $this->getVideo( | ||
$url, | ||
$format, | ||
$description, | ||
$representation->resourceMeasurementsSet | ||
) | ||
) { | ||
$videoUrls = array_merge($videoUrls, $video); | ||
if ($extraDetails = $this->getExtraDetails($resourceSet, $language)) { | ||
$videoUrls = array_merge($videoUrls, $extraDetails); | ||
|
@@ -815,16 +836,18 @@ protected function getExtraDetails( | |
* - type Model type preview_3d or provided_3d as key | ||
* url to model as value | ||
* | ||
* @param string $url Model url | ||
* @param string $format Model format | ||
* @param string $type Model type | ||
* @param string $url Model url | ||
* @param string $format Model format | ||
* @param string $type Model type | ||
* @param \SimpleXmlElement $measurements Measurements SimpleXmlElement | ||
* | ||
* @return array | ||
*/ | ||
protected function getModel( | ||
string $url, | ||
string $format, | ||
string $type, | ||
\SimpleXmlElement $measurements = null, | ||
): array { | ||
$type = $this->modelTypes[$type]; | ||
$format = strtolower($format); | ||
|
@@ -835,6 +858,9 @@ protected function getModel( | |
'url' => $url, | ||
'format' => $format, | ||
'type' => $type, | ||
'data' => $this->formatResourceMeasurements( | ||
$measurements | ||
), | ||
]; | ||
} | ||
|
||
|
@@ -882,7 +908,7 @@ protected function getImage( | |
$highResolution = []; | ||
if (in_array($size, ['master', 'original'])) { | ||
$currentHiRes = [ | ||
'data' => $this->formatImageMeasurements( | ||
'data' => $this->formatResourceMeasurements( | ||
$measurements | ||
), | ||
'url' => $url, | ||
|
@@ -905,16 +931,18 @@ protected function getImage( | |
* - type Type what type is the audio file | ||
* - embed Type of embed is audio | ||
* | ||
* @param string $url Url of the audio | ||
* @param string $format Format of the audio | ||
* @param string $description Description of the audio | ||
* @param string $url Url of the audio | ||
* @param string $format Format of the audio | ||
* @param string $description Description of the audio | ||
* @param \SimpleXmlElement $measurements Measurements SimpleXmlElement | ||
* | ||
* @return array | ||
*/ | ||
protected function getAudio( | ||
string $url, | ||
string $format, | ||
string $description | ||
string $description, | ||
\SimpleXmlElement $measurements = null | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Tämän tyypin pitäisi olla |
||
): array { | ||
if ($codec = $this->supportedAudioFormats[$format] ?? false) { | ||
return [ | ||
|
@@ -923,6 +951,9 @@ protected function getAudio( | |
'codec' => $format, | ||
'type' => 'audio', | ||
'embed' => 'audio', | ||
'data' => $this->formatResourceMeasurements( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ei voi kutsua formatResourceMeasurements-metodia varmistamatta, ettei $measurements ole null. |
||
$measurements | ||
), | ||
]; | ||
} | ||
return []; | ||
|
@@ -937,16 +968,18 @@ protected function getAudio( | |
* - src Different sources for the video | ||
* - type Codec type | ||
* | ||
* @param string $url Url of the video | ||
* @param string $format Format of the video | ||
* @param string $description Description of the video | ||
* @param string $url Url of the video | ||
* @param string $format Format of the video | ||
* @param string $description Description of the video | ||
* @param \SimpleXmlElement $measurements Measurements SimpleXmlElement | ||
* | ||
* @return array | ||
*/ | ||
protected function getVideo( | ||
string $url, | ||
string $format, | ||
string $description | ||
string $description, | ||
\SimpleXmlElement $measurements = null | ||
): array { | ||
$mediaType = $this->supportedVideoFormats[$format] ?? false; | ||
return match ($mediaType) { | ||
|
@@ -955,6 +988,9 @@ protected function getVideo( | |
'url' => $url, | ||
'embed' => 'iframe', | ||
'format' => $format, | ||
'data' => $this->formatResourceMeasurements( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ei voi kutsua formatResourceMeasurements-metodia varmistamatta, ettei $measurements ole null. |
||
$measurements | ||
), | ||
], | ||
false => [], | ||
default => [ | ||
|
@@ -966,6 +1002,9 @@ protected function getVideo( | |
'src' => $url, | ||
'type' => $mediaType, | ||
], | ||
'data' => $this->formatResourceMeasurements( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ei voi kutsua formatResourceMeasurements-metodia varmistamatta, ettei $measurements ole null. |
||
$measurements | ||
), | ||
], | ||
}; | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tämän tyypin pitäisi olla
?\SimpleXmlElement