getTitle(); if ( $title->getNamespace() === NS_AV_ANNOT ) { $out = $editor->getContext()->getOutput(); $out->addModules('ext.annot.prev'); } return true; } /** * MWHook: Add preloaded text to editor on page creation * * @see https://www.mediawiki.org/wiki/Manual:Hooks/EditFormPreloadText * * @param string $text editor text * @param Title $Title title of the created page * @return bool|void True or no return value to continue or false to abort */ public static function onEditFormPreloadText( &$text, &$title ) { if ( $title->getNamespace() === NS_AV_ANNOT ) { $titleText = $title->getBaseText(); $text = <<Annotated File Click below to create or edit an annotated version of this image.
ANHEAD; $titleText = $imagePage->getFile()->getTitle()->getBaseText(); $extPos = strpos($titleText,'.'); if ($extPos !== false) { $imName = substr($titleText, 0, $extPos); } else { $imName = $titleText; } $linkRenderer = MediaWikiServices::getInstance()->getLinkRenderer(); $title = Title::newFromText( "Annotation:" . $imName ); $mwLink = $linkRenderer->makeLink( $title ); $html = $newText . $mwLink . $html; } /** * Small helper function to display information on the browser console * * Usage: * echo ''; * * @param $data information to display * @param bool $add_script_tags true to put information is inside complete script tag */ public static function console_log($data, $add_script_tags = false) { $command = 'console.log('. json_encode($data, JSON_HEX_TAG).');'; if ($add_script_tags) { $command = ''; } echo $command; } }