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[ 'ImageServing::buildAndGetIndex' ][] = 'PortableInfoboxHooks::onImageServingCollectImages';
$wgHooks[ 'wgQueryPages' ][] = 'PortableInfoboxHooks::onWgQueryPages';
$wgHooks[ 'ShowMissingArticle::BeforeTextAppend' ][] = 'PortableInfoboxHooks::onShowMissingArticleBeforeTextAppend';
$wgHooks[ 'ArticleNonExistentPage' ][] = 'PortableInfoboxHooks::onArticleNonExistentPage';
$wgHooks[ 'SkinAfterBottomScripts' ][] = 'PortableInfoboxHooks::onSkinAfterBottomScripts';
// special pages

View file

@ -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;
}
}