Merge "Stop using the Xml class in this codebase"

This commit is contained in:
jenkins-bot 2024-04-26 18:51:38 +00:00 committed by Gerrit Code Review
commit e1e04a2ee6
2 changed files with 24 additions and 28 deletions

View file

@ -18,7 +18,6 @@ use Psr\Log\LoggerInterface;
use StatusValue;
use stdClass;
use Throwable;
use Xml;
use XmlTypeCheck;
/**
@ -468,10 +467,7 @@ class MathMathML extends MathRenderer {
$titleObj = SpecialPage::getTitleFor( 'MathWikibase' );
$hyperlink = $titleObj->getLocalURL( [ 'qid' => $this->params['qid'] ] );
}
$output = Html::openElement( $element, $attribs );
if ( $hyperlink && $enableLinks ) {
$output .= Html::openElement( 'a', [ 'href' => $hyperlink, 'style' => 'color:inherit;' ] );
}
$output = '';
// MathML has to be wrapped into a div or span in order to be able to hide it.
// Remove displayStyle attributes set by the MathML converter
// (Beginning from Mathoid 0.2.5 block is the default layout.)
@ -481,15 +477,19 @@ class MathMathML extends MathRenderer {
if ( $this->getMathStyle() == 'display' ) {
$mml = preg_replace( '/<math/', '<math display="block"', $mml );
}
$output .= Xml::tags( $element, [
$output .= Html::rawElement( $element, [
'class' => $this->getClassName(), 'style' => 'display: none;'
], $mml );
$output .= $this->getFallbackImage();
if ( $hyperlink && $enableLinks ) {
$output .= Html::closeElement( 'a' );
$output = Html::rawElement( 'a',
[ 'href' => $hyperlink, 'style' => 'color:inherit;' ],
$output
);
}
$output .= Html::closeElement( $element );
return $output;
return Html::rawElement( $element, $attribs, $output );
}
protected function dbOutArray() {

View file

@ -175,8 +175,7 @@ class MathWikibaseInfo {
$labelAlign = $lang->isRTL() ? 'left' : 'right';
$labelAlignOpposite = !$lang->isRTL() ? 'left' : 'right';
$output = Html::openElement( "table", [ "style" => "padding: 5px" ] );
$output .= Html::openElement( "tbody" );
$output = '';
foreach ( $this->hasParts as $part ) {
$output .= Html::openElement( "tr" );
@ -193,7 +192,7 @@ class MathWikibaseInfo {
$part->getLabel()
);
} else {
$output .= $part->getLabel();
$output .= htmlspecialchars( $part->getLabel() );
}
$output .= Html::closeElement( "td" );
@ -221,10 +220,9 @@ class MathWikibaseInfo {
$output .= Html::closeElement( "tr" );
}
$output .= Html::closeElement( "tbody" );
$output .= Html::closeElement( "table" );
return $output;
return Html::rawElement( 'table', [ 'style' => 'padding: 5px' ],
Html::rawElement( 'tbody', [], $output )
);
}
/**
@ -232,22 +230,20 @@ class MathWikibaseInfo {
* @return string
*/
public function generateSmallTableOfParts() {
$output = Html::openElement( "table" );
$output .= Html::openElement( "tbody" );
$output = '';
foreach ( $this->hasParts as $part ) {
$output .= Html::openElement( "tr" );
$output .= Html::rawElement(
"td",
[ "style" => "text-align: center; padding-right: 5px;" ],
$part->getFormattedSymbol()
$output .= Html::rawElement( 'tr', [],
Html::rawElement( 'td',
[ 'style' => 'text-align: center; padding-right: 5px;' ],
$part->getFormattedSymbol()
) .
Html::element( 'td', [ 'style' => 'text-align:left;' ], $part->getLabel() )
);
$output .= Html::element( "td", [ "style" => "text-align:left;" ], $part->getLabel() );
$output .= Html::closeElement( "tr" );
}
$output .= Html::closeElement( "tbody" );
$output .= Html::closeElement( "table" );
return $output;
return Html::rawElement( 'table', [],
Html::rawElement( 'tbody', [], $output )
);
}
}