Simplify code by using Xml::element()

Change-Id: I8b0d1c35d8d7cc310769d586a1716ef5ffbd46b3
This commit is contained in:
Fomafix 2019-02-08 15:34:27 +01:00 committed by Krinkle
parent a02e1278c9
commit 0a3f30b8d7

View file

@ -638,20 +638,19 @@ class CategoryTree {
$linkattr[ 'class' ] = "CategoryTreeToggle";
$linkattr['data-ct-title'] = $key;
$tag = 'span';
if ( $children == 0 ) {
// Use ->plain() and htmlspecialchars() to ensure
// identical to what is done by JS, which does:
// $link.text( mw.msg( 'categorytree-expand-bullet' ) )
$txt = htmlspecialchars( wfMessage( 'categorytree-expand-bullet' )->plain() );
// Use ->plain() to ensure identical result as JS,
// which does:
// $link.text( mw.msg( 'categorytree-expand-bullet' ) );
$txt = wfMessage( 'categorytree-expand-bullet' )->plain();
$linkattr[ 'data-ct-state' ] = 'collapsed';
} else {
$txt = htmlspecialchars( wfMessage( 'categorytree-collapse-bullet' )->plain() );
$txt = wfMessage( 'categorytree-collapse-bullet' )->plain();
$linkattr[ 'data-ct-loaded' ] = true;
$linkattr[ 'data-ct-state' ] = 'expanded';
}
$bullet = Xml::openElement( $tag, $linkattr ) . $txt . Xml::closeElement( $tag ) . ' ';
$bullet = Html::element( 'span', $linkattr, $txt ) . ' ';
}
} else {
$bullet = wfMessage( 'categorytree-page-bullet' )->escaped();