MediaWiki REL1_28
BlockListPager.php
Go to the documentation of this file.
1<?php
26
27 protected $conds;
28 protected $page;
29
34 function __construct( $page, $conds ) {
35 $this->page = $page;
36 $this->conds = $conds;
37 $this->mDefaultDirection = IndexPager::DIR_DESCENDING;
38 parent::__construct( $page->getContext() );
39 }
40
41 function getFieldNames() {
42 static $headers = null;
43
44 if ( $headers === null ) {
45 $headers = [
46 'ipb_timestamp' => 'blocklist-timestamp',
47 'ipb_target' => 'blocklist-target',
48 'ipb_expiry' => 'blocklist-expiry',
49 'ipb_by' => 'blocklist-by',
50 'ipb_params' => 'blocklist-params',
51 'ipb_reason' => 'blocklist-reason',
52 ];
53 foreach ( $headers as $key => $val ) {
54 $headers[$key] = $this->msg( $val )->text();
55 }
56 }
57
58 return $headers;
59 }
60
61 function formatValue( $name, $value ) {
62 static $msg = null;
63 if ( $msg === null ) {
64 $keys = [
65 'anononlyblock',
66 'createaccountblock',
67 'noautoblockblock',
68 'emailblock',
69 'blocklist-nousertalk',
70 'unblocklink',
71 'change-blocklink',
72 ];
73
74 foreach ( $keys as $key ) {
75 $msg[$key] = $this->msg( $key )->escaped();
76 }
77 }
78
80 $row = $this->mCurrentRow;
81
82 $language = $this->getLanguage();
83
84 $formatted = '';
85
86 switch ( $name ) {
87 case 'ipb_timestamp':
88 $formatted = htmlspecialchars( $language->userTimeAndDate( $value, $this->getUser() ) );
89 break;
90
91 case 'ipb_target':
92 if ( $row->ipb_auto ) {
93 $formatted = $this->msg( 'autoblockid', $row->ipb_id )->parse();
94 } else {
95 list( $target, $type ) = Block::parseTarget( $row->ipb_address );
96 switch ( $type ) {
98 case Block::TYPE_IP:
99 $formatted = Linker::userLink( $target->getId(), $target );
100 $formatted .= Linker::userToolLinks(
101 $target->getId(),
102 $target,
103 false,
105 );
106 break;
108 $formatted = htmlspecialchars( $target );
109 }
110 }
111 break;
112
113 case 'ipb_expiry':
114 $formatted = htmlspecialchars( $language->formatExpiry(
115 $value,
116 /* User preference timezone */true
117 ) );
118 if ( $this->getUser()->isAllowed( 'block' ) ) {
119 if ( $row->ipb_auto ) {
120 $links[] = Linker::linkKnown(
121 SpecialPage::getTitleFor( 'Unblock' ),
122 $msg['unblocklink'],
123 [],
124 [ 'wpTarget' => "#{$row->ipb_id}" ]
125 );
126 } else {
127 $links[] = Linker::linkKnown(
128 SpecialPage::getTitleFor( 'Unblock', $row->ipb_address ),
129 $msg['unblocklink']
130 );
131 $links[] = Linker::linkKnown(
132 SpecialPage::getTitleFor( 'Block', $row->ipb_address ),
133 $msg['change-blocklink']
134 );
135 }
136 $formatted .= ' ' . Html::rawElement(
137 'span',
138 [ 'class' => 'mw-blocklist-actions' ],
139 $this->msg( 'parentheses' )->rawParams(
140 $language->pipeList( $links ) )->escaped()
141 );
142 }
143 if ( $value !== 'infinity' ) {
145 $formatted .= '<br />' . $this->msg(
146 'ipb-blocklist-duration-left',
147 $language->formatDuration(
148 $timestamp->getTimestamp() - time(),
149 // reasonable output
150 [
151 'minutes',
152 'hours',
153 'days',
154 'years',
155 ]
156 )
157 )->escaped();
158 }
159 break;
160
161 case 'ipb_by':
162 if ( isset( $row->by_user_name ) ) {
163 $formatted = Linker::userLink( $value, $row->by_user_name );
164 $formatted .= Linker::userToolLinks( $value, $row->by_user_name );
165 } else {
166 $formatted = htmlspecialchars( $row->ipb_by_text ); // foreign user?
167 }
168 break;
169
170 case 'ipb_reason':
171 $formatted = Linker::formatComment( $value );
172 break;
173
174 case 'ipb_params':
175 $properties = [];
176 if ( $row->ipb_anon_only ) {
177 $properties[] = $msg['anononlyblock'];
178 }
179 if ( $row->ipb_create_account ) {
180 $properties[] = $msg['createaccountblock'];
181 }
182 if ( $row->ipb_user && !$row->ipb_enable_autoblock ) {
183 $properties[] = $msg['noautoblockblock'];
184 }
185
186 if ( $row->ipb_block_email ) {
187 $properties[] = $msg['emailblock'];
188 }
189
190 if ( !$row->ipb_allow_usertalk ) {
191 $properties[] = $msg['blocklist-nousertalk'];
192 }
193
194 $formatted = $language->commaList( $properties );
195 break;
196
197 default:
198 $formatted = "Unable to format $name";
199 break;
200 }
201
202 return $formatted;
203 }
204
205 function getQueryInfo() {
206 $info = [
207 'tables' => [ 'ipblocks', 'user' ],
208 'fields' => [
209 'ipb_id',
210 'ipb_address',
211 'ipb_user',
212 'ipb_by',
213 'ipb_by_text',
214 'by_user_name' => 'user_name',
215 'ipb_reason',
216 'ipb_timestamp',
217 'ipb_auto',
218 'ipb_anon_only',
219 'ipb_create_account',
220 'ipb_enable_autoblock',
221 'ipb_expiry',
222 'ipb_range_start',
223 'ipb_range_end',
224 'ipb_deleted',
225 'ipb_block_email',
226 'ipb_allow_usertalk',
227 ],
228 'conds' => $this->conds,
229 'join_conds' => [ 'user' => [ 'LEFT JOIN', 'user_id = ipb_by' ] ]
230 ];
231
232 # Filter out any expired blocks
233 $db = $this->getDatabase();
234 $info['conds'][] = 'ipb_expiry > ' . $db->addQuotes( $db->timestamp() );
235
236 # Is the user allowed to see hidden blocks?
237 if ( !$this->getUser()->isAllowed( 'hideuser' ) ) {
238 $info['conds']['ipb_deleted'] = 0;
239 }
240
241 return $info;
242 }
243
244 protected function getTableClass() {
245 return parent::getTableClass() . ' mw-blocklist';
246 }
247
248 function getIndexField() {
249 return 'ipb_timestamp';
250 }
251
252 function getDefaultSort() {
253 return 'ipb_timestamp';
254 }
255
256 function isFieldSortable( $name ) {
257 return false;
258 }
259
265 # Do a link batch query
266 $lb = new LinkBatch;
267 $lb->setCaller( __METHOD__ );
268
269 foreach ( $result as $row ) {
270 $lb->add( NS_USER, $row->ipb_address );
271 $lb->add( NS_USER_TALK, $row->ipb_address );
272
273 if ( isset( $row->by_user_name ) ) {
274 $lb->add( NS_USER, $row->by_user_name );
275 $lb->add( NS_USER_TALK, $row->by_user_name );
276 }
277 }
278
279 $lb->execute();
280 }
281
282}
getQueryInfo()
This function should be overridden to provide all parameters needed for the main paged query.
isFieldSortable( $name)
Return true if the named field should be sortable by the UI, false otherwise.
__construct( $page, $conds)
getFieldNames()
An array mapping database field names to a textual description of the field name, for use in the tabl...
preprocessResults( $result)
Do a LinkBatch query to minimise database load when generating all these links.
formatValue( $name, $value)
Format a table cell.
getDefaultSort()
The database field name used as a default sort order.
static parseTarget( $target)
From an existing Block, get the target and the type of target.
Definition Block.php:1305
const TYPE_RANGE
Definition Block.php:80
const TYPE_USER
Definition Block.php:78
const TYPE_IP
Definition Block.php:79
getUser()
Get the User object.
msg()
Get a Message object with context set Parameters are the same as wfMessage()
getLanguage()
Get the Language object.
getDatabase()
Get the Database object in use.
const DIR_DESCENDING
Class representing a list of titles The execute() method checks them all for existence and adds them ...
Definition LinkBatch.php:32
setCaller( $caller)
Use ->setCaller( METHOD ) to indicate which code is using this class.
Definition LinkBatch.php:60
static userLink( $userId, $userName, $altUserName=false)
Make user link (or user contributions for unregistered users)
Definition Linker.php:984
static linkKnown( $target, $html=null, $customAttribs=[], $query=[], $options=[ 'known'])
Identical to link(), except $options defaults to 'known'.
Definition Linker.php:255
const TOOL_LINKS_NOBLOCK
Flags for userToolLinks()
Definition Linker.php:38
static userToolLinks( $userId, $userText, $redContribsWhenNoEdits=false, $flags=0, $edits=null)
Generate standard user tool links (talk, contributions, block link, etc.)
Definition Linker.php:1017
static formatComment( $comment, $title=null, $local=false, $wikiId=null)
This function is called by all recent changes variants, by the page history, and by the user contribu...
Definition Linker.php:1180
Library for creating and parsing MW-style timestamps.
static getTitleFor( $name, $subpage=false, $fragment='')
Get a localised Title object for a specified special page name If you don't need a full Title object,...
Table-based display with a user-selectable sort order.
deferred txt A few of the database updates required by various functions here can be deferred until after the result page is displayed to the user For updating the view updating the linked to tables after a etc PHP does not yet have any way to tell the server to actually return and disconnect while still running these but it might have such a feature in the future We handle these by creating a deferred update object and putting those objects on a global list
Definition deferred.txt:11
This document is intended to provide useful advice for parties seeking to redistribute MediaWiki to end users It s targeted particularly at maintainers for Linux since it s been observed that distribution packages of MediaWiki often break We ve consistently had to recommend that users seeking support use official tarballs instead of their distribution s and this often solves whatever problem the user is having It would be nice if this could such as
const NS_USER
Definition Defines.php:58
const NS_USER_TALK
Definition Defines.php:59
namespace are movable Hooks may change this value to override the return value of MWNamespace::isMovable(). 'NewDifferenceEngine' do that in ParserLimitReportFormat instead use this to modify the parameters of the image and a DIV can begin in one section and end in another Make sure your code can handle that case gracefully See the EditSectionClearerLink extension for an example zero but section is usually empty its values are the globals values before the output is cached one of or reset my talk my contributions etc etc otherwise the built in rate limiting checks are if enabled allows for interception of redirect as a string mapping parameter names to values & $type
Definition hooks.txt:2568
The index of the header message $result[1]=The index of the body text message $result[2 through n]=Parameters passed to body text message. Please note the header message cannot receive/use parameters. 'ImportHandleLogItemXMLTag':When parsing a XML tag in a log item. Return false to stop further processing of the tag $reader:XMLReader object $logInfo:Array of information 'ImportHandlePageXMLTag':When parsing a XML tag in a page. Return false to stop further processing of the tag $reader:XMLReader object & $pageInfo:Array of information 'ImportHandleRevisionXMLTag':When parsing a XML tag in a page revision. Return false to stop further processing of the tag $reader:XMLReader object $pageInfo:Array of page information $revisionInfo:Array of revision information 'ImportHandleToplevelXMLTag':When parsing a top level XML tag. Return false to stop further processing of the tag $reader:XMLReader object 'ImportHandleUploadXMLTag':When parsing a XML tag in a file upload. Return false to stop further processing of the tag $reader:XMLReader object $revisionInfo:Array of information 'ImportLogInterwikiLink':Hook to change the interwiki link used in log entries and edit summaries for transwiki imports. & $fullInterwikiPrefix:Interwiki prefix, may contain colons. & $pageTitle:String that contains page title. 'ImportSources':Called when reading from the $wgImportSources configuration variable. Can be used to lazy-load the import sources list. & $importSources:The value of $wgImportSources. Modify as necessary. See the comment in DefaultSettings.php for the detail of how to structure this array. 'InfoAction':When building information to display on the action=info page. $context:IContextSource object & $pageInfo:Array of information 'InitializeArticleMaybeRedirect':MediaWiki check to see if title is a redirect. & $title:Title object for the current page & $request:WebRequest & $ignoreRedirect:boolean to skip redirect check & $target:Title/string of redirect target & $article:Article object 'InternalParseBeforeLinks':during Parser 's internalParse method before links but after nowiki/noinclude/includeonly/onlyinclude and other processings. & $parser:Parser object & $text:string containing partially parsed text & $stripState:Parser 's internal StripState object 'InternalParseBeforeSanitize':during Parser 's internalParse method just before the parser removes unwanted/dangerous HTML tags and after nowiki/noinclude/includeonly/onlyinclude and other processings. Ideal for syntax-extensions after template/parser function execution which respect nowiki and HTML-comments. & $parser:Parser object & $text:string containing partially parsed text & $stripState:Parser 's internal StripState object 'InterwikiLoadPrefix':When resolving if a given prefix is an interwiki or not. Return true without providing an interwiki to continue interwiki search. $prefix:interwiki prefix we are looking for. & $iwData:output array describing the interwiki with keys iw_url, iw_local, iw_trans and optionally iw_api and iw_wikiid. 'InvalidateEmailComplete':Called after a user 's email has been invalidated successfully. $user:user(object) whose email is being invalidated 'IRCLineURL':When constructing the URL to use in an IRC notification. Callee may modify $url and $query, URL will be constructed as $url . $query & $url:URL to index.php & $query:Query string $rc:RecentChange object that triggered url generation 'IsFileCacheable':Override the result of Article::isFileCacheable()(if true) & $article:article(object) being checked 'IsTrustedProxy':Override the result of IP::isTrustedProxy() & $ip:IP being check & $result:Change this value to override the result of IP::isTrustedProxy() 'IsUploadAllowedFromUrl':Override the result of UploadFromUrl::isAllowedUrl() $url:URL used to upload from & $allowed:Boolean indicating if uploading is allowed for given URL 'isValidEmailAddr':Override the result of Sanitizer::validateEmail(), for instance to return false if the domain name doesn 't match your organization. $addr:The e-mail address entered by the user & $result:Set this and return false to override the internal checks 'isValidPassword':Override the result of User::isValidPassword() $password:The password entered by the user & $result:Set this and return false to override the internal checks $user:User the password is being validated for 'Language::getMessagesFileName':$code:The language code or the language we 're looking for a messages file for & $file:The messages file path, you can override this to change the location. 'LanguageGetMagic':DEPRECATED! Use $magicWords in a file listed in $wgExtensionMessagesFiles instead. Use this to define synonyms of magic words depending of the language & $magicExtensions:associative array of magic words synonyms $lang:language code(string) 'LanguageGetNamespaces':Provide custom ordering for namespaces or remove namespaces. Do not use this hook to add namespaces. Use CanonicalNamespaces for that. & $namespaces:Array of namespaces indexed by their numbers 'LanguageGetSpecialPageAliases':DEPRECATED! Use $specialPageAliases in a file listed in $wgExtensionMessagesFiles instead. Use to define aliases of special pages names depending of the language & $specialPageAliases:associative array of magic words synonyms $lang:language code(string) 'LanguageGetTranslatedLanguageNames':Provide translated language names. & $names:array of language code=> language name $code:language of the preferred translations 'LanguageLinks':Manipulate a page 's language links. This is called in various places to allow extensions to define the effective language links for a page. $title:The page 's Title. & $links:Associative array mapping language codes to prefixed links of the form "language:title". & $linkFlags:Associative array mapping prefixed links to arrays of flags. Currently unused, but planned to provide support for marking individual language links in the UI, e.g. for featured articles. 'LanguageSelector':Hook to change the language selector available on a page. $out:The output page. $cssClassName:CSS class name of the language selector. 'LinkBegin':DEPRECATED! Use HtmlPageLinkRendererBegin instead. Used when generating internal and interwiki links in Linker::link(), before processing starts. Return false to skip default processing and return $ret. See documentation for Linker::link() for details on the expected meanings of parameters. $skin:the Skin object $target:the Title that the link is pointing to & $html:the contents that the< a > tag should have(raw HTML) $result
Definition hooks.txt:1937
namespace are movable Hooks may change this value to override the return value of MWNamespace::isMovable(). 'NewDifferenceEngine' do that in ParserLimitReportFormat instead use this to modify the parameters of the image and a DIV can begin in one section and end in another Make sure your code can handle that case gracefully See the EditSectionClearerLink extension for an example zero but section is usually empty its values are the globals values before the output is cached one of or reset my talk page
Definition hooks.txt:2543
Allows to change the fields on the form that will be generated $name
Definition hooks.txt:304
if( $limit) $timestamp
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency which acts as the top level factory for services in MediaWiki which can be used to gain access to default instances of various services MediaWikiServices however also allows new services to be defined and default services to be redefined Services are defined or redefined by providing a callback the instantiator that will return a new instance of the service When it will create an instance of MediaWikiServices and populate it with the services defined in the files listed by thereby bootstrapping the DI framework Per $wgServiceWiringFiles lists includes ServiceWiring php
Definition injection.txt:37