3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation; either version 2 of the License, or
6 * (at your option) any later version.
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License along
14 * with this program; if not, write to the Free Software Foundation, Inc.,
15 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
16 * http://www.gnu.org/copyleft/gpl.html
25 class NewFilesPager
extends ReverseChronologicalPager
{
38 * @param IContextSource $context
39 * @param FormOptions $opts
41 function __construct( IContextSource
$context, FormOptions
$opts ) {
44 $this->setLimit( $opts->getValue( 'limit' ) );
46 parent
::__construct( $context );
49 function getQueryInfo() {
51 $conds = $jconds = [];
52 $tables = [ 'image' ];
53 $fields = [ 'img_name', 'img_user', 'img_timestamp' ];
56 if ( !$opts->getValue( 'showbots' ) ) {
57 $groupsWithBotPermission = User
::getGroupsWithPermission( 'bot' );
59 if ( count( $groupsWithBotPermission ) ) {
60 $tables[] = 'user_groups';
61 $conds[] = 'ug_group IS NULL';
62 $jconds['user_groups'] = [
65 'ug_group' => $groupsWithBotPermission,
72 if ( $opts->getValue( 'hidepatrolled' ) ) {
73 $tables[] = 'recentchanges';
74 $conds['rc_type'] = RC_LOG
;
75 $conds['rc_log_type'] = 'upload';
76 $conds['rc_patrolled'] = 0;
77 $conds['rc_namespace'] = NS_FILE
;
78 $jconds['recentchanges'] = [
81 'rc_title = img_name',
83 'rc_timestamp = img_timestamp'
86 // We're ordering by img_timestamp, so we have to make sure MariaDB queries `image` first.
87 // It sometimes decides to query `recentchanges` first and filesort the result set later
88 // to get the right ordering. T124205 / https://mariadb.atlassian.net/browse/MDEV-8880
89 $options[] = 'STRAIGHT_JOIN';
92 $likeVal = $opts->getValue( 'like' );
93 if ( !$this->getConfig()->get( 'MiserMode' ) && $likeVal !== '' ) {
94 $dbr = wfGetDB( DB_SLAVE
);
95 $likeObj = Title
::newFromText( $likeVal );
96 if ( $likeObj instanceof Title
) {
97 $like = $dbr->buildLike(
99 strtolower( $likeObj->getDBkey() ),
102 $conds[] = "LOWER(img_name) $like";
109 'join_conds' => $jconds,
111 'options' => $options,
117 function getIndexField() {
118 return 'img_timestamp';
121 function getStartBody() {
122 if ( !$this->gallery
) {
123 // Note that null for mode is taken to mean use default.
124 $mode = $this->getRequest()->getVal( 'gallerymode', null );
126 $this->gallery
= ImageGalleryBase
::factory( $mode, $this->getContext() );
127 } catch ( Exception
$e ) {
128 // User specified something invalid, fallback to default.
129 $this->gallery
= ImageGalleryBase
::factory( false, $this->getContext() );
136 function getEndBody() {
137 return $this->gallery
->toHTML();
140 function formatRow( $row ) {
141 $name = $row->img_name
;
142 $user = User
::newFromId( $row->img_user
);
144 $title = Title
::makeTitle( NS_FILE
, $name );
145 $ul = Linker
::link( $user->getUserPage(), $user->getName() );
146 $time = $this->getLanguage()->userTimeAndDate( $row->img_timestamp
, $this->getUser() );
151 . htmlspecialchars( $time )