From: Alexandre Emsenhuber Date: Sat, 10 Jul 2010 20:13:06 +0000 (+0000) Subject: * Modified Special:Specialpages to subclass UnlistedSpecialPage instead of using... X-Git-Tag: 1.31.0-rc.0~36170 X-Git-Url: http://git.cyclocoop.org/%7B%24admin_url%7Dmes_infos.php?a=commitdiff_plain;h=33cdc2202ba9757a45cb81797e11a285e7065317;p=lhc%2Fweb%2Fwiklou.git * Modified Special:Specialpages to subclass UnlistedSpecialPage instead of using wfSpecialSpecialpages() * Use Html:: methods --- diff --git a/includes/AutoLoader.php b/includes/AutoLoader.php index 64f57e8a32..f75d285fb5 100644 --- a/includes/AutoLoader.php +++ b/includes/AutoLoader.php @@ -598,6 +598,7 @@ $wgAutoloadLocalClasses = array( 'SpecialRecentchangeslinked' => 'includes/specials/SpecialRecentchangeslinked.php', 'SpecialSearch' => 'includes/specials/SpecialSearch.php', 'SpecialSelenium' => 'includes/specials/SpecialSelenium.php', + 'SpecialSpecialpages' => 'includes/specials/SpecialSpecialpages.php', 'SpecialStatistics' => 'includes/specials/SpecialStatistics.php', 'SpecialTags' => 'includes/specials/SpecialTags.php', 'SpecialUnlockdb' => 'includes/specials/SpecialUnlockdb.php', diff --git a/includes/SpecialPage.php b/includes/SpecialPage.php index b88969f86f..fec32b7e2e 100644 --- a/includes/SpecialPage.php +++ b/includes/SpecialPage.php @@ -191,7 +191,7 @@ class SpecialPage { 'Mytalk' => 'SpecialMytalk', 'Revisiondelete' => 'SpecialRevisionDelete', 'RevisionMove' => 'SpecialRevisionMove', - 'Specialpages' => array( 'UnlistedSpecialPage', 'Specialpages' ), + 'Specialpages' => 'SpecialSpecialpages', 'Userlogout' => array( 'UnlistedSpecialPage', 'Userlogout' ), ); diff --git a/includes/specials/SpecialSpecialpages.php b/includes/specials/SpecialSpecialpages.php index 05cd9ccefb..25134bd995 100644 --- a/includes/specials/SpecialSpecialpages.php +++ b/includes/specials/SpecialSpecialpages.php @@ -21,78 +21,111 @@ * @file * @ingroup SpecialPage */ +class SpecialSpecialpages extends UnlistedSpecialPage { -function wfSpecialSpecialpages() { - global $wgOut, $wgUser, $wgMessageCache, $wgSortSpecialPages; + function __construct() { + parent::__construct( 'Specialpages' ); + } - $wgMessageCache->loadAllMessages(); + function execute( $par ) { + $this->setHeaders(); + $this->outputHeader(); - $wgOut->setRobotPolicy( 'noindex,nofollow' ); # Is this really needed? - $sk = $wgUser->getSkin(); + $groups = $this->getPageGroups(); - $pages = SpecialPage::getUsablePages(); + if ( $groups === false ) { + return; + } - if( count( $pages ) == 0 ) { - # Yeah, that was pointless. Thanks for coming. - return; + $this->outputPageList( $groups ); } - /** Put them into a sortable array */ - $groups = array(); - foreach ( $pages as $page ) { - if ( $page->isListed() ) { - $group = SpecialPage::getGroup( $page ); - if( !isset($groups[$group]) ) { - $groups[$group] = array(); + private function getPageGroups() { + global $wgSortSpecialPages; + + $pages = SpecialPage::getUsablePages(); + + if( !count( $pages ) ) { + # Yeah, that was pointless. Thanks for coming. + return false; + } + + /** Put them into a sortable array */ + $groups = array(); + foreach ( $pages as $page ) { + if ( $page->isListed() ) { + $group = SpecialPage::getGroup( $page ); + if( !isset( $groups[$group] ) ) { + $groups[$group] = array(); + } + $groups[$group][$page->getDescription()] = array( $page->getTitle(), $page->isRestricted() ); } - $groups[$group][$page->getDescription()] = array( $page->getTitle(), $page->isRestricted() ); } - } - /** Sort */ - if ( $wgSortSpecialPages ) { - foreach( $groups as $group => $sortedPages ) { - ksort( $groups[$group] ); + /** Sort */ + if ( $wgSortSpecialPages ) { + 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; + /** Always move "other" to end */ + if( array_key_exists( 'other', $groups ) ) { + $other = $groups['other']; + unset( $groups['other'] ); + $groups['other'] = $other; + } + + return $groups; } - $includesRestrictedPages = false; - /** Now output the HTML */ - foreach ( $groups as $group => $sortedPages ) { - $middle = ceil( count($sortedPages)/2 ); - $total = count($sortedPages); - $count = 0; - - $wgOut->wrapWikiMsg( "

$1

\n", "specialpages-group-$group" ); - $wgOut->addHTML( "" ); - $wgOut->addHTML( "
    \n" ); - foreach( $sortedPages as $desc => $specialpage ) { - list( $title, $restricted ) = $specialpage; - $link = $sk->linkKnown( $title , htmlspecialchars( $desc ) ); - if( $restricted ) { - $includesRestrictedPages = true; - $wgOut->addHTML( "
  • {$link}
  • \n" ); - } else { - $wgOut->addHTML( "
  • {$link}
  • \n" ); - } + private function outputPageList( $groups ) { + global $wgUser, $wgOut; + + $sk = $wgUser->getSkin(); + $includesRestrictedPages = false; - # Split up the larger groups - $count++; - if( $total > 3 && $count == $middle ) { - $wgOut->addHTML( "
    " ); + foreach ( $groups as $group => $sortedPages ) { + $middle = ceil( count( $sortedPages )/2 ); + $total = count( $sortedPages ); + $count = 0; + + $wgOut->wrapWikiMsg( "

    $1

    \n", "specialpages-group-$group" ); + $wgOut->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 ) = $specialpage; + $link = $sk->linkKnown( $title , htmlspecialchars( $desc ) ); + if( $restricted ) { + $includesRestrictedPages = true; + $wgOut->addHTML( Html::rawElement( 'li', array( 'class' => 'mw-specialpages-page mw-specialpagerestricted' ), Html::rawElement( 'strong', array(), $link ) ) . "\n" ); + } else { + $wgOut->addHTML( Html::rawElement( 'li', array(), $link ) . "\n" ); + } + + # Split up the larger groups + $count++; + if( $total > 3 && $count == $middle ) { + $wgOut->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" + ); + } } + $wgOut->addHTML( + Html::closeElement( 'ul' ) . Html::closeElement( 'td' ) . + Html::element( 'td', array( 'style' => 'width:30%' ), '' ) . + Html::closeElement( 'tr' ) . Html::closeElement( 'table' ) . "\n" + ); } - $wgOut->addHTML( "
\n" ); - } - if ( $includesRestrictedPages ) { - $wgOut->wrapWikiMsg( "
\n$1\n
", 'specialpages-note' ); + if ( $includesRestrictedPages ) { + $wgOut->wrapWikiMsg( "
\n$1\n
", 'specialpages-note' ); + } } }