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