function set_body_object($body, $type)
{
    $out = "";
    $etiquette = find_body_etiquette($type);
    if (isset($body->resources)) {
        $res = $body->resources;
        $out = "\"resource\": {\n                            \"id\":\"{$res->id}\",\n                            \"label\": \"{$res->label}\"\n                        }";
    } else {
        $out = "\"{$etiquette}\": \"{$body->literal}\"";
    }
    return $out;
}
Esempio n. 2
0
function print_annotation($multiannotation)
{
    foreach ($multiannotation->annotation as $key => $val) {
        echo "<br>annotazione {$key}: <br>";
        echo "Tipo: {$val->type} <br>";
        echo "Label: {$val->label} <br>";
        echo "body:<br>";
        $body = $val->body;
        if (strcmp($body->label, "") != 0) {
            echo "&nbsp&nbsp Label: {$body->label} <br>";
        }
        echo "&nbsp&nbsp Soggetto: {$body->subject} <br>";
        echo "&nbsp&nbsp Predicato: {$body->predicate} <br>";
        $etiquette = find_body_etiquette($val->type);
        if (strcmp($body->literal, "") != 0) {
            echo "&nbsp&nbsp {$etiquette}: {$body->literal} <br>";
        } else {
            if (isset($body->resources)) {
                //if(strcmp())
                $res = $body->resources;
                echo "&nbsp&nbsp {$etiquette}:<br>&nbsp&nbsp&nbsp&nbsp&nbsp Id: {$res->id} <br>";
                echo "&nbsp&nbsp&nbsp&nbsp&nbsp Label: {$res->label} <br>";
            } else {
                exit;
            }
        }
    }
    echo "Target: <br>";
    $target = $multiannotation->target;
    echo "&nbsp Source: {$target->source} <br>";
    echo "&nbsp Id: {$target->id} <br>";
    echo "&nbsp Start: {$target->start} <br>";
    echo "&nbsp End: {$target->end} <br>";
    echo "Provenance: <br>";
    $provenance = $multiannotation->provenance;
    $author = $provenance->author;
    echo "&nbsp Nome: {$author->name} <br>";
    echo "&nbsp Mail: {$author->email} <br>";
    echo "&nbsp Time: {$provenance->time} <br>";
}