4 * @addtogroup SpecialPage
7 class DisambiguationsPage
extends PageQueryPage
{
10 return 'Disambiguations';
13 function isExpensive( ) { return true; }
14 function isSyndicated() { return false; }
17 function getPageHeader( ) {
19 return $wgOut->parse( wfMsg( 'disambiguations-text' ) );
23 $dbr = wfGetDB( DB_SLAVE
);
25 $dMsgText = wfMsgForContent('disambiguationspage');
27 $linkBatch = new LinkBatch
;
29 # If the text can be treated as a title, use it verbatim.
30 # Otherwise, pull the titles from the links table
31 $dp = Title
::newFromText($dMsgText);
33 if($dp->getNamespace() != NS_TEMPLATE
) {
34 # FIXME we assume the disambiguation message is a template but
35 # the page can potentially be from another namespace :/
36 wfDebug("Mediawiki:disambiguationspage message does not refer to a template!\n");
38 $linkBatch->addObj( $dp );
40 # Get all the templates linked from the Mediawiki:Disambiguationspage
41 $disPageObj = Title
::makeTitleSafe( NS_MEDIAWIKI
, 'disambiguationspage' );
43 array('pagelinks', 'page'),
45 array('page_id = pl_from', 'pl_namespace' => NS_TEMPLATE
,
46 'page_namespace' => $disPageObj->getNamespace(), 'page_title' => $disPageObj->getDBkey()),
49 while ( $row = $dbr->fetchObject( $res ) ) {
50 $linkBatch->addObj( Title
::makeTitle( NS_TEMPLATE
, $row->pl_title
));
53 $dbr->freeResult( $res );
56 $set = $linkBatch->constructSet( 'lb.tl', $dbr );
57 if( $set === false ) {
58 # We must always return a valid sql query, but this way DB will always quicly return an empty result
60 wfDebug("Mediawiki:disambiguationspage message does not link to any templates!\n");
63 list( $page, $pagelinks, $templatelinks) = $dbr->tableNamesN( 'page', 'pagelinks', 'templatelinks' );
65 $sql = "SELECT 'Disambiguations' AS \"type\", pb.page_namespace AS namespace,"
66 ." pb.page_title AS title, la.pl_from AS value"
67 ." FROM {$templatelinks} AS lb, {$page} AS pb, {$pagelinks} AS la, {$page} AS pa"
68 ." WHERE $set" # disambiguation template(s)
69 .' AND pa.page_id = la.pl_from'
70 .' AND pa.page_namespace = ' . NS_MAIN
# Limit to just articles in the main namespace
71 .' AND pb.page_id = lb.tl_from'
72 .' AND pb.page_namespace = la.pl_namespace'
73 .' AND pb.page_title = la.pl_title'
74 .' ORDER BY lb.tl_namespace, lb.tl_title';
83 function formatResult( $skin, $result ) {
85 $title = Title
::newFromId( $result->value
);
86 $dp = Title
::makeTitle( $result->namespace, $result->title
);
88 $from = $skin->makeKnownLinkObj( $title, '' );
89 $edit = $skin->makeKnownLinkObj( $title, "(".wfMsgHtml("qbedit").")" , 'redirect=no&action=edit' );
90 $arr = $wgContLang->getArrow();
91 $to = $skin->makeKnownLinkObj( $dp, '' );
93 return "$from $edit $arr $to";
100 function wfSpecialDisambiguations() {
101 list( $limit, $offset ) = wfCheckLimits();
103 $sd = new DisambiguationsPage();
105 return $sd->doQuery( $offset, $limit );