5 * @subpackage SpecialPage
8 class DisambiguationsPage
extends PageQueryPage
{
11 return 'Disambiguations';
14 function isExpensive( ) { return true; }
15 function isSyndicated() { return false; }
18 function getPageHeader( ) {
20 return $wgOut->parse( wfMsg( 'disambiguations-text' ) );
24 $dbr =& wfGetDB( DB_SLAVE
);
26 $dMsgText = wfMsgForContent('disambiguationspage');
28 $linkBatch = new LinkBatch
;
30 # If the text can be treated as a title, use it verbatim.
31 # Otherwise, pull the titles from the links table
32 $dp = Title
::newFromText($dMsgText);
34 if($dp->getNamespace() != NS_TEMPLATE
) {
35 # FIXME we assume the disambiguation message is a template but
36 # the page can potentially be from another namespace :/
37 wfDebug("Mediawiki:disambiguationspage message does not refer to a template!\n");
39 $linkBatch->addObj( $dp );
41 # Get all the templates linked from the Mediawiki:Disambiguationspage
42 $disPageObj = Title
::makeTitleSafe( NS_MEDIAWIKI
, 'disambiguationspage' );
44 array('pagelinks', 'page'),
46 array('page_id = pl_from', 'pl_namespace' => NS_TEMPLATE
,
47 'page_namespace' => $disPageObj->getNamespace(), 'page_title' => $disPageObj->getDBkey()),
50 while ( $row = $dbr->fetchObject( $res ) ) {
51 $linkBatch->addObj( Title
::makeTitle( NS_TEMPLATE
, $row->pl_title
));
54 $dbr->freeResult( $res );
57 $set = $linkBatch->constructSet( 'lb.tl', $dbr );
58 if( $set === false ) {
59 # We must always return a valid sql query, but this way DB will always quicly return an empty result
61 wfDebug("Mediawiki:disambiguationspage message does not link to any templates!\n");
64 list( $page, $pagelinks, $templatelinks) = $dbr->tableNamesN( 'page', 'pagelinks', 'templatelinks' );
66 $sql = "SELECT 'Disambiguations' AS \"type\", pb.page_namespace AS namespace,"
67 ." pb.page_title AS title, la.pl_from AS value"
68 ." FROM {$templatelinks} AS lb, {$page} AS pb, {$pagelinks} AS la, {$page} AS pa"
69 ." WHERE $set" # disambiguation template(s)
70 .' AND pa.page_id = la.pl_from'
71 .' AND pa.page_namespace = ' . NS_MAIN
# Limit to just articles in the main namespace
72 .' AND pb.page_id = lb.tl_from'
73 .' AND pb.page_namespace = la.pl_namespace'
74 .' AND pb.page_title = la.pl_title'
75 .' ORDER BY lb.tl_namespace, lb.tl_title';
84 function formatResult( $skin, $result ) {
86 $title = Title
::newFromId( $result->value
);
87 $dp = Title
::makeTitle( $result->namespace, $result->title
);
89 $from = $skin->makeKnownLinkObj( $title, '' );
90 $edit = $skin->makeKnownLinkObj( $title, "(".wfMsgHtml("qbedit").")" , 'redirect=no&action=edit' );
91 $arr = $wgContLang->getArrow();
92 $to = $skin->makeKnownLinkObj( $dp, '' );
94 return "$from $edit $arr $to";
101 function wfSpecialDisambiguations() {
102 list( $limit, $offset ) = wfCheckLimits();
104 $sd = new DisambiguationsPage();
106 return $sd->doQuery( $offset, $limit );