public function filterBrowse($p_array) { $browserFilter = new SMWOntologyBrowserFilter(); $type = $p_array[0]; $hint = explode(" ", $p_array[1]); $hint = smwfEliminateStopWords($hint); if ($type != 'instance') { return parent::filterBrowse($p_array); } global $wgServer, $wgScript, $smwgWebserviceUser, $smwgWebservicePassword, $smwgDeployVersion; $client = TSConnection::getConnector(); $client->connect(); try { global $smwgTripleStoreGraph; $dataSpace = $this->getDataSourceParameters(); //query for ($i = 0; $i < count($hint); $i++) { $hint[$i] = preg_quote($hint[$i]); $hint[$i] = str_replace("\\", "\\\\", $hint[$i]); } $filter = ""; if (count($hint) > 0) { $filter = "FILTER ("; for ($i = 0; $i < count($hint); $i++) { if ($i > 0) { $filter .= " && "; } $filter .= "regex(str(?s), \"{$hint[$i]}\", \"i\")"; } $filter .= ")"; } $response = $client->query(TSNamespaces::getW3CPrefixes() . " SELECT ?s ?cat WHERE { ?s ?p ?o. OPTIONAL { ?s rdf:type ?cat. } {$filter} }", "limit=1000{$dataSpace}"); $titles = array(); $this->parseInstances($response, $titles); } catch (Exception $e) { return "Internal error: " . $e->getMessage(); } // do not show partitions. 1000 instances is maximum here. return SMWOntologyBrowserXMLGenerator::encapsulateAsInstancePartition($titles, 1001, 0); }
function changeTitle(Title $oldtitle, Title $newtitle, $pageid, $redirid = 0) { $this->smwstore->changeTitle($oldtitle, $newtitle, $pageid, $redirid); $old_ns = $this->tsNamespace->getNSPrefix($oldtitle->getNamespace()); $new_ns = $this->tsNamespace->getNSPrefix($newtitle->getNamespace()); // update local rule store global $smwgEnableObjectLogicRules; if (isset($smwgEnableObjectLogicRules)) { SMWRuleStore::getInstance()->updateRules($redirid, $pageid); } // update triple store global $smwgMessageBroker, $smwgTripleStoreGraph; try { $con = TSConnection::getConnector(); $sparulCommands = array(); $sparulCommands[] = TSNamespaces::getW3CPrefixes() . "MODIFY <{$smwgTripleStoreGraph}> DELETE { <{$smwgTripleStoreGraph}/{$old_ns}#" . $oldtitle->getDBkey() . "> ?p ?o. } INSERT { <{$smwgTripleStoreGraph}/{$new_ns}#" . $newtitle->getDBkey() . "> ?p ?o. }"; $sparulCommands[] = TSNamespaces::getW3CPrefixes() . "MODIFY <{$smwgTripleStoreGraph}> DELETE { ?s <{$smwgTripleStoreGraph}/{$old_ns}#" . $oldtitle->getDBkey() . "> ?o. } INSERT { ?s <{$smwgTripleStoreGraph}/{$new_ns}#" . $newtitle->getDBkey() . "> ?o. }"; $sparulCommands[] = TSNamespaces::getW3CPrefixes() . "MODIFY <{$smwgTripleStoreGraph}> DELETE { ?s ?p <{$smwgTripleStoreGraph}/{$old_ns}#" . $oldtitle->getDBkey() . ">. } INSERT { ?s ?p <{$smwgTripleStoreGraph}/{$new_ns}#" . $newtitle->getDBkey() . ">. }"; $con->connect(); $con->update("/topic/WIKI.TS.UPDATE", $sparulCommands); $con->disconnect(); } catch (Exception $e) { } }