| 1 |
<?php |
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
namespace PageImages\Hooks; |
| 6 |
|
| 7 |
use MediaWiki\Context\IContextSource; |
| 8 |
use MediaWiki\Title\Title; |
| 9 |
use MobileFrontend\Hooks\SpecialMobileEditWatchlistImagesHook; |
| 10 |
use PageImages\PageImages; |
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
class MobileFrontendHookHandlers implements SpecialMobileEditWatchlistImagesHook { |
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
public function onSpecialMobileEditWatchlist__images( |
| 26 |
IContextSource $context, array &$watchlist, array &$images |
| 27 |
) { |
| 28 |
$ids = []; |
| 29 |
foreach ( $watchlist as $ns => $pages ) { |
| 30 |
foreach ( array_keys( $pages ) as $dbKey ) { |
| 31 |
$title = Title::makeTitle( $ns, $dbKey ); |
| 32 |
|
| 33 |
|
| 34 |
$id = $title->getArticleID(); |
| 35 |
if ( $id ) { |
| 36 |
$ids[$id] = $dbKey; |
| 37 |
} |
| 38 |
} |
| 39 |
} |
| 40 |
|
| 41 |
$data = PageImages::getImages( array_keys( $ids ) ); |
| 42 |
foreach ( $data as $id => $page ) { |
| 43 |
if ( isset( $page['pageimage'] ) ) { |
| 44 |
$images[ $page['ns'] ][ $ids[$id] ] = $page['pageimage']; |
| 45 |
} |
| 46 |
} |
| 47 |
} |
| 48 |
|
| 49 |
} |