Skip to content

Commit

Permalink
Change HookRegistry.php for SMW 1.35.
Browse files Browse the repository at this point in the history
Possible solution for: SkinTemplateOutputPageBeforeExec hook is being deprecated SemanticMediaWiki#69.
  • Loading branch information
UnknownSkyrimPasserby authored Feb 18, 2021
1 parent 2039125 commit bfc5c45
Showing 1 changed file with 33 additions and 1 deletion.
34 changes: 33 additions & 1 deletion src/HookRegistry.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,40 @@ private function addCallbackHandlers( $store, $options ) {
*
* @see https://www.mediawiki.org/wiki/Manual:Hooks/OutputPageParserOutput
*/
$this->handlers['OutputPageParserOutput'] = function( &$outputPage, $parserOutput ) {
$this->handlers['OutputPageParserOutput'] = function( &$outputPage, $parserOutput ) use( $store, $options )
{
$outputPage->smwmagicwords = $parserOutput->getExtensionData( 'smwmagicwords' );

// For MW 1.35
$bySubpageLinksFinder = new BySubpageLinksFinder();
$bySubpageLinksFinder->setSubpageDiscoveryFallback ( $options->get( 'useSubpageFinderFallback' ) );

$byPropertyHierarchicalLinksFinder = new ByPropertyHierarchicalLinksFinder( $store );
$byPropertyHierarchicalLinksFinder->setFindClosestDescendantState( $options->get( 'tryToFindClosestDescendant' ) );

$byPropertyHierarchicalLinksFinder->setPropertySearchPatternByNamespace( $options->get( 'propertySearchPatternByNamespace' ) );

$htmlBreadcrumbLinksBuilder = new HtmlBreadcrumbLinksBuilder
(
$byPropertyHierarchicalLinksFinder,
$bySubpageLinksFinder
);

$htmlBreadcrumbLinksBuilder->setLinker( new DummyLinker() );
$htmlBreadcrumbLinksBuilder->setBreadcrumbTrailStyleClass( $options->get( 'breadcrumbTrailStyleClass' ) );

$htmlBreadcrumbLinksBuilder->setBreadcrumbDividerStyleClass( $options->get( 'breadcrumbDividerStyleClass' ) );

$htmlBreadcrumbLinksBuilder->hideSubpageParent( $options->get( 'hideSubpageParent' ) );

$skinTemplateOutputModifier = new SkinTemplateOutputModifier
(
$htmlBreadcrumbLinksBuilder,
ApplicationFactory::getInstance()->getNamespaceExaminer()
);

$skinTemplateOutputModifier->modify2( $outputPage );

return true;
};

Expand Down

0 comments on commit bfc5c45

Please sign in to comment.