r33197 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r33196‎ | r33197 | r33198 >
Date:21:42, 12 April 2008
Author:aaron
Status:old
Tags:
Comment:
Group special pages at Special:SpecialPages
Modified paths:
  • /trunk/phase3/includes/DefaultSettings.php (modified) (history)
  • /trunk/phase3/includes/SpecialPage.php (modified) (history)
  • /trunk/phase3/includes/SpecialSpecialpages.php (modified) (history)
  • /trunk/phase3/languages/messages/MessagesEn.php (modified) (history)
  • /trunk/phase3/skins/common/shared.css (modified) (history)

Diff [purge]

Index: trunk/phase3/skins/common/shared.css
@@ -136,3 +136,15 @@
137137 padding: 0.5em 0.2em 0.5em 0.2em;
138138 border: 1px solid #ccc;
139139 }
 140+
 141+/* Special:SpecialPages styling */
 142+h3.mw-specialpagesgroup {
 143+ background-color: #dcdcdc;
 144+ padding: 2px;
 145+ margin: .3em 0em 0em 0em;
 146+}
 147+
 148+table.mw-specialpages-table {
 149+ background-color: #f9f9f9;
 150+}
 151+
Index: trunk/phase3/includes/SpecialSpecialpages.php
@@ -37,25 +37,53 @@
3838 }
3939
4040 /** Put them into a sortable array */
41 - $sortedPages = array();
 41+ $groups = array();
4242 foreach ( $pages as $page ) {
4343 if ( $page->isListed() ) {
44 - $sortedPages[$page->getDescription()] = $page->getTitle();
 44+ $group = SpecialPage::getGroup( $page );
 45+ if( !isset($groups[$group]) ) {
 46+ $groups[$group] = array();
 47+ }
 48+ $groups[$group][$page->getDescription()] = $page->getTitle();
4549 }
4650 }
4751
4852 /** Sort */
4953 if ( $wgSortSpecialPages ) {
50 - ksort( $sortedPages );
 54+ foreach( $groups as $group => $sortedPages ) {
 55+ ksort( $groups[$group] );
 56+ }
5157 }
 58+
 59+ /** Always move "other" to end */
 60+ if( array_key_exists('other',$groups) ) {
 61+ $other = $groups['other'];
 62+ unset( $groups['other'] );
 63+ $groups['other'] = $other;
 64+ }
5265
5366 /** Now output the HTML */
54 - $wgOut->addHTML( '<h2>' . wfMsgHtml( $heading ) . "</h2>\n<ul>" );
55 - foreach ( $sortedPages as $desc => $title ) {
56 - $link = $sk->makeKnownLinkObj( $title , htmlspecialchars( $desc ) );
57 - $wgOut->addHTML( "<li>{$link}</li>\n" );
 67+ $wgOut->addHTML( '<h2>' . wfMsgHtml( $heading ) . "</h2>\n" );
 68+ foreach ( $groups as $group => $sortedPages ) {
 69+ $middle = ceil( count($sortedPages)/2 );
 70+ $max = count($sortedPages) - 1;
 71+ $count = 0;
 72+
 73+ $wgOut->addHTML( "<h3 class='mw-specialpagesgroup'>".wfMsgHtml("specialpages-group-$group")."</h3>\n" );
 74+ $wgOut->addHTML( "<table style='width: 100%;' class='mw-specialpages-table'><tr>" );
 75+ $wgOut->addHTML( "<td width='30%' valign='top'><ul>\n" );
 76+ foreach ( $sortedPages as $desc => $title ) {
 77+ $link = $sk->makeKnownLinkObj( $title , htmlspecialchars( $desc ) );
 78+ $wgOut->addHTML( "<li>{$link}</li>\n" );
 79+
 80+ # Slit up the larger groups
 81+ $count++;
 82+ if( $max > 3 && $count == $middle && $count < $max ) {
 83+ $wgOut->addHTML( "</ul></td><td width='10%'></td><td width='30%' valign='top'><ul>" );
 84+ }
 85+ }
 86+ $wgOut->addHTML( "</ul></td><td width='30%' valign='top'></td></tr></table>\n" );
5887 }
59 - $wgOut->addHTML( "</ul>\n" );
6088 }
6189
6290
Index: trunk/phase3/includes/DefaultSettings.php
@@ -1336,7 +1336,7 @@
13371337 * to ensure that client-side caches don't keep obsolete copies of global
13381338 * styles.
13391339 */
1340 -$wgStyleVersion = '133';
 1340+$wgStyleVersion = '134';
13411341
13421342
13431343 # Server-side caching:
Index: trunk/phase3/includes/SpecialPage.php
@@ -68,7 +68,15 @@
6969 * Query parameters that can be passed through redirects
7070 */
7171 var $mAllowedRedirectParams = array();
72 -
 72+ /**
 73+ * List of special pages, followed by parameters.
 74+ * If the only parameter is a string, that is the page name.
 75+ * Otherwise, it is an array. The format is one of:
 76+ ** array( 'SpecialPage', name, right )
 77+ ** array( 'IncludableSpecialPage', name, right, listed? )
 78+ ** array( 'UnlistedSpecialPage', name, right )
 79+ ** array( 'SpecialRedirectToSpecial', name, page to redirect to, special page param, ... )
 80+ */
7381 static public $mList = array(
7482 'DoubleRedirects' => array( 'SpecialPage', 'DoubleRedirects' ),
7583 'BrokenRedirects' => array( 'SpecialPage', 'BrokenRedirects' ),
@@ -117,7 +125,7 @@
118126 'Specialpages' => array( 'UnlistedSpecialPage', 'Specialpages' ),
119127 'Contributions' => array( 'SpecialPage', 'Contributions' ),
120128 'Emailuser' => array( 'UnlistedSpecialPage', 'Emailuser' ),
121 - 'Whatlinkshere' => array( 'SpecialPage', 'Whatlinkshere' ),
 129+ 'Whatlinkshere' => array( 'UnlistedSpecialPage', 'Whatlinkshere' ),
122130 'Recentchangeslinked' => array( 'UnlistedSpecialPage', 'Recentchangeslinked' ),
123131 'Movepage' => array( 'UnlistedSpecialPage', 'Movepage' ),
124132 'Blockme' => array( 'UnlistedSpecialPage', 'Blockme' ),
@@ -154,7 +162,98 @@
155163
156164 static public $mAliases;
157165 static public $mListInitialised = false;
 166+ /**
 167+ * List of special pages, followed by what subtitle they should go under
 168+ * at Special:SpecialPages
 169+ */
 170+ static public $mGroupsList = array(
 171+ 'DoubleRedirects' => 'maintenance',
 172+ 'BrokenRedirects' => 'maintenance',
 173+ 'Lonelypages' => 'maintenance',
 174+ 'Uncategorizedpages' => 'maintenance',
 175+ 'Uncategorizedcategories' => 'maintenance',
 176+ 'Uncategorizedimages' => 'maintenance',
 177+ 'Uncategorizedtemplates' => 'maintenance',
 178+ 'Unusedcategories' => 'maintenance',
 179+ 'Unusedimages' => 'maintenance',
 180+ 'Protectedpages' => 'maintenance',
 181+ 'Protectedtitles' => 'maintenance',
 182+ 'Unusedtemplates' => 'maintenance',
 183+ 'Withoutinterwiki' => 'maintenance',
 184+ 'Longpages' => 'maintenance',
158185
 186+ 'Userlogin' => 'login',
 187+ 'Userlogout' => 'login',
 188+ 'CreateAccount' => 'login',
 189+
 190+ 'Recentchanges' => 'changes',
 191+ 'Recentchangeslinked' => 'changes',
 192+ 'Watchlist' => 'changes',
 193+ 'Newimages' => 'changes',
 194+ 'Newpages' => 'changes',
 195+ 'Log' => 'changes',
 196+
 197+ 'Upload' => 'media',
 198+ 'Imagelist' => 'media',
 199+ 'MIMEsearch' => 'media',
 200+ 'FileDuplicateSearch' => 'media',
 201+ 'Filepath' => 'media',
 202+
 203+ 'Listusers' => 'users',
 204+ 'Listgrouprights' => 'users',
 205+ 'Ipblocklist' => 'users',
 206+ 'Contributions' => 'users',
 207+ 'Emailuser' => 'users',
 208+ 'Listadmins' => 'users',
 209+ 'Listbots' => 'users',
 210+
 211+ 'Wantedpages' => 'needy',
 212+ 'Wantedcategories' => 'needy',
 213+ 'Shortpages' => 'needy',
 214+ 'Ancientpages' => 'needy',
 215+ 'Deadendpages' => 'needy',
 216+
 217+ 'Mostlinked' => 'highuse',
 218+ 'Mostlinkedcategories' => 'highuse',
 219+ 'Mostlinkedtemplates' => 'highuse',
 220+ 'Mostcategories' => 'highuse',
 221+ 'Mostimages' => 'highuse',
 222+ 'Mostrevisions' => 'highuse',
 223+
 224+ 'Userrights' => 'permissions',
 225+ 'Blockip' => 'permissions',
 226+
 227+ 'Statistics' => 'other',
 228+ 'Fewestrevisions' => 'other',
 229+ 'Randompage' => 'other',
 230+ 'Disambiguations' => 'other',
 231+ 'Specialpages' => 'other',
 232+ 'Blockme' => 'other',
 233+ 'Movepage' => 'other',
 234+ 'MergeHistory' => 'other',
 235+ 'Lockdb' => 'other',
 236+ 'Unlockdb' => 'other',
 237+ 'Version' => 'other',
 238+ 'Whatlinkshere' => 'other',
 239+ 'Booksources' => 'other',
 240+ 'Revisiondelete' => 'other',
 241+ 'Export' => 'other',
 242+ 'Categories' => 'other',
 243+ 'Undelete' => 'other',
 244+ 'Import' => 'other',
 245+ 'Unwatchedpages' => 'other',
 246+ 'Randomredirect' => 'other',
 247+ 'Allpages' => 'other',
 248+ 'Allmessages' => 'other',
 249+ 'Prefixindex' => 'other',
 250+ 'Listredirects' => 'other',
 251+ 'Preferences' => 'other',
 252+ 'Resetpass' => 'other',
 253+ 'Mypage' => 'other',
 254+ 'Mytalk' => 'other',
 255+ 'Mycontributions' => 'other',
 256+ );
 257+
159258 /**#@-*/
160259
161260 /**
@@ -265,6 +364,37 @@
266365 }
267366 self::$mList[$page->mName] = $page;
268367 }
 368+
 369+ /**
 370+ * Add a page to a certain display group for Special:SpecialPages
 371+ *
 372+ * @param mixed $page Must either be an array specifying a class name and
 373+ * constructor parameters, or an object.
 374+ * @param string $group
 375+ * @static
 376+ */
 377+ static function setGroup( &$page, $group ) {
 378+ if ( !self::$mListInitialised ) {
 379+ self::initList();
 380+ }
 381+ self::$mGroupsList[$page->mName] = $group;
 382+ }
 383+
 384+ /**
 385+ * Add a page to a certain display group for Special:SpecialPages
 386+ *
 387+ * @param mixed $page Must either be an array specifying a class name and
 388+ * constructor parameters, or an object.
 389+ * @static
 390+ */
 391+ static function getGroup( &$page ) {
 392+ if ( !self::$mListInitialised ) {
 393+ self::initList();
 394+ }
 395+ $group = isset(self::$mGroupsList[$page->mName]) ?
 396+ self::$mGroupsList[$page->mName] : 'other';
 397+ return $group;
 398+ }
269399
270400 /**
271401 * Remove a special page from the list
Index: trunk/phase3/languages/messages/MessagesEn.php
@@ -3254,6 +3254,17 @@
32553255 'version-software-product' => 'Product',
32563256 'version-software-version' => 'Version',
32573257
 3258+# Special:SpecialPages
 3259+'specialpages-group-maintenance' => 'Maintenance reports',
 3260+'specialpages-group-other' => 'Other special pages',
 3261+'specialpages-group-login' => 'Login/sign up',
 3262+'specialpages-group-changes' => 'Recent changes and logs',
 3263+'specialpages-group-media' => 'Media reports',
 3264+'specialpages-group-users' => 'Users and rights',
 3265+'specialpages-group-needy' => 'Pages in need of work',
 3266+'specialpages-group-highuse' => 'High use pages',
 3267+'specialpages-group-permissions' => 'Set user permissions',
 3268+
32583269 # Special:Filepath
32593270 'filepath' => 'File path',
32603271 'filepath-page' => 'File:',

Follow-up revisions

RevisionCommit summaryAuthorDate
r33199Update per r33197aaron22:07, 12 April 2008
r33338Add a fixed bug from r33197raymond10:36, 15 April 2008

Status & tagging log