From 341f6dc847f8c64601ae86bfc1d3be4ad727ba5b Mon Sep 17 00:00:00 2001 From: Aaron Schulz Date: Sat, 12 Apr 2008 21:42:19 +0000 Subject: [PATCH] Group special pages at Special:SpecialPages --- includes/DefaultSettings.php | 2 +- includes/SpecialPage.php | 134 +++++++++++++++++++++++++++++- includes/SpecialSpecialpages.php | 44 ++++++++-- languages/messages/MessagesEn.php | 11 +++ skins/common/shared.css | 12 +++ 5 files changed, 192 insertions(+), 11 deletions(-) diff --git a/includes/DefaultSettings.php b/includes/DefaultSettings.php index 386253b983..97ff9a2c54 100644 --- a/includes/DefaultSettings.php +++ b/includes/DefaultSettings.php @@ -1336,7 +1336,7 @@ $wgCacheEpoch = '20030516000000'; * to ensure that client-side caches don't keep obsolete copies of global * styles. */ -$wgStyleVersion = '133'; +$wgStyleVersion = '134'; # Server-side caching: diff --git a/includes/SpecialPage.php b/includes/SpecialPage.php index ea891c8690..246f80a785 100644 --- a/includes/SpecialPage.php +++ b/includes/SpecialPage.php @@ -68,7 +68,15 @@ class SpecialPage * Query parameters that can be passed through redirects */ var $mAllowedRedirectParams = array(); - + /** + * List of special pages, followed by parameters. + * If the only parameter is a string, that is the page name. + * Otherwise, it is an array. The format is one of: + ** array( 'SpecialPage', name, right ) + ** array( 'IncludableSpecialPage', name, right, listed? ) + ** array( 'UnlistedSpecialPage', name, right ) + ** array( 'SpecialRedirectToSpecial', name, page to redirect to, special page param, ... ) + */ static public $mList = array( 'DoubleRedirects' => array( 'SpecialPage', 'DoubleRedirects' ), 'BrokenRedirects' => array( 'SpecialPage', 'BrokenRedirects' ), @@ -117,7 +125,7 @@ class SpecialPage 'Specialpages' => array( 'UnlistedSpecialPage', 'Specialpages' ), 'Contributions' => array( 'SpecialPage', 'Contributions' ), 'Emailuser' => array( 'UnlistedSpecialPage', 'Emailuser' ), - 'Whatlinkshere' => array( 'SpecialPage', 'Whatlinkshere' ), + 'Whatlinkshere' => array( 'UnlistedSpecialPage', 'Whatlinkshere' ), 'Recentchangeslinked' => array( 'UnlistedSpecialPage', 'Recentchangeslinked' ), 'Movepage' => array( 'UnlistedSpecialPage', 'Movepage' ), 'Blockme' => array( 'UnlistedSpecialPage', 'Blockme' ), @@ -154,6 +162,97 @@ class SpecialPage static public $mAliases; static public $mListInitialised = false; + /** + * List of special pages, followed by what subtitle they should go under + * at Special:SpecialPages + */ + static public $mGroupsList = array( + 'DoubleRedirects' => 'maintenance', + 'BrokenRedirects' => 'maintenance', + 'Lonelypages' => 'maintenance', + 'Uncategorizedpages' => 'maintenance', + 'Uncategorizedcategories' => 'maintenance', + 'Uncategorizedimages' => 'maintenance', + 'Uncategorizedtemplates' => 'maintenance', + 'Unusedcategories' => 'maintenance', + 'Unusedimages' => 'maintenance', + 'Protectedpages' => 'maintenance', + 'Protectedtitles' => 'maintenance', + 'Unusedtemplates' => 'maintenance', + 'Withoutinterwiki' => 'maintenance', + 'Longpages' => 'maintenance', + + 'Userlogin' => 'login', + 'Userlogout' => 'login', + 'CreateAccount' => 'login', + + 'Recentchanges' => 'changes', + 'Recentchangeslinked' => 'changes', + 'Watchlist' => 'changes', + 'Newimages' => 'changes', + 'Newpages' => 'changes', + 'Log' => 'changes', + + 'Upload' => 'media', + 'Imagelist' => 'media', + 'MIMEsearch' => 'media', + 'FileDuplicateSearch' => 'media', + 'Filepath' => 'media', + + 'Listusers' => 'users', + 'Listgrouprights' => 'users', + 'Ipblocklist' => 'users', + 'Contributions' => 'users', + 'Emailuser' => 'users', + 'Listadmins' => 'users', + 'Listbots' => 'users', + + 'Wantedpages' => 'needy', + 'Wantedcategories' => 'needy', + 'Shortpages' => 'needy', + 'Ancientpages' => 'needy', + 'Deadendpages' => 'needy', + + 'Mostlinked' => 'highuse', + 'Mostlinkedcategories' => 'highuse', + 'Mostlinkedtemplates' => 'highuse', + 'Mostcategories' => 'highuse', + 'Mostimages' => 'highuse', + 'Mostrevisions' => 'highuse', + + 'Userrights' => 'permissions', + 'Blockip' => 'permissions', + + 'Statistics' => 'other', + 'Fewestrevisions' => 'other', + 'Randompage' => 'other', + 'Disambiguations' => 'other', + 'Specialpages' => 'other', + 'Blockme' => 'other', + 'Movepage' => 'other', + 'MergeHistory' => 'other', + 'Lockdb' => 'other', + 'Unlockdb' => 'other', + 'Version' => 'other', + 'Whatlinkshere' => 'other', + 'Booksources' => 'other', + 'Revisiondelete' => 'other', + 'Export' => 'other', + 'Categories' => 'other', + 'Undelete' => 'other', + 'Import' => 'other', + 'Unwatchedpages' => 'other', + 'Randomredirect' => 'other', + 'Allpages' => 'other', + 'Allmessages' => 'other', + 'Prefixindex' => 'other', + 'Listredirects' => 'other', + 'Preferences' => 'other', + 'Resetpass' => 'other', + 'Mypage' => 'other', + 'Mytalk' => 'other', + 'Mycontributions' => 'other', + ); /**#@-*/ @@ -265,6 +364,37 @@ class SpecialPage } self::$mList[$page->mName] = $page; } + + /** + * Add a page to a certain display group for Special:SpecialPages + * + * @param mixed $page Must either be an array specifying a class name and + * constructor parameters, or an object. + * @param string $group + * @static + */ + static function setGroup( &$page, $group ) { + if ( !self::$mListInitialised ) { + self::initList(); + } + self::$mGroupsList[$page->mName] = $group; + } + + /** + * Add a page to a certain display group for Special:SpecialPages + * + * @param mixed $page Must either be an array specifying a class name and + * constructor parameters, or an object. + * @static + */ + static function getGroup( &$page ) { + if ( !self::$mListInitialised ) { + self::initList(); + } + $group = isset(self::$mGroupsList[$page->mName]) ? + self::$mGroupsList[$page->mName] : 'other'; + return $group; + } /** * Remove a special page from the list diff --git a/includes/SpecialSpecialpages.php b/includes/SpecialSpecialpages.php index 4ea956b899..4c31c60fcf 100644 --- a/includes/SpecialSpecialpages.php +++ b/includes/SpecialSpecialpages.php @@ -37,25 +37,53 @@ function wfSpecialSpecialpages_gen($pages,$heading,$sk) { } /** Put them into a sortable array */ - $sortedPages = array(); + $groups = array(); foreach ( $pages as $page ) { if ( $page->isListed() ) { - $sortedPages[$page->getDescription()] = $page->getTitle(); + $group = SpecialPage::getGroup( $page ); + if( !isset($groups[$group]) ) { + $groups[$group] = array(); + } + $groups[$group][$page->getDescription()] = $page->getTitle(); } } /** Sort */ if ( $wgSortSpecialPages ) { - ksort( $sortedPages ); + 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; } /** Now output the HTML */ - $wgOut->addHTML( '

' . wfMsgHtml( $heading ) . "

\n\n" ); } diff --git a/languages/messages/MessagesEn.php b/languages/messages/MessagesEn.php index 1063e8f7ac..98421a1c7e 100644 --- a/languages/messages/MessagesEn.php +++ b/languages/messages/MessagesEn.php @@ -3254,6 +3254,17 @@ You can also [[Special:Watchlist/edit|use the standard editor]].', 'version-software-product' => 'Product', 'version-software-version' => 'Version', +# Special:SpecialPages +'specialpages-group-maintenance' => 'Maintenance reports', +'specialpages-group-other' => 'Other special pages', +'specialpages-group-login' => 'Login/sign up', +'specialpages-group-changes' => 'Recent changes and logs', +'specialpages-group-media' => 'Media reports', +'specialpages-group-users' => 'Users and rights', +'specialpages-group-needy' => 'Pages in need of work', +'specialpages-group-highuse' => 'High use pages', +'specialpages-group-permissions' => 'Set user permissions', + # Special:Filepath 'filepath' => 'File path', 'filepath-page' => 'File:', diff --git a/skins/common/shared.css b/skins/common/shared.css index 66bc5619c6..47f016b378 100644 --- a/skins/common/shared.css +++ b/skins/common/shared.css @@ -136,3 +136,15 @@ table.mw-listgrouprights-table td, table.mw-listgrouprights-table th { padding: 0.5em 0.2em 0.5em 0.2em; border: 1px solid #ccc; } + +/* Special:SpecialPages styling */ +h3.mw-specialpagesgroup { + background-color: #dcdcdc; + padding: 2px; + margin: .3em 0em 0em 0em; +} + +table.mw-specialpages-table { + background-color: #f9f9f9; +} + -- 2.20.1