Beispiel #1
0
foreach ($cpss as $prop) {
    echo '<tr>';
    echo '<td>' . $prop->display_name . '</td>';
    echo '<td>' . ($prop->required ? 'Yes' : 'No') . '</td>';
    // work out which uri we will use
    echo '<td>';
    $is_first = true;
    $is_resource = false;
    foreach ($prop->qnames as $uri) {
        if ($is_first) {
            $prefered_class = "herbal-prefered-uri";
        } else {
            $prefered_class = "herbal-not-prefered-uri";
        }
        if ($prop->resource_expected) {
            $r = $doc->getResource($specimen_uri, '<' . $uri . '>');
            if ($r) {
                $val = $r->getUri();
                $is_resource = true;
            } else {
                $val = $doc->getLiteral($specimen_uri, '<' . $uri . '>');
            }
        } else {
            $val = $doc->getLiteral($specimen_uri, '<' . $uri . '>');
        }
        if ($val) {
            echo '<span class="herbal-used-uri ' . $prefered_class . '">' . $uri . "</span><br/>";
            break;
        } else {
            echo '<span class="herbal-not-used-uri ' . $prefered_class . '" >' . $uri . "</span><br/>";
            $is_first = false;
Beispiel #2
0
 /**
  * Rebase the graph on triples with the start fragment to our own base URI
  *
  * @param string        $start_fragment
  * @param EasyRdf_Graph $graph
  *
  * @return EasyRdf_Graph
  */
 private function rebaseGraph($start_fragment, $graph)
 {
     // Filter out the #dataset meta-data (if present) and change the URI's to our base URI
     $collections = $graph->allOfType('hydra:Collection');
     // Fetch all of the subject URI's that bring forth hydra meta-data (and are thus irrelevant)
     $ignore_subjects = array();
     if (empty($collection)) {
         $collections = $graph->allOfType('hydra:PagedCollection');
     }
     if (!empty($collections)) {
         foreach ($collections as $collection) {
             array_push($ignore_subjects, $collection->getUri());
         }
     }
     // Fetch the bnode of the hydra mapping (property is hydra:search)
     $hydra_mapping = $graph->getResource($start_fragment . '#dataset', 'hydra:search');
     if (!empty($hydra_mapping)) {
         // Hydra mapping's will be a bnode structure
         array_push($ignore_subjects, '_:' . $hydra_mapping->getBNodeId());
         $mapping_nodes = $hydra_mapping->all('hydra:mapping');
         foreach ($mapping_nodes as $mapping_node) {
             if ($mapping_node->isBNode()) {
                 array_push($ignore_subjects, '_:' . $mapping_node->getBNodeId());
             }
         }
         $graph->deleteResource($start_fragment . '#dataset', 'hydra:search', '_:genid1');
         $graph->deleteResource('_:genid1', 'hydra:mapping', '_:genid2');
         // Delete all of the mapping related resources
         $triples = $graph->toRdfPhp();
     } else {
         // Change all of the base (startfragment) URI's to our own base URI
         $triples = $graph->toRdfPhp();
     }
     // Unset the #dataset
     unset($triples[$start_fragment . '#dataset']);
     foreach ($ignore_subjects as $ignore_subject) {
         unset($triples[$ignore_subject]);
     }
     $adjusted_graph = new \EasyRdf_Graph();
     foreach ($triples as $subject => $triple) {
         foreach ($triple as $predicate => $objects) {
             foreach ($objects as $object) {
                 $adjusted_graph->add($subject, $predicate, $object['value']);
             }
         }
     }
     return $adjusted_graph;
 }