3 * Variant of QueryPage which uses a gallery to output results.
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 * http://www.gnu.org/copyleft/gpl.html
21 * @ingroup SpecialPage
24 use Wikimedia\Rdbms\ResultWrapper
;
25 use Wikimedia\Rdbms\IDatabase
;
28 * Variant of QueryPage which uses a gallery to output results, thus
29 * suited for reports generating images
31 * @ingroup SpecialPage
32 * @author Rob Church <robchur@gmail.com>
34 abstract class ImageQueryPage
extends QueryPage
{
36 * Format and output report results using the given information plus
39 * @param OutputPage $out OutputPage to print to
40 * @param Skin $skin User skin to use [unused]
41 * @param IDatabase $dbr (read) connection to use
42 * @param ResultWrapper $res Result pointer
43 * @param int $num Number of available result rows
44 * @param int $offset Paging offset
46 protected function outputResults( $out, $skin, $dbr, $res, $num, $offset ) {
48 $gallery = ImageGalleryBase
::factory( false, $this->getContext() );
50 # $res might contain the whole 1,000 rows, so we read up to
51 # $num [should update this to use a Pager]
53 foreach ( $res as $row ) {
55 $namespace = isset( $row->namespace ) ?
$row->namespace : NS_FILE
;
56 $title = Title
::makeTitleSafe( $namespace, $row->title
);
57 if ( $title instanceof Title
&& $title->getNamespace() == NS_FILE
) {
58 $gallery->add( $title, $this->getCellHtml( $row ) );
65 $out->addHTML( $gallery->toHTML() );
69 // Gotta override this since it's abstract
70 function formatResult( $skin, $result ) {
74 * Get additional HTML to be shown in a results' cell
76 * @param object $row Result row
79 protected function getCellHtml( $row ) {