/**
  * @dataProvider getTypeDataProvider
  */
 public function testGetHtml($type)
 {
     $instance = Highlighter::factory($type);
     $instance->setContent(array('title' => 'Foo'));
     // Check without caption/content set
     $this->assertInternalType('string', $instance->getHtml());
     $instance->setContent(array('caption' => '123', 'content' => 'ABC'));
     // Check with caption/content set
     $this->assertInternalType('string', $instance->getHtml());
 }
 private function getAbbreviatedText($text, $length, $linker)
 {
     if ($linker === false || $linker === null) {
         $ellipsis = ' <span class="smwwarning">…</span> ';
     } else {
         $highlighter = Highlighter::factory(Highlighter::TYPE_TEXT);
         $highlighter->setContent(array('caption' => ' … ', 'content' => $text));
         $ellipsis = $highlighter->getHtml();
     }
     return mb_substr($text, 0, 42) . $ellipsis . mb_substr($text, $length - 42);
 }
 private function doHighlightText($text, $linker = null)
 {
     $content = '';
     if (!$this->canHighlight($content, $linker)) {
         return $text;
     }
     $highlighter = Highlighter::factory(Highlighter::TYPE_PROPERTY, $this->dataValue->getOptionBy(PropertyValue::OPT_USER_LANGUAGE));
     $highlighter->setContent(array('userDefined' => $this->dataValue->getDataItem()->isUserDefined(), 'caption' => $text, 'content' => $content !== '' ? $content : Message::get('smw_isspecprop')));
     return $highlighter->getHtml();
 }
 public function getShortWikiText($linked = null)
 {
     if (is_null($linked) || $linked === false || $this->m_outformat == '-' || $this->m_outformat == '-u' || $this->m_outformat == '-n' || !$this->isValid()) {
         return $this->m_caption;
     } else {
         $this->makeConversionValues();
         $tooltip = '';
         $i = 0;
         $sep = '';
         foreach ($this->m_unitvalues as $unit => $value) {
             if ($unit != $this->m_unitin) {
                 $number = NumberFormatter::getInstance()->getLocalizedFormattedNumber($value, $this->getPrecision());
                 if ($unit !== '') {
                     $tooltip .= isset($this->prefixalUnitPreference[$unit]) && $this->prefixalUnitPreference[$unit] ? $unit . '&#160;' . $number : $number . '&#160;' . $unit;
                 } else {
                     $tooltip .= $number;
                 }
                 $tooltip .= ' <br />';
                 $i++;
                 if ($i >= 5) {
                     // limit number of printouts in tooltip
                     break;
                 }
             }
         }
         if ($tooltip !== '') {
             $highlighter = Highlighter::factory(Highlighter::TYPE_QUANTITY);
             $highlighter->setContent(array('caption' => $this->m_caption, 'content' => $tooltip));
             return $highlighter->getHtml();
         } else {
             return $this->m_caption;
         }
     }
 }
 private function doFormatByShort($linker = null)
 {
     $outformat = $this->dataValue->getOutputFormat();
     if ($linker === null || $linker === false || $outformat == '-' || $outformat == '-u' || $outformat == '-n' || !$this->dataValue->isValid()) {
         return $this->dataValue->getCaption();
     }
     $convertedUnitValues = $this->dataValue->getConvertedUnitValues();
     $tooltip = '';
     $i = 0;
     foreach ($convertedUnitValues as $unit => $value) {
         if ($unit != $this->dataValue->getCanonicalMainUnit()) {
             $number = $this->dataValue->getLocalizedFormattedNumber($value);
             if ($unit !== '') {
                 $tooltip .= $this->dataValue->hasPrefixalUnitPreference($unit) ? $unit . '&#160;' . $number : $number . '&#160;' . $unit;
             } else {
                 $tooltip .= $number;
             }
             $tooltip .= ' <br />';
             $i++;
             if ($i >= 5) {
                 // limit number of printouts in tooltip
                 break;
             }
         }
     }
     if ($tooltip === '') {
         return $this->dataValue->getCaption();
     }
     $highlighter = Highlighter::factory(Highlighter::TYPE_QUANTITY, $this->dataValue->getOptionBy('user.language'));
     $highlighter->setContent(array('caption' => $this->dataValue->getCaption(), 'content' => $tooltip));
     return $highlighter->getHtml();
 }
 /**
  * Returns html representation of the formatted messages
  *
  * @since 1.9
  *
  * @return string
  */
 public function getHtml()
 {
     if ($this->exists()) {
         $highlighter = Highlighter::factory($this->type);
         $highlighter->setContent(array('content' => $this->getString(true)));
         return $highlighter->getHtml();
     }
     return '';
 }