66 'img_timestamp' => [
'img_timestamp',
'img_name' ],
67 'img_name' => [
'img_name' ],
68 'img_size' => [
'img_size',
'img_name' ],
99 $this->mIncluding = $including;
100 $this->mShowAll = $showAll;
103 if ( $userName !==
null && $userName !==
'' ) {
104 $nt = Title::makeTitleSafe(
NS_USER, $userName );
105 if ( $nt ===
null ) {
108 $this->mUserName = $nt->getText();
111 $this->mUser = $user;
113 if ( !$user || ( $user->isAnon() && !$userNameUtils->
isIP( $user->getName() ) ) ) {
120 if ( $this->
getRequest()->getText(
'sort',
'img_date' ) ==
'img_date' ) {
152 $this->
getOutput()->addHtml( Html::warningBox(
154 'mw-userpage-userdoesnotexist'
166 $prefix = $table ===
'image' ?
'img' :
'oi';
169 if ( $this->mUserName !==
null ) {
174 if ( $table ===
'oldimage' ) {
178 $conds[
'oi_deleted'] = 0;
186 if ( !$this->mFieldNames ) {
187 $this->mFieldNames = [
188 'img_timestamp' => $this->
msg(
'listfiles_date' )->text(),
189 'img_name' => $this->
msg(
'listfiles_name' )->text(),
190 'thumb' => $this->
msg(
'listfiles_thumb' )->text(),
191 'img_size' => $this->
msg(
'listfiles_size' )->text(),
193 if ( $this->mUserName ===
null ) {
195 $this->mFieldNames[
'img_actor'] = $this->
msg(
'listfiles_user' )->text();
198 $this->mFieldNames[
'img_description'] = $this->
msg(
'listfiles_description' )->text();
200 if ( !$this->
getConfig()->
get(
'MiserMode' ) && !$this->mShowAll ) {
201 $this->mFieldNames[
'count'] = $this->
msg(
'listfiles_count' )->text();
203 if ( $this->mShowAll ) {
204 $this->mFieldNames[
'top'] = $this->
msg(
'listfiles-latestversion' )->text();
212 if ( $this->mIncluding ) {
215 $sortable = array_keys( self::INDEX_FIELDS );
223 if ( $this->
getConfig()->
get(
'MiserMode' ) && $this->mUserName !==
null ) {
225 return $field ===
'img_timestamp';
226 } elseif ( $this->
getConfig()->
get(
'MiserMode' )
230 return $field ===
'img_name';
233 return in_array( $field, $sortable );
257 $prefix = $table ===
'oldimage' ?
'oi' :
'img';
259 $tables = [ $table,
'actor' ];
262 if ( $table ===
'oldimage' ) {
264 'img_timestamp' =>
'oi_timestamp',
265 'img_name' =>
'oi_name',
266 'img_size' =>
'oi_size',
267 'top' =>
$dbr->addQuotes(
'no' )
269 $join_conds[
'actor'] = [
'JOIN',
'actor_id=oi_actor' ];
275 'top' =>
$dbr->addQuotes(
'yes' )
277 $join_conds[
'actor'] = [
'JOIN',
'actor_id=img_actor' ];
283 $commentQuery = $this->commentStore->getJoin( $prefix .
'_description' );
284 $tables += $commentQuery[
'tables'];
285 $fields += $commentQuery[
'fields'];
286 $join_conds += $commentQuery[
'joins'];
287 $fields[
'description_field'] =
$dbr->addQuotes(
"{$prefix}_description" );
290 $fields[] =
'actor_user';
291 $fields[] =
'actor_name';
293 # Depends on $wgMiserMode
294 # Will also not happen if mShowAll is true.
296 $fields[
'count'] =
$dbr->buildSelectSubquery(
298 'COUNT(oi_archive_name)',
299 'oi_name = img_name',
308 'options' => $options,
309 'join_conds' => $join_conds
325 $this->mTableName =
'image';
326 list( $tables, $fields, $conds, $fname, $options, $join_conds ) =
328 $imageRes =
$dbr->select( $tables, $fields, $conds, $fname, $options, $join_conds );
329 $this->mTableName = $prevTableName;
331 if ( !$this->mShowAll ) {
335 $this->mTableName =
'oldimage';
339 foreach ( $this->mIndexField as &$index ) {
340 if ( substr( $index, 0, 4 ) !==
'img_' ) {
341 throw new MWException(
"Expected to be sorting on an image table field" );
343 $index =
'oi_' . substr( $index, 4 );
346 list( $tables, $fields, $conds, $fname, $options, $join_conds ) =
348 $oldimageRes =
$dbr->select( $tables, $fields, $conds, $fname, $options, $join_conds );
350 $this->mTableName = $prevTableName;
351 $this->mIndexField = $oldIndex;
353 return $this->
combineResult( $imageRes, $oldimageRes, $limit, $order );
370 $topRes1 = $res1->next();
371 $topRes2 = $res2->next();
373 for ( $i = 0; $i < $limit && $topRes1 && $topRes2; $i++ ) {
374 if ( strcmp( $topRes1->{$this->mIndexField[0]}, $topRes2->{$this->mIndexField[0]} ) > 0 ) {
376 $resultArray[] = $topRes1;
377 $topRes1 = $res1->next();
379 $resultArray[] = $topRes2;
380 $topRes2 = $res2->next();
383 $resultArray[] = $topRes2;
384 $topRes2 = $res2->next();
386 $resultArray[] = $topRes1;
387 $topRes1 = $res1->next();
391 for ( ; $i < $limit && $topRes1; $i++ ) {
392 $resultArray[] = $topRes1;
393 $topRes1 = $res1->next();
396 for ( ; $i < $limit && $topRes2; $i++ ) {
397 $resultArray[] = $topRes2;
398 $topRes2 = $res2->next();
405 return [ self::INDEX_FIELDS[$this->mSort] ];
409 if ( $this->mShowAll && $this->getConfig()->
get(
'MiserMode' ) && $this->mUserName ===
null ) {
413 return 'img_timestamp';
419 $this->mResult->seek( 0 );
420 foreach ( $this->mResult as $row ) {
421 if ( $row->actor_user ) {
422 $userIds[] = $row->actor_user;
425 # Do a link batch query for names and userpages
426 $this->userCache->doQuery( $userIds, [
'userpage' ], __METHOD__ );
436 $linkRenderer = $this->getLinkRenderer();
439 $opt = [
'time' =>
wfTimestamp( TS_MW, $this->mCurrentRow->img_timestamp ) ];
440 $file = $this->localRepo->findFile( $this->getCurrentRow()->img_name, $opt );
443 $thumb =
$file->transform( [
'width' => 180,
'height' => 360 ] );
445 return $thumb->toHtml( [
'desc-link' =>
true ] );
447 return $this->msg(
'thumbnail_error',
'' )->escaped();
450 return htmlspecialchars( $this->getCurrentRow()->img_name );
452 case 'img_timestamp':
454 return htmlspecialchars( $this->getLanguage()->userTimeAndDate( $value, $this->
getUser() ) );
456 static $imgfile =
null;
457 if ( $imgfile ===
null ) {
458 $imgfile = $this->msg(
'imgfile' )->text();
462 $filePage = Title::makeTitleSafe(
NS_FILE, $value );
464 $link = $linkRenderer->makeKnownLink(
468 $download = Xml::element(
470 [
'href' => $this->localRepo->newFile( $filePage )->getUrl() ],
473 $download = $this->msg(
'parentheses' )->rawParams( $download )->escaped();
477 if ( $this->
getAuthority()->probablyCan(
'delete', $filePage ) ) {
478 $deleteMsg = $this->msg(
'listfiles-delete' )->text();
480 $delete = $linkRenderer->makeKnownLink(
481 $filePage, $deleteMsg, [], [
'action' =>
'delete' ]
483 $delete = $this->msg(
'parentheses' )->rawParams( $delete )->escaped();
485 return "$link $download $delete";
488 return "$link $download";
490 return htmlspecialchars( $value );
493 if ( $this->mCurrentRow->actor_user ) {
494 $name = $this->mCurrentRow->actor_name;
495 $link = $linkRenderer->makeLink(
496 Title::makeTitle(
NS_USER, $name ),
500 $link = $value !==
null ? htmlspecialchars( $value ) :
'';
505 return htmlspecialchars( $this->getLanguage()->formatSize( (
int)$value ) );
506 case 'img_description':
507 $field = $this->mCurrentRow->description_field;
508 $value = $this->commentStore->getComment( $field, $this->mCurrentRow )->text;
511 return htmlspecialchars( $this->getLanguage()->formatNum( intval( $value ) + 1 ) );
514 return $this->msg(
'listfiles-latestversion-' . $value )->escaped();
521 $formDescriptor = [];
522 $formDescriptor[
'limit'] = [
525 'label-message' =>
'table_pager_limit_label',
526 'options' => $this->getLimitSelectList(),
527 'default' => $this->mLimit,
530 $formDescriptor[
'user'] = [
533 'id' =>
'mw-listfiles-user',
534 'label-message' =>
'username',
535 'default' => $this->mUserName,
537 'maxlength' =>
'255',
540 $formDescriptor[
'ilshowall'] = [
542 'name' =>
'ilshowall',
543 'id' =>
'mw-listfiles-show-all',
544 'label-message' =>
'listfiles-show-all',
545 'default' => $this->mShowAll,
548 $query = $this->getRequest()->getQueryValues();
549 unset( $query[
'title'] );
550 unset( $query[
'limit'] );
551 unset( $query[
'ilsearch'] );
552 unset( $query[
'ilshowall'] );
553 unset( $query[
'user'] );
555 HTMLForm::factory(
'ooui', $formDescriptor, $this->
getContext() )
557 ->setId(
'mw-listfiles-form' )
559 ->setSubmitTextMsg(
'table_pager_limit_submit' )
560 ->setWrapperLegendMsg(
'listfiles' )
561 ->addHiddenFields( $query )
567 return parent::getTableClass() .
' listfiles';
571 return parent::getNavClass() .
' listfiles_nav';
575 return parent::getSortHeaderClass() .
' listfiles_sort';
579 $queries = parent::getPagingQueries();
580 if ( $this->mUserName !==
null ) {
581 # Append the username to the query string
582 foreach ( $queries as &$query ) {
583 if ( $query !==
false ) {
584 $query[
'user'] = $this->mUserName;
593 $queries = parent::getDefaultQuery();
594 if ( !isset( $queries[
'user'] ) && $this->mUserName !==
null ) {
595 $queries[
'user'] = $this->mUserName;
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,...
msg( $key,... $params)
Get a Message object with context set Parameters are the same as wfMessage()
setContext(IContextSource $context)
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...
A repository that stores files in the local filesystem and registers them in the wiki's own database.
Prioritized list of file repositories.
getLocalRepo()
Get the local repository, i.e.
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 newFromName( $name, $validate='valid')
Interface for objects which can provide a MediaWiki context on request.
if(PHP_SAPI !='cli-server') if(!isset( $_SERVER['SCRIPT_FILENAME'])) $file
Item class for a filearchive table row.