Followup r82641, set default for 2nd param
[lhc/web/wiklou.git] / includes / specials / SpecialWantedpages.php
1 <?php
2 /**
3 * Implements Special:Wantedpages
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 * http://www.gnu.org/copyleft/gpl.html
19 *
20 * @file
21 * @ingroup SpecialPage
22 */
23
24 /**
25 * A special page that lists most linked pages that does not exist
26 *
27 * @ingroup SpecialPage
28 */
29 class WantedPagesPage extends WantedQueryPage {
30 function __construct( $name = 'Wantedpages' ) {
31 parent::__construct( $name );
32 }
33
34 function execute( $par ) {
35 $inc = $this->including();
36
37 if ( $inc ) {
38 @list( $limit, $nlinks ) = explode( '/', $par, 2 );
39 $this->limit = (int)$limit;
40 // FIXME: nlinks is ignored
41 $nlinks = $nlinks === 'nlinks';
42 $this->offset = 0;
43 } else {
44 $nlinks = true;
45 }
46 $this->setListOutput( $inc );
47 $this->shownavigation = !$inc;
48 parent::execute( $par );
49 }
50
51 function getQueryInfo() {
52 global $wgWantedPagesThreshold;
53 $count = $wgWantedPagesThreshold - 1;
54 $query = array (
55 'tables' => array ( 'pagelinks', 'pg1' => 'page',
56 'pg2' => 'page' ),
57 'fields' => array ( 'pl_namespace AS namespace',
58 'pl_title AS title',
59 'COUNT(*) AS value' ),
60 'conds' => array ( 'pg1.page_namespace IS NULL',
61 "pl_namespace NOT IN ( '" . NS_USER .
62 "', '" . NS_USER_TALK . "' )",
63 "pg2.page_namespace != '" .
64 NS_MEDIAWIKI . "'" ),
65 'options' => array ( 'HAVING' => "COUNT(*) > $count",
66 'GROUP BY' => 'pl_namespace, pl_title' ),
67 'join_conds' => array ( 'pg1' => array (
68 'LEFT JOIN', array (
69 'pg1.page_namespace = pl_namespace',
70 'pg1.page_title = pl_title' ) ),
71 'pg2' => array ( 'LEFT JOIN',
72 'pg2.page_id = pl_from' ) )
73 );
74 // Replacement WantedPages::getSQL
75 wfRunHooks( 'WantedPages::getQueryInfo',
76 array( &$this, &$query ) );
77 return $query;
78 }
79 }