/**
  * @param Fingerprint $fingerprint the fingerprint to render
  * @param EntityId|null $entityId the id of the fingerprint's entity
  * @param string $termBoxHtml
  * @param TextInjector $textInjector
  *
  * @return string HTML
  */
 public function getHtml(Fingerprint $fingerprint, EntityId $entityId = null, $termBoxHtml, TextInjector $textInjector)
 {
     $descriptions = $fingerprint->getDescriptions();
     $aliasGroups = $fingerprint->getAliasGroups();
     $marker = $textInjector->newMarker('entityViewPlaceholder-entitytermsview-entitytermsforlanguagelistview-class');
     return $this->templateFactory->render('wikibase-entitytermsview', $descriptions->hasTermForLanguage($this->languageCode) ? '' : 'wb-empty', $this->getDescriptionText($descriptions), $aliasGroups->hasGroupForLanguage($this->languageCode) ? '' : 'wb-empty', $this->getHtmlForAliases($aliasGroups), $termBoxHtml, $marker, $this->getHtmlForLabelDescriptionAliasesEditSection($entityId));
 }
 public function testInject()
 {
     $injector = new TextInjector();
     $text = 'Good ' . $injector->newMarker('morning') . ' to ' . $injector->newMarker('you', 'all') . '!';
     $expected = 'Good morning to you all!';
     $actual = $injector->inject($text, function () {
         $args = func_get_args();
         return implode(' ', $args);
     });
     $this->assertEquals($expected, $actual);
 }
 /**
  * @param EntityId $entityId
  * @param string $revisionId
  *
  * @return string HTML
  */
 private function getHtmlForTermBox(EntityId $entityId = null, $revisionId)
 {
     if ($entityId !== null) {
         // Placeholder for a termbox for the present item.
         // EntityViewPlaceholderExpander must know about the parameters used here.
         return $this->textInjector->newMarker('termbox', $entityId->getSerialization(), $revisionId);
     }
     return '';
 }
 /**
  * @param OutputPage $out
  * @param string &$html
  *
  * @return bool
  */
 public function doOutputPageBeforeHTML(OutputPage $out, &$html)
 {
     $placeholders = $out->getProperty('wikibase-view-chunks');
     if (!empty($placeholders)) {
         $injector = new TextInjector($placeholders);
         $expander = $this->getEntityViewPlaceholderExpander($out);
         $html = $injector->inject($html, array($expander, 'getHtmlForPlaceholder'));
         $out->addJsConfigVars('wbUserSpecifiedLanguages', array_values(array_intersect($this->userLanguageLookup->getUserSpecifiedLanguages($out->getUser()), $this->termsLanguages->getLanguages())));
     }
 }