/** * Serializes the tree structure (without root node) */ public function serializeAsXML($type) { $id = uniqid(rand()); $count = 0; $result = ""; $gi_store = SGAGardeningIssuesAccess::getGardeningIssuesAccess(); foreach ($this->children as $title => $treeObject) { $isExpanded = count($treeObject->children) == 0 ? "false" : "true"; $title_esc = htmlspecialchars($treeObject->getTitle()->getDBkey()); $titleURLEscaped = htmlspecialchars(SMWOntologyBrowserXMLGenerator::urlescape($treeObject->getTitle()->getDBkey())); $issues = $gi_store->getGardeningIssues('smw_consistencybot', NULL, NULL, $treeObject->getTitle()); $gi_issues = SMWOntologyBrowserErrorHighlighting::getGardeningIssuesAsXML($issues); $result .= "<{$type} title_url=\"{$titleURLEscaped}\" title=\"" . $title_esc . "\" img=\"{$type}.gif\" id=\"ID_{$id}{$count}\" expanded=\"{$isExpanded}\">"; $result .= $gi_issues; $result .= $treeObject->serializeAsXML($type); $result .= "</{$type}>"; $count++; } return $result; }
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); }
/** * Encapsulate an array of properties as XML * * @param array & $properties: Tuple of (title, minCard, maxCard, type, isSym, isTrans, range) * * @return XML string */ public static function encapsulateAsPropertyList(array &$properties) { $count = 0; $propertiesXML = ""; $gi_store = SGAGardeningIssuesAccess::getGardeningIssuesAccess(); foreach ($properties as $t) { $directIssues = $gi_store->getGardeningIssues('smw_consistencybot', NULL, NULL, $t[0]); $propertiesXML .= SMWOntologyBrowserXMLGenerator::encapsulateAsProperty($t, $count, $directIssues); $count++; } return $propertiesXML == '' ? "<propertyList isEmpty=\"true\" textToDisplay=\"" . wfMsg('smw_ob_no_properties') . "\"/>" : "<propertyList>" . $propertiesXML . "</propertyList>"; }