parent
6b25ad6780
commit
35e4402030
|
@ -50,27 +50,39 @@ trait TimelineQuerySingleItem
|
||||||
|
|
||||||
$row = $qb->executeQuery()->fetch();
|
$row = $qb->executeQuery()->fetch();
|
||||||
|
|
||||||
$utcTs = 0;
|
// Basic information to return
|
||||||
|
$info = [
|
||||||
|
'fileid' => (int) $row['fileid'],
|
||||||
|
'dayid' => (int) $row['dayid'],
|
||||||
|
'w' => (int) $row['w'],
|
||||||
|
'h' => (int) $row['h'],
|
||||||
|
'datetaken' => (int) $row['datetaken'],
|
||||||
|
];
|
||||||
|
|
||||||
|
// Attempt to get the date in the correct timezone
|
||||||
try {
|
try {
|
||||||
$utcDate = new \DateTime($row['datetaken'], new \DateTimeZone('UTC'));
|
$utcDate = new \DateTime($row['datetaken'], new \DateTimeZone('UTC'));
|
||||||
$utcTs = $utcDate->getTimestamp();
|
$info['datetaken'] = $utcDate->getTimestamp();
|
||||||
} catch (\Throwable $e) {
|
} catch (\Throwable $e) {
|
||||||
|
// Ignore
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get exif if needed
|
// Return if only basic info is needed
|
||||||
$exif = [];
|
if ($basic) {
|
||||||
if (!$basic && !empty($row['exif'])) {
|
return $info;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get exif data for metadata
|
||||||
|
if (!empty($row['exif'])) {
|
||||||
try {
|
try {
|
||||||
$exif = json_decode($row['exif'], true);
|
$info['exif'] = json_decode($row['exif'], true);
|
||||||
} catch (\Throwable $e) {
|
} catch (\Throwable $e) {
|
||||||
|
// Ignore
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get address from places
|
// Get address from places
|
||||||
$gisType = \OCA\Memories\Util::placesGISType();
|
if (Util::placesGISType() > 0) {
|
||||||
$address = -1 === $gisType ? 'Geocoding Unconfigured' : null;
|
|
||||||
if (!$basic && $gisType > 0) {
|
|
||||||
$qb = $this->connection->getQueryBuilder();
|
$qb = $this->connection->getQueryBuilder();
|
||||||
$qb->select('e.name', 'e.other_names')
|
$qb->select('e.name', 'e.other_names')
|
||||||
->from('memories_places', 'mp')
|
->from('memories_places', 'mp')
|
||||||
|
@ -84,18 +96,10 @@ trait TimelineQuerySingleItem
|
||||||
$lang = Util::getUserLang();
|
$lang = Util::getUserLang();
|
||||||
if (\count($places) > 0) {
|
if (\count($places) > 0) {
|
||||||
$places = array_map(fn ($p) => PlacesBackend::choosePlaceLang($p, $lang)['name'], $places);
|
$places = array_map(fn ($p) => PlacesBackend::choosePlaceLang($p, $lang)['name'], $places);
|
||||||
$address = implode(', ', $places);
|
$info['address'] = implode(', ', $places);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return [
|
return $info;
|
||||||
'fileid' => (int) $row['fileid'],
|
|
||||||
'dayid' => (int) $row['dayid'],
|
|
||||||
'w' => (int) $row['w'],
|
|
||||||
'h' => (int) $row['h'],
|
|
||||||
'datetaken' => $utcTs,
|
|
||||||
'address' => $address,
|
|
||||||
'exif' => $exif,
|
|
||||||
];
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue