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