Index: trunk/extensions/SemanticMediaWiki/includes/storage/SMW_SparqlStoreQueryEngine.php |
— | — | @@ -479,7 +479,7 @@ |
480 | 480 | if ( $description instanceof SMWSomeProperty ) { |
481 | 481 | return $this->buildPropertyCondition( $description, $joinVariable, $orderByProperty ); |
482 | 482 | } elseif ( $description instanceof SMWNamespaceDescription ) { |
483 | | - return new SMWSparqlTrueCondition(); ///TODO Implement namespace filtering |
| 483 | + return $this->buildNamespaceCondition( $description, $joinVariable, $orderByProperty ); |
484 | 484 | } elseif ( $description instanceof SMWConjunction ) { |
485 | 485 | return $this->buildConjunctionCondition( $description, $joinVariable, $orderByProperty ); |
486 | 486 | } elseif ( $description instanceof SMWDisjunction ) { |
— | — | @@ -742,6 +742,27 @@ |
743 | 743 | } |
744 | 744 | |
745 | 745 | /** |
| 746 | + * Create an SMWSparqlCondition from an SMWNamespaceDescription. |
| 747 | + * |
| 748 | + * @param $description SMWNamespaceDescription |
| 749 | + * @param $joinVariable string name, see buildSparqlCondition() |
| 750 | + * @param $orderByProperty mixed SMWDIProperty or null, see buildSparqlCondition() |
| 751 | + * @return SMWSparqlCondition |
| 752 | + */ |
| 753 | + protected function buildNamespaceCondition( SMWNamespaceDescription $description, $joinVariable, $orderByProperty ) { |
| 754 | + $nspropExpElement = SMWExporter::getSpecialNsResource( 'swivt', 'wikiNamespace' ); |
| 755 | + $nsExpElement = new SMWExpLiteral( $description->getNamespace(), 'http://www.w3.org/2001/XMLSchema#integer' ); |
| 756 | + $nsName = SMWTurtleSerializer::getTurtleNameForExpElement( $nsExpElement ); |
| 757 | + $condition = "{ ?$joinVariable " . $nspropExpElement->getQName() . " $nsName . }\n"; |
| 758 | + |
| 759 | + $result = new SMWSparqlWhereCondition( $condition, true, array() ); |
| 760 | + |
| 761 | + $this->addOrderByDataForProperty( $result, $joinVariable, $orderByProperty, SMWDataItem::TYPE_WIKIPAGE ); |
| 762 | + |
| 763 | + return $result; |
| 764 | + } |
| 765 | + |
| 766 | + /** |
746 | 767 | * Create an SMWSparqlCondition from an SMWValueDescription. |
747 | 768 | * |
748 | 769 | * @param $description SMWValueDescription |