Correct the address of the FSF in some of the GPL headers
[lhc/web/wiklou.git] / includes / specials / SpecialUnwatchedpages.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 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17 * http://www.gnu.org/copyleft/gpl.html
18 */
19
20 /**
21 * @file
22 * @ingroup SpecialPage
23 */
24
25 /**
26 * A special page that displays a list of pages that are not on anyones watchlist.
27 * Implements Special:Unwatchedpages
28 *
29 * @ingroup SpecialPage
30 * @author Ævar Arnfjörð Bjarmason <avarab@gmail.com>
31 * @copyright Copyright © 2005, Ævar Arnfjörð Bjarmason
32 * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License 2.0 or later
33 */
34 class UnwatchedpagesPage extends QueryPage {
35
36 function getName() { return 'Unwatchedpages'; }
37 function isExpensive() { return true; }
38 function isSyndicated() { return false; }
39
40 function getSQL() {
41 $dbr = wfGetDB( DB_SLAVE );
42 list( $page, $watchlist ) = $dbr->tableNamesN( 'page', 'watchlist' );
43 $mwns = NS_MEDIAWIKI;
44 return
45 "
46 SELECT
47 'Unwatchedpages' as type,
48 page_namespace as namespace,
49 page_title as title,
50 page_namespace as value
51 FROM $page
52 LEFT JOIN $watchlist ON wl_namespace = page_namespace AND page_title = wl_title
53 WHERE wl_title IS NULL AND page_is_redirect = 0 AND page_namespace<>$mwns
54 ";
55 }
56
57 function sortDescending() { return false; }
58
59 function formatResult( $skin, $result ) {
60 global $wgContLang;
61
62 $nt = Title::makeTitle( $result->namespace, $result->title );
63 $text = $wgContLang->convert( $nt->getPrefixedText() );
64
65 $plink = $skin->linkKnown(
66 $nt,
67 htmlspecialchars( $text )
68 );
69 $wlink = $skin->linkKnown(
70 $nt,
71 wfMsgHtml( 'watch' ),
72 array(),
73 array( 'action' => 'watch' )
74 );
75
76 return wfSpecialList( $plink, $wlink );
77 }
78 }
79
80 /**
81 * constructor
82 */
83 function wfSpecialUnwatchedpages() {
84 global $wgUser, $wgOut;
85
86 if ( ! $wgUser->isAllowed( 'unwatchedpages' ) )
87 return $wgOut->permissionRequired( 'unwatchedpages' );
88
89 list( $limit, $offset ) = wfCheckLimits();
90
91 $wpp = new UnwatchedpagesPage();
92
93 $wpp->doQuery( $offset, $limit );
94 }