public function prune( &$maxsize, &$maxdepth, &$log ) { if ( $maxsize <= 0 ) { $log[] = $this->getQueryString(); return new SMWThingDescription(); } $prunelog = array(); $newdepth = $maxdepth; $result = new SMWConjunction(); foreach ( $this->m_descriptions as $desc ) { $restdepth = $maxdepth; $result->addDescription( $desc->prune( $maxsize, $restdepth, $prunelog ) ); $newdepth = min( $newdepth, $restdepth ); } if ( count( $result->getDescriptions() ) > 0 ) { $log = array_merge( $log, $prunelog ); $maxdepth = $newdepth; if ( count( $result->getDescriptions() ) == 1 ) { // simplify unary conjunctions! $descriptions = $result->getDescriptions(); $result = array_shift( $descriptions ); } $result->setPrintRequests( $this->getPrintRequests() ); return $result; } else { $log[] = $this->getQueryString(); $result = new SMWThingDescription(); $result->setPrintRequests( $this->getPrintRequests() ); return $result; } }
/** * Returns whether the concepts of the group cover the specified page. * * @since 0.1 * * @param Title $title * * @return boolean */ public function conceptsCoverPage(Title $title) { if (count($this->concepts) == 0) { return true; } $foundMatch = false; foreach ($this->concepts as $groupConcept) { $queryDescription = new SMWConjunction(); $conceptTitle = Title::newFromText($groupConcept, SMW_NS_CONCEPT); if (!$conceptTitle->exists()) { continue; } $queryDescription->addDescription(new SMWConceptDescription(SMWDIWikiPage::newFromTitle($conceptTitle))); $queryDescription->addDescription(new SMWValueDescription(SMWDIWikiPage::newFromTitle($title))); $query = new SMWQuery($queryDescription); $query->querymode = SMWQuery::MODE_COUNT; /* SMWQueryResult */ $result = smwfGetStore()->getQueryResult($query); $foundMatch = $result instanceof SMWQueryResult ? $result->getCount() > 0 : $result > 0; if ($foundMatch) { break; } } return $foundMatch; }