/** * @since 2.4 * * @param string $property * * @return boolean */ public function findPropertyListFor($property = '') { $this->meta = array(); $this->propertyList = array(); $this->namespaces = array(); $this->requestOptions->limit++; // increase by one to look ahead $this->continueOffset = 1; if ($property !== '') { $property = str_replace("_", " ", $property); $this->requestOptions->addStringCondition($property, StringCondition::STRCOND_MID); // Disjunctive condition to allow for auto searches of foaf OR Foaf $this->requestOptions->addStringCondition(ucfirst($property), StringCondition::STRCOND_MID, true); } $propertyListLookup = $this->store->getPropertiesSpecial($this->requestOptions); $this->requestOptions->limit--; foreach ($propertyListLookup->fetchList() as $value) { if ($this->continueOffset > $this->requestOptions->limit) { break; } $this->addPropertyToList($value); $this->continueOffset++; } $this->continueOffset = $this->continueOffset > $this->requestOptions->limit ? $this->requestOptions->limit : 0; $this->namespaces = array_keys($this->namespaces); $this->meta = array('limit' => $this->requestOptions->limit, 'count' => count($this->propertyList), 'isCached' => $propertyListLookup->isCached()); return true; }
public function testAddStringCondition() { $instance = new RequestOptions(); $instance->addStringCondition('Foo', StringCondition::STRCOND_PRE); foreach ($instance->getStringConditions() as $stringCondition) { $this->assertInstanceOf('\\SMW\\StringCondition', $stringCondition); $this->assertFalse($stringCondition->asDisjunctiveCondition); } }
/** * Returns an introductory text for a predefined property * * @note In order to enable a more detailed description for a specific * predefined property a concatenated message key can be used (e.g * 'smw-pa-property-predefined' + <internal property key> => '_asksi' ) * * @since 1.9 * * @return string */ protected function getTopText() { $propertyName = htmlspecialchars($this->mTitle->getText()); $usageCount = ''; $requestOptions = new RequestOptions(); $requestOptions->limit = 1; $requestOptions->addStringCondition($propertyName, StringCondition::STRCOND_PRE); $cachedLookupList = $this->store->getPropertiesSpecial($requestOptions); $usageList = $cachedLookupList->fetchList(); if ($usageList && $usageList !== array()) { $usage = end($usageList); $usageCount = wfMessage('smw-pa-property-usage', $propertyName, $usage[1], $this->getContext()->getLanguage()->timeanddate($cachedLookupList->getTimestamp()))->parse(); } if (!$this->mProperty->isUserDefined()) { $propertyKey = 'smw-pa-property-predefined' . strtolower($this->mProperty->getKey()); $messageKey = wfMessage($propertyKey)->exists() ? $propertyKey : 'smw-pa-property-predefined-default'; return Html::rawElement('div', array('class' => 'smw-pa-property-predefined-intro'), wfMessage($messageKey, $propertyName)->parse() . ' ' . wfMessage('smw-pa-property-predefined-common')->parse() . ' ' . $usageCount); } return $usageCount; }
protected function getTopIndicator() { $propertyName = htmlspecialchars($this->mTitle->getText()); $usageCountHtml = ''; $requestOptions = new RequestOptions(); $requestOptions->setLimit(1); $requestOptions->addStringCondition($propertyName, StringCondition::COND_EQ); $cachedLookupList = $this->store->getPropertiesSpecial($requestOptions); $usageList = $cachedLookupList->fetchList(); if ($usageList && $usageList !== array()) { $usage = end($usageList); $usageCount = $usage[1]; $usageCountHtml = Html::rawElement('div', array('title' => $this->getContext()->getLanguage()->timeanddate($cachedLookupList->getTimestamp()), 'class' => 'smw-page-indicator usage-count' . ($usageCount < 25000 ? $usageCount > 5000 ? ' moderate' : '' : ' high')), $usageCount); } return Html::rawElement('div', array(), Html::rawElement('div', array('class' => 'smw-page-indicator property-type', 'title' => wfMessage('smw-page-indicator-type-info', $this->mProperty->isUserDefined())->parse()), $this->mProperty->isUserDefined() ? 'U' : 'S') . $usageCountHtml); }