private function mapCategoriesToConditionElements(array $categories, $joinVariable)
 {
     $condition = '';
     $namespaces = array();
     $instExpElement = $this->exporter->getSpecialPropertyResource('_INST');
     foreach ($categories as $category) {
         $categoryExpElement = $this->exporter->getResourceElementForWikiPage($category);
         $categoryName = TurtleSerializer::getTurtleNameForExpElement($categoryExpElement);
         $namespaces[$categoryExpElement->getNamespaceId()] = $categoryExpElement->getNamespace();
         $newcondition = "{ ?{$joinVariable} " . $instExpElement->getQName() . " {$categoryName} . }\n";
         if ($condition === '') {
             $condition = $newcondition;
         } else {
             $condition .= "UNION\n{$newcondition}";
         }
     }
     return array($condition, $namespaces);
 }
 private function doMapClassDescription(ClassDescription $description, &$exact)
 {
     if (count($description->getCategories()) == 1) {
         // single category
         $categories = $description->getCategories();
         $result = new ExpData($this->exporter->getResourceElementForWikiPage(end($categories)));
     } else {
         // disjunction of categories
         $result = new ExpData(new ExpResource(''));
         $elements = array();
         foreach ($description->getCategories() as $cat) {
             $elements[] = new ExpData($this->exporter->getResourceElementForWikiPage($cat));
         }
         $result->addPropertyObjectValue($this->exporter->getSpecialNsResource('owl', 'unionOf'), ExpData::makeCollection($elements));
     }
     $result->addPropertyObjectValue($this->exporter->getSpecialNsResource('rdf', 'type'), new ExpData($this->exporter->getSpecialNsResource('owl', 'Class')));
     return $result;
 }
 /**
  * Create an SMWSparqlCondition from an SMWClassDescription.
  *
  * @param $description SMWClassDescription
  * @param $joinVariable string name, see buildSparqlCondition()
  * @param $orderByProperty mixed SMWDIProperty or null, see buildSparqlCondition()
  * @return SMWSparqlCondition
  */
 protected function buildClassCondition(SMWClassDescription $description, $joinVariable, $orderByProperty)
 {
     $condition = '';
     $namespaces = array();
     $instExpElement = SMWExporter::getSpecialPropertyResource('_INST');
     foreach ($description->getCategories() as $diWikiPage) {
         $categoryExpElement = SMWExporter::getResourceElementForWikiPage($diWikiPage);
         $categoryName = SMWTurtleSerializer::getTurtleNameForExpElement($categoryExpElement);
         $namespaces[$categoryExpElement->getNamespaceId()] = $categoryExpElement->getNamespace();
         $newcondition = "{ ?{$joinVariable} " . $instExpElement->getQName() . " {$categoryName} . }\n";
         if ($condition === '') {
             $condition = $newcondition;
         } else {
             $condition .= "UNION\n{$newcondition}";
         }
     }
     if ($condition === '') {
         // empty disjunction: always false, no results to order
         return new SMWSparqlFalseCondition();
     }
     $result = new SMWSparqlWhereCondition($condition, true, $namespaces);
     $this->addOrderByDataForProperty($result, $joinVariable, $orderByProperty, SMWDataItem::TYPE_WIKIPAGE);
     return $result;
 }