/** * @see superclass */ function getAllPropertyAnnotations(SMWPropertyValue $property, $requestoptions = NULL) { global $smwgTripleStoreGraph; $client = TSConnection::getConnector(); $client->connect(); $values = array(); $propertyName = $property->getWikiPageValue()->getTitle()->getDBkey(); $limit = isset($requestoptions->limit) ? " LIMIT " . $requestoptions->limit : ""; $offset = isset($requestoptions->offset) ? " OFFSET " . $requestoptions->offset : ""; // query $nsPrefixProp = $this->tsNamespace->getNSPrefix($property->getWikiPageValue()->getTitle()->getNamespace()); try { $response = $client->query("SELECT ?s ?o WHERE { GRAPH ?g { ?s <{$smwgTripleStoreGraph}/{$nsPrefixProp}#{$propertyName}> ?o. } } ORDER BY ASC(?s) {$limit} {$offset}", "merge=false"); } catch (Exception $e) { wfDebug("Triplestore does probably not run.\n"); $response = TSNamespaces::$EMPTY_SPARQL_XML; } global $smwgSPARQLResultEncoding; // PHP strings are always interpreted in ISO-8859-1 but may be actually encoded in // another charset. if (isset($smwgSPARQLResultEncoding) && $smwgSPARQLResultEncoding == 'UTF-8') { $response = utf8_decode($response); } $dom = simplexml_load_string($response); $annotations = array(); $results = $dom->xpath('//result'); foreach ($results as $r) { $values = array(); $children = $r->children(); // binding nodes $b = $children->binding[0]; $sv = $b->children()->uri[0]; $title = $this->getTitleFromURI((string) $sv); $title_dv = SMWDataValueFactory::newTypeIDValue('_wpg'); $title_dv->setValues($title->getDBkey(), $title->getNamespace(), $title->getArticleID()); $b = $children->binding[1]; foreach ($b->children()->uri as $sv) { $object = $this->getTitleFromURI((string) $sv); $value = SMWDataValueFactory::newPropertyObjectValue($property, $object); $metadata = $sv->attributes(); foreach ($metadata as $mdProperty => $mdValue) { if (strpos($mdProperty, "_meta_") === 0) { $value->setMetadata(substr($mdProperty, 6), explode("|||", $mdValue)); } } $values[] = $value; } foreach ($b->children()->literal as $sv) { $literal = array((string) $sv, $sv->attributes()->datatype); $value = $this->getLiteral($literal, $property); $metadata = $sv->attributes(); foreach ($metadata as $mdProperty => $mdValue) { if (strpos($mdProperty, "_meta_") === 0) { $value->setMetadata(substr($mdProperty, 6), explode("|||", $mdValue)); } } $values[] = $value; } $annotations[] = array($title_dv, $values); } return $annotations; }