MediaWiki  master
ImageQueryPage.php
Go to the documentation of this file.
1 <?php
26 
36 abstract class ImageQueryPage extends QueryPage {
50  protected function outputResults( $out, $skin, $dbr, $res, $num, $offset ) {
51  if ( $num > 0 ) {
52  $gallery = ImageGalleryBase::factory( false, $this->getContext() );
53 
54  # $res might contain the whole 1,000 rows, so we read up to
55  # $num [should update this to use a Pager]
56  $i = 0;
57  foreach ( $res as $row ) {
58  $i++;
59  $namespace = $row->namespace ?? NS_FILE;
60  $title = Title::makeTitleSafe( $namespace, $row->title );
61  if ( $title instanceof Title && $title->getNamespace() === NS_FILE ) {
62  $gallery->add( $title, $this->getCellHtml( $row ) );
63  }
64  if ( $i === $num ) {
65  break;
66  }
67  }
68 
69  $out->addHTML( $gallery->toHTML() );
70  }
71  }
72 
81  protected function formatResult( $skin, $result ) {
82  return false;
83  }
84 
93  protected function getCellHtml( $row ) {
94  return '';
95  }
96 }
ImageQueryPage\outputResults
outputResults( $out, $skin, $dbr, $res, $num, $offset)
Format and output report results using the given information plus OutputPage.
Definition: ImageQueryPage.php:50
NS_FILE
const NS_FILE
Definition: Defines.php:75
$res
$res
Definition: testCompression.php:57
QueryPage
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:39
QueryPage\$offset
int $offset
The offset and limit in use, as passed to the query() function.
Definition: QueryPage.php:44
Wikimedia\Rdbms\IDatabase
Basic database interface for live and lazy-loaded relation database handles.
Definition: IDatabase.php:38
$dbr
$dbr
Definition: testCompression.php:54
Wikimedia\Rdbms\IResultWrapper
Result wrapper for grabbing data queried from an IDatabase object.
Definition: IResultWrapper.php:24
$title
$title
Definition: testCompression.php:38
ImageQueryPage\formatResult
formatResult( $skin, $result)
Stable to override.
Definition: ImageQueryPage.php:81
SpecialPage\getContext
getContext()
Gets the context this SpecialPage is executed in.
Definition: SpecialPage.php:717
Title\makeTitleSafe
static makeTitleSafe( $ns, $title, $fragment='', $interwiki='')
Create a new Title from a namespace index and a DB key.
Definition: Title.php:618
Title
Represents a title within MediaWiki.
Definition: Title.php:42
ImageQueryPage\getCellHtml
getCellHtml( $row)
Get additional HTML to be shown in a results' cell.
Definition: ImageQueryPage.php:93
ImageGalleryBase\factory
static factory( $mode=false, IContextSource $context=null)
Get a new image gallery.
Definition: ImageGalleryBase.php:116
ImageQueryPage
Variant of QueryPage which uses a gallery to output results, thus suited for reports generating image...
Definition: ImageQueryPage.php:36