getOutput();
$this->setHeaders();
$this->outputHeader();
$out->allowClickjacking();
$out->addModuleStyles( 'mediawiki.special' );
$groups = $this->getPageGroups();
if ( $groups === false ) {
return;
}
$this->addHelpLink( 'Help:Special pages' );
$this->outputPageList( $groups );
}
private function getPageGroups() {
$pages = SpecialPageFactory::getUsablePages( $this->getUser() );
if ( !count( $pages ) ) {
# Yeah, that was pointless. Thanks for coming.
return false;
}
/** Put them into a sortable array */
$groups = array();
/** @var SpecialPage $page */
foreach ( $pages as $page ) {
if ( $page->isListed() ) {
$group = $page->getFinalGroupName();
if ( !isset( $groups[$group] ) ) {
$groups[$group] = array();
}
$groups[$group][$page->getDescription()] = array(
$page->getPageTitle(),
$page->isRestricted(),
$page->isCached()
);
}
}
/** Sort */
foreach ( $groups as $group => $sortedPages ) {
ksort( $groups[$group] );
}
/** Always move "other" to end */
if ( array_key_exists( 'other', $groups ) ) {
$other = $groups['other'];
unset( $groups['other'] );
$groups['other'] = $other;
}
return $groups;
}
private function outputPageList( $groups ) {
$out = $this->getOutput();
$includesRestrictedPages = false;
$includesCachedPages = false;
foreach ( $groups as $group => $sortedPages ) {
$total = count( $sortedPages );
$middle = ceil( $total / 2 );
$count = 0;
$out->wrapWikiMsg(
"
$1
\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"
);
foreach ( $sortedPages as $desc => $specialpage ) {
list( $title, $restricted, $cached ) = $specialpage;
$pageClasses = array();
if ( $cached ) {
$includesCachedPages = true;
$pageClasses[] = 'mw-specialpagecached';
}
if ( $restricted ) {
$includesRestrictedPages = true;
$pageClasses[] = 'mw-specialpagerestricted';
}
$link = Linker::linkKnown( $title, htmlspecialchars( $desc ) );
$out->addHTML( Html::rawElement(
'li',
array( '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"
);
}
if ( $includesRestrictedPages || $includesCachedPages ) {
$out->wrapWikiMsg( "$1
", 'specialpages-note-top' );
$out->wrapWikiMsg( "\n$1\n
", 'specialpages-note' );
}
}
}