Index: trunk/phase3/includes/SpecialRecentchanges.php |
— | — | @@ -477,24 +477,26 @@ |
478 | 478 | /** |
479 | 479 | * |
480 | 480 | */ |
481 | | -function rcCountLink( $lim, $d, $page='Recentchanges', $more='' ) { |
| 481 | +function rcCountLink( $lim, $d, $page='Recentchanges', $more='', $active = false ) { |
482 | 482 | global $wgUser, $wgLang, $wgContLang; |
483 | 483 | $sk = $wgUser->getSkin(); |
484 | 484 | $s = $sk->makeKnownLink( $wgContLang->specialPage( $page ), |
485 | 485 | ($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;"' : '' ); |
487 | 488 | return $s; |
488 | 489 | } |
489 | 490 | |
490 | 491 | /** |
491 | 492 | * |
492 | 493 | */ |
493 | | -function rcDaysLink( $lim, $d, $page='Recentchanges', $more='' ) { |
| 494 | +function rcDaysLink( $lim, $d, $page='Recentchanges', $more='', $active = false ) { |
494 | 495 | global $wgUser, $wgLang, $wgContLang; |
495 | 496 | $sk = $wgUser->getSkin(); |
496 | 497 | $s = $sk->makeKnownLink( $wgContLang->specialPage( $page ), |
497 | 498 | ($d ? $wgLang->formatNum( "{$d}" ) : wfMsg( 'recentchangesall' ) ), $more.'days='.$d . |
498 | | - ($lim ? '&limit='.$lim : '') ); |
| 499 | + ($lim ? '&limit='.$lim : ''), '', '', |
| 500 | + $active ? 'style="font-weight: bold;"' : '' ); |
499 | 501 | return $s; |
500 | 502 | } |
501 | 503 | |
— | — | @@ -503,19 +505,31 @@ |
504 | 506 | */ |
505 | 507 | function rcDayLimitLinks( $days, $limit, $page='Recentchanges', $more='', $doall = false, $minorLink = '', |
506 | 508 | $botLink = '', $liuLink = '', $patrLink = '', $myselfLink = '' ) { |
| 509 | + global $wgRCLinkLimits, $wgRCLinkDays; |
507 | 510 | 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 | + |
520 | 534 | $linkParts = array( 'minorLink' => 'minor', 'botLink' => 'bots', 'liuLink' => 'liu', 'patrLink' => 'patr', 'myselfLink' => 'mine' ); |
521 | 535 | foreach( $linkParts as $linkVar => $linkMsg ) { |
522 | 536 | if( $$linkVar != '' ) |
— | — | @@ -534,11 +548,12 @@ |
535 | 549 | * @param $override |
536 | 550 | * @param $options |
537 | 551 | */ |
538 | | -function makeOptionsLink( $title, $override, $options ) { |
| 552 | +function makeOptionsLink( $title, $override, $options, $active = false ) { |
539 | 553 | global $wgUser, $wgContLang; |
540 | 554 | $sk = $wgUser->getSkin(); |
541 | 555 | return $sk->makeKnownLink( $wgContLang->specialPage( 'Recentchanges' ), |
542 | | - htmlspecialchars( $title ), wfArrayToCGI( $override, $options ) ); |
| 556 | + htmlspecialchars( $title ), wfArrayToCGI( $override, $options ), '', '', |
| 557 | + $active ? 'style="font-weight: bold;"' : '' ); |
543 | 558 | } |
544 | 559 | |
545 | 560 | /** |
— | — | @@ -547,7 +562,7 @@ |
548 | 563 | * @param $nondefaults |
549 | 564 | */ |
550 | 565 | function rcOptionsPanel( $defaults, $nondefaults ) { |
551 | | - global $wgLang, $wgUser; |
| 566 | + global $wgLang, $wgUser, $wgRCLinkLimits, $wgRCLinkDays; |
552 | 567 | |
553 | 568 | $options = $nondefaults + $defaults; |
554 | 569 | |
— | — | @@ -561,19 +576,25 @@ |
562 | 577 | $wgLang->formatNum( $options['days'] ), |
563 | 578 | $wgLang->timeAndDate( wfTimestampNow(), true ) ); |
564 | 579 | |
| 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 | + |
565 | 588 | // limit links |
566 | | - $options_limit = array(50, 100, 250, 500); |
567 | | - foreach( $options_limit as $value ) { |
| 589 | + foreach( $wgRCLinkLimits as $value ) { |
568 | 590 | $cl[] = makeOptionsLink( $wgLang->formatNum( $value ), |
569 | | - array( 'limit' => $value ), $nondefaults) ; |
| 591 | + array( 'limit' => $value ), $nondefaults, $value == $options['limit'] ) ; |
570 | 592 | } |
571 | 593 | $cl = implode( ' | ', $cl); |
572 | 594 | |
573 | 595 | // 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 ) { |
576 | 597 | $dl[] = makeOptionsLink( $wgLang->formatNum( $value ), |
577 | | - array( 'days' => $value, 'from' => '' ), $nondefaults) ; |
| 598 | + array( 'days' => $value, 'from' => '' ), $nondefaults, $value == $options['days'] ) ; |
578 | 599 | } |
579 | 600 | $dl = implode( ' | ', $dl); |
580 | 601 | |
Index: trunk/phase3/includes/Setup.php |
— | — | @@ -159,6 +159,19 @@ |
160 | 160 | wfDebug( $_SERVER['REQUEST_METHOD'] . ' ' . $_SERVER['REQUEST_URI'] . "\n" ); |
161 | 161 | } |
162 | 162 | |
| 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 | + |
163 | 176 | if ( $wgSkipSkin ) { |
164 | 177 | $wgSkipSkins[] = $wgSkipSkin; |
165 | 178 | } |
Index: trunk/phase3/includes/DefaultSettings.php |
— | — | @@ -1933,7 +1933,19 @@ |
1934 | 1934 | */ |
1935 | 1935 | $wgRCMaxAge = 7 * 24 * 3600; |
1936 | 1936 | |
| 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; |
1937 | 1943 | |
| 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 | + |
1938 | 1950 | # Send RC updates via UDP |
1939 | 1951 | $wgRC2UDPAddress = false; |
1940 | 1952 | $wgRC2UDPPort = false; |