PortableInfobox/PortableInfoboxHooks.class.php

142 lines
4 KiB
PHP
Raw Normal View History

<?php
class PortableInfoboxHooks {
2015-06-19 12:16:07 +00:00
public static function onBeforePageDisplay( OutputPage $out, Skin $skin ) {
global $wgEnablePortableInfoboxEuropaTheme;
Wikia::addAssetsToOutput( 'portable_infobox_js' );
if ( F::app()->checkSkin( 'monobook', $skin ) ) {
Wikia::addAssetsToOutput( 'portable_infobox_monobook_scss' );
Wikia::addAssetsToOutput( 'portable_infobox_monobook_js' );
} else {
Wikia::addAssetsToOutput( 'portable_infobox_scss' );
if ( !empty( $wgEnablePortableInfoboxEuropaTheme ) ) {
Wikia::addAssetsToOutput( 'portable_infobox_europa_theme_scss' );
}
}
return true;
}
public static function onImageServingCollectImages( &$imageNamesArray, $articleTitle ) {
if ( $articleTitle ) {
$infoboxImages = PortableInfoboxDataService::newFromTitle( $articleTitle )->getImages();
if ( !empty( $infoboxImages ) ) {
$imageNamesArray = array_merge( $infoboxImages, (array)$imageNamesArray );
}
}
return true;
}
/**
* Store data of all galleries in article to handle images in infoboxes
*
* @param $marker
* @param WikiaPhotoGallery $gallery
* @return bool
*/
public static function onAfterParserParseImageGallery( $marker, $gallery ) {
if ( $gallery instanceof WikiaPhotoGallery ) {
\Wikia\PortableInfobox\Helpers\PortableInfoboxDataBag::getInstance()->setGallery($marker, $gallery->getData());
}
return true;
}
public static function onWgQueryPages( &$queryPages = [ ] ) {
$queryPages[] = [ 'AllinfoboxesQueryPage', 'AllInfoboxes' ];
return true;
}
public static function onAllInfoboxesQueryRecached() {
F::app()->wg->Memc->delete( wfMemcKey( ApiQueryAllinfoboxes::MCACHE_KEY ) );
return true;
}
/**
* Purge memcache before edit
*
* @param $article Page|WikiPage
* @param $user
* @param $text
* @param $summary
* @param $minor
* @param $watchthis
* @param $sectionanchor
* @param $flags
* @param $status
*
* @return bool
*/
SUS-2178: &$this should not be passed by reference (#13444) * SUS-2178: Normalize hook handling in Answers * SUS-2178: Normalize hook handling in Achievements * SUS-2178: Normalize hook handling in AppPromoLanding * SUS-2178: Normalize hook handling in ArticleComments * SUS-2178: Normalize hook handling in ArchiveWikiForum * SUS-2178: Normalize hook handling in ArticleAsJson * SUS-2178: Normalize hook handling in ArticleMetaDescription * SUS-2178: Normalize hook handling in AutoMainpageFixer * SUS-2178: Normalize hook handling AutomaticWikiAdoptionHelper * SUS-2178: Normalize hook handling in BannerNotifications * SUS-2178: Normalize hook handling in Blogs * SUS-2178: Normalize hook handling in CanonicalHref * SUS-2178: Normalize hook handling in Category* * SUS-2178: Normalize hook handling in Chat * SUS-2178: Normalize hook handling in CloseMyAccount * SUS-2178: Normalize hook handling in CommunityMessages * SUS-2178: Normalize hook handling in Comteam * SUS-2178: Normalize hook handling in ContentFeeds * SUS-2178: Normalize hook handling in ContentWarning * SUS-2178: Normalize hook handling in CreatePage * SUS-2178: Normalize hook handling in Discussions * SUS-2178: Normalize hook handling in EditPageLayout * SUS-2178: Normalize hook handling in EditTagging * SUS-2178: Normalize hook handling in EditorPreference * SUS-2178: Normalize hook handling in FlowTracking * SUS-2178: Normalize hook handling in Follow * SUS-2178: Normalize hook handling in Forum * SUS-2178: Normalize hook handling in FounderProgressBar * SUS-2178: Normalize hook handling in HAWelcome * SUS-2178: Normalize hook handling in ImageLazyLoad * SUS-2178: Normalize hook handling in ImageServing * SUS-2178: Normalize hook handling in ImageSizeInfoFunctions * SUS-2178: Normalize hook handling in IndexingPipeline * SUS-2178: Normalize hook handling inInfoboxBuilder * SUS-2178: Normalize hook handling in InterwikiDispatcher * SUS-2178: Normalize hook handling in LatestPhotos * SUS-2178: Normalize hook handling in LinkSuggest * SUS-2178: Normalize hook handling in MainPageTag * SUS-2178: Normalize hook handling in MobileContent * SUS-2178: Normalize hook handling in MyHome * SUS-2178: Normalize hook handling in YouTube * SUS-2178: Normalize hook handling in Phalanx * SUS-2178: Normalize hook handling in Piggyback * SUS-2178: Normalize hook handling in Places * SUS-2178: Normalize hook handling in xbox * SUS-2178: Normalize hook handling in PortableInfobox * SUS-2178: Normalize hook handling in Qualaroo * SUS-2178: Normalize hook handling in RTE * SUS-2178: Normalize hook handling in SEOTweaks * SUS-2178: Normalize hook handling in Scribe * SUS-2178: Normalize hook handling in SharedHelp * SUS-2178: Normalize hook handling in SiteWideMessages * SUS-2178: Normalize hook handling in StaffSig * SUS-2178: Normalize hook handling in UserLogin * SUS-2178: Normalize hook handling in Profile * SUS-2178: Normalize hook handling in Video * SUS-2178: Normalize hook handling in Wall * sus-2178: Normalize hook handling in WAMPage * SUS-2178: Normalize hook Handling in WallNotifications * SUS-2178: Normalize hook handling in WidgetTag * SUS-2178: Normalize hook handling in WikiAnswers * SUS-2178: Normalize hook handling in WikiFactory * SUS-2178: Normalize hook handling in WikiaApi * SUS-2178: Normalize hook handling in WMU * SUS-2178: Normalize hook handling in WikiaMobile * SUS-2178: Normalize hook handling in WikiaPhotoGallery * SUS-2178: Normalize hook handling in WikiaNewtalk * SUS-2178: Normalize hook handling in WikiaWhiteList * SUS-2178: Normalize hook handling in skins * SUS-2178: Normalize hook handling in VisualEditor, remove dead code * SUS-2178: Normalize hooks handling in AbuseFilter * SUS-2178: Normalize hook handling in Variables * SUS-2178: Normalize hooks handling in AntiSpoof * SUS-2178: Normalize hook handling in Arrays * SUS-2178: Normalize hooks handling in Loops * SUS-2178: Normalize hooks handling in Autoincrement * SUS-2178: Normalize hooks handling in CharInsert * SUS-2178: Normalize hooks handling in CharInsert * SUS-2178: Normalize hook handling in ImageMap * SUS-2178: Normalize hooks handling in ConfirmEdit * SUS-2178: Normalize hooks handling in DPLforu * SUS-2178: Normalize hooks handling in Scribunto * SUS-2178: Normalize hooks handling in InputBox * SUS-2178: Normalize hooks handling in MultiUpload * SUS-2178: Normalize hooks handling in OGM * SUS-2178: Normalize hooks handling in Poem * SUS-2178: Normalize hooks handling in RandomImage * SUS-2178: Normalize hooks handling in RegexFu * SUS-2178: Normalize hooks handling in Semantic* * SUS-2178: Normalize hook handling in SpamBlacklist * SUS-2178: Normalize hooks handling in GeSHi * SUS-2178: Normalize hooks handling in TitleBlacklist * SUS-2178: Normalize hooks handling in TorBlock * SUS-2178: Normalize hooks handling in timeline * SUS-2178: Normalize hook handling in includes/wikia * SUS-2178: add few extension hooks I missed * SUS-2178: Get rid of &$this from core MediaWiki * SUS-2178: Remove remaining &$this from extensions * SUS-2178: Remove &$this from maintenance scripts * SUS-2178: remove annoying hooks.txt &$this * SUS-2178: apply SonarQube suggestions * SUS-2178: add two missing extensions * SUS-2178: Update Maps and SMW via composer * SUS-2178: BeforeParserrenderImageGallery - bring back the wonders of pass by reference * Disabling memcache in NavigationTest * SUS-2178: Normalize hook handling in TwitterCards * SUS-2178: Correct parameter type in CommunityMessages * SUS-2178: Correct parameter type in WallHooksHelper::onPersonalUrls * SUS-2178: Correct parameter type in FollowHelper::addPersonalUrl * SUS-2178: Correct parameter type in WikiaApp::onArticleViewHeader * SUS-2178: Correct parameter type in ArticleComment::watchlistNotify * SUS-2178: onArticleSaveComplete - $revision may be null for null edits * SUS-2178: Correct few errors in Scribe and Variables * SUS-2178: Correct parameter types in Arrays extension * SUS-2178: fix class resolution error in IndexingPipeline * SUS-2178: Fix type hint in WallHooksHelper * SUS-2178: Include Maps schema * SUS-2178: Correct parameter types in PageStatsService * SUS-2178: Correct parameter type in ContentReviewHooks::onArticleDeleteComplete * SUS-2178: Update WallHooksHelper::onUserIsBlockedFrom * SUS-2178: Correct parameter type in GadgetHooks::registerModules * SUS-2178: Correct parameter type in FliteTagController * SUS-2178: Correct few more param types * SUS-2178: Remove &$parser from legacy extensions
2017-08-07 19:26:54 +00:00
public static function onArticleSave( Page $article, User $user, &$text, &$summary, $minor, $watchthis, $sectionanchor, &$flags, Status &$status ): bool {
PortableInfoboxDataService::newFromTitle( $article->getTitle() )->delete();
return true;
}
/**
* Purge memcache, this will not rebuild infobox data
*
* @param Page|WikiPage $article
*
* @return bool
*/
SUS-2178: &$this should not be passed by reference (#13444) * SUS-2178: Normalize hook handling in Answers * SUS-2178: Normalize hook handling in Achievements * SUS-2178: Normalize hook handling in AppPromoLanding * SUS-2178: Normalize hook handling in ArticleComments * SUS-2178: Normalize hook handling in ArchiveWikiForum * SUS-2178: Normalize hook handling in ArticleAsJson * SUS-2178: Normalize hook handling in ArticleMetaDescription * SUS-2178: Normalize hook handling in AutoMainpageFixer * SUS-2178: Normalize hook handling AutomaticWikiAdoptionHelper * SUS-2178: Normalize hook handling in BannerNotifications * SUS-2178: Normalize hook handling in Blogs * SUS-2178: Normalize hook handling in CanonicalHref * SUS-2178: Normalize hook handling in Category* * SUS-2178: Normalize hook handling in Chat * SUS-2178: Normalize hook handling in CloseMyAccount * SUS-2178: Normalize hook handling in CommunityMessages * SUS-2178: Normalize hook handling in Comteam * SUS-2178: Normalize hook handling in ContentFeeds * SUS-2178: Normalize hook handling in ContentWarning * SUS-2178: Normalize hook handling in CreatePage * SUS-2178: Normalize hook handling in Discussions * SUS-2178: Normalize hook handling in EditPageLayout * SUS-2178: Normalize hook handling in EditTagging * SUS-2178: Normalize hook handling in EditorPreference * SUS-2178: Normalize hook handling in FlowTracking * SUS-2178: Normalize hook handling in Follow * SUS-2178: Normalize hook handling in Forum * SUS-2178: Normalize hook handling in FounderProgressBar * SUS-2178: Normalize hook handling in HAWelcome * SUS-2178: Normalize hook handling in ImageLazyLoad * SUS-2178: Normalize hook handling in ImageServing * SUS-2178: Normalize hook handling in ImageSizeInfoFunctions * SUS-2178: Normalize hook handling in IndexingPipeline * SUS-2178: Normalize hook handling inInfoboxBuilder * SUS-2178: Normalize hook handling in InterwikiDispatcher * SUS-2178: Normalize hook handling in LatestPhotos * SUS-2178: Normalize hook handling in LinkSuggest * SUS-2178: Normalize hook handling in MainPageTag * SUS-2178: Normalize hook handling in MobileContent * SUS-2178: Normalize hook handling in MyHome * SUS-2178: Normalize hook handling in YouTube * SUS-2178: Normalize hook handling in Phalanx * SUS-2178: Normalize hook handling in Piggyback * SUS-2178: Normalize hook handling in Places * SUS-2178: Normalize hook handling in xbox * SUS-2178: Normalize hook handling in PortableInfobox * SUS-2178: Normalize hook handling in Qualaroo * SUS-2178: Normalize hook handling in RTE * SUS-2178: Normalize hook handling in SEOTweaks * SUS-2178: Normalize hook handling in Scribe * SUS-2178: Normalize hook handling in SharedHelp * SUS-2178: Normalize hook handling in SiteWideMessages * SUS-2178: Normalize hook handling in StaffSig * SUS-2178: Normalize hook handling in UserLogin * SUS-2178: Normalize hook handling in Profile * SUS-2178: Normalize hook handling in Video * SUS-2178: Normalize hook handling in Wall * sus-2178: Normalize hook handling in WAMPage * SUS-2178: Normalize hook Handling in WallNotifications * SUS-2178: Normalize hook handling in WidgetTag * SUS-2178: Normalize hook handling in WikiAnswers * SUS-2178: Normalize hook handling in WikiFactory * SUS-2178: Normalize hook handling in WikiaApi * SUS-2178: Normalize hook handling in WMU * SUS-2178: Normalize hook handling in WikiaMobile * SUS-2178: Normalize hook handling in WikiaPhotoGallery * SUS-2178: Normalize hook handling in WikiaNewtalk * SUS-2178: Normalize hook handling in WikiaWhiteList * SUS-2178: Normalize hook handling in skins * SUS-2178: Normalize hook handling in VisualEditor, remove dead code * SUS-2178: Normalize hooks handling in AbuseFilter * SUS-2178: Normalize hook handling in Variables * SUS-2178: Normalize hooks handling in AntiSpoof * SUS-2178: Normalize hook handling in Arrays * SUS-2178: Normalize hooks handling in Loops * SUS-2178: Normalize hooks handling in Autoincrement * SUS-2178: Normalize hooks handling in CharInsert * SUS-2178: Normalize hooks handling in CharInsert * SUS-2178: Normalize hook handling in ImageMap * SUS-2178: Normalize hooks handling in ConfirmEdit * SUS-2178: Normalize hooks handling in DPLforu * SUS-2178: Normalize hooks handling in Scribunto * SUS-2178: Normalize hooks handling in InputBox * SUS-2178: Normalize hooks handling in MultiUpload * SUS-2178: Normalize hooks handling in OGM * SUS-2178: Normalize hooks handling in Poem * SUS-2178: Normalize hooks handling in RandomImage * SUS-2178: Normalize hooks handling in RegexFu * SUS-2178: Normalize hooks handling in Semantic* * SUS-2178: Normalize hook handling in SpamBlacklist * SUS-2178: Normalize hooks handling in GeSHi * SUS-2178: Normalize hooks handling in TitleBlacklist * SUS-2178: Normalize hooks handling in TorBlock * SUS-2178: Normalize hooks handling in timeline * SUS-2178: Normalize hook handling in includes/wikia * SUS-2178: add few extension hooks I missed * SUS-2178: Get rid of &$this from core MediaWiki * SUS-2178: Remove remaining &$this from extensions * SUS-2178: Remove &$this from maintenance scripts * SUS-2178: remove annoying hooks.txt &$this * SUS-2178: apply SonarQube suggestions * SUS-2178: add two missing extensions * SUS-2178: Update Maps and SMW via composer * SUS-2178: BeforeParserrenderImageGallery - bring back the wonders of pass by reference * Disabling memcache in NavigationTest * SUS-2178: Normalize hook handling in TwitterCards * SUS-2178: Correct parameter type in CommunityMessages * SUS-2178: Correct parameter type in WallHooksHelper::onPersonalUrls * SUS-2178: Correct parameter type in FollowHelper::addPersonalUrl * SUS-2178: Correct parameter type in WikiaApp::onArticleViewHeader * SUS-2178: Correct parameter type in ArticleComment::watchlistNotify * SUS-2178: onArticleSaveComplete - $revision may be null for null edits * SUS-2178: Correct few errors in Scribe and Variables * SUS-2178: Correct parameter types in Arrays extension * SUS-2178: fix class resolution error in IndexingPipeline * SUS-2178: Fix type hint in WallHooksHelper * SUS-2178: Include Maps schema * SUS-2178: Correct parameter types in PageStatsService * SUS-2178: Correct parameter type in ContentReviewHooks::onArticleDeleteComplete * SUS-2178: Update WallHooksHelper::onUserIsBlockedFrom * SUS-2178: Correct parameter type in GadgetHooks::registerModules * SUS-2178: Correct parameter type in FliteTagController * SUS-2178: Correct few more param types * SUS-2178: Remove &$parser from legacy extensions
2017-08-07 19:26:54 +00:00
public static function onArticlePurge( Page $article ) {
PortableInfoboxDataService::newFromTitle( $article->getTitle() )->purge();
return true;
}
2015-09-23 13:56:08 +00:00
/**
* Purge articles memcache when template is edited
*
* @param $articles Array of Titles
2015-09-23 13:56:08 +00:00
*
* @return bool
*/
public static function onBacklinksPurge( Array $articles ) {
foreach ( $articles as $title ) {
2016-12-21 08:09:25 +00:00
PortableInfoboxDataService::newFromTitle( $title )->delete();
}
return true;
}
/**
* Insert a newly created infobox into querycache, and purge the list of
* infoboxes.
*
* @param Page $page The created page object
* @param User $user The user who created the page
* @param string $text Text of the new article
* @param string $summary Edit summary
* @param int $minoredit Minor edit flag
* @param boolean $watchThis Whether or not the user should watch the page
* @param null $sectionAnchor Not used, set to null
* @param int $flags Flags for this page
* @param Revision $revision The newly inserted revision object
* @return boolean
*/
public static function onArticleInsertComplete( Page $page, User $user, $text, $summary, $minoredit,
$watchThis, $sectionAnchor, &$flags, Revision $revision ) {
$title = $page->getTitle();
if ( $title->inNamespace( NS_TEMPLATE ) ) {
( new AllinfoboxesQueryPage() )->addTitleToCache( $title );
}
return true;
}
public static function onArticleAsJsonBeforeEncode( &$text ) {
$tagController = PortableInfoboxParserTagController::getInstance();
$tagController->moveFirstMarkerToTop( $text );
$text = $tagController->replaceMarkers( $text );
return true;
}
}