mirror of
https://github.com/Universal-Omega/PortableInfobox.git
synced 2024-11-16 04:22:37 +00:00
DAT-3153 missing template hook approach changed
This commit is contained in:
parent
ff1f403dae
commit
b8e82efa10
|
@ -73,7 +73,7 @@ $wgHooks[ 'BeforePageDisplay' ][] = 'PortableInfoboxHooks::onBeforePageDisplay';
|
|||
$wgHooks[ 'ParserAfterTidy' ][] = 'PortableInfoboxParserTagController::replaceInfoboxMarkers';
|
||||
$wgHooks[ 'ImageServing::buildAndGetIndex' ][] = 'PortableInfoboxHooks::onImageServingCollectImages';
|
||||
$wgHooks[ 'wgQueryPages' ][] = 'PortableInfoboxHooks::onWgQueryPages';
|
||||
$wgHooks[ 'ShowMissingArticle::BeforeTextAppend' ][] = 'PortableInfoboxHooks::onShowMissingArticleBeforeTextAppend';
|
||||
$wgHooks[ 'ArticleNonExistentPage' ][] = 'PortableInfoboxHooks::onArticleNonExistentPage';
|
||||
$wgHooks[ 'SkinAfterBottomScripts' ][] = 'PortableInfoboxHooks::onSkinAfterBottomScripts';
|
||||
|
||||
// special pages
|
||||
|
|
|
@ -58,24 +58,19 @@ class PortableInfoboxHooks {
|
|||
*
|
||||
* @return bool
|
||||
*/
|
||||
public static function onShowMissingArticleBeforeTextAppend( &$article, &$text, &$wgOut, &$errors ) {
|
||||
public static function onArticleNonExistentPage( Article $article, OutputPage $wgOut, $text ) {
|
||||
$title = $article->getTitle();
|
||||
|
||||
if (
|
||||
$title &&
|
||||
!$title->exists() &&
|
||||
$title->getNamespace() === NS_TEMPLATE &&
|
||||
!count( $errors )
|
||||
) {
|
||||
$text = '';
|
||||
|
||||
if ( $title && !$title->exists() && $title->inNamespace( NS_TEMPLATE ) ) {
|
||||
$HTML = F::app()->renderView(
|
||||
'PortableInfoboxBuilderSpecialController',
|
||||
'renderCreateTemplateEntryPoint',
|
||||
[ 'title' => $title->getText() ]
|
||||
);
|
||||
|
||||
$wgOut->clearHTML();
|
||||
$wgOut->addHTML( $HTML );
|
||||
// we don't want to add anything else, it also stops parser
|
||||
// (see Article.php:wfRunHook(ArticleNonExistentPage))
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -97,6 +92,7 @@ class PortableInfoboxHooks {
|
|||
$text .= Html::linkedScript( $script );
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue