return;
}
- $out->addHelpLink( 'Help:Special pages' );
+ $this->addHelpLink( 'Help:Special pages' );
$this->outputPageList( $groups );
}
}
/** Put them into a sortable array */
- $groups = array();
+ $groups = [];
/** @var SpecialPage $page */
foreach ( $pages as $page ) {
if ( $page->isListed() ) {
$group = $page->getFinalGroupName();
if ( !isset( $groups[$group] ) ) {
- $groups[$group] = array();
+ $groups[$group] = [];
}
- $groups[$group][$page->getDescription()] = array(
+ $groups[$group][$page->getDescription()] = [
$page->getPageTitle(),
$page->isRestricted(),
$page->isCached()
- );
+ ];
}
}
$includesCachedPages = false;
foreach ( $groups as $group => $sortedPages ) {
- $total = count( $sortedPages );
- $middle = ceil( $total / 2 );
- $count = 0;
-
$out->wrapWikiMsg(
"<h2 class=\"mw-specialpagesgroup\" id=\"mw-specialpagesgroup-$group\">$1</h2>\n",
"specialpages-group-$group"
);
$out->addHTML(
- Html::openElement(
- 'table',
- array( 'style' => 'width:100%;', 'class' => 'mw-specialpages-table' )
- ) . "\n" .
- Html::openElement( 'tr' ) . "\n" .
- Html::openElement( 'td', array( 'style' => 'width:30%;vertical-align:top' ) ) . "\n" .
- Html::openElement( 'ul' ) . "\n"
+ Html::openElement( 'div', [ 'class' => 'mw-specialpages-list' ] )
+ . '<ul>'
);
foreach ( $sortedPages as $desc => $specialpage ) {
list( $title, $restricted, $cached ) = $specialpage;
- $pageClasses = array();
+ $pageClasses = [];
if ( $cached ) {
$includesCachedPages = true;
$pageClasses[] = 'mw-specialpagecached';
$pageClasses[] = 'mw-specialpagerestricted';
}
- $link = Linker::linkKnown( $title, htmlspecialchars( $desc ) );
+ $link = $this->getLinkRenderer()->makeKnownLink( $title, $desc );
$out->addHTML( Html::rawElement(
'li',
- array( 'class' => implode( ' ', $pageClasses ) ),
+ [ 'class' => implode( ' ', $pageClasses ) ],
$link
) . "\n" );
-
- # Split up the larger groups
- $count++;
- if ( $total > 3 && $count == $middle ) {
- $out->addHTML(
- Html::closeElement( 'ul' ) . Html::closeElement( 'td' ) .
- Html::element( 'td', array( 'style' => 'width:10%' ), '' ) .
- Html::openElement( 'td', array( 'style' => 'width:30%' ) ) . Html::openElement( 'ul' ) . "\n"
- );
- }
}
$out->addHTML(
- Html::closeElement( 'ul' ) . Html::closeElement( 'td' ) .
- Html::element( 'td', array( 'style' => 'width:30%' ), '' ) .
- Html::closeElement( 'tr' ) . Html::closeElement( 'table' ) . "\n"
+ Html::closeElement( 'ul' ) .
+ Html::closeElement( 'div' )
);
}
- if ( $includesRestrictedPages || $includesCachedPages ) {
- $out->wrapWikiMsg( "<h2 class=\"mw-specialpages-note-top\">$1</h2>", 'specialpages-note-top' );
- $out->wrapWikiMsg( "<div class=\"mw-specialpages-notes\">\n$1\n</div>", 'specialpages-note' );
+ // add legend
+ $notes = [];
+ if ( $includesRestrictedPages ) {
+ $restricedMsg = $this->msg( 'specialpages-note-restricted' );
+ if ( !$restricedMsg->isDisabled() ) {
+ $notes[] = $restricedMsg->plain();
+ }
+ }
+ if ( $includesCachedPages ) {
+ $cachedMsg = $this->msg( 'specialpages-note-cached' );
+ if ( !$cachedMsg->isDisabled() ) {
+ $notes[] = $cachedMsg->plain();
+ }
+ }
+ if ( $notes !== [] ) {
+ $out->wrapWikiMsg(
+ "<h2 class=\"mw-specialpages-note-top\">$1</h2>", 'specialpages-note-top'
+ );
+ $out->addWikiText(
+ "<div class=\"mw-specialpages-notes\">\n" .
+ implode( "\n", $notes ) .
+ "\n</div>"
+ );
}
}
}