r34983 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r34982‎ | r34983 | r34984 >
Date:16:08, 17 May 2008
Author:dantman
Status:old
Tags:
Comment:
Improve UI for Special:Recentchanges and Special:Recentchangeslinked.
* Allow configuration of the default limit and days links with the variables $wgRCLinkLimits and $wgRCLinkDays.
* When selecting a limit and a days on the special pages, if you use a number not within the default list it will be added to the display.
** The selected limit and days is bolded. (This can be considered the first step for bug 3327)
* Optional other configuration option $wgRCFilterByAge, when enabled the list of days will be filtered so that only links within what $wgRCMaxAge says will be stored in the database will be displayed. Note that this is disabled by default because MediaWiki doesn't quite seam to trim out old entries as quickly as $wgRCMaxAge says it should be and some people appear to use the extra 30days links to display older entries even though $wgRCMaxAge is set to 7days on said wiki.

This should also solve bug 9257.
Modified paths:
  • /trunk/phase3/includes/DefaultSettings.php (modified) (history)
  • /trunk/phase3/includes/Setup.php (modified) (history)
  • /trunk/phase3/includes/SpecialRecentchanges.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/SpecialRecentchanges.php
@@ -477,24 +477,26 @@
478478 /**
479479 *
480480 */
481 -function rcCountLink( $lim, $d, $page='Recentchanges', $more='' ) {
 481+function rcCountLink( $lim, $d, $page='Recentchanges', $more='', $active = false ) {
482482 global $wgUser, $wgLang, $wgContLang;
483483 $sk = $wgUser->getSkin();
484484 $s = $sk->makeKnownLink( $wgContLang->specialPage( $page ),
485485 ($lim ? $wgLang->formatNum( "{$lim}" ) : wfMsg( 'recentchangesall' ) ), "{$more}" .
486 - ($d ? "days={$d}&" : '') . 'limit='.$lim );
 486+ ($d ? "days={$d}&" : '') . 'limit='.$lim, '', '',
 487+ $active ? 'style="font-weight: bold;"' : '' );
487488 return $s;
488489 }
489490
490491 /**
491492 *
492493 */
493 -function rcDaysLink( $lim, $d, $page='Recentchanges', $more='' ) {
 494+function rcDaysLink( $lim, $d, $page='Recentchanges', $more='', $active = false ) {
494495 global $wgUser, $wgLang, $wgContLang;
495496 $sk = $wgUser->getSkin();
496497 $s = $sk->makeKnownLink( $wgContLang->specialPage( $page ),
497498 ($d ? $wgLang->formatNum( "{$d}" ) : wfMsg( 'recentchangesall' ) ), $more.'days='.$d .
498 - ($lim ? '&limit='.$lim : '') );
 499+ ($lim ? '&limit='.$lim : ''), '', '',
 500+ $active ? 'style="font-weight: bold;"' : '' );
499501 return $s;
500502 }
501503
@@ -503,19 +505,31 @@
504506 */
505507 function rcDayLimitLinks( $days, $limit, $page='Recentchanges', $more='', $doall = false, $minorLink = '',
506508 $botLink = '', $liuLink = '', $patrLink = '', $myselfLink = '' ) {
 509+ global $wgRCLinkLimits, $wgRCLinkDays;
507510 if ($more != '') $more .= '&';
508 - $cl = rcCountLink( 50, $days, $page, $more ) . ' | ' .
509 - rcCountLink( 100, $days, $page, $more ) . ' | ' .
510 - rcCountLink( 250, $days, $page, $more ) . ' | ' .
511 - rcCountLink( 500, $days, $page, $more ) .
512 - ( $doall ? ( ' | ' . rcCountLink( 0, $days, $page, $more ) ) : '' );
513 - $dl = rcDaysLink( $limit, 1, $page, $more ) . ' | ' .
514 - rcDaysLink( $limit, 3, $page, $more ) . ' | ' .
515 - rcDaysLink( $limit, 7, $page, $more ) . ' | ' .
516 - rcDaysLink( $limit, 14, $page, $more ) . ' | ' .
517 - rcDaysLink( $limit, 30, $page, $more ) .
518 - ( $doall ? ( ' | ' . rcDaysLink( $limit, 0, $page, $more ) ) : '' );
519 -
 511+
 512+ # Sort data for display and make sure it's unique after we've added user data.
 513+ $wgRCLinkLimits[] = $limit;
 514+ $wgRCLinkDays[] = $days;
 515+ sort(&$wgRCLinkLimits);
 516+ sort(&$wgRCLinkDays);
 517+ $wgRCLinkLimits = array_unique($wgRCLinkLimits);
 518+ $wgRCLinkDays = array_unique($wgRCLinkDays);
 519+
 520+ $cl = array();
 521+ foreach( $wgRCLinkLimits as $countLink ) {
 522+ $cl[] = rcCountLink( $countLink, $days, $page, $more, $countLink == $limit );
 523+ }
 524+ if( $doall ) $cl[] = rcCountLink( 0, $days, $page, $more );
 525+ $cl = implode( ' | ', $cl);
 526+
 527+ $dl = array();
 528+ foreach( $wgRCLinkDays as $daysLink ) {
 529+ $dl[] = rcDaysLink( $limit, $daysLink, $page, $more, $daysLink == $days );
 530+ }
 531+ if( $doall ) $dl[] = rcDaysLink( $limit, 0, $page, $more );
 532+ $dl = implode( ' | ', $dl);
 533+
520534 $linkParts = array( 'minorLink' => 'minor', 'botLink' => 'bots', 'liuLink' => 'liu', 'patrLink' => 'patr', 'myselfLink' => 'mine' );
521535 foreach( $linkParts as $linkVar => $linkMsg ) {
522536 if( $$linkVar != '' )
@@ -534,11 +548,12 @@
535549 * @param $override
536550 * @param $options
537551 */
538 -function makeOptionsLink( $title, $override, $options ) {
 552+function makeOptionsLink( $title, $override, $options, $active = false ) {
539553 global $wgUser, $wgContLang;
540554 $sk = $wgUser->getSkin();
541555 return $sk->makeKnownLink( $wgContLang->specialPage( 'Recentchanges' ),
542 - htmlspecialchars( $title ), wfArrayToCGI( $override, $options ) );
 556+ htmlspecialchars( $title ), wfArrayToCGI( $override, $options ), '', '',
 557+ $active ? 'style="font-weight: bold;"' : '' );
543558 }
544559
545560 /**
@@ -547,7 +562,7 @@
548563 * @param $nondefaults
549564 */
550565 function rcOptionsPanel( $defaults, $nondefaults ) {
551 - global $wgLang, $wgUser;
 566+ global $wgLang, $wgUser, $wgRCLinkLimits, $wgRCLinkDays;
552567
553568 $options = $nondefaults + $defaults;
554569
@@ -561,19 +576,25 @@
562577 $wgLang->formatNum( $options['days'] ),
563578 $wgLang->timeAndDate( wfTimestampNow(), true ) );
564579
 580+ # Sort data for display and make sure it's unique after we've added user data.
 581+ $wgRCLinkLimits[] = $options['limit'];
 582+ $wgRCLinkDays[] = $options['days'];
 583+ sort(&$wgRCLinkLimits);
 584+ sort(&$wgRCLinkDays);
 585+ $wgRCLinkLimits = array_unique($wgRCLinkLimits);
 586+ $wgRCLinkDays = array_unique($wgRCLinkDays);
 587+
565588 // limit links
566 - $options_limit = array(50, 100, 250, 500);
567 - foreach( $options_limit as $value ) {
 589+ foreach( $wgRCLinkLimits as $value ) {
568590 $cl[] = makeOptionsLink( $wgLang->formatNum( $value ),
569 - array( 'limit' => $value ), $nondefaults) ;
 591+ array( 'limit' => $value ), $nondefaults, $value == $options['limit'] ) ;
570592 }
571593 $cl = implode( ' | ', $cl);
572594
573595 // day links, reset 'from' to none
574 - $options_days = array(1, 3, 7, 14, 30);
575 - foreach( $options_days as $value ) {
 596+ foreach( $wgRCLinkDays as $value ) {
576597 $dl[] = makeOptionsLink( $wgLang->formatNum( $value ),
577 - array( 'days' => $value, 'from' => '' ), $nondefaults) ;
 598+ array( 'days' => $value, 'from' => '' ), $nondefaults, $value == $options['days'] ) ;
578599 }
579600 $dl = implode( ' | ', $dl);
580601
Index: trunk/phase3/includes/Setup.php
@@ -159,6 +159,19 @@
160160 wfDebug( $_SERVER['REQUEST_METHOD'] . ' ' . $_SERVER['REQUEST_URI'] . "\n" );
161161 }
162162
 163+if( $wgRCFilterByAge ) {
 164+ ## Trim down $wgRCLinkDays so that it only lists links which are valid
 165+ ## as determined by $wgRCMaxAge.
 166+ ## Note that we allow 1 link higher than the max for things like 56 days but a 60 day link.
 167+ sort($wgRCLinkDays);
 168+ for( $i = 0; $i < count($wgRCLinkDays); $i++ ) {
 169+ if( $wgRCLinkDays[$i] >= $wgRCMaxAge / ( 3600 * 24 ) ) {
 170+ $wgRCLinkDays = array_slice( $wgRCLinkDays, 0, $i+1, false );
 171+ break;
 172+ }
 173+ }
 174+}
 175+
163176 if ( $wgSkipSkin ) {
164177 $wgSkipSkins[] = $wgSkipSkin;
165178 }
Index: trunk/phase3/includes/DefaultSettings.php
@@ -1933,7 +1933,19 @@
19341934 */
19351935 $wgRCMaxAge = 7 * 24 * 3600;
19361936
 1937+/**
 1938+ * Filter $wgRCLinkDays by $wgRCMaxAge to avoid showing links for numbers higher than what will be stored.
 1939+ * Note that this is disabled by default because we sometimes do have RC data which is beyond the limit
 1940+ * for some reason, and some users may use the high numbers to display that data which is still there.
 1941+ */
 1942+$wgRCFilterByAge = false;
19371943
 1944+/**
 1945+ * List of Days and Limits options to list in the Special:Recentchanges and Special:Recentchangeslinked pages.
 1946+ */
 1947+$wgRCLinkLimits = array( 50, 100, 250, 500 );
 1948+$wgRCLinkDays = array( 1, 3, 7, 14, 30 );
 1949+
19381950 # Send RC updates via UDP
19391951 $wgRC2UDPAddress = false;
19401952 $wgRC2UDPPort = false;

Follow-up revisions

RevisionCommit summaryAuthorDate
r34990Missing RELEASE-NOTES for r34983.dantman20:02, 17 May 2008
r41723Remove some redundant "starting from" message cruft (bug 3327)aaron03:49, 6 October 2008
r50930* (bug 9257) $wgRCMaxAge now defaults to three monthsnikerabbit08:42, 23 May 2009

Status & tagging log