/**
  * @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);
 }
Esempio n. 2
0
 /**
  * Displays a value, including all relevant links (browse and search by property)
  *
  * @param[in] $property SMWPropertyValue  The property this value is linked to the subject with
  * @param[in] $value SMWDataValue  The actual value
  * @param[in] $incoming bool  If this is an incoming or outgoing link
  *
  * @return string  HTML with the link to the article, browse, and search pages
  */
 private function displayValue(SMWPropertyValue $property, SMWDataValue $dataValue, $incoming)
 {
     $linker = smwfGetLinker();
     $html = $dataValue->getLongHTMLText($linker);
     if ($dataValue->getTypeID() === '_wpg' || $dataValue->getTypeID() === '__sob') {
         $html .= " " . SMWInfolink::newBrowsingLink('+', $dataValue->getLongWikiText())->getHTML($linker);
     } elseif ($incoming && $property->isVisible()) {
         $html .= " " . SMWInfolink::newInversePropertySearchLink('+', $dataValue->getTitle(), $property->getDataItem()->getLabel(), 'smwsearch')->getHTML($linker);
     } elseif ($dataValue->getProperty() instanceof DIProperty && $dataValue->getProperty()->getKey() !== '_INST') {
         $html .= $dataValue->getInfolinkText(SMW_OUTPUT_HTML, $linker);
     }
     return $html;
 }
 /**
  * Displays a value, including all relevant links (browse and search by property)
  *
  * @param[in] $property SMWPropertyValue  The property this value is linked to the subject with
  * @param[in] $value DataValue  The actual value
  * @param[in] $incoming bool  If this is an incoming or outgoing link
  *
  * @return string  HTML with the link to the article, browse, and search pages
  */
 private function displayValue(\SMWPropertyValue $property, DataValue $dataValue, $incoming)
 {
     $linker = smwfGetLinker();
     // Allow the DV formatter to access a specific language code
     $dataValue->setOption(DataValue::OPT_CONTENT_LANGUAGE, Localizer::getInstance()->getPreferredContentLanguage($this->subject->getDataItem())->getCode());
     $dataValue->setOption(DataValue::OPT_USER_LANGUAGE, Localizer::getInstance()->getUserLanguage()->getCode());
     $dataValue->setContextPage($this->subject->getDataItem());
     // Use LOCL formatting where appropriate (date)
     $dataValue->setOutputFormat('LOCL');
     $html = $dataValue->getLongHTMLText($linker);
     if ($dataValue->getTypeID() === '_wpg' || $dataValue->getTypeID() === '__sob') {
         $html .= " " . \SMWInfolink::newBrowsingLink('+', $dataValue->getLongWikiText())->getHTML($linker);
     } elseif ($incoming && $property->isVisible()) {
         $html .= " " . \SMWInfolink::newInversePropertySearchLink('+', $dataValue->getTitle(), $property->getDataItem()->getLabel(), 'smwsearch')->getHTML($linker);
     } elseif ($dataValue->getProperty() instanceof DIProperty && $dataValue->getProperty()->getKey() !== '_INST') {
         $html .= $dataValue->getInfolinkText(SMW_OUTPUT_HTML, $linker);
     }
     return $html;
 }
 /**
  * @since 2.5
  *
  * @param DataValue $dataValue
  *
  * @return DIContainer|null
  */
 public function getErrorContainerFromDataValue(DataValue $dataValue)
 {
     if ($dataValue->getErrors() === array()) {
         return null;
     }
     $property = $dataValue->getProperty();
     $hash = '';
     if ($property !== null) {
         $hash = $property->getKey();
     }
     $containerSemanticData = $this->newContainerSemanticData($hash);
     foreach ($dataValue->getErrors() as $error) {
         $this->addToContainerSemanticData($containerSemanticData, $property, Message::encode($error));
     }
     return new DIContainer($containerSemanticData);
 }