/**
  * 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();
 }
 /**
  * Check whether the values of a given type of dataitem have helper
  * values in the sense of SMWExporter::getInstance()->getDataItemHelperExpElement().
  *
  * @param DIProperty $property
  *
  * @return boolean
  */
 public static function hasHelperExpElement(DIProperty $property)
 {
     return $property->findPropertyTypeID() === '_dat' || $property->findPropertyTypeID() === '_geo' || !$property->isUserDefined() && !self::hasSpecialPropertyResource($property);
 }
Beispiel #3
0
 /**
  * Store a value for a property identified by its SMWDataItem object.
  *
  * @note There is no check whether the type of the given data item
  * agrees with the type of the property. Since property types can
  * change, all parts of SMW are prepared to handle mismatched data item
  * types anyway.
  *
  * @param $property DIProperty
  * @param $dataItem SMWDataItem
  */
 public function addPropertyObjectValue(DIProperty $property, SMWDataItem $dataItem)
 {
     if ($dataItem instanceof SMWDIContainer) {
         $this->addSubSemanticData($dataItem->getSemanticData());
         $dataItem = $dataItem->getSemanticData()->getSubject();
     }
     if ($property->isInverse()) {
         // inverse properties cannot be used for annotation
         return;
     }
     if (!array_key_exists($property->getKey(), $this->mPropVals)) {
         $this->mPropVals[$property->getKey()] = array();
         $this->mProperties[$property->getKey()] = $property;
     }
     if ($this->mNoDuplicates) {
         $this->mPropVals[$property->getKey()][$dataItem->getHash()] = $dataItem;
     } else {
         $this->mPropVals[$property->getKey()][] = $dataItem;
     }
     if (!$property->isUserDefined()) {
         if ($property->isShown()) {
             $this->mHasVisibleSpecs = true;
             $this->mHasVisibleProps = true;
         }
     } else {
         $this->mHasVisibleProps = true;
     }
 }
 /**
  * Store a value for a property identified by its SMWDataItem object.
  *
  * @note There is no check whether the type of the given data item
  * agrees with the type of the property. Since property types can
  * change, all parts of SMW are prepared to handle mismatched data item
  * types anyway.
  *
  * @param $property DIProperty
  * @param $dataItem SMWDataItem
  */
 public function addPropertyObjectValue(DIProperty $property, SMWDataItem $dataItem)
 {
     $this->hash = null;
     if ($dataItem instanceof SMWDIContainer) {
         $this->addSubSemanticData($dataItem->getSemanticData());
         $dataItem = $dataItem->getSemanticData()->getSubject();
     }
     if ($property->isInverse()) {
         // inverse properties cannot be used for annotation
         return;
     }
     if (!array_key_exists($property->getKey(), $this->mPropVals)) {
         $this->mPropVals[$property->getKey()] = array();
         $this->mProperties[$property->getKey()] = $property;
     }
     if ($this->mNoDuplicates) {
         $this->mPropVals[$property->getKey()][$dataItem->getHash()] = $dataItem;
     } else {
         $this->mPropVals[$property->getKey()][] = $dataItem;
     }
     if (!$property->isUserDefined()) {
         if ($property->isShown()) {
             $this->mHasVisibleSpecs = true;
             $this->mHasVisibleProps = true;
         }
     } else {
         $this->mHasVisibleProps = true;
     }
     // Inherit the sortkey from the root if not explicitly given
     if ($this->mSubject->getSubobjectName() === '' && $property->getKey() === DIProperty::TYPE_SORTKEY) {
         foreach ($this->subSemanticData as $subSemanticData) {
             if (!$subSemanticData->hasProperty($property)) {
                 $subSemanticData->addPropertyObjectValue($property, $dataItem);
             }
         }
     }
 }
 /**
  * @note rdfs:subPropertyOf* where * means a property path of arbitrary length
  * can be found using the "zero or more" will resolve the complete path
  *
  * @see http://www.w3.org/TR/sparql11-query/#propertypath-arbitrary-length
  */
 private function tryToAddPropertyPathForSaturatedHierarchy(&$condition, DIProperty $property, &$propertyName)
 {
     if (!$this->compoundConditionBuilder->canUseQFeature(SMW_SPARQL_QF_SUBP) || !$property->isUserDefined()) {
         return null;
     }
     if ($this->compoundConditionBuilder->getPropertyHierarchyLookup() == null || !$this->compoundConditionBuilder->getPropertyHierarchyLookup()->hasSubpropertyFor($property)) {
         return null;
     }
     $subPropExpElement = $this->exporter->getSpecialPropertyResource('_SUBP', SMW_NS_PROPERTY);
     $propertyByVariable = '?' . $this->compoundConditionBuilder->getNextVariable('sp');
     $condition->weakConditions[$propertyName] = "\n" . "{$propertyByVariable} " . $subPropExpElement->getQName() . "*" . " {$propertyName} .\n" . "";
     $propertyName = $propertyByVariable;
 }
 /**
  * Unstub a single property from the stub data array. If available, an
  * existing object for that property might be provided, so we do not
  * need to make a new one. It is not checked if the object matches the
  * property name.
  *
  * @since 1.8
  *
  * @param string $propertyKey
  * @param SMWDIProperty $diProperty if available
  * @throws SMWDataItemException if property key is not valid
  * 	and $diProperty is null
  */
 protected function unstubProperty($propertyKey, $diProperty = null)
 {
     if (!array_key_exists($propertyKey, $this->mProperties)) {
         if (is_null($diProperty)) {
             $diProperty = new DIProperty($propertyKey, false);
         }
         $this->mProperties[$propertyKey] = $diProperty;
         if (!$diProperty->isUserDefined()) {
             if ($diProperty->isShown()) {
                 $this->mHasVisibleSpecs = true;
                 $this->mHasVisibleProps = true;
             }
         } else {
             $this->mHasVisibleProps = true;
         }
     }
 }
 /**
  * Produce a formatted string representation for showing a property and
  * its usage count in the list of used properties.
  *
  * @since 1.8
  *
  * @param DIProperty $property
  * @param integer $useCount
  * @return string
  */
 protected function formatPropertyItem(DIProperty $property, $useCount)
 {
     // Clear formatter before invoking messages
     $this->getMessageFormatter()->clear();
     $diWikiPage = $property->getDiWikiPage();
     $title = $diWikiPage !== null ? $diWikiPage->getTitle() : null;
     if ($useCount == 0 && !$this->settings->get('smwgPropertyZeroCountDisplay')) {
         return '';
     }
     if ($property->isUserDefined()) {
         if ($title === null) {
             // Show even messed up property names.
             $typestring = '';
             $proplink = $property->getLabel();
             $this->getMessageFormatter()->addFromKey('smw_notitle', $proplink);
         } else {
             list($typestring, $proplink) = $this->getUserDefinedPropertyInfo($title, $property, $useCount);
         }
     } else {
         list($typestring, $proplink) = $this->getPredefinedPropertyInfo($property);
     }
     if ($typestring === '') {
         // Built-ins have no type
         // @todo Should use numParams for $useCount?
         return $this->msg('smw_property_template_notype')->rawParams($proplink)->numParams($useCount)->text() . ' ' . $this->getMessageFormatter()->setType('warning')->escape(false)->getHtml();
     } else {
         // @todo Should use numParams for $useCount?
         return $this->msg('smw_property_template')->rawParams($proplink, $typestring)->numParams($useCount)->escaped() . ' ' . $this->getMessageFormatter()->setType('warning')->escape(false)->getHtml();
     }
 }
 /**
  * Produce a formatted string representation for showing a property and
  * its usage count in the list of used properties.
  *
  * @since 1.8
  *
  * @param DIProperty $property
  * @param integer $useCount
  * @return string
  */
 protected function formatPropertyItem(DIProperty $property, $useCount)
 {
     // Clear formatter before invoking messages
     $this->getMessageFormatter()->clear();
     $diWikiPage = $property->getDiWikiPage();
     $title = $diWikiPage !== null ? $diWikiPage->getTitle() : null;
     if ($useCount == 0 && !$this->settings->get('smwgPropertyZeroCountDisplay')) {
         return '';
     }
     if ($property->isUserDefined()) {
         if ($title === null) {
             // Show even messed up property names.
             $typestring = '';
             $proplink = $property->getLabel();
             $this->getMessageFormatter()->addFromArray(array('ID: ' . (isset($property->id) ? $property->id : 'N/A')))->addFromKey('smw_notitle', $proplink);
         } else {
             list($typestring, $proplink) = $this->getUserDefinedPropertyInfo($title, $property, $useCount);
         }
         $infoLink = '';
         // Add a link to SearchByProperty to hopefully identify the
         // "hidden" reference
         if ($useCount < 1) {
             $infoLink = '&#160;' . \SMWInfolink::newPropertySearchLink('+', $property->getLabel(), '')->getHTML($this->getLinker());
         }
         $proplink .= $infoLink;
     } else {
         list($typestring, $proplink) = $this->getPredefinedPropertyInfo($property);
     }
     if ($typestring === '') {
         // Built-ins have no type
         // @todo Should use numParams for $useCount?
         return $this->msg('smw_property_template_notype')->rawParams($proplink)->numParams($useCount)->text() . ' ' . $this->getMessageFormatter()->setType('warning')->escape(false)->getHtml();
     } else {
         // @todo Should use numParams for $useCount?
         return $this->msg('smw_property_template')->rawParams($proplink, $typestring)->numParams($useCount)->escaped() . ' ' . $this->getMessageFormatter()->setType('warning')->escape(false)->getHtml();
     }
 }
 /**
  * @since 2.5
  *
  * {@inheritDoc}
  */
 public function isResourceBuilderFor(DIProperty $property)
 {
     return !$property->isUserDefined() && $this->requiresAuxiliary($property->getKey());
 }
 /**
  * @since 2.5
  *
  * {@inheritDoc}
  */
 public function isResourceBuilderFor(DIProperty $property)
 {
     return !$property->isUserDefined();
 }