Move to namespace specific svg annotations #1
@@ -13,17 +13,13 @@
|
||||
"constant": "NS_AV_ANNOT",
|
||||
"name": "Annotation",
|
||||
"protection": "annotations-edit",
|
||||
"subpages": false,
|
||||
"content": true,
|
||||
"defaultcontentmodel": "annotation"
|
||||
"subpages": false
|
||||
},
|
||||
{
|
||||
"id": 2219,
|
||||
"constant": "NS_AV_ANNOT_TALK",
|
||||
"name": "Annotation_talk",
|
||||
"subpages": true,
|
||||
"content": false,
|
||||
"defaultcontentmodel": "wikitext"
|
||||
"subpages": true
|
||||
}
|
||||
],
|
||||
"callback": "MediaWiki\\Extension\\AnatImageViewer\\AnnotationHooks::registrationCallback",
|
||||
@@ -31,8 +27,9 @@
|
||||
"MediaWiki\\Extension\\AnatImageViewer\\": "includes/"
|
||||
},
|
||||
"ContentHandlers": {
|
||||
"annotation": "MediaWiki\\Extension\\AnatImageViewer\\AnnotationHandler"
|
||||
"annotation": "MediaWiki\\Extension\\AnatImageViewer\\AnnotationHandler::class"
|
||||
},
|
||||
"Hooks": {
|
||||
"ContentHandlerDefaultModelFor": "MediaWiki\\Extension\\AnatImageViewer\\AnnotationHooks::onContentHandlerDefaultModelFor"
|
||||
}
|
||||
}
|
||||
@@ -8,7 +8,7 @@ class AnnotationContent extends TextContent {
|
||||
public function __construct( $modelId = 'annotation' ) {
|
||||
parent::__construct( $modelId );
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
public function getTextForSearchIndex() {
|
||||
}
|
||||
|
||||
@@ -4,20 +4,41 @@ namespace MediaWiki\Extension\AnatImageViewer;
|
||||
use Devium\Toml\Toml;
|
||||
use MediaWiki\MediaWikiServices;
|
||||
use Content;
|
||||
use TextContentHandler;
|
||||
use Title;
|
||||
use CodeContentHandler;
|
||||
use MediaWiki\Content\Renderer\ContentParseParams;
|
||||
use ParserOutput;
|
||||
use ConfigFactory;
|
||||
use RequestContext;
|
||||
use Html;
|
||||
|
||||
class AnnotationHandler extends TextContentHandler {
|
||||
class AnnotationHandler extends CodeContentHandler {
|
||||
private const ANNOT_VERSION = '0.1';
|
||||
|
||||
public function __construct( $modelId = 'annotation' ) {
|
||||
parent::__construct( $modelId, [ CONTENT_FORMAT_TEXT ] );
|
||||
}
|
||||
|
||||
protected function getContentClass() {
|
||||
return AnnotationContent::class;
|
||||
}
|
||||
|
||||
/**
|
||||
* Only allow this content handler to be used in the Module namespace
|
||||
* @param Title $title
|
||||
* @return bool
|
||||
*/
|
||||
public function canBeUsedOn( Title $title ) {
|
||||
if ( $title->getNamespace() !== NS_AV_ANNOT ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return parent::canBeUsedOn( $title );
|
||||
}
|
||||
|
||||
/** @inheritDoc */
|
||||
public function supportsPreloadContent(): bool {
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
public function serializeContent( Content $content, $format = null ) {
|
||||
}
|
||||
@@ -25,7 +46,7 @@ class AnnotationHandler extends TextContentHandler {
|
||||
public function unserializeContent( $blob, $format = null ) {
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
public function makeEmptyContent() {
|
||||
return new AnnotationContent();
|
||||
}
|
||||
@@ -35,9 +56,7 @@ class AnnotationHandler extends TextContentHandler {
|
||||
}
|
||||
|
||||
protected function fillParserOutput( Content $content, ContentParseParams $cpoParams, ParserOutput &$output ) {
|
||||
// define $html somewhere
|
||||
// e.g. $output->setText( $html );
|
||||
|
||||
self::console_log('Parsing the fucking thing', true);
|
||||
self::console_log($content, true);
|
||||
|
||||
$metadata = toml_decode($content->getNativeData(), true);
|
||||
@@ -83,8 +102,6 @@ class AnnotationHandler extends TextContentHandler {
|
||||
);
|
||||
$elBaseImg = Html::rawElement('image', $attrBase);
|
||||
}
|
||||
$mainConfig = ConfigFactory::getDefaultInstance()->makeConfig( 'main' );
|
||||
$context = RequestContext::getMain();
|
||||
|
||||
//Render and return svg
|
||||
$attrSvg = array(
|
||||
|
||||
@@ -1,17 +1,25 @@
|
||||
<?php
|
||||
namespace MediaWiki\Extension\AnatImageViewer;
|
||||
|
||||
use MediaWiki\MediaWikiServices;
|
||||
use RequestContext;
|
||||
use Html;
|
||||
use ParserOutput;
|
||||
|
||||
class AnnotationHooks {
|
||||
public static function registrationCallback() {
|
||||
// Must match the name used in the 'ContentHandlers' section of extension.json
|
||||
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
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user