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( 'showbots', false );
43 $opts->add( 'hidepatrolled', false );
44 $opts->add( 'limit', 50 );
45 $opts->add( 'offset', '' );
47 $opts->fetchValuesFromRequest( $this->getRequest() );
49 if ( $par !== null ) {
50 $opts->setValue( is_numeric( $par ) ?
'limit' : 'like', $par );
53 $opts->validateIntBounds( 'limit', 0, 500 );
57 if ( !$this->including() ) {
62 $pager = new NewFilesPager( $this->getContext(), $opts );
64 $out->addHTML( $pager->getBody() );
65 if ( !$this->including() ) {
66 $out->addHTML( $pager->getNavigationBar() );
70 protected function buildForm() {
74 'label-message' => 'newimages-label',
80 'label-message' => 'newimages-showbots',
86 'label-message' => 'newimages-hidepatrolled',
87 'name' => 'hidepatrolled',
92 'default' => $this->opts
->getValue( 'limit' ),
98 'default' => $this->opts
->getValue( 'offset' ),
103 if ( $this->getConfig()->get( 'MiserMode' ) ) {
104 unset( $formDescriptor['like'] );
107 if ( !$this->getUser()->useFilePatrol() ) {
108 unset( $formDescriptor['hidepatrolled'] );
111 HTMLForm
::factory( 'ooui', $formDescriptor, $this->getContext() )
112 ->setWrapperLegendMsg( 'newimages-legend' )
113 ->setSubmitTextMsg( 'ilsubmit' )
116 ->displayForm( false );
119 protected function getGroupName() {
124 * Send the text to be displayed above the options
126 function setTopText() {
129 $message = $this->msg( 'newimagestext' )->inContentLanguage();
130 if ( !$message->isDisabled() ) {
131 $this->getOutput()->addWikiText(
132 Html
::rawElement( 'p',
133 [ 'lang' => $wgContLang->getHtmlCode(), 'dir' => $wgContLang->getDir() ],
134 "\n" . $message->plain() . "\n"
136 /* $lineStart */ false,
137 /* $interface */ false