68 'img_timestamp' => [
'img_timestamp',
'img_name' ],
69 'img_name' => [
'img_name' ],
70 'img_size' => [
'img_size',
'img_name' ],
101 $this->mIncluding = $including;
102 $this->mShowAll = $showAll;
105 if ( $userName !==
null && $userName !==
'' ) {
106 $nt = Title::makeTitleSafe(
NS_USER, $userName );
107 if ( $nt ===
null ) {
110 $this->mUserName = $nt->getText();
113 $this->mUser = $user;
115 if ( !$user || ( $user->isAnon() && !$userNameUtils->
isIP( $user->getName() ) ) ) {
121 if ( $search !==
'' && !$this->
getConfig()->
get(
'MiserMode' ) ) {
122 $this->mSearch = $search;
123 $nt = Title::newFromText( $this->mSearch );
126 $this->mQueryConds[] =
'LOWER(img_name)' .
128 strtolower( $nt->getDBkey() ),
$dbr->anyString() );
133 if ( $this->
getRequest()->getText(
'sort',
'img_date' ) ==
'img_date' ) {
166 "<div class=\"mw-userpage-userdoesnotexist error\">\n$1\n</div>",
168 'listfiles-userdoesnotexist',
182 $prefix = $table ===
'image' ?
'img' :
'oi';
185 if ( $this->mUserName !==
null ) {
190 if ( $this->mSearch !==
'' ) {
191 $nt = Title::newFromText( $this->mSearch );
194 $conds[] =
'LOWER(' . $prefix .
'_name)' .
196 strtolower( $nt->getDBkey() ),
$dbr->anyString() );
200 if ( $table ===
'oldimage' ) {
204 $conds[
'oi_deleted'] = 0;
212 if ( !$this->mFieldNames ) {
213 $this->mFieldNames = [
214 'img_timestamp' => $this->
msg(
'listfiles_date' )->text(),
215 'img_name' => $this->
msg(
'listfiles_name' )->text(),
216 'thumb' => $this->
msg(
'listfiles_thumb' )->text(),
217 'img_size' => $this->
msg(
'listfiles_size' )->text(),
219 if ( $this->mUserName ===
null ) {
221 $this->mFieldNames[
'img_actor'] = $this->
msg(
'listfiles_user' )->text();
224 $this->mFieldNames[
'img_description'] = $this->
msg(
'listfiles_description' )->text();
226 if ( !$this->
getConfig()->
get(
'MiserMode' ) && !$this->mShowAll ) {
227 $this->mFieldNames[
'count'] = $this->
msg(
'listfiles_count' )->text();
229 if ( $this->mShowAll ) {
230 $this->mFieldNames[
'top'] = $this->
msg(
'listfiles-latestversion' )->text();
238 if ( $this->mIncluding ) {
241 $sortable = array_keys( self::INDEX_FIELDS );
249 if ( $this->
getConfig()->
get(
'MiserMode' ) && $this->mUserName !==
null ) {
251 return $field ===
'img_timestamp';
252 } elseif ( $this->
getConfig()->
get(
'MiserMode' )
256 return $field ===
'img_name';
259 return in_array( $field, $sortable );
283 $prefix = $table ===
'oldimage' ?
'oi' :
'img';
285 $tables = [ $table,
'actor' ];
288 if ( $table ===
'oldimage' ) {
290 'img_timestamp' =>
'oi_timestamp',
291 'img_name' =>
'oi_name',
292 'img_size' =>
'oi_size',
293 'top' =>
$dbr->addQuotes(
'no' )
295 $join_conds[
'actor'] = [
'JOIN',
'actor_id=oi_actor' ];
301 'top' =>
$dbr->addQuotes(
'yes' )
303 $join_conds[
'actor'] = [
'JOIN',
'actor_id=img_actor' ];
309 $commentQuery = $this->commentStore->getJoin( $prefix .
'_description' );
310 $tables += $commentQuery[
'tables'];
311 $fields += $commentQuery[
'fields'];
312 $join_conds += $commentQuery[
'joins'];
313 $fields[
'description_field'] =
$dbr->addQuotes(
"{$prefix}_description" );
316 $fields[] =
'actor_user';
317 $fields[] =
'actor_name';
319 # Depends on $wgMiserMode
320 # Will also not happen if mShowAll is true.
322 $fields[
'count'] =
$dbr->buildSelectSubquery(
324 'COUNT(oi_archive_name)',
325 'oi_name = img_name',
334 'options' => $options,
335 'join_conds' => $join_conds
351 $this->mTableName =
'image';
352 list( $tables, $fields, $conds, $fname, $options, $join_conds ) =
354 $imageRes =
$dbr->select( $tables, $fields, $conds, $fname, $options, $join_conds );
355 $this->mTableName = $prevTableName;
357 if ( !$this->mShowAll ) {
361 $this->mTableName =
'oldimage';
365 foreach ( $this->mIndexField as &$index ) {
366 if ( substr( $index, 0, 4 ) !==
'img_' ) {
367 throw new MWException(
"Expected to be sorting on an image table field" );
369 $index =
'oi_' . substr( $index, 4 );
372 list( $tables, $fields, $conds, $fname, $options, $join_conds ) =
374 $oldimageRes =
$dbr->select( $tables, $fields, $conds, $fname, $options, $join_conds );
376 $this->mTableName = $prevTableName;
377 $this->mIndexField = $oldIndex;
379 return $this->
combineResult( $imageRes, $oldimageRes, $limit, $order );
396 $topRes1 = $res1->next();
397 $topRes2 = $res2->next();
399 for ( $i = 0; $i < $limit && $topRes1 && $topRes2; $i++ ) {
400 if ( strcmp( $topRes1->{$this->mIndexField[0]}, $topRes2->{$this->mIndexField[0]} ) > 0 ) {
402 $resultArray[] = $topRes1;
403 $topRes1 = $res1->next();
405 $resultArray[] = $topRes2;
406 $topRes2 = $res2->next();
409 $resultArray[] = $topRes2;
410 $topRes2 = $res2->next();
412 $resultArray[] = $topRes1;
413 $topRes1 = $res1->next();
417 for ( ; $i < $limit && $topRes1; $i++ ) {
418 $resultArray[] = $topRes1;
419 $topRes1 = $res1->next();
422 for ( ; $i < $limit && $topRes2; $i++ ) {
423 $resultArray[] = $topRes2;
424 $topRes2 = $res2->next();
431 return [ self::INDEX_FIELDS[$this->mSort] ];
435 if ( $this->mShowAll && $this->getConfig()->
get(
'MiserMode' ) && $this->mUserName ===
null ) {
439 return 'img_timestamp';
445 $this->mResult->seek( 0 );
446 foreach ( $this->mResult as $row ) {
447 if ( $row->actor_user ) {
448 $userIds[] = $row->actor_user;
451 # Do a link batch query for names and userpages
452 $this->userCache->doQuery( $userIds, [
'userpage' ], __METHOD__ );
470 $linkRenderer = $this->getLinkRenderer();
473 $opt = [
'time' =>
wfTimestamp( TS_MW, $this->mCurrentRow->img_timestamp ) ];
474 $file = $this->localRepo->findFile( $this->getCurrentRow()->img_name, $opt );
477 $thumb =
$file->transform( [
'width' => 180,
'height' => 360 ] );
479 return $thumb->toHtml( [
'desc-link' =>
true ] );
481 return $this->msg(
'thumbnail_error',
'' )->escaped();
484 return htmlspecialchars( $this->getCurrentRow()->img_name );
486 case 'img_timestamp':
488 return htmlspecialchars( $this->getLanguage()->userTimeAndDate( $value, $this->getUser() ) );
490 static $imgfile =
null;
491 if ( $imgfile ===
null ) {
492 $imgfile = $this->msg(
'imgfile' )->text();
496 $filePage = Title::makeTitleSafe(
NS_FILE, $value );
498 $link = $linkRenderer->makeKnownLink(
502 $download = Xml::element(
504 [
'href' => $this->localRepo->newFile( $filePage )->getUrl() ],
507 $download = $this->msg(
'parentheses' )->rawParams( $download )->escaped();
511 if ( $this->
getAuthority()->probablyCan(
'delete', $filePage ) ) {
512 $deleteMsg = $this->msg(
'listfiles-delete' )->text();
514 $delete = $linkRenderer->makeKnownLink(
515 $filePage, $deleteMsg, [], [
'action' =>
'delete' ]
517 $delete = $this->msg(
'parentheses' )->rawParams( $delete )->escaped();
519 return "$link $download $delete";
522 return "$link $download";
524 return htmlspecialchars( $value );
527 if ( $this->mCurrentRow->actor_user ) {
528 $name = $this->mCurrentRow->actor_name;
529 $link = $linkRenderer->makeLink(
530 Title::makeTitle(
NS_USER, $name ),
534 $link = $value !==
null ? htmlspecialchars( $value ) :
'';
539 return htmlspecialchars( $this->getLanguage()->formatSize( $value ) );
540 case 'img_description':
541 $field = $this->mCurrentRow->description_field;
542 $value = $this->commentStore->getComment( $field, $this->mCurrentRow )->text;
545 return $this->getLanguage()->formatNum( intval( $value ) + 1 );
548 return $this->msg(
'listfiles-latestversion-' . $value )->escaped();
555 $formDescriptor = [];
556 $formDescriptor[
'limit'] = [
559 'label-message' =>
'table_pager_limit_label',
560 'options' => $this->getLimitSelectList(),
561 'default' => $this->mLimit,
564 if ( !$this->getConfig()->
get(
'MiserMode' ) ) {
565 $formDescriptor[
'ilsearch'] = [
567 'name' =>
'ilsearch',
568 'id' =>
'mw-ilsearch',
569 'label-message' =>
'listfiles_search_for',
570 'default' => $this->mSearch,
572 'maxlength' =>
'255',
576 $formDescriptor[
'user'] = [
579 'id' =>
'mw-listfiles-user',
580 'label-message' =>
'username',
581 'default' => $this->mUserName,
583 'maxlength' =>
'255',
586 $formDescriptor[
'ilshowall'] = [
588 'name' =>
'ilshowall',
589 'id' =>
'mw-listfiles-show-all',
590 'label-message' =>
'listfiles-show-all',
591 'default' => $this->mShowAll,
594 $query = $this->getRequest()->getQueryValues();
595 unset( $query[
'title'] );
596 unset( $query[
'limit'] );
597 unset( $query[
'ilsearch'] );
598 unset( $query[
'ilshowall'] );
599 unset( $query[
'user'] );
601 HTMLForm::factory(
'ooui', $formDescriptor, $this->
getContext() )
603 ->setId(
'mw-listfiles-form' )
605 ->setSubmitTextMsg(
'table_pager_limit_submit' )
606 ->setWrapperLegendMsg(
'listfiles' )
607 ->addHiddenFields( $query )
613 return parent::getTableClass() .
' listfiles';
617 return parent::getNavClass() .
' listfiles_nav';
621 return parent::getSortHeaderClass() .
' listfiles_sort';
625 $queries = parent::getPagingQueries();
626 if ( $this->mUserName !==
null ) {
627 # Append the username to the query string
628 foreach ( $queries as &$query ) {
629 if ( $query !==
false ) {
630 $query[
'user'] = $this->mUserName;
639 $queries = parent::getDefaultQuery();
640 if ( !isset( $queries[
'user'] ) && $this->mUserName !==
null ) {
641 $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.