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
23 class SpecialNewFiles
extends IncludableSpecialPage
{
24 public function __construct() {
25 parent
::__construct( 'Newimages' );
28 public function execute( $par ) {
30 $this->outputHeader();
32 $pager = new NewFilesPager( $this->getContext(), $par );
34 if ( !$this->including() ) {
35 $form = $pager->getForm();
37 $form->displayForm( '' );
40 $this->getOutput()->addHTML( $pager->getBody() );
41 if ( !$this->including() ) {
42 $this->getOutput()->addHTML( $pager->getNavigationBar() );
46 protected function getGroupName() {
52 * @ingroup SpecialPage Pager
54 class NewFilesPager
extends ReverseChronologicalPager
{
60 function __construct( IContextSource
$context, $par = null ) {
61 $this->like
= $context->getRequest()->getText( 'like' );
62 $this->showbots
= $context->getRequest()->getBool( 'showbots', 0 );
63 if ( is_numeric( $par ) ) {
64 $this->setLimit( $par );
67 parent
::__construct( $context );
70 function getQueryInfo() {
72 $conds = $jconds = array();
73 $tables = array( 'image' );
75 if ( !$this->showbots
) {
76 $groupsWithBotPermission = User
::getGroupsWithPermission( 'bot' );
78 if ( count( $groupsWithBotPermission ) ) {
79 $tables[] = 'user_groups';
80 $conds[] = 'ug_group IS NULL';
81 $jconds['user_groups'] = array(
84 'ug_group' => $groupsWithBotPermission,
91 if ( !$wgMiserMode && $this->like
!== null ) {
92 $dbr = wfGetDB( DB_SLAVE
);
93 $likeObj = Title
::newFromURL( $this->like
);
94 if ( $likeObj instanceof Title
) {
95 $like = $dbr->buildLike(
97 strtolower( $likeObj->getDBkey() ),
100 $conds[] = "LOWER(img_name) $like";
107 'join_conds' => $jconds,
114 function getIndexField() {
115 return 'img_timestamp';
118 function getStartBody() {
119 if ( !$this->gallery
) {
120 $this->gallery
= new ImageGallery();
126 function getEndBody() {
127 return $this->gallery
->toHTML();
130 function formatRow( $row ) {
131 $name = $row->img_name
;
132 $user = User
::newFromId( $row->img_user
);
134 $title = Title
::makeTitle( NS_FILE
, $name );
135 $ul = Linker
::link( $user->getUserpage(), $user->getName() );
136 $time = $this->getLanguage()->userTimeAndDate( $row->img_timestamp
, $this->getUser() );
141 . htmlspecialchars( $time )
152 'label-message' => 'newimages-label',
157 'label' => $this->msg( 'showhidebots', $this->msg( 'show' )->plain() )->escaped(),
158 'name' => 'showbots',
162 'default' => $this->mLimit
,
167 'default' => $this->getRequest()->getText( 'offset' ),
172 if ( $wgMiserMode ) {
173 unset( $fields['like'] );
176 $form = new HTMLForm( $fields, $this->getContext() );
177 $form->setTitle( $this->getTitle() );
178 $form->setSubmitTextMsg( 'ilsubmit' );
179 $form->setMethod( 'get' );
180 $form->setWrapperLegendMsg( 'newimages-legend' );