From: Antoine Musso
Date: Sat, 21 Aug 2004 22:05:47 +0000 (+0000)
Subject: Moving disambiguations code from specialMaintenance. Fixing the function meantime
X-Git-Tag: 1.5.0alpha1~2265
X-Git-Url: https://git.cyclocoop.org/%7B%24www_url%7Dadmin/compta/comptes/journal.php?a=commitdiff_plain;h=fe299887d8c5fcbfcc9defeb3437564c2b47851c;p=lhc%2Fweb%2Fwiklou.git
Moving disambiguations code from specialMaintenance. Fixing the function meantime
---
diff --git a/includes/SpecialDisambiguations.php b/includes/SpecialDisambiguations.php
new file mode 100644
index 0000000000..b0a28bad60
--- /dev/null
+++ b/includes/SpecialDisambiguations.php
@@ -0,0 +1,60 @@
+'.wfMsg("disambiguationstext", wfMsg("disambiguationspage"))."
\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 );
+
+}
+?>
diff --git a/includes/SpecialMaintenance.php b/includes/SpecialMaintenance.php
index 220da9af5a..8b76d3e65b 100644
--- a/includes/SpecialMaintenance.php
+++ b/includes/SpecialMaintenance.php
@@ -52,7 +52,7 @@ function wfSpecialMaintenance( $par=NULL ) {
# Links to subfunctions
$r .= "\n" ;
- #$r .= "- ".getMPL("disambiguations")."
\n" ; # Doesn't work
+ $r .= "- ".$sk->makeKnownLink( sns().':Disambiguations', wfMsg('disambiguations')) . "
\n";
$r .= '- '.$sk->makeKnownLink( sns().':DoubleRedirects', wfMsg('doubleredirects')) . "
\n";
$r .= '- '.$sk->makeKnownLink( sns().':BrokenRedirects', wfMsg('brokenredirects')) . "
\n";
#$r .= "- ".getMPL("selflinks")."
\n" ; # Doesn't work
@@ -107,60 +107,9 @@ function getMaintenancePageBacklink( $subfunction ) {
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 = "".wfMsg( "disambiguationstext", $sk->makeKnownLink( $dp ) )."
\n";
- $top = getMaintenancePageBacklink( "disambiguations" ) . $top;
- $top .= wfShowingResults( $offset, $limit );
- $wgOut->addHTML( "{$top}\n" );
- $sl = wfViewPrevNext( $offset, $limit, "REPLACETHIS" ) ;
- $sl = str_replace ( "REPLACETHIS" , sns().":Maintenance&subfunction=disambiguations" , $sl ) ;
- $wgOut->addHTML( "
{$sl}\n" );
-
- $s = "
";
- 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 .= "- {$l1} {$l3} => {$l2}
\n" ;
- }
- $dbr->freeResult( $res );
- $s .= '
';
- $wgOut->addHTML( $s );
- $wgOut->addHTML( "{$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" );
@@ -173,6 +122,13 @@ function wfSpecialBrokenRedirects() {
$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() {
diff --git a/includes/SpecialPage.php b/includes/SpecialPage.php
index 4737db6484..a497da4914 100644
--- a/includes/SpecialPage.php
+++ b/includes/SpecialPage.php
@@ -15,6 +15,7 @@ global $wgSpecialPages;
/* private */ $wgSpecialPages = array(
'DoubleRedirects' => new UnlistedSpecialPage ( 'DoubleRedirects' ),
'BrokenRedirects' => new UnlistedSpecialPage ( 'BrokenRedirects' ),
+ 'Disambiguations' => new UnlistedSpecialPage ( 'Disambiguations' ),
"Userlogin" => new SpecialPage( "Userlogin" ),
"Userlogout" => new UnlistedSpecialPage( "Userlogout" ),