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 ){
30 global $wgOut, $wgLang;
33 $pager = new NewFilesPager( $par );
35 $form = $pager->getForm();
36 $wgOut->addWikiMsg( 'newimages-text' );
38 $form->displayForm( '' );
39 $wgOut->addHTML( $pager->getBody() . $pager->getNavigationBar() );
45 * @ingroup SpecialPage Pager
47 class NewFilesPager
extends ReverseChronologicalPager
{
49 function __construct( $par = null ) {
50 global $wgRequest, $wgUser;
52 $this->like
= $wgRequest->getText( 'like' );
53 $this->showbots
= $wgRequest->getBool( 'showbots' , 0 );
54 $this->skin
= $wgUser->getSkin();
56 parent
::__construct();
59 function getQueryInfo() {
61 $conds = $jconds = array();
62 $tables = array( 'image' );
64 if( !$this->showbots
) {
65 $tables[] = 'user_groups';
66 $conds[] = 'ug_group IS NULL';
67 $jconds['user_groups'] = array(
70 'ug_group' => User
::getGroupsWithPermission( 'bot' ),
76 if( !$wgMiserMode && $this->like
!== null ){
77 $dbr = wfGetDB( DB_SLAVE
);
78 $likeObj = Title
::newFromURL( $this->like
);
79 if( $likeObj instanceof Title
){
80 $like = $dbr->buildLike( $dbr->anyString(), strtolower( $likeObj->getDBkey() ), $dbr->anyString() );
81 $conds[] = "LOWER(img_name) $like";
88 'join_conds' => $jconds,
95 function getIndexField(){
96 return 'img_timestamp';
99 function getStartBody(){
100 $this->gallery
= new ImageGallery();
103 function getEndBody(){
104 return $this->gallery
->toHTML();
107 function formatRow( $row ) {
110 $name = $row->img_name
;
111 $user = User
::newFromId( $row->img_user
);
113 $title = Title
::newFromText( $name, NS_FILE
);
114 $ul = $this->skin
->link( $user->getUserpage(), $user->getName() );
119 . htmlspecialchars( $wgLang->timeanddate( $row->img_timestamp
, true ) )
125 global $wgRequest, $wgMiserMode;
130 'label-message' => 'newimages-label',
135 'label' => wfMessage( 'showhidebots', wfMsg( 'show' ) ),
136 'name' => 'showbots',
137 # 'default' => $wgRequest->getBool( 'showbots', 0 ),
141 'default' => $wgRequest->getText( 'limit' ),
146 'default' => $wgRequest->getText( 'offset' ),
152 unset( $fields['like'] );
155 $form = new HTMLForm( $fields );
156 $form->setTitle( $this->getTitle() );
157 $form->setSubmitText( wfMsg( 'ilsubmit' ) );
158 $form->setMethod( 'get' );
159 $form->setWrapperLegend( wfMsg( 'newimages-legend' ) );