/** * Only type '_wpg' objects can appear on query level (essentially as nominal classes) * * @since 2.2 * * @param Description $description * * @return QuerySegment */ public function interpretDescription(Description $description) { $query = new QuerySegment(); if (!$description->getDataItem() instanceof DIWikiPage) { return $query; } $comparator = $description->getComparator(); $value = $description->getDataItem()->getSortKey(); // A simple value match using the `~~Foo` will initiate a fulltext // search without being bound to a property allowing a broad match // search if (($comparator === SMW_CMP_LIKE || $comparator === SMW_CMP_NLKE) && strpos($value, '~') !== false) { $fulltextSearchSupport = $this->addFulltextSearchCondition($query, $comparator, $value); if ($fulltextSearchSupport) { return $query; } } if ($comparator === SMW_CMP_EQ) { $query->type = QuerySegment::Q_VALUE; $oid = $this->querySegmentListBuilder->getStore()->getObjectIds()->getSMWPageID($description->getDataItem()->getDBkey(), $description->getDataItem()->getNamespace(), $description->getDataItem()->getInterwiki(), $description->getDataItem()->getSubobjectName()); $query->joinfield = array($oid); } else { // Join with SMW IDs table needed for other comparators (apply to title string). $query->joinTable = SMWSql3SmwIds::TABLE_NAME; $query->joinfield = "{$query->alias}.smw_id"; $comparator = $this->comparatorMapper->mapComparator($description, $value); $db = $this->querySegmentListBuilder->getStore()->getConnection('mw.db.queryengine'); $query->where = "{$query->alias}.smw_sortkey{$comparator}" . $db->addQuotes($value); } return $query; }
/** * @since 2.2 * * {@inheritDoc} */ public function interpretDescription(Description $description) { $joinVariable = $this->compoundConditionBuilder->getJoinVariable(); $orderByProperty = $this->compoundConditionBuilder->getOrderByProperty(); $dataItem = $description->getDataItem(); $property = $description->getProperty(); switch ($description->getComparator()) { case SMW_CMP_EQ: $comparator = '='; break; case SMW_CMP_LESS: $comparator = '<'; break; case SMW_CMP_GRTR: $comparator = '>'; break; case SMW_CMP_LEQ: $comparator = '<='; break; case SMW_CMP_GEQ: $comparator = '>='; break; case SMW_CMP_NEQ: $comparator = '!='; break; case SMW_CMP_LIKE: $comparator = 'regex'; break; case SMW_CMP_NLKE: $comparator = '!regex'; break; default: $comparator = ''; // unkown, unsupported } if ($comparator === '') { return $this->createConditionForEmptyComparator($joinVariable, $orderByProperty); } elseif ($comparator == '=') { return $this->createConditionForEqualityComparator($dataItem, $property, $joinVariable, $orderByProperty); } elseif ($comparator == 'regex' || $comparator == '!regex') { return $this->createConditionForRegexComparator($dataItem, $joinVariable, $orderByProperty, $comparator); } return $this->createFilterConditionForAnyOtherComparator($dataItem, $joinVariable, $orderByProperty, $comparator); }
/** * Only type '_wpg' objects can appear on query level (essentially as nominal classes) * * @since 2.2 * * @param Description $description * * @return QuerySegment */ public function interpretDescription(Description $description) { $query = new QuerySegment(); if (!$description->getDataItem() instanceof DIWikiPage) { return $query; } if ($description->getComparator() === SMW_CMP_EQ) { $query->type = QuerySegment::Q_VALUE; $oid = $this->querySegmentListBuilder->getStore()->getObjectIds()->getSMWPageID($description->getDataItem()->getDBkey(), $description->getDataItem()->getNamespace(), $description->getDataItem()->getInterwiki(), $description->getDataItem()->getSubobjectName()); $query->joinfield = array($oid); } else { // Join with SMW IDs table needed for other comparators (apply to title string). $query->joinTable = SMWSql3SmwIds::TABLE_NAME; $query->joinfield = "{$query->alias}.smw_id"; $value = $description->getDataItem()->getSortKey(); $comparator = $this->comparatorMapper->mapComparator($description, $value); $query->where = "{$query->alias}.smw_sortkey{$comparator}" . $this->querySegmentListBuilder->getStore()->getConnection('mw.db')->addQuotes($value); } return $query; }