API: fix copyright symbol, coding style cleanup, more braces
[lhc/web/wiklou.git] / includes / specials / SpecialWantedpages.php
1 <?php
2 /**
3 * @file
4 * @ingroup SpecialPage
5 */
6
7 /**
8 * implements Special:Wantedpages
9 * @ingroup SpecialPage
10 */
11 class WantedPagesPage extends WantedQueryPage {
12 var $nlinks;
13
14 function WantedPagesPage( $inc = false, $nlinks = true ) {
15 $this->setListoutput( $inc );
16 $this->nlinks = $nlinks;
17 }
18
19 function getName() {
20 return 'Wantedpages';
21 }
22
23 function getSQL() {
24 global $wgWantedPagesThreshold;
25 $count = $wgWantedPagesThreshold - 1;
26 $dbr = wfGetDB( DB_SLAVE );
27 $pagelinks = $dbr->tableName( 'pagelinks' );
28 $page = $dbr->tableName( 'page' );
29 $sql = "SELECT 'Wantedpages' AS type,
30 pl_namespace AS namespace,
31 pl_title AS title,
32 COUNT(*) AS value
33 FROM $pagelinks
34 LEFT JOIN $page AS pg1
35 ON pl_namespace = pg1.page_namespace AND pl_title = pg1.page_title
36 LEFT JOIN $page AS pg2
37 ON pl_from = pg2.page_id
38 WHERE pg1.page_namespace IS NULL
39 AND pl_namespace NOT IN ( " . NS_USER . ", ". NS_USER_TALK . ")
40 AND pg2.page_namespace != " . NS_MEDIAWIKI . "
41 GROUP BY pl_namespace, pl_title
42 HAVING COUNT(*) > $count";
43
44 wfRunHooks( 'WantedPages::getSQL', array( &$this, &$sql ) );
45 return $sql;
46 }
47 }
48
49 /**
50 * constructor
51 */
52 function wfSpecialWantedpages( $par = null, $specialPage ) {
53 $inc = $specialPage->including();
54
55 if ( $inc ) {
56 @list( $limit, $nlinks ) = explode( '/', $par, 2 );
57 $limit = (int)$limit;
58 $nlinks = $nlinks === 'nlinks';
59 $offset = 0;
60 } else {
61 list( $limit, $offset ) = wfCheckLimits();
62 $nlinks = true;
63 }
64
65 $wpp = new WantedPagesPage( $inc, $nlinks );
66
67 $wpp->doQuery( $offset, $limit, !$inc );
68 }