50 $including =
false, $showAll =
false
53 $this->mIncluding = $including;
54 $this->mShowAll = $showAll;
56 if ( $userName !==
null && $userName !==
'' ) {
57 $nt = Title::makeTitleSafe(
NS_USER, $userName );
58 if ( is_null( $nt ) ) {
61 $this->mUserName = $nt->getText();
62 $user = User::newFromName( $this->mUserName,
false );
66 if ( !
$user || (
$user->isAnon() && !User::isIP(
$user->getName() ) ) ) {
72 if ( $search !==
'' && !$this->
getConfig()->
get(
'MiserMode' ) ) {
73 $this->mSearch = $search;
74 $nt = Title::newFromText( $this->mSearch );
78 $this->mQueryConds[] =
'LOWER(img_name)' .
80 strtolower( $nt->getDBkey() ),
$dbr->anyString() );
85 if ( $this->
getRequest()->getText(
'sort',
'img_date' ) ==
'img_date' ) {
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 !==
'' ) {
137 $nt = Title::newFromText( $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 wfMessage(
'thumbnail_error',
'' )->escaped();
438 return htmlspecialchars(
$value );
440 case 'img_timestamp':
442 return htmlspecialchars( $this->getLanguage()->userTimeAndDate(
$value, $this->getUser() ) );
444 static $imgfile =
null;
445 if ( $imgfile ===
null ) {
446 $imgfile = $this->msg(
'imgfile' )->text();
454 htmlspecialchars( $filePage->getText() )
460 $download = $this->msg(
'parentheses' )->rawParams( $download )->escaped();
464 if ( $filePage->userCan(
'delete', $this->getUser() ) ) {
465 $deleteMsg = $this->msg(
'listfiles-delete' )->escaped();
468 $filePage, $deleteMsg, [], [
'action' =>
'delete' ]
470 $delete = $this->msg(
'parentheses' )->rawParams( $delete )->escaped();
472 return "$link $download $delete";
475 return "$link $download";
477 return htmlspecialchars(
$value );
479 case 'img_user_text':
480 if ( $this->mCurrentRow->img_user ) {
481 $name = User::whoIs( $this->mCurrentRow->img_user );
484 htmlspecialchars(
$name )
492 return htmlspecialchars( $this->getLanguage()->formatSize(
$value ) );
493 case 'img_description':
496 return $this->getLanguage()->formatNum( intval(
$value ) + 1 );
499 return $this->msg(
'listfiles-latestversion-' .
$value );
510 'label-message' =>
'table_pager_limit_label',
511 'options' => $this->getLimitSelectList(),
512 'default' => $this->mLimit,
515 if ( !$this->getConfig()->
get(
'MiserMode' ) ) {
516 $fields[
'ilsearch'] = [
518 'name' =>
'ilsearch',
519 'id' =>
'mw-ilsearch',
520 'label-message' =>
'listfiles_search_for',
521 'default' => $this->mSearch,
523 'maxlength' =>
'255',
527 $this->getOutput()->addModules(
'mediawiki.userSuggest' );
531 'id' =>
'mw-listfiles-user',
532 'label-message' =>
'username',
533 'default' => $this->mUserName,
535 'maxlength' =>
'255',
536 'cssclass' =>
'mw-autocomplete-user',
539 $fields[
'ilshowall'] = [
541 'name' =>
'ilshowall',
542 'id' =>
'mw-listfiles-show-all',
543 'label-message' =>
'listfiles-show-all',
544 'default' => $this->mShowAll,
547 $query = $this->getRequest()->getQueryValues();
550 unset(
$query[
'ilsearch'] );
551 unset(
$query[
'ilshowall'] );
556 $form->setMethod(
'get' );
557 $form->setTitle( $this->getTitle() );
558 $form->setId(
'mw-listfiles-form' );
559 $form->setWrapperLegendMsg(
'listfiles' );
560 $form->setSubmitTextMsg(
'table_pager_limit_submit' );
561 $form->addHiddenFields(
$query );
563 $form->prepareForm();
564 $form->displayForm(
'' );
568 return parent::getTableClass() .
' listfiles';
572 return parent::getNavClass() .
' listfiles_nav';
576 return parent::getSortHeaderClass() .
' listfiles_sort';
580 $queries = parent::getPagingQueries();
581 if ( !is_null( $this->mUserName ) ) {
582 # Append the username to the query string
585 $query[
'user'] = $this->mUserName;
594 $queries = parent::getDefaultQuery();
595 if ( !isset(
$queries[
'user'] ) && !is_null( $this->mUserName ) ) {
596 $queries[
'user'] = $this->mUserName;
wfGetDB( $db, $groups=[], $wiki=false)
Get a Database object.
wfLocalFile( $title)
Get an object referring to a locally registered file.
wfTimestamp( $outputtype=TS_UNIX, $ts=0)
Get a timestamp string in one of various formats.
wfEscapeWikiText( $text)
Escapes the given text so that it may be output using addWikiText() without any linking,...
if(!defined( 'MEDIAWIKI')) $fname
This file is not a valid entry point, perform no further processing unless MEDIAWIKI is defined.
getRequest()
Get the WebRequest object.
getConfig()
Get the Config object.
msg()
Get a Message object with context set Parameters are the same as wfMessage()
getOutput()
Get the OutputPage object.
setContext(IContextSource $context)
Set the IContextSource object.
Overloads the relevant methods of the real ResultsWrapper so it doesn't go anywhere near an actual da...
static link( $target, $html=null, $customAttribs=[], $query=[], $options=[])
This function returns an HTML link to the given target.
static linkKnown( $target, $html=null, $customAttribs=[], $query=[], $options=[ 'known'])
Identical to link(), except $options defaults to 'known'.
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...
static singleton()
Get a RepoGroup instance.
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,...
The User object encapsulates all of the user-specific settings (user_id, name, rights,...
static element( $element, $attribs=null, $contents='', $allowShortTag=true)
Format an XML element with given attributes and, optionally, text content.
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
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
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
this hook is for auditing only RecentChangesLinked and Watchlist RecentChangesLinked and Watchlist e g Watchlist & $tables
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
either a unescaped string or a HtmlArmor object after in associative array form externallinks including delete and has completed for all link tables whether this was an auto creation default is conds Array Extra conditions for the No matching items in log is displayed if loglist is empty msgKey Array If you want a nice box with a set this to the key of the message First element is the message additional optional elements are parameters for the key that are processed with wfMessage() -> params() ->parseAsBlock() - offset Set to overwrite offset parameter in $wgRequest set to '' to unset offset - wrap String Wrap the message in html(usually something like "<div ...>$1</div>"). - flags Integer display flags(NO_ACTION_LINK, NO_EXTRA_USER_LINKS) 'LogException':Called before an exception(or PHP error) is logged. This is meant for integration with external error aggregation services
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
usually copyright or history_copyright This message must be in HTML not wikitext & $link
Allows to change the fields on the form that will be generated $name
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
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
Interface for objects which can provide a MediaWiki context on request.
const TS_MW
MediaWiki concatenated string timestamp (YYYYMMDDHHMMSS)