* @ingroup SpecialPage Pager
*/
class ImageListPager extends TablePager {
- var $mFieldNames = null;
+ protected $mFieldNames = null;
+
// Subclasses should override buildQueryConds instead of using $mQueryConds variable.
- var $mQueryConds = array();
- var $mUserName = null;
- var $mSearch = '';
- var $mIncluding = false;
- var $mShowAll = false;
- var $mTableName = 'image';
+ protected $mQueryConds = array();
+
+ protected $mUserName = null;
+
+ protected $mSearch = '';
+
+ protected $mIncluding = false;
+
+ protected $mShowAll = false;
+
+ protected $mTableName = 'image';
function __construct( IContextSource $context, $userName = null, $search = '',
$including = false, $showAll = false
* Build the where clause of the query.
*
* Replaces the older mQueryConds member variable.
- * @param $table String Either "image" or "oldimage"
+ * @param string $table Either "image" or "oldimage"
* @return array The query conditions.
*/
protected function buildQueryConds( $table ) {
}
/**
- * @return Array
+ * @return array
*/
function getFieldNames() {
if ( !$this->mFieldNames ) {
'img_name' => $this->msg( 'listfiles_name' )->text(),
'thumb' => $this->msg( 'listfiles_thumb' )->text(),
'img_size' => $this->msg( 'listfiles_size' )->text(),
- 'img_user_text' => $this->msg( 'listfiles_user' )->text(),
- 'img_description' => $this->msg( 'listfiles_description' )->text(),
);
+ if ( is_null( $this->mUserName ) ) {
+ // Do not show username if filtering by username
+ $this->mFieldNames['img_user_text'] = $this->msg( 'listfiles_user' )->text();
+ }
+ // img_description down here, in order so that its still after the username field.
+ $this->mFieldNames['img_description'] = $this->msg( 'listfiles_description' )->text();
+
if ( !$wgMiserMode && !$this->mShowAll ) {
$this->mFieldNames['count'] = $this->msg( 'listfiles_count' )->text();
}
*
* This is a bit hacky.
*
- * @param $table String Either 'image' or 'oldimage'
+ * @param string $table Either 'image' or 'oldimage'
* @return array Query info
*/
protected function getQueryInfoReal( $table ) {
* @note $asc is named $descending in IndexPager base class. However
* it is true when the order is ascending, and false when the order
* is descending, so I renamed it to $asc here.
+ * @param int $offset
+ * @param int $limit
+ * @param bool $asc
*/
function reallyDoQuery( $offset, $limit, $asc ) {
$prevTableName = $this->mTableName;
$this->mTableName = 'image';
- list( $tables, $fields, $conds, $fname, $options, $join_conds ) = $this->buildQueryInfo( $offset, $limit, $asc );
+ list( $tables, $fields, $conds, $fname, $options, $join_conds ) =
+ $this->buildQueryInfo( $offset, $limit, $asc );
$imageRes = $this->mDb->select( $tables, $fields, $conds, $fname, $options, $join_conds );
$this->mTableName = $prevTableName;
}
$this->mIndexField = 'oi_' . substr( $this->mIndexField, 4 );
- list( $tables, $fields, $conds, $fname, $options, $join_conds ) = $this->buildQueryInfo( $offset, $limit, $asc );
+ list( $tables, $fields, $conds, $fname, $options, $join_conds ) =
+ $this->buildQueryInfo( $offset, $limit, $asc );
$oldimageRes = $this->mDb->select( $tables, $fields, $conds, $fname, $options, $join_conds );
$this->mTableName = $prevTableName;
*
* Note: This will throw away some results
*
- * @param $res1 ResultWrapper
- * @param $res2 ResultWrapper
- * @param $limit int
- * @param $ascending boolean See note about $asc in $this->reallyDoQuery
+ * @param ResultWrapper $res1
+ * @param ResultWrapper $res2
+ * @param int $limit
+ * @param bool $ascending See note about $asc in $this->reallyDoQuery
* @return FakeResultWrapper $res1 and $res2 combined
*/
protected function combineResult( $res1, $res2, $limit, $ascending ) {
}
}
}
+
+ // @codingStandardsIgnoreStart Squiz.WhiteSpace.SemicolonSpacing.Incorrect
for ( ; $i < $limit && $topRes1; $i++ ) {
+ // @codingStandardsIgnoreEnd
$resultArray[] = $topRes1;
$topRes1 = $res1->next();
}
+
+ // @codingStandardsIgnoreStart Squiz.WhiteSpace.SemicolonSpacing.Incorrect
for ( ; $i < $limit && $topRes2; $i++ ) {
+ // @codingStandardsIgnoreEnd
$resultArray[] = $topRes2;
$topRes2 = $res2->next();
}
if ( !is_null( $this->mUserName ) ) {
# Append the username to the query string
foreach ( $queries as &$query ) {
- $query['user'] = $this->mUserName;
+ if ( $query !== false ) {
+ $query['user'] = $this->mUserName;
+ }
}
}