MediaWiki master
ImageQueryPage.php
Go to the documentation of this file.
1<?php
10namespace MediaWiki\SpecialPage;
11
16use stdClass;
19
29abstract class ImageQueryPage extends QueryPage {
43 protected function outputResults( $out, $skin, $dbr, $res, $num, $offset ) {
44 if ( $num > 0 ) {
45 $gallery = ImageGalleryBase::factory( false, $this->getContext() );
46
47 // $res might contain the whole 1,000 rows, so we read up to
48 // $num [should update this to use a Pager]
49 $i = 0;
50 foreach ( $res as $row ) {
51 $i++;
52 $namespace = $row->namespace ?? NS_FILE;
53 $title = Title::makeTitleSafe( $namespace, $row->title );
54 if ( $title instanceof Title && $title->inNamespace( NS_FILE ) ) {
55 $gallery->add( $title, $this->getCellHtml( $row ), '', '', [], ImageGalleryBase::LOADING_LAZY );
56 }
57 if ( $i === $num ) {
58 break;
59 }
60 }
61
62 $out->addHTML( $gallery->toHTML() );
63 }
64 }
65
74 protected function formatResult( $skin, $result ) {
75 return false;
76 }
77
86 protected function getCellHtml( $row ) {
87 return '';
88 }
89}
90
92class_alias( ImageQueryPage::class, 'ImageQueryPage' );
const NS_FILE
Definition Defines.php:57
This is one of the Core classes and should be read at least once by any new developers.
The base class for all skins.
Definition Skin.php:52
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:77
int $offset
The offset and limit in use, as passed to the query() function.
Definition QueryPage.php:82
getContext()
Gets the context this SpecialPage is executed in.
Represents a title within MediaWiki.
Definition Title.php:70
inNamespace(int $ns)
Returns true if the title is inside the specified namespace.
Definition Title.php:1296
A database connection without write operations.
Result wrapper for grabbing data queried from an IDatabase object.