Load WikiEditor ref toolbar button on other content types

Allow other extensions to provide lists of page content
models for which they want to load the Cite toolbar button.
This will, for example, make it possible for ProofreadPage
to have the button on Page pages.

Bug: T348403
Change-Id: Id28cb0b6cb8a2b86a66b17232575afe513969c54
This commit is contained in:
Sam Wilson 2023-10-10 09:46:58 +08:00 committed by Jdlrobson
parent 7ef1d0d009
commit b03dd1bba8

View file

@ -91,11 +91,16 @@ class CiteHooks implements
* @param OutputPage $outputPage object.
*/
public function onEditPage__showEditForm_initial( $editPage, $outputPage ) {
if ( $editPage->contentModel !== CONTENT_MODEL_WIKITEXT ) {
$extensionRegistry = ExtensionRegistry::getInstance();
$allowedContentModels = array_merge(
[ CONTENT_MODEL_WIKITEXT ],
$extensionRegistry->getAttribute( 'CiteAllowedContentModels' )
);
if ( !in_array( $editPage->contentModel, $allowedContentModels ) ) {
return;
}
$wikiEditorEnabled = ExtensionRegistry::getInstance()->isLoaded( 'WikiEditor' );
$wikiEditorEnabled = $extensionRegistry->isLoaded( 'WikiEditor' );
$user = $editPage->getContext()->getUser();