/**
  * 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;
 }
	public function prune( &$maxsize, &$maxdepth, &$log ) {
		if ( $maxsize >= $this->getSize() ) {
			$maxsize = $maxsize - $this->getSize();
			return $this;
		} elseif ( $maxsize <= 0 ) {
			$log[] = $this->getQueryString();
			$result = new SMWThingDescription();
		} else {
			$result = new SMWClassDescription( array_slice( $this->m_diWikiPages, 0, $maxsize ) );
			$rest = new SMWClassDescription( array_slice( $this->m_diWikiPages, $maxsize ) );
			
			$log[] = $rest->getQueryString();
			$maxsize = 0;
		}
		
		$result->setPrintRequests( $this->getPrintRequests() );
		return $result;
	}