language = $language; $this->parser = $parser; } /** * @param string $key Message name of the error or warning * @param mixed ...$params * * @return string HTML ready for output */ public function html( $key, ...$params ) { // FIXME: We suspect this is not necessary and can be replaced with Message::parse(), // except wikis have custom error messages with example tags. return $this->parser->recursiveTagParse( $this->wikitext( $key, ...$params ) ); } /** * @param string $key Message name of the error or warning * @param mixed ...$params * * @return string Wikitext ready for output * @return-taint tainted */ public function wikitext( $key, ...$params ) { $msg = wfMessage( $key, $params )->inLanguage( $this->language ); if ( strncmp( $key, 'cite_warning_', 13 ) === 0 ) { $type = 'warning'; $id = substr( $key, 13 ); $extraClass = ' mw-ext-cite-warning-' . Sanitizer::escapeClass( $id ); } else { $type = 'error'; $extraClass = ''; // Take care; this is a sideeffect that might not belong to this class. $this->parser->addTrackingCategory( 'cite-tracking-category-cite-error' ); } return Html::rawElement( 'span', [ 'class' => "$type mw-ext-cite-$type" . $extraClass, 'lang' => $this->language->getHtmlCode(), 'dir' => $this->language->getDir(), ], wfMessage( "cite_$type", $msg->plain() )->inLanguage( $this->language )->plain() ); } }