Coding style
[lhc/web/wiklou.git] / includes / specials / SpecialWithoutinterwiki.php
1 <?php
2 /**
3 * Implements Special:Withoutinterwiki
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 * @author Rob Church <robchur@gmail.com>
23 */
24
25 /**
26 * Special page lists pages without language links
27 *
28 * @ingroup SpecialPage
29 */
30 class WithoutInterwikiPage extends PageQueryPage {
31 private $prefix = '';
32
33 function getName() {
34 return 'Withoutinterwiki';
35 }
36
37 function getPageHeader() {
38 global $wgScript, $wgMiserMode;
39
40 # Do not show useless input form if wiki is running in misermode
41 if( $wgMiserMode ) {
42 return '';
43 }
44
45 $prefix = $this->prefix;
46 $t = SpecialPage::getTitleFor( $this->getName() );
47
48 return Xml::openElement( 'form', array( 'method' => 'get', 'action' => $wgScript ) ) .
49 Xml::openElement( 'fieldset' ) .
50 Xml::element( 'legend', null, wfMsg( 'withoutinterwiki-legend' ) ) .
51 Xml::hidden( 'title', $t->getPrefixedText() ) .
52 Xml::inputLabel( wfMsg( 'allpagesprefix' ), 'prefix', 'wiprefix', 20, $prefix ) . ' ' .
53 Xml::submitButton( wfMsg( 'withoutinterwiki-submit' ) ) .
54 Xml::closeElement( 'fieldset' ) .
55 Xml::closeElement( 'form' );
56 }
57
58 function sortDescending() {
59 return false;
60 }
61
62 function isExpensive() {
63 return true;
64 }
65
66 function isSyndicated() {
67 return false;
68 }
69
70 function getSQL() {
71 $dbr = wfGetDB( DB_SLAVE );
72 list( $page, $langlinks ) = $dbr->tableNamesN( 'page', 'langlinks' );
73 $prefix = $this->prefix ? 'AND page_title' . $dbr->buildLike( $this->prefix , $dbr->anyString() ) : '';
74 return
75 "SELECT 'Withoutinterwiki' AS type,
76 page_namespace AS namespace,
77 page_title AS title,
78 page_title AS value
79 FROM $page
80 LEFT JOIN $langlinks
81 ON ll_from = page_id
82 WHERE ll_title IS NULL
83 AND page_namespace=" . NS_MAIN . "
84 AND page_is_redirect = 0
85 {$prefix}";
86 }
87
88 function setPrefix( $prefix = '' ) {
89 $this->prefix = $prefix;
90 }
91
92 }
93
94 function wfSpecialWithoutinterwiki() {
95 global $wgRequest;
96 list( $limit, $offset ) = wfCheckLimits();
97 // Only searching the mainspace anyway
98 $prefix = Title::capitalize( $wgRequest->getVal( 'prefix' ), NS_MAIN );
99 $wip = new WithoutInterwikiPage();
100 $wip->setPrefix( $prefix );
101 $wip->doQuery( $offset, $limit );
102 }