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 ){
33 $this->outputHeader();
35 $pager = new NewFilesPager( $par );
37 $form = $pager->getForm();
38 $wgOut->addWikiMsg( 'newimages-text' );
40 $form->displayForm( '' );
41 $wgOut->addHTML( $pager->getBody() . $pager->getNavigationBar() );
47 * @ingroup SpecialPage Pager
49 class NewFilesPager
extends ReverseChronologicalPager
{
51 function __construct( $par = null ) {
52 global $wgRequest, $wgUser;
54 $this->like
= $wgRequest->getText( 'like' );
55 $this->showbots
= $wgRequest->getBool( 'showbots' , 0 );
56 $this->skin
= $wgUser->getSkin();
58 parent
::__construct();
61 function getQueryInfo() {
63 $conds = $jconds = array();
64 $tables = array( 'image' );
66 if( !$this->showbots
) {
67 $tables[] = 'user_groups';
68 $conds[] = 'ug_group IS NULL';
69 $jconds['user_groups'] = array(
72 'ug_group' => User
::getGroupsWithPermission( 'bot' ),
78 if( !$wgMiserMode && $this->like
!== null ){
79 $dbr = wfGetDB( DB_SLAVE
);
80 $likeObj = Title
::newFromURL( $this->like
);
81 if( $likeObj instanceof Title
){
82 $like = $dbr->buildLike( $dbr->anyString(), strtolower( $likeObj->getDBkey() ), $dbr->anyString() );
83 $conds[] = "LOWER(img_name) $like";
90 'join_conds' => $jconds,
97 function getIndexField(){
98 return 'img_timestamp';
101 function getStartBody(){
102 $this->gallery
= new ImageGallery();
105 function getEndBody(){
106 return $this->gallery
->toHTML();
109 function formatRow( $row ) {
112 $name = $row->img_name
;
113 $user = User
::newFromId( $row->img_user
);
115 $title = Title
::newFromText( $name, NS_FILE
);
116 $ul = $this->skin
->link( $user->getUserpage(), $user->getName() );
121 . htmlspecialchars( $wgLang->timeanddate( $row->img_timestamp
, true ) )
127 global $wgRequest, $wgMiserMode;
132 'label-message' => 'newimages-label',
137 'label' => wfMessage( 'showhidebots', wfMsg( 'show' ) ),
138 'name' => 'showbots',
139 # 'default' => $wgRequest->getBool( 'showbots', 0 ),
143 'default' => $wgRequest->getText( 'limit' ),
148 'default' => $wgRequest->getText( 'offset' ),
154 unset( $fields['like'] );
157 $form = new HTMLForm( $fields );
158 $form->setTitle( $this->getTitle() );
159 $form->setSubmitText( wfMsg( 'ilsubmit' ) );
160 $form->setMethod( 'get' );
161 $form->setWrapperLegend( wfMsg( 'newimages-legend' ) );