* @ingroup SpecialPage
*/
class WantedCategoriesPage extends WantedQueryPage {
+ private $currentCategoryCounts;
function __construct( $name = 'Wantedcategories' ) {
parent::__construct( $name );
);
}
+ function preprocessResults( $db, $res ) {
+ parent::preprocessResults( $db, $res );
+
+ $this->currentCategoryCounts = array();
+
+ if ( !$res->numRows() || !$this->isCached() ) {
+ return;
+ }
+
+ // Fetch (hopefully) up-to-date numbers of pages in each category.
+ // This should be fast enough as we limit the list to a reasonable length.
+
+ $allCategories = array();
+ foreach ( $res as $row ) {
+ $allCategories[] = $row->title;
+ }
+
+ $categoryRes = $db->select(
+ 'category',
+ array( 'cat_title', 'cat_pages' ),
+ array( 'cat_title' => $allCategories ),
+ __METHOD__
+ );
+ foreach ( $categoryRes as $row ) {
+ $this->currentCategoryCounts[ $row->cat_title ] = $row->cat_pages;
+ }
+
+ // Back to start for display
+ $res->seek( 0 );
+ }
+
/**
* @param Skin $skin
* @param object $result Result row
$nt = Title::makeTitle( $result->namespace, $result->title );
$text = htmlspecialchars( $wgContLang->convert( $nt->getText() ) );
- $plink = $this->isCached() ?
- Linker::link( $nt, $text ) :
- Linker::link(
+ if ( !$this->isCached() ) {
+ // We can assume the freshest data
+ $plink = Linker::link(
$nt,
$text,
array(),
array(),
array( 'broken' )
);
+ $nlinks = $this->msg( 'nmembers' )->numParams( $result->value )->escaped();
+ } else {
+ $plink = Linker::link( $nt, $text );
+
+ $currentValue = isset( $this->currentCategoryCounts[ $result->title ] )
+ ? $this->currentCategoryCounts[ $result->title ]
+ : 0;
+
+ // If the category has been created or emptied since the list was refreshed, strike it
+ if ( $nt->isKnown() || $currentValue === 0 ) {
+ $plink = "<del>$plink</del>";
+ }
+
+ // Show the current number of category entries if it changed
+ if ( $currentValue !== $result->value ) {
+ $nlinks = $this->msg( 'nmemberschanged' )
+ ->numParams( $result->value, $currentValue )->escaped();
+ } else {
+ $nlinks = $this->msg( 'nmembers' )->numParams( $result->value )->escaped();
+ }
+ }
- $nlinks = $this->msg( 'nmembers' )->numParams( $result->value )->escaped();
return $this->getLanguage()->specialList( $plink, $nlinks );
}
'ninterwikis' => '$1 {{PLURAL:$1|interwiki|interwikis}}',
'nlinks' => '$1 {{PLURAL:$1|link|links}}',
'nmembers' => '$1 {{PLURAL:$1|member|members}}',
+'nmemberschanged' => '$1 → $2 {{PLURAL:$2|member|members}}',
'nrevisions' => '$1 {{PLURAL:$1|revision|revisions}}',
'nviews' => '$1 {{PLURAL:$1|view|views}}',
'nimagelinks' => 'Used on $1 {{PLURAL:$1|page|pages}}',
* $1 - the number of interwiki links",
'nlinks' => 'This appears in brackets after each entry on the special page [[Special:MostLinked]]. $1 is the number of wiki links.',
'nmembers' => 'Appears in brackets after each category listed on the special page [[Special:WantedCategories]]. $1 is the number of members of the category.',
+'nmemberschanged' => 'Appears in brackets after each category listed on the special page [[Special:WantedCategories]] if the number of pages in the category has changed since the list was last refreshed. $1 is the original number of members of the category, $2 is the current one.',
'nrevisions' => 'Used as link text in [[Special:FewestRevisions]].
The link points to the page history (action=history).