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 $out->addModules( 'mediawiki.special.newFiles' );
38 $this->addHelpLink( 'Help:New images' );
40 $opts = new FormOptions();
42 $opts->add( 'like', '' );
43 $opts->add( 'user', '' );
44 $opts->add( 'showbots', false );
45 $opts->add( 'newbies', false );
46 $opts->add( 'hidepatrolled', false );
47 $opts->add( 'limit', 50 );
48 $opts->add( 'offset', '' );
49 $opts->add( 'start', '' );
50 $opts->add( 'end', '' );
52 $opts->fetchValuesFromRequest( $this->getRequest() );
54 if ( $par !== null ) {
55 $opts->setValue( is_numeric( $par ) ?
'limit' : 'like', $par );
58 // If start date comes after end date chronologically, swap them.
59 // They are swapped in the interface by JS.
60 $start = $opts->getValue( 'start' );
61 $end = $opts->getValue( 'end' );
62 if ( $start !== '' && $end !== '' && $start > $end ) {
67 $opts->setValue( 'start', $start, true );
68 $opts->setValue( 'end', $end, true );
71 $opts->validateIntBounds( 'limit', 0, 500 );
75 if ( !$this->including() ) {
80 $pager = new NewFilesPager( $this->getContext(), $opts );
82 $out->addHTML( $pager->getBody() );
83 if ( !$this->including() ) {
84 $out->addHTML( $pager->getNavigationBar() );
88 protected function buildForm() {
92 'label-message' => 'newimages-label',
98 'label-message' => 'newimages-user',
104 'label-message' => 'newimages-newbies',
110 'label-message' => 'newimages-showbots',
111 'name' => 'showbots',
116 'label-message' => 'newimages-hidepatrolled',
117 'name' => 'hidepatrolled',
122 'default' => $this->opts
->getValue( 'limit' ),
128 'default' => $this->opts
->getValue( 'offset' ),
134 'label-message' => 'date-range-from',
140 'label-message' => 'date-range-to',
145 if ( $this->getConfig()->get( 'MiserMode' ) ) {
146 unset( $formDescriptor['like'] );
149 if ( !$this->getUser()->useFilePatrol() ) {
150 unset( $formDescriptor['hidepatrolled'] );
153 HTMLForm
::factory( 'ooui', $formDescriptor, $this->getContext() )
154 ->setWrapperLegendMsg( 'newimages-legend' )
155 ->setSubmitTextMsg( 'ilsubmit' )
158 ->displayForm( false );
161 protected function getGroupName() {
166 * Send the text to be displayed above the options
168 function setTopText() {
171 $message = $this->msg( 'newimagestext' )->inContentLanguage();
172 if ( !$message->isDisabled() ) {
173 $this->getOutput()->addWikiText(
174 Html
::rawElement( 'p',
175 [ 'lang' => $wgContLang->getHtmlCode(), 'dir' => $wgContLang->getDir() ],
176 "\n" . $message->plain() . "\n"
178 /* $lineStart */ false,
179 /* $interface */ false