4 * Variant of QueryPage which uses a gallery to output results, thus
5 * suited for reports generating images
8 * @author Rob Church <robchur@gmail.com>
10 class ImageQueryPage
extends QueryPage
{
13 * Format and output report results using the given information plus
16 * @param OutputPage $out OutputPage to print to
17 * @param Skin $skin User skin to use
18 * @param Database $dbr Database (read) connection to use
19 * @param int $res Result pointer
20 * @param int $num Number of available result rows
21 * @param int $offset Paging offset
23 protected function outputResults( $out, $skin, $dbr, $res, $num, $offset ) {
25 $gallery = new ImageGallery();
26 $gallery->useSkin( $skin );
28 # $res might contain the whole 1,000 rows, so we read up to
29 # $num [should update this to use a Pager]
30 for( $i = 0; $i < $num && $row = $dbr->fetchObject( $res ); $i++
) {
31 $image = $this->prepareImage( $row );
32 if( $image instanceof Image
)
33 $gallery->add( $image, $this->getCellHtml( $row ) );
36 $out->addHtml( $gallery->toHtml() );
41 * Prepare an image object given a result row
43 * @param object $row Result row
46 private function prepareImage( $row ) {
47 $namespace = isset( $row->namespace ) ?
$row->namespace : NS_IMAGE
;
48 $title = Title
::makeTitleSafe( $namespace, $row->title
);
49 return ( $title instanceof Title
&& $title->getNamespace() == NS_IMAGE
)
55 * Get additional HTML to be shown in a results' cell
57 * @param object $row Result row
60 protected function getCellHtml( $row ) {