3 * Implements Special:Newimages
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 * http://www.gnu.org/copyleft/gpl.html
21 * @ingroup SpecialPage
24 class SpecialNewFiles
extends IncludableSpecialPage
{
25 /** @var FormOptions */
28 public function __construct() {
29 parent
::__construct( 'Newimages' );
32 public function execute( $par ) {
34 $this->outputHeader();
36 $out = $this->getOutput();
37 $this->addHelpLink( 'Help:New images' );
39 $opts = new FormOptions();
41 $opts->add( 'like', '' );
42 $opts->add( 'user', '' );
43 $opts->add( 'showbots', false );
44 $opts->add( 'hidepatrolled', false );
45 $opts->add( 'limit', 50 );
46 $opts->add( 'offset', '' );
47 $opts->add( 'start', '' );
48 $opts->add( 'end', '' );
50 $opts->fetchValuesFromRequest( $this->getRequest() );
52 if ( $par !== null ) {
53 $opts->setValue( is_numeric( $par ) ?
'limit' : 'like', $par );
56 // If start date comes after end date chronologically, swap them.
57 // They are swapped in the interface by JS.
58 $start = $opts->getValue( 'start' );
59 $end = $opts->getValue( 'end' );
60 if ( $start !== '' && $end !== '' && $start > $end ) {
65 $opts->setValue( 'start', $start, true );
66 $opts->setValue( 'end', $end, true );
69 $opts->validateIntBounds( 'limit', 0, 500 );
73 if ( !$this->including() ) {
78 $pager = new NewFilesPager( $this->getContext(), $opts );
80 $out->addHTML( $pager->getBody() );
81 if ( !$this->including() ) {
82 $out->addHTML( $pager->getNavigationBar() );
86 protected function buildForm() {
90 'label-message' => 'newimages-label',
96 'label-message' => 'newimages-user',
102 'label-message' => 'newimages-showbots',
103 'name' => 'showbots',
108 'label-message' => 'newimages-hidepatrolled',
109 'name' => 'hidepatrolled',
114 'default' => $this->opts
->getValue( 'limit' ),
120 'default' => $this->opts
->getValue( 'offset' ),
126 'label-message' => 'date-range-from',
132 'label-message' => 'date-range-to',
137 if ( $this->getConfig()->get( 'MiserMode' ) ) {
138 unset( $formDescriptor['like'] );
141 if ( !$this->getUser()->useFilePatrol() ) {
142 unset( $formDescriptor['hidepatrolled'] );
145 HTMLForm
::factory( 'ooui', $formDescriptor, $this->getContext() )
146 ->setWrapperLegendMsg( 'newimages-legend' )
147 ->setSubmitTextMsg( 'ilsubmit' )
150 ->displayForm( false );
152 $this->getOutput()->addModules( 'mediawiki.special.newFiles' );
155 protected function getGroupName() {
160 * Send the text to be displayed above the options
162 function setTopText() {
165 $message = $this->msg( 'newimagestext' )->inContentLanguage();
166 if ( !$message->isDisabled() ) {
167 $this->getOutput()->addWikiText(
168 Html
::rawElement( 'p',
169 [ 'lang' => $wgContLang->getHtmlCode(), 'dir' => $wgContLang->getDir() ],
170 "\n" . $message->plain() . "\n"
172 /* $lineStart */ false,
173 /* $interface */ false