diff --git a/extension.json b/extension.json index acef89b..3e818d1 100644 --- a/extension.json +++ b/extension.json @@ -34,6 +34,7 @@ }, "Hooks": { "AlternateEditPreview": "MediaWiki\\Extension\\AnatImageViewer\\AnnotationHooks::onAlternateEditPreview", + "ParserAfterTidy": "MediaWiki\\Extension\\AnatImageViewer\\AnnotationHooks::onParserAfterTidy", "EditFormPreloadText": "MediaWiki\\Extension\\AnatImageViewer\\AnnotationHooks::onEditFormPreloadText" }, "ContentHandlers": { diff --git a/includes/AnnotationHooks.php b/includes/AnnotationHooks.php index d362c48..18c08d0 100644 --- a/includes/AnnotationHooks.php +++ b/includes/AnnotationHooks.php @@ -1,6 +1,8 @@ getNamespace() === NS_AV_ANNOT ) { + $titleText = $title->getBaseText(); $text = <<getTitle(); + if ($title->getNamespace() === NS_FILE) { + $titleText = $title->getBaseText(); + $extPos = strpos($titleText,'.'); + if ($extPos !== false) { + $imName = substr($titleText, 0, $extPos); + } else { + $imName = $titleText; + } + $findLoc = strpos($text, "

recursiveTagParseFully($mwLink); + $newText = <<Annotated File

+ Click below to create or edit an annotated version of this image.
+ ANHEAD; + $text = $text . $newText . $htmlLink; + } + } + } + /** * Small helper function to display information on the browser console *