]> scripts.mit.edu Git - autoinstallsdev/mediawiki.git/blob - includes/specials/SpecialWantedpages.php
MediaWiki 1.17.3-scripts
[autoinstallsdev/mediawiki.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         var $nlinks;
31
32         function __construct( $inc = false, $nlinks = true ) {
33                 $this->setListoutput( $inc );
34                 $this->nlinks = $nlinks;
35         }
36
37         function getName() {
38                 return 'Wantedpages';
39         }
40
41         function getSQL() {
42                 global $wgWantedPagesThreshold;
43                 $count = $wgWantedPagesThreshold - 1;
44                 $dbr = wfGetDB( DB_SLAVE );
45                 $pagelinks = $dbr->tableName( 'pagelinks' );
46                 $page      = $dbr->tableName( 'page' );
47                 $sql = "SELECT 'Wantedpages' AS type,
48                                 pl_namespace AS namespace,
49                                 pl_title AS title,
50                                 COUNT(*) AS value
51                         FROM $pagelinks
52                         LEFT JOIN $page AS pg1
53                         ON pl_namespace = pg1.page_namespace AND pl_title = pg1.page_title
54                         LEFT JOIN $page AS pg2
55                         ON pl_from = pg2.page_id
56                         WHERE pg1.page_namespace IS NULL
57                         AND pl_namespace NOT IN ( " . NS_USER . ", ". NS_USER_TALK . ")
58                         AND pg2.page_namespace != " . NS_MEDIAWIKI . "
59                         GROUP BY pl_namespace, pl_title
60                         HAVING COUNT(*) > $count";
61
62                 wfRunHooks( 'WantedPages::getSQL', array( &$this, &$sql ) );
63                 return $sql;
64         }
65 }
66
67 /**
68  * constructor
69  */
70 function wfSpecialWantedpages( $par = null, $specialPage ) {
71         $inc = $specialPage->including();
72
73         if ( $inc ) {
74                 @list( $limit, $nlinks ) = explode( '/', $par, 2 );
75                 $limit = (int)$limit;
76                 $nlinks = $nlinks === 'nlinks';
77                 $offset = 0;
78         } else {
79                 list( $limit, $offset ) = wfCheckLimits();
80                 $nlinks = true;
81         }
82
83         $wpp = new WantedPagesPage( $inc, $nlinks );
84
85         $wpp->doQuery( $offset, $limit, !$inc );
86 }