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() {
93 $conds = $jconds = array();
94 $tables = array( 'image' );
96 if ( !$this->showbots
) {
97 $groupsWithBotPermission = User
::getGroupsWithPermission( 'bot' );
99 if ( count( $groupsWithBotPermission ) ) {
100 $tables[] = 'user_groups';
101 $conds[] = 'ug_group IS NULL';
102 $jconds['user_groups'] = array(
105 'ug_group' => $groupsWithBotPermission,
112 if ( !$wgMiserMode && $this->like
!== null ) {
113 $dbr = wfGetDB( DB_SLAVE
);
114 $likeObj = Title
::newFromURL( $this->like
);
115 if ( $likeObj instanceof Title
) {
116 $like = $dbr->buildLike(
118 strtolower( $likeObj->getDBkey() ),
121 $conds[] = "LOWER(img_name) $like";
128 'join_conds' => $jconds,
135 function getIndexField() {
136 return 'img_timestamp';
139 function getStartBody() {
140 if ( !$this->gallery
) {
141 // Note that null for mode is taken to mean use default.
142 $mode = $this->getRequest()->getVal( 'gallerymode', null );
144 $this->gallery
= ImageGalleryBase
::factory( $mode );
145 } catch ( MWException
$e ) {
146 // User specified something invalid, fallback to default.
147 $this->gallery
= ImageGalleryBase
::factory();
149 $this->gallery
->setContext( $this->getContext() );
155 function getEndBody() {
156 return $this->gallery
->toHTML();
159 function formatRow( $row ) {
160 $name = $row->img_name
;
161 $user = User
::newFromId( $row->img_user
);
163 $title = Title
::makeTitle( NS_FILE
, $name );
164 $ul = Linker
::link( $user->getUserpage(), $user->getName() );
165 $time = $this->getLanguage()->userTimeAndDate( $row->img_timestamp
, $this->getUser() );
170 . htmlspecialchars( $time )
181 'label-message' => 'newimages-label',
186 'label-message' => 'newimages-showbots',
187 'name' => 'showbots',
191 'default' => $this->mLimit
,
196 'default' => $this->getRequest()->getText( 'offset' ),
201 if ( $wgMiserMode ) {
202 unset( $fields['like'] );
205 $context = new DerivativeContext( $this->getContext() );
206 $context->setTitle( $this->getTitle() ); // Remove subpage
207 $form = new HTMLForm( $fields, $context );
208 $form->setSubmitTextMsg( 'ilsubmit' );
209 $form->setMethod( 'get' );
210 $form->setWrapperLegendMsg( 'newimages-legend' );