/** * @see superclass */ function getPropertySubjects(SMWPropertyValue $property, $value, $requestoptions = NULL) { if (!$property->isUserDefined()) { return parent::getPropertySubjects($property, $value, $requestoptions); } if (smwfCheckIfPredefinedSMWHaloProperty($property)) { return parent::getPropertyValues($subject, $property, $requestoptions, $outputformat); } 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 : ""; $nsPrefixProp = $this->tsNamespace->getNSPrefix($property->getWikiPageValue()->getTitle()->getNamespace()); try { if (is_null($value)) { $response = $client->query("SELECT ?s WHERE { GRAPH ?g { ?s <{$smwgTripleStoreGraph}/{$nsPrefixProp}#{$propertyName}> ?o. } } {$limit} {$offset}", "merge=false|graph={$smwgTripleStoreGraph}"); } else { if ($value instanceof SMWWikiPageValue) { $objectName = $value->getTitle()->getDBkey(); $nsPrefixObj = $this->tsNamespace->getNSPrefix($value->getTitle()->getNamespace()); $response = $client->query("SELECT ?s WHERE { GRAPH ?g { ?s <{$smwgTripleStoreGraph}/{$nsPrefixProp}#{$propertyName}> <{$smwgTripleStoreGraph}/{$nsPrefixObj}#{$objectName}>. } } {$limit} {$offset}", "merge=false"); } else { $objectvalue = str_replace('"', '\\"', array_shift($value->getDBkeys())); $objecttype = WikiTypeToXSD::getXSDType($value->getTypeID()); $response = $client->query("SELECT ?s WHERE { GRAPH ?g { ?s <{$smwgTripleStoreGraph}/{$nsPrefixProp}#{$propertyName}> \"{$objectvalue}\"^^{$objecttype}. } } {$limit} {$offset}", "merge=false"); } } } catch (Exception $e) { wfDebug("Triplestore does probably not run.\n"); $response = TSNamespaces::$EMPTY_SPARQL_XML; } // query 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) { $children = $r->children(); // binding nodes $b = $children->binding[0]; // predicate $sv = $b->children()->uri[0]; $title = $this->getTitleFromURI((string) $sv); $value = SMWWikiPageValue::makePage($title->getDBkey(), $title->getNamespace()); $metadata = $sv->attributes(); foreach ($metadata as $mdProperty => $mdValue) { if (strpos($mdProperty, "_meta_") === 0) { $value->setMetadata(substr($mdProperty, 6), explode("|||", $mdValue)); } } $values[] = $value; } return $values; }