$this->setHeaders();
$this->outputHeader();
- $pager = new NewFilesPager( $par );
+ $pager = new NewFilesPager( $this->getContext(), $par );
if ( !$this->including() ) {
$form = $pager->getForm();
*/
class NewFilesPager extends ReverseChronologicalPager {
- function __construct( $par = null ) {
- global $wgRequest, $wgUser;
+ /**
+ * @var ImageGallery
+ */
+ var $gallery;
- $this->like = $wgRequest->getText( 'like' );
- $this->showbots = $wgRequest->getBool( 'showbots' , 0 );
- $this->skin = $wgUser->getSkin();
+ function __construct( IContextSource $context, $par = null ) {
+ $this->like = $context->getRequest()->getText( 'like' );
+ $this->showbots = $context->getRequest()->getBool( 'showbots' , 0 );
+ if ( is_numeric( $par ) ) {
+ $this->setLimit( $par );
+ }
- parent::__construct();
+ parent::__construct( $context );
}
function getQueryInfo() {
$tables = array( 'image' );
if( !$this->showbots ) {
- $tables[] = 'user_groups';
- $conds[] = 'ug_group IS NULL';
- $jconds['user_groups'] = array(
- 'LEFT JOIN',
- array(
- 'ug_group' => User::getGroupsWithPermission( 'bot' ),
- 'ug_user = img_user'
- )
- );
+ $groupsWithBotPermission = User::getGroupsWithPermission( 'bot' );
+ if( count( $groupsWithBotPermission ) ) {
+ $tables[] = 'user_groups';
+ $conds[] = 'ug_group IS NULL';
+ $jconds['user_groups'] = array(
+ 'LEFT JOIN',
+ array(
+ 'ug_group' => $groupsWithBotPermission,
+ 'ug_user = img_user'
+ )
+ );
+ }
}
if( !$wgMiserMode && $this->like !== null ){
}
function getStartBody(){
- $this->gallery = new ImageGallery();
+ if ( !$this->gallery ) {
+ $this->gallery = new ImageGallery();
+ }
+ return '';
}
function getEndBody(){
}
function formatRow( $row ) {
- global $wgLang;
-
$name = $row->img_name;
$user = User::newFromId( $row->img_user );
- $title = Title::newFromText( $name, NS_FILE );
- $ul = $this->skin->link( $user->getUserpage(), $user->getName() );
+ $title = Title::makeTitle( NS_FILE, $name );
+ $ul = Linker::link( $user->getUserpage(), $user->getName() );
$this->gallery->add(
$title,
"$ul<br />\n<i>"
- . htmlspecialchars( $wgLang->timeanddate( $row->img_timestamp, true ) )
+ . htmlspecialchars( $this->getLanguage()->userTimeAndDate( $row->img_timestamp, $this->getUser() ) )
. "</i><br />\n"
);
}
function getForm() {
- global $wgRequest, $wgMiserMode;
+ global $wgMiserMode;
$fields = array(
'like' => array(
),
'showbots' => array(
'type' => 'check',
- 'label' => wfMessage( 'showhidebots', wfMsg( 'show' ) ),
+ 'label' => $this->msg( 'showhidebots', $this->msg( 'show' )->plain() )->escaped(),
'name' => 'showbots',
- # 'default' => $wgRequest->getBool( 'showbots', 0 ),
+ # 'default' => $this->getRequest()->getBool( 'showbots', 0 ),
),
'limit' => array(
'type' => 'hidden',
- 'default' => $wgRequest->getText( 'limit' ),
+ 'default' => $this->mLimit,
'name' => 'limit',
),
'offset' => array(
'type' => 'hidden',
- 'default' => $wgRequest->getText( 'offset' ),
+ 'default' => $this->getRequest()->getText( 'offset' ),
'name' => 'offset',
),
);
unset( $fields['like'] );
}
- $form = new HTMLForm( $fields );
+ $form = new HTMLForm( $fields, $this->getContext() );
$form->setTitle( $this->getTitle() );
- $form->setSubmitText( wfMsg( 'ilsubmit' ) );
+ $form->setSubmitTextMsg( 'ilsubmit' );
$form->setMethod( 'get' );
- $form->setWrapperLegend( wfMsg( 'newimages-legend' ) );
+ $form->setWrapperLegendMsg( 'newimages-legend' );
return $form;
}