b227ba66421e8f4c86fa8e52262a1e901571fdc9
[lhc/web/wiklou.git] / includes / SpecialDisambiguations.php
1 <?php
2 /**
3 *
4 * @package MediaWiki
5 * @subpackage SpecialPage
6 */
7
8 /**
9 *
10 */
11 require_once('QueryPage.php');
12
13 /**
14 *
15 * @package MediaWiki
16 * @subpackage SpecialPage
17 */
18 class DisambiguationsPage extends PageQueryPage {
19
20 function getName() {
21 return 'Disambiguations';
22 }
23
24 function isExpensive( ) { return true; }
25 function isSyndicated() { return false; }
26
27 function getPageHeader( ) {
28 global $wgUser;
29 $sk = $wgUser->getSkin();
30
31 #FIXME : probably need to add a backlink to the maintenance page.
32 return '<p>'.wfMsg("disambiguationstext", $sk->makeKnownLink(wfMsgForContent('disambiguationspage')) )."</p><br />\n";
33 }
34
35 function getSQL() {
36 $dbr =& wfGetDB( DB_SLAVE );
37 extract( $dbr->tableNames( 'page', 'pagelinks' ) );
38
39 $dp = Title::newFromText(wfMsgForContent("disambiguationspage"));
40 $id = $dp->getArticleId();
41 $dns = $dp->getNamespace();
42 $dtitle = $dbr->addQuotes( $dp->getDBkey() );
43
44 $sql = "SELECT 'Disambiguations' as type,"
45 . "la.pl_namespace AS namespace, la.pl_title AS title, la.pl_from AS value"
46 . " FROM {$pagelinks} AS la, {$pagelinks} AS lb,"
47 . " {$page} AS pa, {$page} AS pb"
48 . " WHERE pb.page_namespace = $dns"
49 . " AND pb.page_title = $dtitle" # disambiguation pages
50 . " AND lb.pl_title = pb.page_title" # title of pages that are disamb
51 . " AND pa.page_id = lb.pl_from" # id of page pointing to a disamb
52 . " AND la.pl_title != $dtitle" # exclude the link
53 . " AND la.pl_title = pa.page_title "; # title of those
54 return $sql;
55 }
56
57 function getOrder() {
58 return '';
59 }
60
61 function formatResult( $skin, $result ) {
62 global $wgContLang ;
63 $title = Title::newFromId( $result->value );
64 $dp = Title::makeTitle( $result->namespace, $result->title );
65
66 $from = $skin->makeKnownLinkObj( $title,'');
67 $edit = $skin->makeBrokenLinkObj( $title, "(".wfMsg("qbedit").")" , 'redirect=no');
68 $to = $skin->makeKnownLinkObj( $dp,'');
69
70 return "$from $edit => $to";
71 }
72 }
73
74 /**
75 * Constructor
76 */
77 function wfSpecialDisambiguations() {
78 list( $limit, $offset ) = wfCheckLimits();
79
80 $sd = new DisambiguationsPage();
81
82 return $sd->doQuery( $offset, $limit );
83 }
84 ?>