/** * Gets an array of tuples (URI, metadata-uri) and creates SMWWikiPageValue objects. * * @param array of tuples (uri, hash array metadata) $uris * @param array SMWDataValue (out) & $allValues */ protected function addURIToResult($uris, &$allValues) { foreach ($uris as $uri) { list($sv, $metadata) = $uri; // check if common namespace from MW or SMW // and create SMWDataValue accoringly $nsFound = false; foreach (TSNamespaces::getAllNamespaces() as $nsIndsex => $ns) { if (stripos($sv, $ns) === 0) { $allValues[] = $this->createSMWDataValue($sv, $metadata, $ns, $nsIndsex); $nsFound = true; } } if ($nsFound) { continue; } // result with unknown namespace // unknown means the namespace has a suffix: /ns_<index># // where <index> is the namespace index. if (stripos($sv, TSNamespaces::$UNKNOWN_NS) === 0) { if (empty($sv)) { $v = SMWDataValueFactory::newTypeIDValue('_wpg'); foreach ($metadata as $mdProperty => $mdValue) { if (strpos($mdProperty, "_meta_") === 0) { $v->setMetadata(substr($mdProperty, 6), explode("|||", $mdValue)); } } $allValues[] = $v; } else { $startNS = strlen(TSNamespaces::$UNKNOWN_NS); $length = strpos($sv, "#") - $startNS; $ns = intval(substr($sv, $startNS, $length)); $local = substr($sv, strpos($sv, "#") + 1); $title = Title::newFromText($local, $ns); if (is_null($title)) { $title = Title::newFromText(wfMsg('smw_ob_invalidtitle'), $ns); } $v = SMWDataValueFactory::newTypeIDValue('_wpg'); $v->setValues($title->getDBkey(), $ns, $title->getArticleID()); foreach ($metadata as $mdProperty => $mdValue) { if (strpos($mdProperty, "_meta_") === 0) { $v->setMetadata(substr($mdProperty, 6), explode("|||", $mdValue)); } } $allValues[] = $v; } } else { // external URI $v = SMWDataValueFactory::newTypeIDValue('_uri'); $v->setDBkeys(array($sv)); foreach ($metadata as $mdProperty => $mdValue) { if (strpos($mdProperty, "_meta_") === 0) { $v->setMetadata(substr($mdProperty, 6), explode("|||", $mdValue)); } } $allValues[] = $v; } } }
private function getPropertyIRI($property) { $tsN = new TSNamespaces(); $uri = $tsN->getAllNamespaces(); $uri = $uri[SMW_NS_PROPERTY]; return '<' . $uri . $property . '>'; }