private function compareWithKey($propertyKey) { if ($this->hasDiff()) { return; } $property = new DIProperty($propertyKey); $newValues = $this->semanticData->getPropertyValues($property); $oldValues = $this->store->getPropertyValues($this->semanticData->getSubject(), $property); $this->notifyDispatcher(!$this->isEqual($oldValues, $newValues)); }
/** * @since 2.4 * * @param DIWikiPage $subject * @param DIProperty $property * @param RequestOptions|null $requestOptions * * @return array */ public function getPropertyValues(DIWikiPage $subject, DIProperty $property, RequestOptions $requestOptions = null) { $key = $property->getKey() . ':' . $subject->getSubobjectName() . ':' . ($requestOptions !== null ? $requestOptions->getHash() : null); $container = $this->blobStore->read($this->getRootHashFrom($subject)); if ($container->has($key)) { return $container->get($key); } $dataItems = $this->store->getPropertyValues($subject, $property, $requestOptions); $container->set($key, $dataItems); $this->blobStore->save($container); return $dataItems; }
/** * Returns information related to user-defined properties * * @since 1.9 * * @param Title $title * @param DIProperty $property * @param integer $useCount * * @return array */ private function getUserDefinedPropertyInfo($title, $property, $useCount) { if ($useCount <= $this->settings->get('smwgPropertyLowUsageThreshold')) { $this->getMessageFormatter()->addFromKey('smw_propertyhardlyused'); } // User defined types default to Page $typestring = SMWTypesValue::newFromTypeId($this->settings->get('smwgPDefaultType'))->getLongHTMLText($this->getLinker()); $label = htmlspecialchars($property->getLabel()); $linkAttributes = array(); if (isset($property->id)) { $linkAttributes['title'] = 'ID: ' . $property->id; } $dataValue = DataValueFactory::getInstance()->newDataValueByItem($property); $dataValue->setLinkAttributes($linkAttributes); $proplink = $dataValue->getFormattedLabel(DataValueFormatter::HTML_SHORT, $this->getLinker()); if (!$title->exists()) { $this->getMessageFormatter()->addFromKey('smw_propertylackspage'); } $typeProperty = new DIProperty('_TYPE'); $types = $this->store->getPropertyValues($property->getDiWikiPage(), $typeProperty); if (count($types) >= 1) { $typeDataValue = DataValueFactory::getInstance()->newDataValueByItem(current($types), $typeProperty); $typestring = $typeDataValue->getLongHTMLText($this->getLinker()); } else { $this->getMessageFormatter()->addFromKey('smw_propertylackstype', $typestring); } return array($typestring, $proplink); }
/** * @since 2.5 * * @param DIWikiPage $subject * @param RequestOptions|null $requestOptions * * @return array */ public function findEmbeddedQueryIdListBySubject(DIWikiPage $subject, RequestOptions $requestOptions = null) { $embeddedQueryIdList = array(); $dataItems = $this->store->getPropertyValues($subject, new DIProperty('_ASK'), $requestOptions); foreach ($dataItems as $dataItem) { $embeddedQueryIdList[$dataItem->getHash()] = $this->dependencyLinksTableUpdater->getId($dataItem); } return $embeddedQueryIdList; }
private function getConceptDescription(DIWikiPage $concept) { $value = $this->store->getPropertyValues($concept, new DIProperty('_CONC')); if ($value === null || $value === array()) { return new ThingDescription(); } $value = end($value); return ApplicationFactory::getInstance()->newQueryParser()->getQueryDescription($value->getConceptQuery()); }
/** * Figures out the label of the property to be used. For outgoing ones it is just * the text, for incoming ones we try to figure out the inverse one if needed, * either by looking for an explicitly stated one or by creating a default one. * * @param[in] $property SMWPropertyValue The property of interest * @param[in] $incoming bool If it is an incoming property * * @return string The label of the property */ private function getPropertyLabel(\SMWPropertyValue $property, $incoming = false) { if ($incoming && $this->getOption('showInverse')) { $oppositeprop = \SMWPropertyValue::makeUserProperty(wfMessage('smw_inverse_label_property')->text()); $labelarray = $this->store->getPropertyValues($property->getDataItem()->getDiWikiPage(), $oppositeprop->getDataItem()); $rv = count($labelarray) > 0 ? $labelarray[0]->getLongWikiText() : wfMessage('smw_inverse_label_default', $property->getWikiValue())->text(); } else { $rv = $property->getWikiValue(); } return $this->unbreak($rv); }
private function tryToFindImportDataItem(DIWikiPage $diWikiPage, $modifier) { $importDataItems = null; // Only try to match an import vocab to an user-defined property if ($modifier === '' && $this->isUserDefinedPropertyPage($diWikiPage)) { $importDataItems = $this->store->getPropertyValues($diWikiPage, new DIProperty('_IMPO')); } if ($importDataItems !== null && $importDataItems !== array()) { $importDataItems = current($importDataItems); } return $importDataItems; }
private function tryToFindImportDataItem(DIWikiPage $diWikiPage, $modifier) { $importDataItems = null; // Only try to find an import vocab for a matchable entity if ($diWikiPage->getNamespace() === NS_CATEGORY || $diWikiPage->getNamespace() === SMW_NS_PROPERTY) { $importDataItems = $this->store->getPropertyValues($diWikiPage, new DIProperty('_IMPO')); } if ($importDataItems !== null && $importDataItems !== array()) { $importDataItems = current($importDataItems); } return $importDataItems; }
private function doFetchPropertyValues($dataItems, $dataValue) { $propertyValues = array(); foreach ($dataItems as $dataItem) { if (!$dataItem instanceof DIWikiPage) { continue; } $pv = $this->store->getPropertyValues($dataItem, $dataValue->getDataItem(), $this->getRequestOptions()); $propertyValues = array_merge($propertyValues, $pv); unset($pv); } return $propertyValues; }
/** * Produce a formatted string representation for showing a property in * the list of unused properties. * * @since 1.8 * * @param DIProperty $property * * @return string */ protected function formatPropertyItem(DIProperty $property) { // Clear formatter before invoking messages and // avoid having previous data to be present $this->getMessageFormatter()->clear(); if ($property->isUserDefined()) { $title = $property->getDiWikiPage()->getTitle(); if (!$title instanceof \Title) { return ''; } $propertyLink = $this->getLinker()->link($title, $property->getLabel()); $types = $this->store->getPropertyValues($property->getDiWikiPage(), new DIProperty('_TYPE')); if (count($types) >= 1) { $typeDataValue = DataValueFactory::getInstance()->newDataItemValue(current($types), new DIProperty('_TYPE')); } else { $typeDataValue = SMWTypesValue::newFromTypeId('_wpg'); $this->getMessageFormatter()->addFromKey('smw_propertylackstype', $typeDataValue->getLongHTMLText()); } } else { $typeDataValue = SMWTypesValue::newFromTypeId($property->findPropertyTypeID()); $propertyLink = DataValueFactory::getInstance()->newDataItemValue($property, null)->getShortHtmlText($this->getLinker()); } return $this->msg('smw_unusedproperty_template', $propertyLink, $typeDataValue->getLongHTMLText($this->getLinker()))->text() . ' ' . $this->getMessageFormatter()->getHtml(); }
private function doQueryForNonValue(PageRequestOptions $pageRequestOptions, RequestOptions $requestOptions) { return $this->store->getPropertyValues(null, $pageRequestOptions->property->getDataItem(), $requestOptions); }
/** * @see Store::getPropertyValues() * @since 1.8 */ public function getPropertyValues($subject, DIProperty $property, $requestoptions = null) { return $this->baseStore->getPropertyValues($subject, $property, $requestoptions); }