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( 'hidepatrolled', false );
46 $opts->add( 'limit', 50 );
47 $opts->add( 'offset', '' );
48 $opts->add( 'start', '' );
49 $opts->add( 'end', '' );
51 $opts->fetchValuesFromRequest( $this->getRequest() );
53 if ( $par !== null ) {
54 $opts->setValue( is_numeric( $par ) ?
'limit' : 'like', $par );
57 // If start date comes after end date chronologically, swap them.
58 // They are swapped in the interface by JS.
59 $start = $opts->getValue( 'start' );
60 $end = $opts->getValue( 'end' );
61 if ( $start !== '' && $end !== '' && $start > $end ) {
66 $opts->setValue( 'start', $start, true );
67 $opts->setValue( 'end', $end, true );
70 $opts->validateIntBounds( 'limit', 0, 500 );
74 if ( !$this->including() ) {
79 $pager = new NewFilesPager( $this->getContext(), $opts );
81 $out->addHTML( $pager->getBody() );
82 if ( !$this->including() ) {
83 $out->addHTML( $pager->getNavigationBar() );
87 protected function buildForm() {
91 'label-message' => 'newimages-label',
97 'label-message' => 'newimages-user',
103 'label-message' => 'newimages-showbots',
104 'name' => 'showbots',
109 'label-message' => 'newimages-hidepatrolled',
110 'name' => 'hidepatrolled',
115 'default' => $this->opts
->getValue( 'limit' ),
121 'default' => $this->opts
->getValue( 'offset' ),
127 'label-message' => 'date-range-from',
133 'label-message' => 'date-range-to',
138 if ( $this->getConfig()->get( 'MiserMode' ) ) {
139 unset( $formDescriptor['like'] );
142 if ( !$this->getUser()->useFilePatrol() ) {
143 unset( $formDescriptor['hidepatrolled'] );
146 HTMLForm
::factory( 'ooui', $formDescriptor, $this->getContext() )
147 ->setWrapperLegendMsg( 'newimages-legend' )
148 ->setSubmitTextMsg( 'ilsubmit' )
151 ->displayForm( false );
154 protected function getGroupName() {
159 * Send the text to be displayed above the options
161 function setTopText() {
164 $message = $this->msg( 'newimagestext' )->inContentLanguage();
165 if ( !$message->isDisabled() ) {
166 $this->getOutput()->addWikiText(
167 Html
::rawElement( 'p',
168 [ 'lang' => $wgContLang->getHtmlCode(), 'dir' => $wgContLang->getDir() ],
169 "\n" . $message->plain() . "\n"
171 /* $lineStart */ false,
172 /* $interface */ false