/**
  * Format an auto summary argument
  *
  * @since 0.4
  *
  * @param mixed $arg
  *
  * @return string
  */
 protected function formatArg($arg)
 {
     try {
         if ($arg instanceof Snak) {
             return $this->snakFormatter->formatSnak($arg);
         } elseif ($arg instanceof EntityId) {
             return $this->idFormatter->formatEntityId($arg);
         } elseif ($arg instanceof DataValue) {
             return $this->valueFormatter->format($arg);
         } elseif (method_exists($arg, '__toString')) {
             return strval($arg);
         } elseif (is_object($arg)) {
             return '<' . get_class($arg) . '>';
         } elseif (is_array($arg)) {
             if (!empty($arg) && !isset($arg[0])) {
                 // turn assoc array into a list
                 $arg = $this->formatKeyValuePairs($arg);
             }
             $strings = $this->formatArgList($arg);
             return $this->language->commaList($strings);
         } else {
             return strval($arg);
         }
     } catch (Exception $ex) {
         wfWarn(__METHOD__ . ': failed to render value: ' . $ex->getMessage());
     }
     return '?';
 }
 /**
  * @param Snak[] $snaks
  *
  * @return string wikitext
  */
 private function formatSnaks(array $snaks)
 {
     $formattedValues = array();
     foreach ($snaks as $snak) {
         $formattedValues[] = $this->snakFormatter->formatSnak($snak);
     }
     return $this->language->commaList($formattedValues);
 }
 /**
  * Get formatted header for a snak, including the snak's property label and value.
  *
  * @since 0.4
  *
  * @param Snak $snak
  *
  * @return string HTML
  */
 public function getPropertyAndValueHeader(Snak $snak)
 {
     $before = $this->getPropertyHeader($snak);
     try {
         $after = $this->snakBreadCrumbFormatter->formatSnak($snak);
         $result = $this->getColonSeparatedHtml($before, $after);
     } catch (Exception $ex) {
         // just ignore it
         $result = $before;
     }
     return $result;
 }
 /**
  * @fixme handle errors more consistently as done in JS UI, and perhaps add
  * localised exception messages.
  *
  * @param Snak $snak
  * @return string
  */
 private function getFormattedSnakValue($snak)
 {
     try {
         $formattedSnak = $this->snakFormatter->formatSnak($snak);
     } catch (FormattingException $ex) {
         return $this->getInvalidSnakMessage();
     } catch (PropertyDataTypeLookupException $ex) {
         return $this->getPropertyNotFoundMessage();
     } catch (InvalidArgumentException $ex) {
         return $this->getInvalidSnakMessage();
     }
     return $formattedSnak;
 }
 /**
  * Render a snak from its serialization as provided from Lua.
  *
  * @since 0.5
  *
  * @param array $snakSerialization As obtained from ItemSerializer
  *
  * @return string wikitext
  */
 public function renderSnak(array $snakSerialization)
 {
     $snak = $this->snakDeserializer->deserialize($snakSerialization);
     return $this->snakFormatter->formatSnak($snak);
 }
 /**
  * @see SnakFormatter::formatSnak
  *
  * @param Snak $snak
  *
  * @return string Typically wikitext or HTML, depending on the $escapeCallback provided.
  */
 public function formatSnak(Snak $snak)
 {
     $text = $this->formatter->formatSnak($snak);
     $escaped = call_user_func($this->escapeCallback, $text);
     return $escaped;
 }
 /**
  * @see SnakFormatter::getFormat
  *
  * @return string One of the SnakFormatter::FORMAT_... constants.
  */
 public function getFormat()
 {
     return $this->snakFormatter->getFormat();
 }