Move to namespace specific svg annotations #1
@@ -7,29 +7,32 @@
|
||||
"license-name": "MIT",
|
||||
"type": "media",
|
||||
"manifest_version": 1,
|
||||
"requires": {
|
||||
"MediaWiki": ">= 1.39.0"
|
||||
},
|
||||
"namespaces": [
|
||||
{
|
||||
"id": 2218,
|
||||
"constant": "NS_AV_ANNOT",
|
||||
"name": "Annotation",
|
||||
"protection": "annotations-edit",
|
||||
"subpages": false
|
||||
"subpages": false,
|
||||
"content": false,
|
||||
"defaultcontentmodel": "annotation"
|
||||
},
|
||||
{
|
||||
"id": 2219,
|
||||
"constant": "NS_AV_ANNOT_TALK",
|
||||
"name": "Annotation_talk",
|
||||
"subpages": true
|
||||
"subpages": true,
|
||||
"content": false,
|
||||
"defaultcontentmodel": "wikitext"
|
||||
}
|
||||
],
|
||||
"callback": "MediaWiki\\Extension\\AnatImageViewer\\AnnotationHooks::registrationCallback",
|
||||
"AutoloadNamespaces": {
|
||||
"MediaWiki\\Extension\\AnatImageViewer\\": "includes/"
|
||||
},
|
||||
"ContentHandlers": {
|
||||
"annotation": "MediaWiki\\Extension\\AnatImageViewer\\AnnotationHandler::class"
|
||||
},
|
||||
"Hooks": {
|
||||
"ContentHandlerDefaultModelFor": "MediaWiki\\Extension\\AnatImageViewer\\AnnotationHooks::onContentHandlerDefaultModelFor"
|
||||
"annotation": "MediaWiki\\Extension\\AnatImageViewer\\AnnotationHandler"
|
||||
}
|
||||
}
|
||||
@@ -1,32 +1,60 @@
|
||||
<?php
|
||||
namespace MediaWiki\Extension\AnatImageViewer;
|
||||
|
||||
use Content;
|
||||
use TextContent;
|
||||
|
||||
class AnnotationContent extends TextContent {
|
||||
public const MODEL = 'annotation';
|
||||
|
||||
public function __construct( $modelId = 'annotation' ) {
|
||||
parent::__construct( $modelId );
|
||||
/** @inheritDoc */
|
||||
public function __construct( $text, $model_id = self::MODEL ) {
|
||||
parent::__construct( $text, $model_id );
|
||||
}
|
||||
|
||||
/*
|
||||
public function getTextForSearchIndex() {
|
||||
}
|
||||
|
||||
public function getWikitextForTransclusion() {
|
||||
}
|
||||
|
||||
public function getTextForSummary( $maxLength = 250 ) {
|
||||
}
|
||||
|
||||
public function getSize() {
|
||||
}
|
||||
|
||||
public function copy() {
|
||||
}
|
||||
/**
|
||||
* Determines whether this content can be considered empty.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isEmpty() {
|
||||
$text = trim( strip_tags( $this->getText() ) );
|
||||
return $text === '';
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines whether this content should be counted as a "page" for the wiki's statistics.
|
||||
*
|
||||
* @param bool|null $hasLinks
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isCountable( $hasLinks = null ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
public function isValid() {
|
||||
return parent::isValid();
|
||||
}
|
||||
|
||||
/**
|
||||
* Should return text relevant to the wiki's search index.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getTextForSearchIndex() {
|
||||
return strip_tags( $this->getText() );
|
||||
}
|
||||
|
||||
public function convert( $toModel, $lossy = '' ) {
|
||||
return parent::convert( $toModel, $lossy );
|
||||
}
|
||||
|
||||
public function getSection( $sectionId ) {
|
||||
return parent::getSection( $sectionId );
|
||||
}
|
||||
|
||||
public function replaceSection( $sectionId, Content $with, $sectionTitle = '' ) {
|
||||
return parent::replaceSection( $sectionId, $with, $sectionTitle );
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,8 @@
|
||||
<?php
|
||||
namespace MediaWiki\Extension\AnatImageViewer;
|
||||
|
||||
require_once __DIR__ . '/../vendor/autoload.php';
|
||||
|
||||
use Devium\Toml\Toml;
|
||||
use MediaWiki\MediaWikiServices;
|
||||
use Content;
|
||||
@@ -9,12 +11,19 @@ use CodeContentHandler;
|
||||
use MediaWiki\Content\Renderer\ContentParseParams;
|
||||
use ParserOutput;
|
||||
use Html;
|
||||
use IContextSource;
|
||||
use MediaWiki\Content\ValidationParams;
|
||||
use Status;
|
||||
|
||||
|
||||
class AnnotationHandler extends CodeContentHandler {
|
||||
private const ANNOT_VERSION = '0.1';
|
||||
|
||||
public function __construct( $modelId = 'annotation' ) {
|
||||
parent::__construct( $modelId, [ CONTENT_FORMAT_TEXT ] );
|
||||
public function __construct(
|
||||
$modelId = AnnotationContent::MODEL,
|
||||
$formats = [ CONTENT_FORMAT_TEXT ]
|
||||
) {
|
||||
parent::__construct( $modelId, $formats );
|
||||
}
|
||||
|
||||
protected function getContentClass() {
|
||||
@@ -39,27 +48,23 @@ class AnnotationHandler extends CodeContentHandler {
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
public function serializeContent( Content $content, $format = null ) {
|
||||
return parent::serializeContent( $content, $format );
|
||||
}
|
||||
|
||||
public function unserializeContent( $blob, $format = null ) {
|
||||
public function unserializeContent( $text, $format = null ) {
|
||||
return new AnnotationContent( $text );
|
||||
}
|
||||
*/
|
||||
|
||||
public function makeEmptyContent() {
|
||||
return new AnnotationContent();
|
||||
}
|
||||
|
||||
public function supportsDirectEditing() {
|
||||
return true;
|
||||
return new AnnotationContent( '' );
|
||||
}
|
||||
|
||||
protected function fillParserOutput( Content $content, ContentParseParams $cpoParams, ParserOutput &$output ) {
|
||||
self::console_log('Parsing the fucking thing', true);
|
||||
self::console_log($content, true);
|
||||
|
||||
$metadata = toml_decode($content->getNativeData(), true);
|
||||
self::console_log(var_dump($metadata), true);
|
||||
|
||||
if (isset($metadata['baseImage'])) {
|
||||
$baseImage = MediaWikiServices::getInstance()->getRepoGroup()->findFile('File:' . $metadata['baseImage']);
|
||||
@@ -77,11 +82,11 @@ class AnnotationHandler extends CodeContentHandler {
|
||||
* and produces the html string for the svg with base image and annotations.
|
||||
*
|
||||
* @param string $metadata The metadata object parsed from the text
|
||||
* @param string $baseImageUrl The full url pointing to the base image to annotate
|
||||
* @param array $frameParams The additional user defined parameters for the viewer such as hotspot and view classes
|
||||
* @return string Html string of the complete model-viewer element inside a div container
|
||||
* @param string $baseImage The full url pointing to the base image to annotate
|
||||
* @return string Html string of the complete svg
|
||||
*/
|
||||
private function buildSvg($metadata, $baseImage) {
|
||||
self::console_log(var_dump($baseImage), true);
|
||||
//Gather basic data
|
||||
$elBaseImg = '';
|
||||
$vbHeight = 100;
|
||||
|
||||
Reference in New Issue
Block a user