/**
  * @since 2.4
  *
  * @param DataValue $dataValue
  *
  * @return Description
  */
 public function newFromDataValue(DataValue $dataValue)
 {
     if (!$dataValue->isValid()) {
         return $this->newThingDescription();
     }
     // Avoid circular reference when called from outside of the DV context
     $dataValue->setOption(DataValue::OPT_QUERY_CONTEXT, true);
     $description = $dataValue->getQueryDescription($dataValue->getWikiValue());
     if ($dataValue->getProperty() === null) {
         return $description;
     }
     return $this->newSomeProperty($dataValue->getProperty(), $description);
 }
Example #2
0
 /**
  * Get a single data value item
  *
  * @since 1.8
  *
  * @param integer $type
  * @param SMWDataValue $dataValue
  *
  * @return mixed
  */
 private function getDataValueItem($type, SMWDataValue $dataValue)
 {
     if ($type == SMWDataItem::TYPE_NUMBER) {
         // Set unit if available
         $dataValue->setOutputFormat($this->params['unit']);
         // Check if unit is available and return the converted value otherwise
         // just return a plain number
         return $dataValue->getUnit() !== '' ? $dataValue->getShortWikiText() : $dataValue->getNumber();
     } else {
         // For all other data types return the wikivalue
         return $dataValue->getWikiValue();
     }
 }