Rights log changes:
[lhc/web/wiklou.git] / includes / SpecialWantedcategories.php
1 <?php
2 /**
3 * A querypage to list the most wanted categories
4 *
5 * @package MediaWiki
6 * @subpackage SpecialPage
7 *
8 * @author Ævar Arnfjörð Bjarmason <avarab@gmail.com>
9 * @copyright Copyright © 2005, Ævar Arnfjörð Bjarmason
10 * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License 2.0 or later
11 */
12
13 /**
14 * @package MediaWiki
15 * @subpackage SpecialPage
16 */
17 class WantedCategoriesPage extends QueryPage {
18
19 function getName() { return 'Wantedcategories'; }
20 function isExpensive() { return true; }
21 function isSyndicated() { return false; }
22
23 function getSQL() {
24 $dbr =& wfGetDB( DB_SLAVE );
25 extract( $dbr->tableNames( 'categorylinks', 'page' ) );
26 $name = $dbr->addQuotes( $this->getName() );
27 return
28 "
29 SELECT
30 $name as type,
31 " . NS_CATEGORY . " as namespace,
32 cl_to as title,
33 COUNT(*) as value
34 FROM $categorylinks
35 LEFT JOIN $page ON cl_to = page_title AND page_namespace = ". NS_CATEGORY ."
36 WHERE page_title IS NULL
37 GROUP BY cl_to
38 ";
39 }
40
41 function sortDescending() { return true; }
42
43 /**
44 * Fetch user page links and cache their existence
45 */
46 function preprocessResults( &$db, &$res ) {
47 $batch = new LinkBatch;
48 while ( $row = $db->fetchObject( $res ) )
49 $batch->addObj( Title::makeTitleSafe( $row->namespace, $row->title ) );
50 $batch->execute();
51
52 // Back to start for display
53 if ( $db->numRows( $res ) > 0 )
54 // If there are no rows we get an error seeking.
55 $db->dataSeek( $res, 0 );
56 }
57
58 function formatResult( $skin, $result ) {
59 global $wgLang, $wgContLang;
60
61 $nt = Title::makeTitle( $result->namespace, $result->title );
62 $text = $wgContLang->convert( $nt->getText() );
63
64 $plink = $this->isCached() ?
65 $skin->makeLinkObj( $nt, htmlspecialchars( $text ) ) :
66 $skin->makeBrokenLinkObj( $nt, htmlspecialchars( $text ) );
67
68 $nlinks = wfMsgExt( 'nmembers', array( 'parsemag', 'escape'),
69 $wgLang->formatNum( $result->value ) );
70 return wfSpecialList($plink, $nlinks);
71 }
72 }
73
74 /**
75 * constructor
76 */
77 function wfSpecialWantedCategories() {
78 list( $limit, $offset ) = wfCheckLimits();
79
80 $wpp = new WantedCategoriesPage();
81
82 $wpp->doQuery( $offset, $limit );
83 }
84
85 ?>