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 $out = $this->getOutput();
34 $this->addHelpLink( 'Help:New images' );
36 $pager = new NewFilesPager( $this->getContext(), $par );
38 if ( !$this->including() ) {
40 $form = $pager->getForm();
42 $form->displayForm( '' );
45 $out->addHTML( $pager->getBody() );
46 if ( !$this->including() ) {
47 $out->addHTML( $pager->getNavigationBar() );
51 protected function getGroupName() {
56 * Send the text to be displayed above the options
58 function setTopText() {
61 $message = $this->msg( 'newimagestext' )->inContentLanguage();
62 if ( !$message->isDisabled() ) {
63 $this->getOutput()->addWikiText(
64 Html
::rawElement( 'p',
65 array( 'lang' => $wgContLang->getHtmlCode(), 'dir' => $wgContLang->getDir() ),
66 "\n" . $message->plain() . "\n"
68 /* $lineStart */ false,
69 /* $interface */ false
76 * @ingroup SpecialPage Pager
78 class NewFilesPager
extends ReverseChronologicalPager
{
84 function __construct( IContextSource
$context, $par = null ) {
85 $this->like
= $context->getRequest()->getText( 'like' );
86 $this->showbots
= $context->getRequest()->getBool( 'showbots', 0 );
87 if ( is_numeric( $par ) ) {
88 $this->setLimit( $par );
91 parent
::__construct( $context );
94 function getQueryInfo() {
95 $conds = $jconds = array();
96 $tables = array( 'image' );
98 if ( !$this->showbots
) {
99 $groupsWithBotPermission = User
::getGroupsWithPermission( 'bot' );
101 if ( count( $groupsWithBotPermission ) ) {
102 $tables[] = 'user_groups';
103 $conds[] = 'ug_group IS NULL';
104 $jconds['user_groups'] = array(
107 'ug_group' => $groupsWithBotPermission,
114 if ( !$this->getConfig()->get( 'MiserMode' ) && $this->like
!== null ) {
115 $dbr = wfGetDB( DB_SLAVE
);
116 $likeObj = Title
::newFromText( $this->like
);
117 if ( $likeObj instanceof Title
) {
118 $like = $dbr->buildLike(
120 strtolower( $likeObj->getDBkey() ),
123 $conds[] = "LOWER(img_name) $like";
130 'join_conds' => $jconds,
137 function getIndexField() {
138 return 'img_timestamp';
141 function getStartBody() {
142 if ( !$this->gallery
) {
143 // Note that null for mode is taken to mean use default.
144 $mode = $this->getRequest()->getVal( 'gallerymode', null );
146 $this->gallery
= ImageGalleryBase
::factory( $mode, $this->getContext() );
147 } catch ( Exception
$e ) {
148 // User specified something invalid, fallback to default.
149 $this->gallery
= ImageGalleryBase
::factory( false, $this->getContext() );
156 function getEndBody() {
157 return $this->gallery
->toHTML();
160 function formatRow( $row ) {
161 $name = $row->img_name
;
162 $user = User
::newFromId( $row->img_user
);
164 $title = Title
::makeTitle( NS_FILE
, $name );
165 $ul = Linker
::link( $user->getUserpage(), $user->getName() );
166 $time = $this->getLanguage()->userTimeAndDate( $row->img_timestamp
, $this->getUser() );
171 . htmlspecialchars( $time )
180 'label-message' => 'newimages-label',
185 'label-message' => 'newimages-showbots',
186 'name' => 'showbots',
190 'default' => $this->mLimit
,
195 'default' => $this->getRequest()->getText( 'offset' ),
200 if ( $this->getConfig()->get( 'MiserMode' ) ) {
201 unset( $fields['like'] );
204 $context = new DerivativeContext( $this->getContext() );
205 $context->setTitle( $this->getTitle() ); // Remove subpage
206 $form = new HTMLForm( $fields, $context );
208 $form->setSubmitTextMsg( 'ilsubmit' );
209 $form->setSubmitProgressive();
211 $form->setMethod( 'get' );
212 $form->setWrapperLegendMsg( 'newimages-legend' );