2015-04-27 14:05:31 +00:00
|
|
|
<?php
|
2015-05-06 12:49:15 +00:00
|
|
|
|
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-08-18 16:12:16 +00:00
|
|
|
public static function onBeforeParserrenderImageGallery( Parser &$parser, ImageGalleryBase &$gallery ) {
|
|
|
|
PortableInfobox\Helpers\PortableInfoboxDataBag::getInstance()->setGallery(
|
|
|
|
Parser::MARKER_PREFIX . "-gallery-" . sprintf( '%08X', $parser->mMarkerIndex - 1 ) . Parser::MARKER_SUFFIX,
|
|
|
|
$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 ) {
|
2015-09-25 14:53:39 +00:00
|
|
|
PortableInfoboxDataService::newFromTitle( $article->getTitle() )->delete();
|
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;
|
|
|
|
}
|
2015-04-27 14:05:31 +00:00
|
|
|
}
|