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