2015-04-27 14:05:31 +00:00
|
|
|
<?php
|
2015-05-06 12:49:15 +00:00
|
|
|
|
2018-10-02 07:41:19 +00:00
|
|
|
// phpcs:ignore MediaWiki.Files.ClassMatchesFilename.NotMatch
|
2015-04-27 14:05:31 +00:00
|
|
|
class PortableInfoboxHooks {
|
2015-06-19 12:16:07 +00:00
|
|
|
|
2018-08-18 16:12:16 +00:00
|
|
|
public static function onWgQueryPages( array &$queryPages = [] ) {
|
2015-08-20 13:14:23 +00:00
|
|
|
$queryPages[] = [ 'AllinfoboxesQueryPage', 'AllInfoboxes' ];
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
2018-08-15 15:10:55 +00:00
|
|
|
|
2018-10-02 07:41:19 +00:00
|
|
|
public static function onBeforeParserrenderImageGallery(
|
|
|
|
Parser &$parser, ImageGalleryBase &$gallery
|
|
|
|
) {
|
2018-08-18 16:12:16 +00:00
|
|
|
PortableInfobox\Helpers\PortableInfoboxDataBag::getInstance()->setGallery(
|
2018-10-02 07:41:19 +00:00
|
|
|
Parser::MARKER_PREFIX . '-gallery-' . sprintf( '%08X', $parser->mMarkerIndex - 1 ) .
|
|
|
|
Parser::MARKER_SUFFIX,
|
2018-08-18 16:12:16 +00:00
|
|
|
$gallery
|
|
|
|
);
|
2018-08-07 14:02:51 +00:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
2015-09-08 17:42:49 +00:00
|
|
|
|
2015-09-22 15:48:38 +00:00
|
|
|
public static function onAllInfoboxesQueryRecached() {
|
2018-08-06 12:27:25 +00:00
|
|
|
$cache = ObjectCache::getMainWANInstance();
|
2018-08-18 16:12:16 +00:00
|
|
|
$cache->delete( $cache->makeKey( ApiQueryAllinfoboxes::MCACHE_KEY ) );
|
2015-09-22 15:48:38 +00:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Purge memcache before edit
|
|
|
|
*
|
2018-08-16 09:25:53 +00:00
|
|
|
* @param Page|WikiPage $article
|
2015-09-22 15:48:38 +00:00
|
|
|
*
|
|
|
|
* @return bool
|
|
|
|
*/
|
2018-08-16 09:25:53 +00:00
|
|
|
public static function onPageContentSave( Page $article ) {
|
2018-10-19 18:06:16 +00:00
|
|
|
$dataService = PortableInfoboxDataService::newFromTitle( $article->getTitle() );
|
|
|
|
$dataService->delete();
|
|
|
|
|
|
|
|
if ( $article->getTitle()->inNamespace( NS_TEMPLATE ) ) {
|
|
|
|
$dataService->reparseArticle( true );
|
|
|
|
}
|
2015-09-22 15:48:38 +00:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2015-09-25 14:53:39 +00:00
|
|
|
* Purge memcache, this will not rebuild infobox data
|
2015-09-22 15:48:38 +00:00
|
|
|
*
|
2015-09-25 07:23:25 +00:00
|
|
|
* @param Page|WikiPage $article
|
2015-09-22 15:48:38 +00:00
|
|
|
*
|
|
|
|
* @return bool
|
|
|
|
*/
|
2017-08-07 19:26:54 +00:00
|
|
|
public static function onArticlePurge( Page $article ) {
|
2015-09-22 15:48:38 +00:00
|
|
|
PortableInfoboxDataService::newFromTitle( $article->getTitle() )->purge();
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
2018-09-01 13:36:05 +00:00
|
|
|
|
|
|
|
public static function onResourceLoaderRegisterModules( ResourceLoader &$resourceLoader ) {
|
|
|
|
global $wgResourceModules;
|
|
|
|
|
2018-10-02 07:41:19 +00:00
|
|
|
if ( isset( $wgResourceModules['ext.templateDataGenerator.data'] ) ) {
|
2018-09-01 13:36:05 +00:00
|
|
|
$wgResourceModules['ext.templateDataGenerator.data']['scripts'][] =
|
|
|
|
'../PortableInfobox/resources/PortableInfoboxParams.js';
|
|
|
|
|
|
|
|
$resourceLoader->register(
|
|
|
|
'ext.templateDataGenerator.data',
|
|
|
|
$wgResourceModules['ext.templateDataGenerator.data']
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
2015-04-27 14:05:31 +00:00
|
|
|
}
|