Index: trunk/extensions/SemanticMediaWiki/includes/SMW_QueryProcessor.php |
— | — | @@ -483,14 +483,21 @@ |
484 | 484 | $result = $this->addDescription($result, $this->getSubqueryDescription(), false); |
485 | 485 | break; |
486 | 486 | default: |
487 | | - $list = preg_split('/:/', $chunk, 3); |
488 | | - if ($list[0] == '') { |
489 | | - $list = array_slice($list, 2); |
| 487 | + $list = preg_split('/:/', $chunk, 3); // ":Category:Foo" "User:bar" ":baz" ":+" |
| 488 | + if ( ($list[0] == '') && (count($list)==3) ) { |
| 489 | + $list = array_slice($list, 1); |
490 | 490 | } |
491 | | - if ( (count($list) == 3) && ($list[2] == '+') ) { // namespace restriction |
492 | | - // TODO |
| 491 | + if ( (count($list) == 2) && ($list[1] == '+') ) { // try namespace restriction |
| 492 | + global $wgContLang; |
| 493 | + $idx = $wgContLang->getNsIndex($list[0]); |
| 494 | + if ($idx !== false) { |
| 495 | + $result = $this->addDescription($result, new SMWNamespaceDescription($idx), false); |
| 496 | + } |
493 | 497 | } else { |
494 | | - $result = $this->addDescription($result, new SMWNominalDescription(Title::newFromText($chunk)), false); |
| 498 | + $title = Title::newFromText($chunk); |
| 499 | + if ($title !== NULL) { |
| 500 | + $result = $this->addDescription($result, new SMWNominalDescription($title), false); |
| 501 | + } |
495 | 502 | } |
496 | 503 | } |
497 | 504 | |
— | — | @@ -558,7 +565,7 @@ |
559 | 566 | */ |
560 | 567 | protected function readChunk($stoppattern = '') { |
561 | 568 | if ($stoppattern == '') { |
562 | | - $stoppattern = '\[\[|\]\]|::|:=|<q>|<\/q>|' . $this->m_categoryprefix . '|\|\||\|'; |
| 569 | + $stoppattern = '\[\[|\]\]|::|:=|<q>|<\/q>|^' . $this->m_categoryprefix . '|\|\||\|'; |
563 | 570 | } |
564 | 571 | $chunks = preg_split('/[\s]*(' . $stoppattern . ')[\s]*/', $this->m_curstring, 2, PREG_SPLIT_DELIM_CAPTURE); |
565 | 572 | if (count($chunks) == 1) { // no matches anymore, strip spaces and finish |
Index: trunk/extensions/SemanticMediaWiki/includes/storage/SMW_Description.php |
— | — | @@ -189,6 +189,34 @@ |
190 | 190 | } |
191 | 191 | |
192 | 192 | /** |
| 193 | + * Description of all pages within a given wiki namespace, |
| 194 | + * given by a numerical constant. |
| 195 | + * Corresponds to a class restriction with a special class |
| 196 | + * that characterises the given namespace (or at least that |
| 197 | + * is how one could map this to OWL etc.). |
| 198 | + */ |
| 199 | +class SMWNamespaceDescription extends SMWDescription { |
| 200 | + protected $m_namespace; |
| 201 | + |
| 202 | + public function SMWNamespaceDescription($namespace) { |
| 203 | + $this->m_namespace = $namespace; |
| 204 | + } |
| 205 | + |
| 206 | + public function getNamespace() { |
| 207 | + return $this->m_namespace; |
| 208 | + } |
| 209 | + |
| 210 | + public function getQueryString() { |
| 211 | + global $wgContlang; |
| 212 | + if ($this->m_title !== NULL) { |
| 213 | + return '[[' . $wgContLang->getNSText($this->m_namespace) . ']]'; |
| 214 | + } else { |
| 215 | + return ''; |
| 216 | + } |
| 217 | + } |
| 218 | +} |
| 219 | + |
| 220 | +/** |
193 | 221 | * Description of a class that contains exactly one explicitly given |
194 | 222 | * object. |
195 | 223 | * |
Index: trunk/extensions/SemanticMediaWiki/includes/storage/SMW_SQLStore.php |
— | — | @@ -866,6 +866,10 @@ |
867 | 867 | if ($this->addInnerJoin('CATS', $from, $db, $curtables)) { |
868 | 868 | $where .= $curtables['CATS'] . '.cl_to=' . $db->addQuotes($description->getCategory()->getDBKey()); |
869 | 869 | } |
| 870 | + } elseif ($description instanceof SMWNamespaceDescription) { |
| 871 | + if ($this->addInnerJoin('PAGE', $from, $db, $curtables)) { |
| 872 | + $where .= $curtables['PAGE'] . '.page_namespace=' . $db->addQuotes($description->getNamespace()); |
| 873 | + } |
870 | 874 | } elseif ($description instanceof SMWNominalDescription) { |
871 | 875 | if (array_key_exists('PREVREL', $curtables)) { |
872 | 876 | $where .= $curtables['PREVREL'] . '.object_title=' . |