109 $this->mIncluding = $including;
110 $this->mShowAll = $showAll;
113 if ( $userName !==
null && $userName !==
'' ) {
114 $nt = Title::makeTitleSafe(
NS_USER, $userName );
115 if ( $nt ===
null ) {
118 $this->mUserName = $nt->getText();
121 $this->mUser = $user;
123 if ( !$user || ( $user->isAnon() && !$userNameUtils->
isIP( $user->getName() ) ) ) {
130 if ( $this->
getRequest()->getText(
'sort',
'img_date' ) ==
'img_date' ) {
141 parent::__construct( $context, $linkRenderer );
142 $this->commentStore = $commentStore;
144 $this->userCache = $userCache;
145 $this->commentFormatter = $commentFormatter;
334 $this->mTableName =
'image';
335 [ $tables, $fields, $conds, $fname, $options, $join_conds ] =
337 $imageRes =
$dbr->select( $tables, $fields, $conds, $fname, $options, $join_conds );
338 $this->mTableName = $prevTableName;
340 if ( !$this->mShowAll ) {
344 $this->mTableName =
'oldimage';
348 foreach ( $this->mIndexField as &$index ) {
349 if ( !str_starts_with( $index,
'img_' ) ) {
350 throw new MWException(
"Expected to be sorting on an image table field" );
352 $index =
'oi_' . substr( $index, 4 );
355 [ $tables, $fields, $conds, $fname, $options, $join_conds ] =
357 $oldimageRes =
$dbr->select( $tables, $fields, $conds, $fname, $options, $join_conds );
359 $this->mTableName = $prevTableName;
360 $this->mIndexField = $oldIndex;
362 return $this->
combineResult( $imageRes, $oldimageRes, $limit, $order );
379 $topRes1 = $res1->fetchObject();
380 $topRes2 = $res2->fetchObject();
382 for ( $i = 0; $i < $limit && $topRes1 && $topRes2; $i++ ) {
383 if ( strcmp( $topRes1->{$this->mIndexField[0]}, $topRes2->{$this->mIndexField[0]} ) > 0 ) {
385 $resultArray[] = $topRes1;
386 $topRes1 = $res1->fetchObject();
388 $resultArray[] = $topRes2;
389 $topRes2 = $res2->fetchObject();
392 $resultArray[] = $topRes2;
393 $topRes2 = $res2->fetchObject();
395 $resultArray[] = $topRes1;
396 $topRes1 = $res1->fetchObject();
400 for ( ; $i < $limit && $topRes1; $i++ ) {
401 $resultArray[] = $topRes1;
402 $topRes1 = $res1->fetchObject();
405 for ( ; $i < $limit && $topRes2; $i++ ) {
406 $resultArray[] = $topRes2;
407 $topRes2 = $res2->fetchObject();
446 $linkRenderer = $this->getLinkRenderer();
449 $opt = [
'time' =>
wfTimestamp( TS_MW, $this->mCurrentRow->img_timestamp ) ];
450 $file = $this->localRepo->findFile( $this->getCurrentRow()->img_name, $opt );
453 $thumb =
$file->transform( [
'width' => 180,
'height' => 360,
'loading' =>
'lazy' ] );
455 return $thumb->toHtml( [
'desc-link' =>
true ] );
457 return $this->msg(
'thumbnail_error',
'' )->escaped();
460 return htmlspecialchars( $this->getCurrentRow()->img_name );
462 case 'img_timestamp':
464 return htmlspecialchars( $this->getLanguage()->userTimeAndDate( $value, $this->
getUser() ) );
466 static $imgfile =
null;
467 if ( $imgfile ===
null ) {
468 $imgfile = $this->msg(
'imgfile' )->text();
472 $filePage = Title::makeTitleSafe(
NS_FILE, $value );
474 $link = $linkRenderer->makeKnownLink(
478 $download = Xml::element(
480 [
'href' => $this->localRepo->newFile( $filePage )->getUrl() ],
483 $download = $this->msg(
'parentheses' )->rawParams( $download )->escaped();
487 if ( $this->
getAuthority()->probablyCan(
'delete', $filePage ) ) {
488 $deleteMsg = $this->msg(
'listfiles-delete' )->text();
490 $delete = $linkRenderer->makeKnownLink(
491 $filePage, $deleteMsg, [], [
'action' =>
'delete' ]
493 $delete = $this->msg(
'parentheses' )->rawParams( $delete )->escaped();
495 return "$link $download $delete";
498 return "$link $download";
500 return htmlspecialchars( $value );
503 if ( $this->mCurrentRow->actor_user ) {
504 $name = $this->mCurrentRow->actor_name;
505 $link = $linkRenderer->makeLink(
506 Title::makeTitle(
NS_USER, $name ),
510 $link = $value !==
null ? htmlspecialchars( $value ) :
'';
515 return htmlspecialchars( $this->getLanguage()->formatSize( (
int)$value ) );
516 case 'img_description':
517 $field = $this->mCurrentRow->description_field;
518 $value = $this->commentStore->getComment( $field, $this->mCurrentRow )->text;
519 return $this->commentFormatter->format( $value );
521 return htmlspecialchars( $this->getLanguage()->formatNum( intval( $value ) + 1 ) );
524 return $this->msg(
'listfiles-latestversion-' . $value )->escaped();
531 $formDescriptor = [];
532 $formDescriptor[
'limit'] = [
535 'label-message' =>
'table_pager_limit_label',
536 'options' => $this->getLimitSelectList(),
537 'default' => $this->mLimit,
540 $formDescriptor[
'user'] = [
543 'id' =>
'mw-listfiles-user',
544 'label-message' =>
'username',
545 'default' => $this->mUserName,
547 'maxlength' =>
'255',
550 $formDescriptor[
'ilshowall'] = [
552 'name' =>
'ilshowall',
553 'id' =>
'mw-listfiles-show-all',
554 'label-message' =>
'listfiles-show-all',
555 'default' => $this->mShowAll,
558 $query = $this->getRequest()->getQueryValues();
559 unset( $query[
'title'] );
560 unset( $query[
'limit'] );
561 unset( $query[
'ilsearch'] );
562 unset( $query[
'ilshowall'] );
563 unset( $query[
'user'] );
565 HTMLForm::factory(
'ooui', $formDescriptor, $this->
getContext() )
567 ->setId(
'mw-listfiles-form' )
569 ->setSubmitTextMsg(
'table_pager_limit_submit' )
570 ->setWrapperLegendMsg(
'listfiles' )
571 ->addHiddenFields( $query )