Ejemplo n.º 1
0
$observation = $observations[0];
// Get observatory information
$stmt = $const->db->prepare("SELECT * FROM archive_observatories WHERE uid=:i;");
$stmt->bindParam(':i', $i, PDO::PARAM_INT);
$stmt->execute(['i' => $observation['observatory']]);
$obstory = $stmt->fetch();
// Check mime type
$mime_type = $result['mimeType'];
$file_url = "/api/files/content/{$result['repositoryFname']}/{$result['fileName']}";
// Does user have permission to set metadata on this item?
$allow_item_to_be_featured = $mime_type == "image/png" && in_array("voter", $user->roles);
// Set categorisation of image based on get data
if ($allow_item_to_be_featured && array_key_exists("update", $_GET)) {
    set_metadata("web:featured", array_key_exists("feature", $_GET) ? 1 : null, $observation['obsTime'], $uid, "fileId");
    if (array_key_exists("caption", $_GET)) {
        set_metadata("web:caption", $_GET["caption"], $observation['obsTime'], $uid, "fileId");
    }
}
// Get list of metadata
$stmt = $const->db->prepare("\nSELECT m.time, mf.metaKey, m.floatValue, m.stringValue\nFROM archive_metadata m\nINNER JOIN archive_metadataFields mf ON m.fieldId = mf.uid\nWHERE fileId=:i;");
$stmt->bindParam(':i', $i, PDO::PARAM_INT);
$stmt->execute(['i' => $uid]);
$metadata = $stmt->fetchAll();
// Make metadata dictionary
$metadata_by_key = [];
foreach ($metadata as $item) {
    $metadata_by_key[$item['metaKey']] = $item['stringValue'] ? $item['stringValue'] : $item['floatValue'];
}
// Get list of other files
$stmt = $const->db->prepare("\nSELECT f.repositoryFname, f.fileName, o.obsTime, l.publicId AS obstoryId, sf.name AS obstoryName,\nf.mimeType AS mimeType,sf.name AS semanticType\nFROM archive_files f\nINNER JOIN archive_observations o ON f.observationId = o.uid\nINNER JOIN archive_observatories l ON o.observatory = l.uid\nINNER JOIN archive_semanticTypes sf ON f.semanticType = sf.uid\nWHERE f.observationId=:i;");
$stmt->bindParam(':i', $i, PDO::PARAM_INT);
Ejemplo n.º 2
0
$uid = $observation['uid'];
// Get observatory information
$stmt = $const->db->prepare("SELECT * FROM archive_observatories WHERE uid=:i;");
$stmt->bindParam(':i', $i, PDO::PARAM_INT);
$stmt->execute(['i' => $observation['observatory']]);
$obstory = $stmt->fetch();
// Does user have permission to set metadata on this item?
$allow_item_to_be_featured = in_array("voter", $user->roles);
// Set categorisation of image based on get data
if ($allow_item_to_be_featured && array_key_exists("update", $_GET)) {
    if (array_key_exists("category", $_GET)) {
        $new_category = $_GET["category"];
        if ($new_category == "Not set") {
            $new_category = null;
        }
        set_metadata("web:category", $new_category, $observation['obsTime'], $uid, "observationId");
    }
}
// Get list of metadata
$stmt = $const->db->prepare("\nSELECT m.time, mf.metaKey, m.floatValue, m.stringValue\nFROM archive_metadata m\nINNER JOIN archive_metadataFields mf ON m.fieldId = mf.uid\nWHERE observationId=:i;");
$stmt->bindParam(':i', $i, PDO::PARAM_INT);
$stmt->execute(['i' => $uid]);
$metadata = $stmt->fetchAll();
// Make metadata dictionary
$metadata_by_key = [];
foreach ($metadata as $item) {
    $metadata_by_key[$item['metaKey']] = $item['stringValue'] ? $item['stringValue'] : $item['floatValue'];
}
// Get list of associated files
$stmt = $const->db->prepare("\nSELECT f.repositoryFname, f.fileName, o.obsTime, l.publicId AS obstoryId, sf.name AS obstoryName,\nf.mimeType AS mimeType,sf.name AS semanticType\nFROM archive_files f\nINNER JOIN archive_observations o ON f.observationId = o.uid\nINNER JOIN archive_observatories l ON o.observatory = l.uid\nINNER JOIN archive_semanticTypes sf ON f.semanticType = sf.uid\nWHERE observationId=:i;");
$stmt->bindParam(':i', $i, PDO::PARAM_INT);