DAT-3153 missing template hook approach changed

This commit is contained in:
idradm 2015-09-08 12:48:40 +02:00
parent ff1f403dae
commit b8e82efa10
2 changed files with 8 additions and 12 deletions

View file

@ -73,7 +73,7 @@ $wgHooks[ 'BeforePageDisplay' ][] = 'PortableInfoboxHooks::onBeforePageDisplay';
$wgHooks[ 'ParserAfterTidy' ][] = 'PortableInfoboxParserTagController::replaceInfoboxMarkers'; $wgHooks[ 'ParserAfterTidy' ][] = 'PortableInfoboxParserTagController::replaceInfoboxMarkers';
$wgHooks[ 'ImageServing::buildAndGetIndex' ][] = 'PortableInfoboxHooks::onImageServingCollectImages'; $wgHooks[ 'ImageServing::buildAndGetIndex' ][] = 'PortableInfoboxHooks::onImageServingCollectImages';
$wgHooks[ 'wgQueryPages' ][] = 'PortableInfoboxHooks::onWgQueryPages'; $wgHooks[ 'wgQueryPages' ][] = 'PortableInfoboxHooks::onWgQueryPages';
$wgHooks[ 'ShowMissingArticle::BeforeTextAppend' ][] = 'PortableInfoboxHooks::onShowMissingArticleBeforeTextAppend'; $wgHooks[ 'ArticleNonExistentPage' ][] = 'PortableInfoboxHooks::onArticleNonExistentPage';
$wgHooks[ 'SkinAfterBottomScripts' ][] = 'PortableInfoboxHooks::onSkinAfterBottomScripts'; $wgHooks[ 'SkinAfterBottomScripts' ][] = 'PortableInfoboxHooks::onSkinAfterBottomScripts';
// special pages // special pages

View file

@ -58,24 +58,19 @@ class PortableInfoboxHooks {
* *
* @return bool * @return bool
*/ */
public static function onShowMissingArticleBeforeTextAppend( &$article, &$text, &$wgOut, &$errors ) { public static function onArticleNonExistentPage( Article $article, OutputPage $wgOut, $text ) {
$title = $article->getTitle(); $title = $article->getTitle();
if ( $title && !$title->exists() && $title->inNamespace( NS_TEMPLATE ) ) {
if (
$title &&
!$title->exists() &&
$title->getNamespace() === NS_TEMPLATE &&
!count( $errors )
) {
$text = '';
$HTML = F::app()->renderView( $HTML = F::app()->renderView(
'PortableInfoboxBuilderSpecialController', 'PortableInfoboxBuilderSpecialController',
'renderCreateTemplateEntryPoint', 'renderCreateTemplateEntryPoint',
[ 'title' => $title->getText() ] [ 'title' => $title->getText() ]
); );
$wgOut->clearHTML();
$wgOut->addHTML( $HTML ); $wgOut->addHTML( $HTML );
// we don't want to add anything else, it also stops parser
// (see Article.php:wfRunHook(ArticleNonExistentPage))
return false;
} }
return true; return true;
@ -97,6 +92,7 @@ class PortableInfoboxHooks {
$text .= Html::linkedScript( $script ); $text .= Html::linkedScript( $script );
} }
} }
return true; return true;
} }
} }