MediaWiki  master
ImageQueryPage.php
Go to the documentation of this file.
1 <?php
27 
37 abstract class ImageQueryPage extends QueryPage {
51  protected function outputResults( $out, $skin, $dbr, $res, $num, $offset ) {
52  if ( $num > 0 ) {
53  $gallery = ImageGalleryBase::factory( false, $this->getContext() );
54 
55  // $res might contain the whole 1,000 rows, so we read up to
56  // $num [should update this to use a Pager]
57  $i = 0;
58  foreach ( $res as $row ) {
59  $i++;
60  $namespace = $row->namespace ?? NS_FILE;
61  $title = Title::makeTitleSafe( $namespace, $row->title );
62  if ( $title instanceof Title && $title->getNamespace() === NS_FILE ) {
63  $gallery->add( $title, $this->getCellHtml( $row ), '', '', [], ImageGalleryBase::LOADING_LAZY );
64  }
65  if ( $i === $num ) {
66  break;
67  }
68  }
69 
70  $out->addHTML( $gallery->toHTML() );
71  }
72  }
73 
82  protected function formatResult( $skin, $result ) {
83  return false;
84  }
85 
94  protected function getCellHtml( $row ) {
95  return '';
96  }
97 }
const NS_FILE
Definition: Defines.php:70
static factory( $mode=false, IContextSource $context=null)
Get a new image gallery.
Variant of QueryPage which uses a gallery to output results, thus suited for reports generating image...
outputResults( $out, $skin, $dbr, $res, $num, $offset)
Format and output report results using the given information plus OutputPage.
formatResult( $skin, $result)
getCellHtml( $row)
Get additional HTML to be shown in a results' cell.
Represents a title within MediaWiki.
Definition: Title.php:82
This is a class for doing query pages; since they're almost all the same, we factor out some of the f...
Definition: QueryPage.php:65
int $offset
The offset and limit in use, as passed to the query() function.
Definition: QueryPage.php:70
getContext()
Gets the context this SpecialPage is executed in.
Basic database interface for live and lazy-loaded relation database handles.
Definition: IDatabase.php:36
Result wrapper for grabbing data queried from an IDatabase object.