/**
  * 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;
 }
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();
     }
 }