]> scripts.mit.edu Git - autoinstalls/mediawiki.git/blob - includes/specials/SpecialWantedtemplates.php
MediaWiki 1.17.0
[autoinstalls/mediawiki.git] / includes / specials / SpecialWantedtemplates.php
1 <?php
2 /**
3  * Implements Special:Wantedtemplates
4  *
5  * Copyright © 2008, Danny B.
6  * Based on SpecialWantedcategories.php by Ævar Arnfjörð Bjarmason <avarab@gmail.com>
7  * makeWlhLink() taken from SpecialMostlinkedtemplates by Rob Church <robchur@gmail.com>
8  *
9  * This program is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 2 of the License, or
12  * (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License along
20  * with this program; if not, write to the Free Software Foundation, Inc.,
21  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
22  * http://www.gnu.org/copyleft/gpl.html
23  *
24  * @file
25  * @ingroup SpecialPage
26  * @author Danny B.
27  */
28
29 /**
30  * A querypage to list the most wanted templates
31  *
32  * @ingroup SpecialPage
33  */
34 class WantedTemplatesPage extends WantedQueryPage {
35
36         function getName() {
37                 return 'Wantedtemplates';
38         }
39
40         function getSQL() {
41                 $dbr = wfGetDB( DB_SLAVE );
42                 list( $templatelinks, $page ) = $dbr->tableNamesN( 'templatelinks', 'page' );
43                 $name = $dbr->addQuotes( $this->getName() );
44                 return
45                         "
46                           SELECT $name as type, 
47                                  tl_namespace as namespace,
48                                  tl_title as title,
49                                  COUNT(*) as value
50                             FROM $templatelinks LEFT JOIN
51                                  $page ON tl_title = page_title AND tl_namespace = page_namespace
52                            WHERE page_title IS NULL AND tl_namespace = ". NS_TEMPLATE ."
53                         GROUP BY tl_namespace, tl_title
54                         ";
55         }
56 }
57
58 /**
59  * constructor
60  */
61 function wfSpecialWantedTemplates() {
62         list( $limit, $offset ) = wfCheckLimits();
63
64         $wpp = new WantedTemplatesPage();
65
66         $wpp->doQuery( $offset, $limit );
67 }