Files
AnatImageViewer/includes/AnnotationHooks.php
Justin Georgi c4e783dd9d Stuck point
Signed-off-by: Justin Georgi <justin.georgi@gmail.com>
2026-05-18 08:56:56 -07:00

41 lines
1.2 KiB
PHP

<?php
namespace MediaWiki\Extension\AnatImageViewer;
class AnnotationHooks {
public static function registrationCallback() {
define( 'CONTENT_MODEL_ANNOTATION', 'annotation' );
}
/**
* Set the content handler for annotations
*
* @param Title $title
* @param string &$model
* @return void
*/
public static function onContentHandlerDefaultModelFor( $title, &$model ) {
if ( $title->getNamespace() === NS_AV_ANNOT ) {
self::console_log('Found fucking thing!',true);
$model = CONTENT_MODEL_ANNOTATION;
}
}
/**
* Small helper function to display information on the browser console
*
* Usage:
* echo '<script>';
* self::console_log('logged string');
* echo '</script>';
*
* @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 = '<script>'. $command . '</script>';
}
echo $command;
}
}