Merge "Update docs/hooks.txt for ShowSearchHitTitle"
[mediawiki.git] / includes / specials / SpecialNewimages.php
blob9e3a7509bcac701a1a61e2176f1eb6da80ff2915
1 <?php
2 /**
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
20 * @file
21 * @ingroup SpecialPage
24 class SpecialNewFiles extends IncludableSpecialPage {
25 /** @var FormOptions */
26 protected $opts;
28 public function __construct() {
29 parent::__construct( 'Newimages' );
32 public function execute( $par ) {
33 $this->setHeaders();
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 );
55 $this->opts = $opts;
57 if ( !$this->including() ) {
58 $this->setTopText();
59 $this->buildForm();
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() {
71 $formDescriptor = [
72 'like' => [
73 'type' => 'text',
74 'label-message' => 'newimages-label',
75 'name' => 'like',
78 'showbots' => [
79 'type' => 'check',
80 'label-message' => 'newimages-showbots',
81 'name' => 'showbots',
84 'hidepatrolled' => [
85 'type' => 'check',
86 'label-message' => 'newimages-hidepatrolled',
87 'name' => 'hidepatrolled',
90 'limit' => [
91 'type' => 'hidden',
92 'default' => $this->opts->getValue( 'limit' ),
93 'name' => 'limit',
96 'offset' => [
97 'type' => 'hidden',
98 'default' => $this->opts->getValue( 'offset' ),
99 'name' => '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' )
114 ->setMethod( 'get' )
115 ->prepareForm()
116 ->displayForm( false );
119 protected function getGroupName() {
120 return 'changes';
124 * Send the text to be displayed above the options
126 function setTopText() {
127 global $wgContLang;
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