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