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
{
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() ) {
36 $form = $pager->getForm();
38 $form->displayForm( '' );
40 $this->getOutput()->addHTML( $pager->getBody() );
41 if ( !$this->including() ) {
42 $this->getOutput()->addHTML( $pager->getNavigationBar() );
49 * @ingroup SpecialPage Pager
51 class NewFilesPager
extends ReverseChronologicalPager
{
58 function __construct( IContextSource
$context, $par = null ) {
59 $this->like
= $context->getRequest()->getText( 'like' );
60 $this->showbots
= $context->getRequest()->getBool( 'showbots' , 0 );
62 parent
::__construct( $context );
65 function getQueryInfo() {
67 $conds = $jconds = array();
68 $tables = array( 'image' );
70 if( !$this->showbots
) {
71 $tables[] = 'user_groups';
72 $conds[] = 'ug_group IS NULL';
73 $jconds['user_groups'] = array(
76 'ug_group' => User
::getGroupsWithPermission( 'bot' ),
82 if( !$wgMiserMode && $this->like
!== null ){
83 $dbr = wfGetDB( DB_SLAVE
);
84 $likeObj = Title
::newFromURL( $this->like
);
85 if( $likeObj instanceof Title
){
86 $like = $dbr->buildLike( $dbr->anyString(), strtolower( $likeObj->getDBkey() ), $dbr->anyString() );
87 $conds[] = "LOWER(img_name) $like";
94 'join_conds' => $jconds,
101 function getIndexField(){
102 return 'img_timestamp';
105 function getStartBody(){
106 if ( !$this->gallery
) {
107 $this->gallery
= new ImageGallery();
112 function getEndBody(){
113 return $this->gallery
->toHTML();
116 function formatRow( $row ) {
117 $name = $row->img_name
;
118 $user = User
::newFromId( $row->img_user
);
120 $title = Title
::makeTitle( NS_FILE
, $name );
121 $ul = Linker
::link( $user->getUserpage(), $user->getName() );
126 . htmlspecialchars( $this->getLanguage()->userTimeAndDate( $row->img_timestamp
, $this->getUser() ) )
137 'label-message' => 'newimages-label',
142 'label' => $this->msg( 'showhidebots', $this->msg( 'show' )->plain() )->escaped(),
143 'name' => 'showbots',
144 # 'default' => $this->getRequest()->getBool( 'showbots', 0 ),
148 'default' => $this->getRequest()->getText( 'limit' ),
153 'default' => $this->getRequest()->getText( 'offset' ),
159 unset( $fields['like'] );
162 $form = new HTMLForm( $fields, $this->getContext() );
163 $form->setTitle( $this->getTitle() );
164 $form->setSubmitTextMsg( 'ilsubmit' );
165 $form->setMethod( 'get' );
166 $form->setWrapperLegendMsg( 'newimages-legend' );