39 protected $mUser = null;
50 $including =
false, $showAll =
false
53 $this->mIncluding = $including;
54 $this->mShowAll = $showAll;
56 if ( $userName !== null && $userName !==
'' ) {
58 if ( is_null( $nt ) ) {
61 $this->mUserName = $nt->getText();
72 if ( $search !==
'' && !$this->
getConfig()->
get(
'MiserMode' ) ) {
73 $this->mSearch = $search;
78 $this->mQueryConds[] =
'LOWER(img_name)' .
80 strtolower( $nt->getDBkey() ),
$dbr->anyString() );
85 if ( $this->
getRequest()->getText(
'sort',
'img_date' ) ==
'img_date' ) {
94 parent::__construct( $context );
113 "<div class=\"mw-userpage-userdoesnotexist error\">\n$1\n</div>",
115 'listfiles-userdoesnotexist',
129 $prefix = $table ===
'image' ?
'img' :
'oi';
132 if ( !is_null( $this->mUserName ) ) {
136 if ( $this->mSearch !==
'' ) {
140 $conds[] =
'LOWER(' . $prefix .
'_name)' .
142 strtolower( $nt->getDBkey() ),
$dbr->anyString() );
146 if ( $table ===
'oldimage' ) {
150 $conds[
'oi_deleted'] = 0;
161 if ( !$this->mFieldNames ) {
162 $this->mFieldNames = [
163 'img_timestamp' => $this->
msg(
'listfiles_date' )->text(),
164 'img_name' => $this->
msg(
'listfiles_name' )->text(),
165 'thumb' => $this->
msg(
'listfiles_thumb' )->text(),
166 'img_size' => $this->
msg(
'listfiles_size' )->text(),
168 if ( is_null( $this->mUserName ) ) {
170 $this->mFieldNames[
'img_user_text'] = $this->
msg(
'listfiles_user' )->text();
173 $this->mFieldNames[
'img_description'] = $this->
msg(
'listfiles_description' )->text();
175 if ( !$this->
getConfig()->
get(
'MiserMode' ) && !$this->mShowAll ) {
176 $this->mFieldNames[
'count'] = $this->
msg(
'listfiles_count' )->text();
178 if ( $this->mShowAll ) {
179 $this->mFieldNames[
'top'] = $this->
msg(
'listfiles-latestversion' )->text();
187 if ( $this->mIncluding ) {
190 $sortable = [
'img_timestamp',
'img_name',
'img_size' ];
198 if ( $this->
getConfig()->
get(
'MiserMode' ) && !is_null( $this->mUserName ) ) {
200 if ( $field ===
'img_timestamp' ) {
205 } elseif ( $this->
getConfig()->
get(
'MiserMode' )
209 if ( $field ===
'img_name' ) {
216 return in_array( $field, $sortable );
239 $prefix = $table ===
'oldimage' ?
'oi' :
'img';
244 if ( $table ===
'oldimage' ) {
245 foreach ( $fields
as $id => &$field ) {
246 if ( substr( $field, 0, 4 ) !==
'img_' ) {
249 $field = $prefix . substr( $field, 3 ) .
' AS ' . $field;
251 $fields[array_search(
'top', $fields )] =
"'no' AS top";
253 if ( $this->mShowAll ) {
254 $fields[array_search(
'top', $fields )] =
"'yes' AS top";
257 $fields[] = $prefix .
'_user AS img_user';
258 $fields[array_search(
'thumb', $fields )] = $prefix .
'_name AS thumb';
262 # Depends on $wgMiserMode
263 # Will also not happen if mShowAll is true.
264 if ( isset( $this->mFieldNames[
'count'] ) ) {
267 # Need to rewrite this one
268 foreach ( $fields
as &$field ) {
269 if ( $field ==
'count' ) {
270 $field =
'COUNT(oi_archive_name) AS count';
276 if (
$dbr->implicitGroupby() ) {
277 $options = [
'GROUP BY' =>
'img_name' ];
279 $columnlist = preg_grep(
'/^img/', array_keys( $this->
getFieldNames() ) );
280 $options = [
'GROUP BY' => array_merge( [
'img_user' ], $columnlist ) ];
282 $join_conds = [
'oldimage' => [
'LEFT JOIN',
'oi_name = img_name' ] ];
290 'join_conds' => $join_conds
308 $this->mTableName =
'image';
312 $this->mTableName = $prevTableName;
314 if ( !$this->mShowAll ) {
318 $this->mTableName =
'oldimage';
322 if ( substr( $this->mIndexField, 0, 4 ) !==
'img_' ) {
323 throw new MWException(
"Expected to be sorting on an image table field" );
325 $this->mIndexField =
'oi_' . substr( $this->mIndexField, 4 );
331 $this->mTableName = $prevTableName;
332 $this->mIndexField = $oldIndex;
351 $topRes1 = $res1->next();
352 $topRes2 = $res2->next();
354 for ( $i = 0; $i <
$limit && $topRes1 && $topRes2; $i++ ) {
355 if ( strcmp( $topRes1->{$this->mIndexField}, $topRes2->{$this->mIndexField} ) > 0 ) {
357 $resultArray[] = $topRes1;
358 $topRes1 = $res1->next();
360 $resultArray[] = $topRes2;
361 $topRes2 = $res2->next();
365 $resultArray[] = $topRes2;
366 $topRes2 = $res2->next();
368 $resultArray[] = $topRes1;
369 $topRes1 = $res1->next();
375 for ( ; $i <
$limit && $topRes1; $i++ ) {
377 $resultArray[] = $topRes1;
378 $topRes1 = $res1->next();
382 for ( ; $i <
$limit && $topRes2; $i++ ) {
384 $resultArray[] = $topRes2;
385 $topRes2 = $res2->next();
392 if ( $this->mShowAll && $this->getConfig()->
get(
'MiserMode' ) && is_null( $this->mUserName ) ) {
396 return 'img_timestamp';
402 $this->mResult->seek( 0 );
403 foreach ( $this->mResult
as $row ) {
404 $userIds[] = $row->img_user;
406 # Do a link batch query for names and userpages
427 $opt = [
'time' =>
wfTimestamp(
TS_MW, $this->mCurrentRow->img_timestamp ) ];
431 $thumb = $file->transform( [
'width' => 180,
'height' => 360 ] );
433 return $thumb->toHtml( [
'desc-link' =>
true ] );
435 return htmlspecialchars(
$value );
437 case 'img_timestamp':
439 return htmlspecialchars( $this->getLanguage()->userTimeAndDate(
$value, $this->getUser() ) );
441 static $imgfile = null;
442 if ( $imgfile === null ) {
443 $imgfile = $this->msg(
'imgfile' )->text();
451 htmlspecialchars( $filePage->getText() )
457 $download = $this->msg(
'parentheses' )->rawParams( $download )->escaped();
461 if ( $filePage->userCan(
'delete', $this->getUser() ) ) {
462 $deleteMsg = $this->msg(
'listfiles-delete' )->escaped();
465 $filePage, $deleteMsg, [], [
'action' =>
'delete' ]
467 $delete = $this->msg(
'parentheses' )->rawParams( $delete )->escaped();
469 return "$link $download $delete";
472 return "$link $download";
474 return htmlspecialchars(
$value );
476 case 'img_user_text':
477 if ( $this->mCurrentRow->img_user ) {
481 htmlspecialchars(
$name )
489 return htmlspecialchars( $this->getLanguage()->formatSize(
$value ) );
490 case 'img_description':
493 return $this->getLanguage()->formatNum( intval(
$value ) + 1 );
496 return $this->msg(
'listfiles-latestversion-' .
$value );
507 'label-message' =>
'table_pager_limit_label',
508 'options' => $this->getLimitSelectList(),
509 'default' => $this->mLimit,
512 if ( !$this->getConfig()->
get(
'MiserMode' ) ) {
513 $fields[
'ilsearch'] = [
515 'name' =>
'ilsearch',
516 'id' =>
'mw-ilsearch',
517 'label-message' =>
'listfiles_search_for',
518 'default' => $this->mSearch,
520 'maxlength' =>
'255',
524 $this->getOutput()->addModules(
'mediawiki.userSuggest' );
528 'id' =>
'mw-listfiles-user',
529 'label-message' =>
'username',
530 'default' => $this->mUserName,
532 'maxlength' =>
'255',
533 'cssclass' =>
'mw-autocomplete-user',
536 $fields[
'ilshowall'] = [
538 'name' =>
'ilshowall',
539 'id' =>
'mw-listfiles-show-all',
540 'label-message' =>
'listfiles-show-all',
541 'default' => $this->mShowAll,
544 $query = $this->getRequest()->getQueryValues();
547 unset(
$query[
'ilsearch'] );
548 unset(
$query[
'ilshowall'] );
551 $form =
new HTMLForm( $fields, $this->getContext() );
553 $form->setMethod(
'get' );
554 $form->setTitle( $this->getTitle() );
555 $form->setId(
'mw-listfiles-form' );
556 $form->setWrapperLegendMsg(
'listfiles' );
557 $form->setSubmitTextMsg(
'table_pager_limit_submit' );
558 $form->addHiddenFields(
$query );
560 $form->prepareForm();
561 $form->displayForm(
'' );
565 return parent::getTableClass() .
' listfiles';
569 return parent::getNavClass() .
' listfiles_nav';
573 return parent::getSortHeaderClass() .
' listfiles_sort';
577 $queries = parent::getPagingQueries();
578 if ( !is_null( $this->mUserName ) ) {
579 # Append the username to the query string
581 if ( $query !==
false ) {
582 $query[
'user'] = $this->mUserName;
591 $queries = parent::getDefaultQuery();
592 if ( !isset(
$queries[
'user'] ) && !is_null( $this->mUserName ) ) {
593 $queries[
'user'] = $this->mUserName;
static newFromName($name, $validate= 'valid')
Static factory method for creation from username.
setContext(IContextSource $context)
Set the IContextSource object.
static whoIs($id)
Get the username corresponding to a given user ID.
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
Interface for objects which can provide a MediaWiki context on request.
wfGetDB($db, $groups=[], $wiki=false)
Get a Database object.
null for the local wiki Added should default to null in handler for backwards compatibility add a value to it if you want to add a cookie that have to vary cache options can modify $query
static linkKnown($target, $html=null, $customAttribs=[], $query=[], $options=[ 'known', 'noclasses'])
Identical to link(), except $options defaults to 'known'.
static element($element, $attribs=null, $contents= '', $allowShortTag=true)
Format an XML element with given attributes and, optionally, text content.
static getTitleFor($name, $subpage=false, $fragment= '')
Get a localised Title object for a specified special page name.
static newFromText($text, $defaultNamespace=NS_MAIN)
Create a new Title from text, such as what one would find in a link.
wfLocalFile($title)
Get an object referring to a locally registered file.
this hook is for auditing only RecentChangesLinked and Watchlist RecentChangesLinked and Watchlist e g Watchlist & $tables
the value to return A Title object or null for latest to be modified or replaced by the hook handler or if authentication is not possible after cache objects are set for highlighting & $link
wfTimestamp($outputtype=TS_UNIX, $ts=0)
Get a timestamp string in one of various formats.
getRequest()
Get the WebRequest object.
msg()
Get a Message object with context set Parameters are the same as wfMessage()
wfEscapeWikiText($text)
Escapes the given text so that it may be output using addWikiText() without any linking, formatting, etc.
this hook is for auditing only RecentChangesLinked and Watchlist RecentChangesLinked and Watchlist e g Watchlist removed from all revisions and log entries to which it was applied This gives extensions a chance to take it off their books as the deletion has already been partly carried out by this point or something similar the user will be unable to create the tag set and then return false from the hook function Ensure you consume the ChangeTagAfterDelete hook to carry out custom deletion actions as context called by AbstractContent::getParserOutput May be used to override the normal model specific rendering of page content as context as context $options
static singleton()
Get a RepoGroup instance.
getConfig()
Get the Config object.
static makeTitleSafe($ns, $title, $fragment= '', $interwiki= '')
Create a new Title from a namespace index and a DB key.
static isIP($name)
Does the string match an anonymous IPv4 address?
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
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...
please add to it if you re going to add events to the MediaWiki code where normally authentication against an external auth plugin would be creating a local account $user
static link($target, $html=null, $customAttribs=[], $query=[], $options=[])
This function returns an HTML link to the given target.
const TS_MW
MediaWiki concatenated string timestamp (YYYYMMDDHHMMSS)
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
if(!defined( 'MEDIAWIKI')) $fname
This file is not a valid entry point, perform no further processing unless MEDIAWIKI is defined...
Overloads the relevant methods of the real ResultsWrapper so it doesn't go anywhere near an actual da...
this hook is for auditing only RecentChangesLinked and Watchlist RecentChangesLinked and Watchlist e g Watchlist removed from all revisions and log entries to which it was applied This gives extensions a chance to take it off their books as the deletion has already been partly carried out by this point or something similar the user will be unable to create the tag set and then return false from the hook function Ensure you consume the ChangeTagAfterDelete hook to carry out custom deletion actions as context called by AbstractContent::getParserOutput May be used to override the normal model specific rendering of page content as context as context the output can only depend on parameters provided to this hook not on global state indicating whether full HTML should be generated If generation of HTML may be but other information should still be present in the ParserOutput object to manipulate or replace but no entry for that model exists in $wgContentHandlers if desired whether it is OK to use $contentModel on $title Handler functions that modify $ok should generally return false to prevent further hooks from further modifying $ok inclusive $limit
static & makeTitle($ns, $title, $fragment= '', $interwiki= '')
Create a new Title from a namespace index and a DB key.
getOutput()
Get the OutputPage object.
Allows to change the fields on the form that will be generated $name