54 $including =
false, $showAll =
false
57 $this->mIncluding = $including;
58 $this->mShowAll = $showAll;
60 if ( $userName !==
null && $userName !==
'' ) {
61 $nt = Title::makeTitleSafe(
NS_USER, $userName );
62 if ( is_null( $nt ) ) {
65 $this->mUserName = $nt->getText();
66 $user = User::newFromName( $this->mUserName,
false );
70 if ( !
$user || (
$user->isAnon() && !User::isIP(
$user->getName() ) ) ) {
76 if ( $search !==
'' && !$this->
getConfig()->
get(
'MiserMode' ) ) {
77 $this->mSearch = $search;
78 $nt = Title::newFromText( $this->mSearch );
82 $this->mQueryConds[] =
'LOWER(img_name)' .
84 strtolower( $nt->getDBkey() ),
$dbr->anyString() );
89 if ( $this->
getRequest()->getText(
'sort',
'img_date' ) ==
'img_date' ) {
117 "<div class=\"mw-userpage-userdoesnotexist error\">\n$1\n</div>",
119 'listfiles-userdoesnotexist',
133 $prefix = $table ===
'image' ?
'img' :
'oi';
136 if ( !is_null( $this->mUserName ) ) {
140 if ( $this->mSearch !==
'' ) {
141 $nt = Title::newFromText( $this->mSearch );
144 $conds[] =
'LOWER(' . $prefix .
'_name)' .
146 strtolower( $nt->getDBkey() ),
$dbr->anyString() );
150 if ( $table ===
'oldimage' ) {
154 $conds[
'oi_deleted'] = 0;
165 if ( !$this->mFieldNames ) {
166 $this->mFieldNames = [
167 'img_timestamp' => $this->
msg(
'listfiles_date' )->text(),
168 'img_name' => $this->
msg(
'listfiles_name' )->text(),
169 'thumb' => $this->
msg(
'listfiles_thumb' )->text(),
170 'img_size' => $this->
msg(
'listfiles_size' )->text(),
172 if ( is_null( $this->mUserName ) ) {
174 $this->mFieldNames[
'img_user_text'] = $this->
msg(
'listfiles_user' )->text();
177 $this->mFieldNames[
'img_description'] = $this->
msg(
'listfiles_description' )->text();
179 if ( !$this->
getConfig()->
get(
'MiserMode' ) && !$this->mShowAll ) {
180 $this->mFieldNames[
'count'] = $this->
msg(
'listfiles_count' )->text();
182 if ( $this->mShowAll ) {
183 $this->mFieldNames[
'top'] = $this->
msg(
'listfiles-latestversion' )->text();
191 if ( $this->mIncluding ) {
194 $sortable = [
'img_timestamp',
'img_name',
'img_size' ];
203 if ( $this->
getConfig()->
get(
'MiserMode' ) && !is_null( $this->mUserName ) ) {
205 if ( $field ===
'img_timestamp' ) {
210 } elseif ( $this->
getConfig()->
get(
'MiserMode' )
214 if ( $field ===
'img_name' ) {
221 return in_array( $field, $sortable );
244 $prefix = $table ===
'oldimage' ?
'oi' :
'img';
248 unset( $fields[
'img_description'] );
249 $fields = array_keys( $fields );
251 if ( $table ===
'oldimage' ) {
252 foreach ( $fields
as $id => &$field ) {
253 if ( substr( $field, 0, 4 ) !==
'img_' ) {
256 $field = $prefix . substr( $field, 3 ) .
' AS ' . $field;
258 $fields[array_search(
'top', $fields )] =
"'no' AS top";
260 if ( $this->mShowAll ) {
261 $fields[array_search(
'top', $fields )] =
"'yes' AS top";
264 $fields[] = $prefix .
'_user AS img_user';
265 $fields[array_search(
'thumb', $fields )] = $prefix .
'_name AS thumb';
271 $tables += $commentQuery[
'tables'];
272 $fields += $commentQuery[
'fields'];
273 $join_conds += $commentQuery[
'joins'];
274 $fields[
'description_field'] =
"'{$prefix}_description'";
276 # Depends on $wgMiserMode
277 # Will also not happen if mShowAll is true.
278 if ( isset( $this->mFieldNames[
'count'] ) ) {
281 # Need to rewrite this one
282 foreach ( $fields
as &$field ) {
283 if ( $field ==
'count' ) {
284 $field =
'COUNT(oi_archive_name) AS count';
289 $columnlist = preg_grep(
'/^img/', array_keys( $this->
getFieldNames() ) );
290 $options = [
'GROUP BY' => array_merge( [
'img_user' ], $columnlist ) ];
291 $join_conds[
'oldimage'] = [
'LEFT JOIN',
'oi_name = img_name' ];
299 'join_conds' => $join_conds
317 $this->mTableName =
'image';
321 $this->mTableName = $prevTableName;
323 if ( !$this->mShowAll ) {
327 $this->mTableName =
'oldimage';
331 if ( substr( $this->mIndexField, 0, 4 ) !==
'img_' ) {
332 throw new MWException(
"Expected to be sorting on an image table field" );
334 $this->mIndexField =
'oi_' . substr( $this->mIndexField, 4 );
340 $this->mTableName = $prevTableName;
341 $this->mIndexField = $oldIndex;
343 return $this->
combineResult( $imageRes, $oldimageRes, $limit, $asc );
360 $topRes1 = $res1->next();
361 $topRes2 = $res2->next();
363 for ( $i = 0; $i < $limit && $topRes1 && $topRes2; $i++ ) {
364 if ( strcmp( $topRes1->{$this->mIndexField}, $topRes2->{$this->mIndexField} ) > 0 ) {
366 $resultArray[] = $topRes1;
367 $topRes1 = $res1->next();
369 $resultArray[] = $topRes2;
370 $topRes2 = $res2->next();
374 $resultArray[] = $topRes2;
375 $topRes2 = $res2->next();
377 $resultArray[] = $topRes1;
378 $topRes1 = $res1->next();
384 for ( ; $i < $limit && $topRes1; $i++ ) {
386 $resultArray[] = $topRes1;
387 $topRes1 = $res1->next();
391 for ( ; $i < $limit && $topRes2; $i++ ) {
393 $resultArray[] = $topRes2;
394 $topRes2 = $res2->next();
401 if ( $this->mShowAll && $this->getConfig()->
get(
'MiserMode' ) && is_null( $this->mUserName ) ) {
405 return 'img_timestamp';
411 $this->mResult->seek( 0 );
412 foreach ( $this->mResult
as $row ) {
413 $userIds[] = $row->img_user;
415 # Do a link batch query for names and userpages
434 $linkRenderer = MediaWikiServices::getInstance()->getLinkRenderer();
437 $opt = [
'time' =>
wfTimestamp( TS_MW, $this->mCurrentRow->img_timestamp ) ];
441 $thumb = $file->transform( [
'width' => 180,
'height' => 360 ] );
443 return $thumb->toHtml( [
'desc-link' =>
true ] );
445 return wfMessage(
'thumbnail_error',
'' )->escaped();
448 return htmlspecialchars(
$value );
450 case 'img_timestamp':
452 return htmlspecialchars( $this->getLanguage()->userTimeAndDate(
$value, $this->getUser() ) );
454 static $imgfile =
null;
455 if ( $imgfile ===
null ) {
456 $imgfile = $this->msg(
'imgfile' )->text();
466 $download = Xml::element(
'a',
470 $download = $this->msg(
'parentheses' )->rawParams( $download )->escaped();
474 if ( $filePage->userCan(
'delete', $this->getUser() ) ) {
475 $deleteMsg = $this->msg(
'listfiles-delete' )->text();
478 $filePage, $deleteMsg, [], [
'action' =>
'delete' ]
480 $delete = $this->msg(
'parentheses' )->rawParams( $delete )->escaped();
482 return "$link $download $delete";
485 return "$link $download";
487 return htmlspecialchars(
$value );
489 case 'img_user_text':
490 if ( $this->mCurrentRow->img_user ) {
491 $name = User::whoIs( $this->mCurrentRow->img_user );
502 return htmlspecialchars( $this->getLanguage()->formatSize(
$value ) );
503 case 'img_description':
504 $field = $this->mCurrentRow->description_field;
508 return $this->getLanguage()->formatNum( intval(
$value ) + 1 );
511 return $this->msg(
'listfiles-latestversion-' .
$value );
522 'label-message' =>
'table_pager_limit_label',
523 'options' => $this->getLimitSelectList(),
524 'default' => $this->mLimit,
527 if ( !$this->getConfig()->
get(
'MiserMode' ) ) {
528 $fields[
'ilsearch'] = [
530 'name' =>
'ilsearch',
531 'id' =>
'mw-ilsearch',
532 'label-message' =>
'listfiles_search_for',
533 'default' => $this->mSearch,
535 'maxlength' =>
'255',
539 $this->getOutput()->addModules(
'mediawiki.userSuggest' );
543 'id' =>
'mw-listfiles-user',
544 'label-message' =>
'username',
545 'default' => $this->mUserName,
547 'maxlength' =>
'255',
548 'cssclass' =>
'mw-autocomplete-user',
551 $fields[
'ilshowall'] = [
553 'name' =>
'ilshowall',
554 'id' =>
'mw-listfiles-show-all',
555 'label-message' =>
'listfiles-show-all',
556 'default' => $this->mShowAll,
559 $query = $this->getRequest()->getQueryValues();
562 unset(
$query[
'ilsearch'] );
563 unset(
$query[
'ilshowall'] );
568 $form->setMethod(
'get' );
569 $form->setTitle( $this->getTitle() );
570 $form->setId(
'mw-listfiles-form' );
571 $form->setWrapperLegendMsg(
'listfiles' );
572 $form->setSubmitTextMsg(
'table_pager_limit_submit' );
573 $form->addHiddenFields(
$query );
575 $form->prepareForm();
576 $form->displayForm(
'' );
580 return parent::getTableClass() .
' listfiles';
584 return parent::getNavClass() .
' listfiles_nav';
588 return parent::getSortHeaderClass() .
' listfiles_sort';
592 $queries = parent::getPagingQueries();
593 if ( !is_null( $this->mUserName ) ) {
594 # Append the username to the query string
597 $query[
'user'] = $this->mUserName;
606 $queries = parent::getDefaultQuery();
607 if ( !isset(
$queries[
'user'] ) && !is_null( $this->mUserName ) ) {
608 $queries[
'user'] = $this->mUserName;
Apache License January AND DISTRIBUTION Definitions License shall mean the terms and conditions for use
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.
msg( $key)
Get a Message object with context set Parameters are the same as wfMessage()
getRequest()
Get the WebRequest object.
getConfig()
Get the Config object.
getOutput()
Get the OutputPage object.
setContext(IContextSource $context)
Set the IContextSource object.
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,...
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
this hook is for auditing only RecentChangesLinked and Watchlist RecentChangesLinked and Watchlist Do not use this to implement individual filters if they are compatible with the ChangesListFilter and ChangesListFilterGroup structure use sub classes of those in conjunction with the ChangesListSpecialPageStructuredFilters hook This hook can be used to implement filters that do not implement that or custom behavior that is not an individual filter e g Watchlist & $tables
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped & $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
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
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped noclasses just before the function returns a value If you return an< a > element with HTML attributes $attribs and contents $html will be returned If you return $ret will be returned and may include noclasses after processing after in associative array form before processing starts Return false to skip default processing and return $ret $linkRenderer
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
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.