Make SQL more SQL compliant, remove some debugging code.
[mediawiki.git] / includes / SpecialDisambiguations.php
blob1a0297af727b5147e8b8e65a72418846a8ef2782
1 <?php
2 /**
4 * @package MediaWiki
5 * @subpackage SpecialPage
6 */
8 /**
10 * @package MediaWiki
11 * @subpackage SpecialPage
13 class DisambiguationsPage extends PageQueryPage {
15 function getName() {
16 return 'Disambiguations';
19 function isExpensive( ) { return true; }
20 function isSyndicated() { return false; }
22 function getPageHeader( ) {
23 global $wgUser;
24 $sk = $wgUser->getSkin();
26 #FIXME : probably need to add a backlink to the maintenance page.
27 return '<p>'.wfMsg('disambiguationstext', $sk->makeKnownLink(wfMsgForContent('disambiguationspage')) )."</p><br />\n";
30 function getSQL() {
31 $dbr =& wfGetDB( DB_SLAVE );
32 extract( $dbr->tableNames( 'page', 'pagelinks', 'templatelinks' ) );
34 $dp = Title::newFromText(wfMsgForContent('disambiguationspage'));
35 $id = $dp->getArticleId();
36 $dns = $dp->getNamespace();
37 $dtitle = $dbr->addQuotes( $dp->getDBkey() );
39 if($dns != NS_TEMPLATE) {
40 # FIXME we assume the disambiguation message is a template but
41 # the page can potentially be from another namespace :/
42 wfDebug("Mediawiki:disambiguationspage message does not refer to a template!\n");
45 $sql = "SELECT 'Disambiguations' AS \"type\", pa.page_namespace AS namespace,"
46 ." pa.page_title AS title, la.pl_from AS value"
47 ." FROM {$templatelinks} AS lb, {$page} AS pa, {$pagelinks} AS la"
48 ." WHERE lb.tl_namespace = $dns AND lb.tl_title = $dtitle" # disambiguation template
49 .' AND pa.page_id = lb.tl_from'
50 .' AND pa.page_namespace = la.pl_namespace'
51 .' AND pa.page_title = la.pl_title';
52 return $sql;
55 function getOrder() {
56 return '';
59 function formatResult( $skin, $result ) {
60 $title = Title::newFromId( $result->value );
61 $dp = Title::makeTitle( $result->namespace, $result->title );
63 $from = $skin->makeKnownLinkObj( $title,'');
64 $edit = $skin->makeBrokenLinkObj( $title, "(".wfMsg("qbedit").")" , 'redirect=no');
65 $to = $skin->makeKnownLinkObj( $dp,'');
67 return "$from $edit => $to";
71 /**
72 * Constructor
74 function wfSpecialDisambiguations() {
75 list( $limit, $offset ) = wfCheckLimits();
77 $sd = new DisambiguationsPage();
79 return $sd->doQuery( $offset, $limit );