makePrependedScript( $context ) . parent::getScript( $context ); } /** * @internal * @param ResourceLoaderContext $context * @return string JavaScript code */ public function makePrependedScript( ResourceLoaderContext $context ) { $citationDefinition = json_decode( $context->msg( 'cite-tool-definition.json' ) ->inContentLanguage() ->plain() ); if ( $citationDefinition === null ) { $citationDefinition = json_decode( $context->msg( 'visualeditor-cite-tool-definition.json' ) ->inContentLanguage() ->plain() ); } $citationTools = []; if ( is_array( $citationDefinition ) ) { foreach ( $citationDefinition as $tool ) { if ( !isset( $tool->title ) ) { $tool->title = $context->msg( 'visualeditor-cite-tool-name-' . $tool->name ) ->text(); } $citationTools[] = $tool; } } return 've.init.platform.addMessages(' . $context->encodeJson( [ 'cite-tool-definition.json' => json_encode( $citationTools ) ] ) . ');'; } /** @inheritDoc */ public function getDefinitionSummary( ResourceLoaderContext $context ) { $summary = parent::getDefinitionSummary( $context ); $summary[] = [ 'script' => $this->makePrependedScript( $context ), ]; return $summary; } }