MediaWiki REL1_31
ProtectedPagesPager.php
Go to the documentation of this file.
1<?php
23
25
26 public $mForm, $mConds;
28
33
47 function __construct( $form, $conds = [], $type, $level, $namespace,
48 $sizetype = '', $size = 0, $indefonly = false, $cascadeonly = false, $noredirect = false,
50 ) {
51 $this->mForm = $form;
52 $this->mConds = $conds;
53 $this->type = ( $type ) ? $type : 'edit';
54 $this->level = $level;
55 $this->namespace = $namespace;
56 $this->sizetype = $sizetype;
57 $this->size = intval( $size );
58 $this->indefonly = (bool)$indefonly;
59 $this->cascadeonly = (bool)$cascadeonly;
60 $this->noredirect = (bool)$noredirect;
61 $this->linkRenderer = $linkRenderer;
62 parent::__construct( $form->getContext() );
63 }
64
66 # Do a link batch query
67 $lb = new LinkBatch;
68 $userids = [];
69
70 foreach ( $result as $row ) {
71 $lb->add( $row->page_namespace, $row->page_title );
72 // field is nullable, maybe null on old protections
73 if ( $row->log_user !== null ) {
74 $userids[] = $row->log_user;
75 }
76 }
77
78 // fill LinkBatch with user page and user talk
79 if ( count( $userids ) ) {
80 $userCache = UserCache::singleton();
81 $userCache->doQuery( $userids, [], __METHOD__ );
82 foreach ( $userids as $userid ) {
83 $name = $userCache->getProp( $userid, 'name' );
84 if ( $name !== false ) {
85 $lb->add( NS_USER, $name );
86 $lb->add( NS_USER_TALK, $name );
87 }
88 }
89 }
90
91 $lb->execute();
92 }
93
94 function getFieldNames() {
95 static $headers = null;
96
97 if ( $headers == [] ) {
98 $headers = [
99 'log_timestamp' => 'protectedpages-timestamp',
100 'pr_page' => 'protectedpages-page',
101 'pr_expiry' => 'protectedpages-expiry',
102 'log_user' => 'protectedpages-performer',
103 'pr_params' => 'protectedpages-params',
104 'log_comment' => 'protectedpages-reason',
105 ];
106 foreach ( $headers as $key => $val ) {
107 $headers[$key] = $this->msg( $val )->text();
108 }
109 }
110
111 return $headers;
112 }
113
120 function formatValue( $field, $value ) {
122 $row = $this->mCurrentRow;
123
124 switch ( $field ) {
125 case 'log_timestamp':
126 // when timestamp is null, this is a old protection row
127 if ( $value === null ) {
128 $formatted = Html::rawElement(
129 'span',
130 [ 'class' => 'mw-protectedpages-unknown' ],
131 $this->msg( 'protectedpages-unknown-timestamp' )->escaped()
132 );
133 } else {
134 $formatted = htmlspecialchars( $this->getLanguage()->userTimeAndDate(
135 $value, $this->getUser() ) );
136 }
137 break;
138
139 case 'pr_page':
140 $title = Title::makeTitleSafe( $row->page_namespace, $row->page_title );
141 if ( !$title ) {
142 $formatted = Html::element(
143 'span',
144 [ 'class' => 'mw-invalidtitle' ],
146 $this->getContext(),
147 $row->page_namespace,
148 $row->page_title
149 )
150 );
151 } else {
152 $formatted = $this->linkRenderer->makeLink( $title );
153 }
154 if ( !is_null( $row->page_len ) ) {
155 $formatted .= $this->getLanguage()->getDirMark() .
156 ' ' . Html::rawElement(
157 'span',
158 [ 'class' => 'mw-protectedpages-length' ],
159 Linker::formatRevisionSize( $row->page_len )
160 );
161 }
162 break;
163
164 case 'pr_expiry':
165 $formatted = htmlspecialchars( $this->getLanguage()->formatExpiry(
166 $value, /* User preference timezone */true ) );
167 $title = Title::makeTitleSafe( $row->page_namespace, $row->page_title );
168 if ( $this->getUser()->isAllowed( 'protect' ) && $title ) {
169 $changeProtection = $this->linkRenderer->makeKnownLink(
170 $title,
171 $this->msg( 'protect_change' )->text(),
172 [],
173 [ 'action' => 'unprotect' ]
174 );
175 $formatted .= ' ' . Html::rawElement(
176 'span',
177 [ 'class' => 'mw-protectedpages-actions' ],
178 $this->msg( 'parentheses' )->rawParams( $changeProtection )->escaped()
179 );
180 }
181 break;
182
183 case 'log_user':
184 // when timestamp is null, this is a old protection row
185 if ( $row->log_timestamp === null ) {
186 $formatted = Html::rawElement(
187 'span',
188 [ 'class' => 'mw-protectedpages-unknown' ],
189 $this->msg( 'protectedpages-unknown-performer' )->escaped()
190 );
191 } else {
192 $username = UserCache::singleton()->getProp( $value, 'name' );
194 $row->log_deleted,
196 $this->getUser()
197 ) ) {
198 if ( $username === false ) {
199 $formatted = htmlspecialchars( $value );
200 } else {
201 $formatted = Linker::userLink( $value, $username )
203 }
204 } else {
205 $formatted = $this->msg( 'rev-deleted-user' )->escaped();
206 }
208 $formatted = '<span class="history-deleted">' . $formatted . '</span>';
209 }
210 }
211 break;
212
213 case 'pr_params':
214 $params = [];
215 // Messages: restriction-level-sysop, restriction-level-autoconfirmed
216 $params[] = $this->msg( 'restriction-level-' . $row->pr_level )->escaped();
217 if ( $row->pr_cascade ) {
218 $params[] = $this->msg( 'protect-summary-cascade' )->escaped();
219 }
220 $formatted = $this->getLanguage()->commaList( $params );
221 break;
222
223 case 'log_comment':
224 // when timestamp is null, this is an old protection row
225 if ( $row->log_timestamp === null ) {
226 $formatted = Html::rawElement(
227 'span',
228 [ 'class' => 'mw-protectedpages-unknown' ],
229 $this->msg( 'protectedpages-unknown-reason' )->escaped()
230 );
231 } else {
233 $row->log_deleted,
235 $this->getUser()
236 ) ) {
237 $value = CommentStore::getStore()->getComment( 'log_comment', $row )->text;
238 $formatted = Linker::formatComment( $value !== null ? $value : '' );
239 } else {
240 $formatted = $this->msg( 'rev-deleted-comment' )->escaped();
241 }
243 $formatted = '<span class="history-deleted">' . $formatted . '</span>';
244 }
245 }
246 break;
247
248 default:
249 throw new MWException( "Unknown field '$field'" );
250 }
251
252 return $formatted;
253 }
254
255 function getQueryInfo() {
256 $conds = $this->mConds;
257 $conds[] = 'pr_expiry > ' . $this->mDb->addQuotes( $this->mDb->timestamp() ) .
258 ' OR pr_expiry IS NULL';
259 $conds[] = 'page_id=pr_page';
260 $conds[] = 'pr_type=' . $this->mDb->addQuotes( $this->type );
261
262 if ( $this->sizetype == 'min' ) {
263 $conds[] = 'page_len>=' . $this->size;
264 } elseif ( $this->sizetype == 'max' ) {
265 $conds[] = 'page_len<=' . $this->size;
266 }
267
268 if ( $this->indefonly ) {
269 $infinity = $this->mDb->addQuotes( $this->mDb->getInfinity() );
270 $conds[] = "pr_expiry = $infinity OR pr_expiry IS NULL";
271 }
272 if ( $this->cascadeonly ) {
273 $conds[] = 'pr_cascade = 1';
274 }
275 if ( $this->noredirect ) {
276 $conds[] = 'page_is_redirect = 0';
277 }
278
279 if ( $this->level ) {
280 $conds[] = 'pr_level=' . $this->mDb->addQuotes( $this->level );
281 }
282 if ( !is_null( $this->namespace ) ) {
283 $conds[] = 'page_namespace=' . $this->mDb->addQuotes( $this->namespace );
284 }
285
286 $commentQuery = CommentStore::getStore()->getJoin( 'log_comment' );
287 $actorQuery = ActorMigration::newMigration()->getJoin( 'log_user' );
288
289 return [
290 'tables' => [
291 'page', 'page_restrictions', 'log_search',
292 'logparen' => [ 'logging' ] + $commentQuery['tables'] + $actorQuery['tables'],
293 ],
294 'fields' => [
295 'pr_id',
296 'page_namespace',
297 'page_title',
298 'page_len',
299 'pr_type',
300 'pr_level',
301 'pr_expiry',
302 'pr_cascade',
303 'log_timestamp',
304 'log_deleted',
305 ] + $commentQuery['fields'] + $actorQuery['fields'],
306 'conds' => $conds,
307 'join_conds' => [
308 'log_search' => [
309 'LEFT JOIN', [
310 'ls_field' => 'pr_id', 'ls_value = ' . $this->mDb->buildStringCast( 'pr_id' )
311 ]
312 ],
313 'logparen' => [
314 'LEFT JOIN', [
315 'ls_log_id = log_id'
316 ]
317 ]
318 ] + $commentQuery['joins'] + $actorQuery['joins']
319 ];
320 }
321
322 protected function getTableClass() {
323 return parent::getTableClass() . ' mw-protectedpages';
324 }
325
326 function getIndexField() {
327 return 'pr_id';
328 }
329
330 function getDefaultSort() {
331 return 'pr_id';
332 }
333
334 function isFieldSortable( $field ) {
335 // no index for sorting exists
336 return false;
337 }
338}
Apache License January AND DISTRIBUTION Definitions License shall mean the terms and conditions for use
msg( $key)
Get a Message object with context set Parameters are the same as wfMessage()
getContext()
Get the base IContextSource object.
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
static userLink( $userId, $userName, $altUserName=false)
Make user link (or user contributions for unregistered users)
Definition Linker.php:893
static getInvalidTitleDescription(IContextSource $context, $namespace, $title)
Get a message saying that an invalid title was encountered.
Definition Linker.php:209
static userToolLinks( $userId, $userText, $redContribsWhenNoEdits=false, $flags=0, $edits=null)
Generate standard user tool links (talk, contributions, block link, etc.)
Definition Linker.php:931
static formatRevisionSize( $size)
Definition Linker.php:1503
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:1109
static userCanBitfield( $bitfield, $field, User $user=null)
Determine if the current user is allowed to view a particular field of this log row,...
static isDeleted( $row, $field)
const DELETED_USER
Definition LogPage.php:34
const DELETED_COMMENT
Definition LogPage.php:33
MediaWiki exception.
Class that generates HTML links for pages.
getFieldNames()
An array mapping database field names to a textual description of the field name, for use in the tabl...
preprocessResults( $result)
Pre-process results; useful for performing batch existence checks, etc.
__construct( $form, $conds=[], $type, $level, $namespace, $sizetype='', $size=0, $indefonly=false, $cascadeonly=false, $noredirect=false, LinkRenderer $linkRenderer)
getQueryInfo()
This function should be overridden to provide all parameters needed for the main paged query.
formatValue( $field, $value)
getDefaultSort()
The database field name used as a default sort order.
isFieldSortable( $field)
Return true if the named field should be sortable by the UI, false otherwise.
Table-based display with a user-selectable sort order.
static singleton()
Definition UserCache.php:34
design txt This is a brief overview of the new design More thorough and up to date information is available on the documentation wiki at etc Handles the details of getting and saving to the user table of the and dealing with sessions and cookies OutputPage Encapsulates the entire HTML page that will be sent in response to any server request It is used by calling its functions to add text
Definition design.txt:18
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:76
const NS_USER_TALK
Definition Defines.php:77
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. 'ImgAuthModifyHeaders':Executed just before a file is streamed to a user via img_auth.php, allowing headers to be modified beforehand. $title:LinkTarget object & $headers:HTTP headers(name=> value, names are case insensitive). Two headers get special handling:If-Modified-Since(value must be a valid HTTP date) and Range(must be of the form "bytes=(\d*-\d*)") will be honored when streaming the file. '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 'ImportHandleUnknownUser':When a user doesn 't exist locally, this hook is called to give extensions an opportunity to auto-create it. If the auto-creation is successful, return false. $name:User name '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:Array with elements of the form "language:title" in the order that they will be output. & $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:1993
namespace and then decline to actually register it file or subcat img or subcat $title
Definition hooks.txt:964
this hook is for auditing only or null if authentication failed before getting that far $username
Definition hooks.txt:785
Allows to change the fields on the form that will be generated $name
Definition hooks.txt:302
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
This document describes the state of Postgres support in and is fairly well maintained The main code is very well while extensions are very hit and miss it is probably the most supported database after MySQL Much of the work in making MediaWiki database agnostic came about through the work of creating Postgres but without copying over all the usage comments General notes on the but these can almost always be programmed around *Although Postgres has a true BOOLEAN type
Definition postgres.txt:30
$params