MediaWiki REL1_30
SpecialListredirects.php
Go to the documentation of this file.
1<?php
29
35 function __construct( $name = 'Listredirects' ) {
36 parent::__construct( $name );
37 }
38
39 public function isExpensive() {
40 return true;
41 }
42
43 function isSyndicated() {
44 return false;
45 }
46
47 function sortDescending() {
48 return false;
49 }
50
51 public function getQueryInfo() {
52 return [
53 'tables' => [ 'p1' => 'page', 'redirect', 'p2' => 'page' ],
54 'fields' => [ 'namespace' => 'p1.page_namespace',
55 'title' => 'p1.page_title',
56 'value' => 'p1.page_title',
57 'rd_namespace',
58 'rd_title',
59 'rd_fragment',
60 'rd_interwiki',
61 'redirid' => 'p2.page_id' ],
62 'conds' => [ 'p1.page_is_redirect' => 1 ],
63 'join_conds' => [ 'redirect' => [
64 'LEFT JOIN', 'rd_from=p1.page_id' ],
65 'p2' => [ 'LEFT JOIN', [
66 'p2.page_namespace=rd_namespace',
67 'p2.page_title=rd_title' ] ] ]
68 ];
69 }
70
71 function getOrderFields() {
72 return [ 'p1.page_namespace', 'p1.page_title' ];
73 }
74
81 function preprocessResults( $db, $res ) {
82 if ( !$res->numRows() ) {
83 return;
84 }
85
86 $batch = new LinkBatch;
87 foreach ( $res as $row ) {
88 $batch->add( $row->namespace, $row->title );
89 $redirTarget = $this->getRedirectTarget( $row );
90 if ( $redirTarget ) {
91 $batch->addObj( $redirTarget );
92 }
93 }
94 $batch->execute();
95
96 // Back to start for display
97 $res->seek( 0 );
98 }
99
104 protected function getRedirectTarget( $row ) {
105 if ( isset( $row->rd_title ) ) {
106 return Title::makeTitle( $row->rd_namespace,
107 $row->rd_title, $row->rd_fragment,
108 $row->rd_interwiki
109 );
110 } else {
111 $title = Title::makeTitle( $row->namespace, $row->title );
112 $article = WikiPage::factory( $title );
113
114 return $article->getRedirectTarget();
115 }
116 }
117
123 function formatResult( $skin, $result ) {
125 # Make a link to the redirect itself
126 $rd_title = Title::makeTitle( $result->namespace, $result->title );
127 $rd_link = $linkRenderer->makeLink(
128 $rd_title,
129 null,
130 [],
131 [ 'redirect' => 'no' ]
132 );
133
134 # Find out where the redirect leads
135 $target = $this->getRedirectTarget( $result );
136 if ( $target ) {
137 # Make a link to the destination page
138 $lang = $this->getLanguage();
139 $arr = $lang->getArrow() . $lang->getDirMark();
140 $targetLink = $linkRenderer->makeLink( $target, $target->getFullText() );
141
142 return "$rd_link $arr $targetLink";
143 } else {
144 return "<del>$rd_link</del>";
145 }
146 }
147
148 protected function getGroupName() {
149 return 'pages';
150 }
151}
Class representing a list of titles The execute() method checks them all for existence and adds them ...
Definition LinkBatch.php:34
add( $ns, $dbkey)
Definition LinkBatch.php:80
Special:Listredirects - Lists all the redirects on the wiki.
getQueryInfo()
Subclasses return an SQL query here, formatted as an array with the following keys: tables => Table(s...
isExpensive()
Is this query expensive (for some definition of expensive)? Then we don't let it run in miser mode.
__construct( $name='Listredirects')
getGroupName()
Under which header this special page is listed in Special:SpecialPages See messages 'specialpages-gro...
isSyndicated()
Sometime we don't want to build rss / atom feeds.
sortDescending()
Override to sort by increasing values.
formatResult( $skin, $result)
preprocessResults( $db, $res)
Cache page existence for performance.
getOrderFields()
Subclasses return an array of fields to order by here.
This is a class for doing query pages; since they're almost all the same, we factor out some of the f...
Definition QueryPage.php:34
getLanguage()
Shortcut to get user's language.
MediaWiki Linker LinkRenderer null $linkRenderer
static factory(Title $title)
Create a WikiPage object of the appropriate class for the given title.
Definition WikiPage.php:121
Result wrapper for grabbing data queried from an IDatabase object.
$res
Definition database.txt:21
Basic database interface for live and lazy-loaded relation database handles.
Definition IDatabase.php:40
$batch
Definition linkcache.txt:23
if(!isset( $args[0])) $lang