[ Index ] |
PHP Cross Reference of MediaWiki-1.24.0 |
[Summary view] [Print] [Text view]
1 <?php 2 /** 3 * Implements Special:Wantedcategories 4 * 5 * Copyright © 2005 Ævar Arnfjörð Bjarmason 6 * 7 * This program is free software; you can redistribute it and/or modify 8 * it under the terms of the GNU General Public License as published by 9 * the Free Software Foundation; either version 2 of the License, or 10 * (at your option) any later version. 11 * 12 * This program is distributed in the hope that it will be useful, 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * GNU General Public License for more details. 16 * 17 * You should have received a copy of the GNU General Public License along 18 * with this program; if not, write to the Free Software Foundation, Inc., 19 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 * http://www.gnu.org/copyleft/gpl.html 21 * 22 * @file 23 * @ingroup SpecialPage 24 */ 25 26 /** 27 * A querypage to list the most wanted categories - implements Special:Wantedcategories 28 * 29 * @ingroup SpecialPage 30 */ 31 class WantedCategoriesPage extends WantedQueryPage { 32 private $currentCategoryCounts; 33 34 function __construct( $name = 'Wantedcategories' ) { 35 parent::__construct( $name ); 36 } 37 38 function getQueryInfo() { 39 return array( 40 'tables' => array( 'categorylinks', 'page' ), 41 'fields' => array( 42 'namespace' => NS_CATEGORY, 43 'title' => 'cl_to', 44 'value' => 'COUNT(*)' 45 ), 46 'conds' => array( 'page_title IS NULL' ), 47 'options' => array( 'GROUP BY' => 'cl_to' ), 48 'join_conds' => array( 'page' => array( 'LEFT JOIN', 49 array( 'page_title = cl_to', 50 'page_namespace' => NS_CATEGORY ) ) ) 51 ); 52 } 53 54 function preprocessResults( $db, $res ) { 55 parent::preprocessResults( $db, $res ); 56 57 $this->currentCategoryCounts = array(); 58 59 if ( !$res->numRows() || !$this->isCached() ) { 60 return; 61 } 62 63 // Fetch (hopefully) up-to-date numbers of pages in each category. 64 // This should be fast enough as we limit the list to a reasonable length. 65 66 $allCategories = array(); 67 foreach ( $res as $row ) { 68 $allCategories[] = $row->title; 69 } 70 71 $categoryRes = $db->select( 72 'category', 73 array( 'cat_title', 'cat_pages' ), 74 array( 'cat_title' => $allCategories ), 75 __METHOD__ 76 ); 77 foreach ( $categoryRes as $row ) { 78 $this->currentCategoryCounts[$row->cat_title] = intval( $row->cat_pages ); 79 } 80 81 // Back to start for display 82 $res->seek( 0 ); 83 } 84 85 /** 86 * @param Skin $skin 87 * @param object $result Result row 88 * @return string 89 */ 90 function formatResult( $skin, $result ) { 91 global $wgContLang; 92 93 $nt = Title::makeTitle( $result->namespace, $result->title ); 94 $text = htmlspecialchars( $wgContLang->convert( $nt->getText() ) ); 95 96 if ( !$this->isCached() ) { 97 // We can assume the freshest data 98 $plink = Linker::link( 99 $nt, 100 $text, 101 array(), 102 array(), 103 array( 'broken' ) 104 ); 105 $nlinks = $this->msg( 'nmembers' )->numParams( $result->value )->escaped(); 106 } else { 107 $plink = Linker::link( $nt, $text ); 108 109 $currentValue = isset( $this->currentCategoryCounts[$result->title] ) 110 ? $this->currentCategoryCounts[$result->title] 111 : 0; 112 113 // If the category has been created or emptied since the list was refreshed, strike it 114 if ( $nt->isKnown() || $currentValue === 0 ) { 115 $plink = "<del>$plink</del>"; 116 } 117 118 // Show the current number of category entries if it changed 119 if ( $currentValue !== $result->value ) { 120 $nlinks = $this->msg( 'nmemberschanged' ) 121 ->numParams( $result->value, $currentValue )->escaped(); 122 } else { 123 $nlinks = $this->msg( 'nmembers' )->numParams( $result->value )->escaped(); 124 } 125 } 126 127 return $this->getLanguage()->specialList( $plink, $nlinks ); 128 } 129 130 protected function getGroupName() { 131 return 'maintenance'; 132 } 133 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Fri Nov 28 14:03:12 2014 | Cross-referenced by PHPXref 0.7.1 |