--- /dev/null
+<?php
+
+require_once('QueryPage.php');
+
+class DisambiguationsPage extends PageQueryPage {
+
+ function getName() {
+ return 'disambiguations';
+ }
+
+ function isExpensive( ) { return true; }
+
+ function getPageHeader( ) {
+ #FIXME : probably need to add a backlink to the maintenance page.
+ return '<p>'.wfMsg("disambiguationstext", wfMsg("disambiguationspage"))."</p><br>\n";
+ }
+
+ function getSQL() {
+ $dbr =& wfGetDB( DB_SLAVE );
+ extract( $dbr->tableNames( 'cur', 'links' ) );
+
+ $dp = Title::newFromText(wfMsg("disambiguationspage"));
+ $dpid = $dp->getArticleID();
+
+ $sql = "SELECT ca.cur_namespace AS ns_art, ca.cur_title AS title_art,"
+ . " cb.cur_namespace AS ns_dis, cb.cur_title AS title_dis"
+ . " FROM links as la, links as lb, cur as ca, cur as cb"
+ . " WHERE la.l_to = '{$dpid}'"
+ . " AND la.l_from = lb.l_to"
+ . " AND ca.cur_id = lb.l_from"
+ . " AND cb.cur_id = lb.l_to";
+
+ return $sql;
+ }
+
+ function getOrder() {
+ return '';
+ }
+
+ function formatResult( $skin, $result ) {
+ global $wgLang ;
+ $ns = $wgLang->getNamespaces() ;
+
+ $from = $skin->makeKnownLink( $ns[$result->ns_art].':'.$result->title_art ,'');
+ $edit = $skin->makeBrokenLink( $ns[$result->ns_art].':'.$result->title_art , "(".wfMsg("qbedit").")" , 'redirect=no');
+ $to = $skin->makeKnownLink( $ns[$result->ns_dis].':'.$result->title_dis ,'');
+
+ return "$from $edit => $to";
+ }
+}
+
+function wfSpecialDisambiguations() {
+ list( $limit, $offset ) = wfCheckLimits();
+
+ $sd = new DisambiguationsPage();
+
+ return $sd->doQuery( $offset, $limit );
+
+}
+?>
# Links to subfunctions
$r .= "<UL>\n" ;
- #$r .= "<li>".getMPL("disambiguations")."</li>\n" ; # Doesn't work
+ $r .= "<li>".$sk->makeKnownLink( sns().':Disambiguations', wfMsg('disambiguations')) . "</li>\n";
$r .= '<li>'.$sk->makeKnownLink( sns().':DoubleRedirects', wfMsg('doubleredirects')) . "</li>\n";
$r .= '<li>'.$sk->makeKnownLink( sns().':BrokenRedirects', wfMsg('brokenredirects')) . "</li>\n";
#$r .= "<li>".getMPL("selflinks")."</li>\n" ; # Doesn't work
return $s ;
}
-# Broken function
-# Suggest deprecating this in favour of a Special:Whatlinkshere with prev/next links [TS]
-function wfSpecialDisambiguations() {
- global $wgUser, $wgOut, $wgLang, $wgTitle;
- $fname = "wfSpecialDisambiguations";
-
- list( $limit, $offset ) = wfCheckLimits();
- $dbr =& wfGetDB( DB_SLAVE );
- extract( $dbr->tableNames( 'links', 'cur' ) );
-
- $dp = $dbr->strencode( wfMsg("disambiguationspage") );
-
- die( "wfSpecialDisambiguation is broken. Link tables have changed...\n" );
-
- $sql = "SELECT la.l_from,la.l_to,"
- . " lb.l_from AS source,lb.l_to AS dest,"
- . " c.cur_id, c.cur_title AS dt"
- . " FROM $links AS la, $links AS lb, $cur AS c, $cur AS d"
- . " WHERE la.l_from='{$dp}'"
- . " AND la.l_to=lb.l_to"
- . " AND la.l_from<>lb.l_from"
- . " AND c.cur_id=lb.l_to"
- . " AND c.cur_namespace=0"
- . " AND d.cur_title=lb.l_from"
- . " AND d.cur_namespace=0"
- . " LIMIT {$offset}, {$limit}";
-
- $res = $dbr->query( $sql, $fname );
-
- $sk = $wgUser->getSkin();
-
- $top = "<p>".wfMsg( "disambiguationstext", $sk->makeKnownLink( $dp ) )."</p><br>\n";
- $top = getMaintenancePageBacklink( "disambiguations" ) . $top;
- $top .= wfShowingResults( $offset, $limit );
- $wgOut->addHTML( "<p>{$top}\n" );
- $sl = wfViewPrevNext( $offset, $limit, "REPLACETHIS" ) ;
- $sl = str_replace ( "REPLACETHIS" , sns().":Maintenance&subfunction=disambiguations" , $sl ) ;
- $wgOut->addHTML( "<br>{$sl}\n" );
-
- $s = "<ol start=" . ( $offset + 1 ) . ">";
- while ( $obj = $dbr->fetchObject( $res ) ) {
- $l1 = $sk->makeKnownLink ( $obj->source , "" , "redirect=no" ) ;
- $l2 = $sk->makeKnownLink ( $obj->dt ) ;
- $l3 = $sk->makeBrokenLink ( $obj->source , "(".wfMsg("qbedit").")" , "redirect=no" ) ;
- $s .= "<li>{$l1} {$l3} => {$l2}</li>\n" ;
- }
- $dbr->freeResult( $res );
- $s .= '</ol>';
- $wgOut->addHTML( $s );
- $wgOut->addHTML( "<p>{$sl}\n" );
-}
-
-# DoubleRedirects and BrokenRedirects are now using the QueryPage class.
+# Disambiguations, DoubleRedirects and BrokenRedirects are now using the
+# QueryPage class. Code is in a Special*.php file.
function wfSpecialDoubleRedirects() {
global $wgOut;
$t = Title::makeTitle( NS_SPECIAL, "DoubleRedirects" );
$wgOut->redirect ($t->getFullURL());
}
+function wfSpecialDisambiguations() {
+ global $wgOut;
+ $t = Title::makeTitle( NS_SPECIAL, "Disambiguations" );
+ $wgOut->redirect ($t->getFullURL());
+}
+
+
# This doesn't really work anymore, because self-links are now displayed as
# unlinked bold text, and are not entered into the link table.
function wfSpecialSelfLinks() {