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 public function __construct() {
26 parent
::__construct( 'Newimages' );
29 public function execute( $par ) {
31 $this->outputHeader();
33 $pager = new NewFilesPager( $this->getContext(), $par );
35 if ( !$this->including() ) {
37 $form = $pager->getForm();
39 $form->displayForm( '' );
42 $this->getOutput()->addHTML( $pager->getBody() );
43 if ( !$this->including() ) {
44 $this->getOutput()->addHTML( $pager->getNavigationBar() );
48 protected function getGroupName() {
53 * Send the text to be displayed above the options
55 function setTopText() {
58 $message = $this->msg( 'newimagestext' )->inContentLanguage();
59 if ( !$message->isDisabled() ) {
60 $this->getOutput()->addWikiText(
61 Html
::rawElement( 'p',
62 array( 'lang' => $wgContLang->getCode(), 'dir' => $wgContLang->getDir() ),
63 "\n" . $message->plain() . "\n"
65 /* $lineStart */ false,
66 /* $interface */ false
73 * @ingroup SpecialPage Pager
75 class NewFilesPager
extends ReverseChronologicalPager
{
81 function __construct( IContextSource
$context, $par = null ) {
82 $this->like
= $context->getRequest()->getText( 'like' );
83 $this->showbots
= $context->getRequest()->getBool( 'showbots', 0 );
84 if ( is_numeric( $par ) ) {
85 $this->setLimit( $par );
88 parent
::__construct( $context );
91 function getQueryInfo() {
92 $conds = $jconds = array();
93 $tables = array( 'image' );
95 if ( !$this->showbots
) {
96 $groupsWithBotPermission = User
::getGroupsWithPermission( 'bot' );
98 if ( count( $groupsWithBotPermission ) ) {
99 $tables[] = 'user_groups';
100 $conds[] = 'ug_group IS NULL';
101 $jconds['user_groups'] = array(
104 'ug_group' => $groupsWithBotPermission,
111 if ( !$this->getConfig()->get( 'MiserMode' ) && $this->like
!== null ) {
112 $dbr = wfGetDB( DB_SLAVE
);
113 $likeObj = Title
::newFromURL( $this->like
);
114 if ( $likeObj instanceof Title
) {
115 $like = $dbr->buildLike(
117 strtolower( $likeObj->getDBkey() ),
120 $conds[] = "LOWER(img_name) $like";
127 'join_conds' => $jconds,
134 function getIndexField() {
135 return 'img_timestamp';
138 function getStartBody() {
139 if ( !$this->gallery
) {
140 // Note that null for mode is taken to mean use default.
141 $mode = $this->getRequest()->getVal( 'gallerymode', null );
143 $this->gallery
= ImageGalleryBase
::factory( $mode, $this->getContext() );
144 } catch ( MWException
$e ) {
145 // User specified something invalid, fallback to default.
146 $this->gallery
= ImageGalleryBase
::factory( false, $this->getContext() );
153 function getEndBody() {
154 return $this->gallery
->toHTML();
157 function formatRow( $row ) {
158 $name = $row->img_name
;
159 $user = User
::newFromId( $row->img_user
);
161 $title = Title
::makeTitle( NS_FILE
, $name );
162 $ul = Linker
::link( $user->getUserpage(), $user->getName() );
163 $time = $this->getLanguage()->userTimeAndDate( $row->img_timestamp
, $this->getUser() );
168 . htmlspecialchars( $time )
177 'label-message' => 'newimages-label',
182 'label-message' => 'newimages-showbots',
183 'name' => 'showbots',
187 'default' => $this->mLimit
,
192 'default' => $this->getRequest()->getText( 'offset' ),
197 if ( $this->getConfig()->get( 'MiserMode' ) ) {
198 unset( $fields['like'] );
201 $context = new DerivativeContext( $this->getContext() );
202 $context->setTitle( $this->getTitle() ); // Remove subpage
203 $form = new HTMLForm( $fields, $context );
205 $form->setSubmitTextMsg( 'ilsubmit' );
206 $form->setSubmitProgressive();
208 $form->setMethod( 'get' );
209 $form->setWrapperLegendMsg( 'newimages-legend' );