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