* (bug 5338) Reject extra initial colons in title
[mediawiki.git] / includes / SpecialDisambiguations.php
blobd30e325898d3d600e6eada68c65898631d65d77c
1 <?php
2 /**
4 * @package MediaWiki
5 * @subpackage SpecialPage
6 */
8 /**
11 require_once('QueryPage.php');
13 /**
15 * @package MediaWiki
16 * @subpackage SpecialPage
18 class DisambiguationsPage extends PageQueryPage {
20 function getName() {
21 return 'Disambiguations';
24 function isExpensive( ) { return true; }
25 function isSyndicated() { return false; }
27 function getPageHeader( ) {
28 global $wgUser;
29 $sk = $wgUser->getSkin();
31 #FIXME : probably need to add a backlink to the maintenance page.
32 return '<p>'.wfMsg('disambiguationstext', $sk->makeKnownLink(wfMsgForContent('disambiguationspage')) )."</p><br />\n";
35 function getSQL() {
36 $dbr =& wfGetDB( DB_SLAVE );
37 extract( $dbr->tableNames( 'page', 'pagelinks', 'templatelinks' ) );
39 $dp = Title::newFromText(wfMsgForContent('disambiguationspage'));
40 $id = $dp->getArticleId();
41 $dns = $dp->getNamespace();
42 $dtitle = $dbr->addQuotes( $dp->getDBkey() );
44 if($dns != NS_TEMPLATE) {
45 # FIXME we assume the disambiguation message is a template but
46 # the page can potentially be from another namespace :/
47 wfDebug("Mediawiki:disambiguationspage message does not refer to a template!\n");
50 $sql = "SELECT 'Disambiguations' AS \"type\", pa.page_namespace AS namespace,"
51 ." pa.page_title AS title, la.pl_from AS value"
52 ." FROM {$templatelinks} AS lb, {$page} AS pa, {$pagelinks} AS la"
53 ." WHERE lb.tl_namespace = $dns AND lb.tl_title = $dtitle" # disambiguation template
54 .' AND pa.page_id = lb.tl_from'
55 .' AND pa.page_namespace = la.pl_namespace'
56 .' AND pa.page_title = la.pl_title';
57 return $sql;
60 function getOrder() {
61 return '';
64 function formatResult( $skin, $result ) {
65 $title = Title::newFromId( $result->value );
66 $dp = Title::makeTitle( $result->namespace, $result->title );
68 $from = $skin->makeKnownLinkObj( $title,'');
69 $edit = $skin->makeBrokenLinkObj( $title, "(".wfMsg("qbedit").")" , 'redirect=no');
70 $to = $skin->makeKnownLinkObj( $dp,'');
72 return "$from $edit => $to";
76 /**
77 * Constructor
79 function wfSpecialDisambiguations() {
80 list( $limit, $offset ) = wfCheckLimits();
82 $sd = new DisambiguationsPage();
84 return $sd->doQuery( $offset, $limit );