function label($props, $uri = 'Something') { global $prefixes; extract($prefixes); $labelPs = array($dct . 'title', $foaf . 'name', $rdfs . 'label'); foreach ($labelPs as $p) { if (isset($props[$p])) { return $props[$p][0]['value']; } } $type = 'Thing'; if (isset($props[$rdf . 'type'])) { $type = $props[$rdf . 'type'][0]['value']; } return "A " . curie($type); }
function addMetadata($data, &$Config, $types, $facets, $namespaces) { $datasetUri = 'http://' . $_SERVER['HTTP_HOST'] . dirname($_SERVER['SCRIPT_NAME']) . '/'; $documentUri = 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; $documentUri = array_shift(explode('?', $documentUri)); if ($query = getQuery()) { $documentUri .= '?' . $query; } if (isset($data[$documentUri])) { $documentUri .= '&_output=turtle'; } $DocumentGraph = new Graph($documentUri, $data); $count = 1; foreach ($data as $uri => $props) { $prop = rdf_ns . '_' . $count++; $DocumentGraph->setResource($prop, $uri); } if ($documentUri != $datasetUri) { $DocumentGraph->setResource(void_ns . 'inDataset', $datasetUri); } else { $DocumentGraph->setResource(rdf_ns . 'type', void_ns . 'Dataset'); foreach ($types as $type => $entities) { $classPartition = $DocumentGraph->setResource(void_ns . 'classPartition', $datasetUri . '?rdf:type=' . curie($type)); $classPartition->setResource(void_ns . 'class', $type); $classPartition->setLiteral(void_ns . 'entities', $entities); } foreach ($namespaces as $ns => $n) { $vocabUri = preg_replace('@#$@', '', $ns); $DocumentGraph->setResource(void_ns . 'vocabulary', $vocabUri); } } if (!empty($Config->license)) { $DocumentGraph->setResource(dcterms_ns . 'license', $Config->license); } if (!empty($Config->name)) { $DocumentGraph->setLiteral(dcterms_ns . 'title', $Config->name); } return $DocumentGraph->getIndex(); }
if (!is_file($data_file)) { throw new Exception("{$data_file} could not be found"); } $store->loadDataFile($data_file); // $store->loadData(file_get_contents($data_file)); // $this->createHierarchicalIndex(); } $types = $store->getTypes(); $query = getQuery(); $page = 1; $offset = isset($_GET['_page']) && ($page = $_GET['_page']) ? ($_GET['_page'] - 1) * 10 : 0; $showMap = strpos($query, '_near') !== false || isset($_GET['_near']) ? true : false; if (!empty($query)) { //query based title list($path, $value) = explode('=', $query); $value = curie($value); $title = local($value); if ($path == 'rdf:type') { $title = plural($title); } else { $title = local($path) . ': ' . $title; } $data = $store->query($query, 10, $offset); } else { if (isset($_GET['_near'])) { $distance = isset($_GET['_near_distance']) ? (double) $_GET['_near_distance'] : 50; $title = "Near: " . local($_GET['_near']); $showMap = true; $data = $store->distance($_GET['_near'], $distance); } else { if (isset($_GET['_search']) && ($search = $_GET['_search'])) {