MediaWiki master
ImageQueryPage.php
Go to the documentation of this file.
1<?php
24namespace MediaWiki\SpecialPage;
25
29use Skin;
30use stdClass;
33
43abstract class ImageQueryPage extends QueryPage {
57 protected function outputResults( $out, $skin, $dbr, $res, $num, $offset ) {
58 if ( $num > 0 ) {
59 $gallery = ImageGalleryBase::factory( false, $this->getContext() );
60
61 // $res might contain the whole 1,000 rows, so we read up to
62 // $num [should update this to use a Pager]
63 $i = 0;
64 foreach ( $res as $row ) {
65 $i++;
66 $namespace = $row->namespace ?? NS_FILE;
67 $title = Title::makeTitleSafe( $namespace, $row->title );
68 if ( $title instanceof Title && $title->inNamespace( NS_FILE ) ) {
69 $gallery->add( $title, $this->getCellHtml( $row ), '', '', [], ImageGalleryBase::LOADING_LAZY );
70 }
71 if ( $i === $num ) {
72 break;
73 }
74 }
75
76 $out->addHTML( $gallery->toHTML() );
77 }
78 }
79
88 protected function formatResult( $skin, $result ) {
89 return false;
90 }
91
100 protected function getCellHtml( $row ) {
101 return '';
102 }
103}
104
106class_alias( ImageQueryPage::class, 'ImageQueryPage' );
const NS_FILE
Definition Defines.php:70
This is one of the Core classes and should be read at least once by any new developers.
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.
getCellHtml( $row)
Get additional HTML to be shown in a results' cell.
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:89
int $offset
The offset and limit in use, as passed to the query() function.
Definition QueryPage.php:94
getContext()
Gets the context this SpecialPage is executed in.
Represents a title within MediaWiki.
Definition Title.php:78
inNamespace(int $ns)
Returns true if the title is inside the specified namespace.
Definition Title.php:1302
The base class for all skins.
Definition Skin.php:58
A database connection without write operations.
Result wrapper for grabbing data queried from an IDatabase object.