Handle nested li in ol or ul. That happens when someone use something like:
[lhc/web/wiklou.git] / includes / SpecialDoubleRedirects.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 DoubleRedirectsPage extends PageQueryPage {
19
20 function getName() {
21 return 'DoubleRedirects';
22 }
23
24 function isExpensive( ) { return true; }
25 function isSyndicated() { return false; }
26
27 function getPageHeader( ) {
28 #FIXME : probably need to add a backlink to the maintenance page.
29 return '<p>'.wfMsg("doubleredirectstext")."</p><br />\n";
30 }
31
32 function getSQLText( &$dbr, $namespace = null, $title = null ) {
33
34 extract( $dbr->tableNames( 'page', 'pagelinks' ) );
35
36 $limitToTitle = !( $namespace === null && $title === null );
37 $sql = $limitToTitle ? "SELECT" : "SELECT 'DoubleRedirects' as type," ;
38 $sql .=
39 " pa.page_namespace as namespace, pa.page_title as title," .
40 " pb.page_namespace as nsb, pb.page_title as tb," .
41 " pc.page_namespace as nsc, pc.page_title as tc" .
42 " FROM $pagelinks AS la, $pagelinks AS lb, $page AS pa, $page AS pb, $page AS pc" .
43 " WHERE pa.page_is_redirect=1 AND pb.page_is_redirect=1" .
44 " AND la.pl_from=pa.page_id" .
45 " AND la.pl_namespace=pb.page_namespace" .
46 " AND la.pl_title=pb.page_title" .
47 " AND lb.pl_from=pb.page_id" .
48 " AND lb.pl_namespace=pc.page_namespace" .
49 " AND lb.pl_title=pc.page_title";
50
51 if( $limitToTitle ) {
52 $encTitle = $dbr->addQuotes( $title );
53 $sql .= " AND pa.page_namespace=$namespace" .
54 " AND pa.page_title=$encTitle";
55 }
56
57 return $sql;
58 }
59
60 function getSQL() {
61 $dbr =& wfGetDB( DB_SLAVE );
62 return $this->getSQLText( $dbr );
63 }
64
65 function getOrder() {
66 return '';
67 }
68
69 function formatResult( $skin, $result ) {
70 global $wgContLang;
71
72 $fname = 'DoubleRedirectsPage::formatResult';
73 $titleA = Title::makeTitle( $result->namespace, $result->title );
74
75 if ( $result && !isset( $result->nsb ) ) {
76 $dbr =& wfGetDB( DB_SLAVE );
77 $sql = $this->getSQLText( $dbr, $result->namespace, $result->title );
78 $res = $dbr->query( $sql, $fname );
79 if ( $res ) {
80 $result = $dbr->fetchObject( $res );
81 $dbr->freeResult( $res );
82 }
83 }
84 if ( !$result ) {
85 return '';
86 }
87
88 $titleB = Title::makeTitle( $result->nsb, $result->tb );
89 $titleC = Title::makeTitle( $result->nsc, $result->tc );
90
91 $linkA = $skin->makeKnownLinkObj( $titleA,'', 'redirect=no' );
92 $edit = $skin->makeBrokenLinkObj( $titleA, "(".wfMsg("qbedit").")" , 'redirect=no');
93 $linkB = $skin->makeKnownLinkObj( $titleB, '', 'redirect=no' );
94 $linkC = $skin->makeKnownLinkObj( $titleC );
95 $arr = $wgContLang->isRTL() ? '&larr;' : '&rarr;';
96
97 return( "{$linkA} {$edit} {$arr} {$linkB} {$arr} {$linkC}" );
98 }
99 }
100
101 /**
102 * constructor
103 */
104 function wfSpecialDoubleRedirects() {
105 list( $limit, $offset ) = wfCheckLimits();
106
107 $sdr = new DoubleRedirectsPage();
108
109 return $sdr->doQuery( $offset, $limit );
110
111 }
112 ?>