MediaWiki
master
Toggle main menu visibility
ImageQueryPage.php
Go to the documentation of this file.
1
<?php
9
10
namespace
MediaWiki\SpecialPage;
11
12
use MediaWiki\Gallery\ImageGalleryBase;
13
use MediaWiki\Output\OutputPage;
14
use MediaWiki\Skin\Skin;
15
use MediaWiki\Title\Title;
16
use stdClass;
17
use Wikimedia\Rdbms\IReadableDatabase;
18
use Wikimedia\Rdbms\IResultWrapper;
19
29
abstract
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
91
// @codeCoverageIgnoreStart
93
class_alias( ImageQueryPage::class,
'ImageQueryPage'
);
94
// @codeCoverageIgnoreEnd
NS_FILE
const NS_FILE
Definition
Defines.php:57
MediaWiki\SpecialPage\ImageQueryPage
Variant of QueryPage which uses a gallery to output results, thus suited for reports generating image...
Definition
ImageQueryPage.php:29
MediaWiki\SpecialPage\ImageQueryPage\formatResult
formatResult( $skin, $result)
Definition
ImageQueryPage.php:74
MediaWiki\SpecialPage\ImageQueryPage\outputResults
outputResults( $out, $skin, $dbr, $res, $num, $offset)
Format and output report results using the given information plus OutputPage.
Definition
ImageQueryPage.php:43
MediaWiki\SpecialPage\ImageQueryPage\getCellHtml
getCellHtml( $row)
Get additional HTML to be shown in a results' cell.
Definition
ImageQueryPage.php:86
MediaWiki\SpecialPage\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:77
MediaWiki\SpecialPage\QueryPage\$offset
int $offset
The offset and limit in use, as passed to the query() function.
Definition
QueryPage.php:82
MediaWiki\SpecialPage\SpecialPage\getContext
getContext()
Gets the context this SpecialPage is executed in.
Definition
SpecialPage.php:834
MediaWiki\Title\Title
Represents a title within MediaWiki.
Definition
Title.php:69
MediaWiki\Title\Title\inNamespace
inNamespace(int $ns)
Returns true if the title is inside the specified namespace.
Definition
Title.php:1287
includes
SpecialPage
ImageQueryPage.php
Generated on
for MediaWiki by
1.18.0