Nikerabbit has submitted this change and it was merged.

Change subject: Migrate to JSON i18n
......................................................................


Migrate to JSON i18n

Procedure per https://www.mediawiki.org/wiki/Manual:GenerateJsonI18n.php
with shim.

Change line endings to Unix.

Change-Id: I994098a1496fd4e69a5d1db9836028d6e9218d8b
---
M SIA_AjaxFunctions.php
M SIA_AnnotationPrinter.php
M SemanticImageAnnotator.php
A i18n/de.json
A i18n/en.json
M languages/SIA_Messages.php
6 files changed, 381 insertions(+), 353 deletions(-)

Approvals:
  Nikerabbit: Verified; Looks good to me, approved



diff --git a/SIA_AjaxFunctions.php b/SIA_AjaxFunctions.php
index 9bec9ce..9a0dca7 100644
--- a/SIA_AjaxFunctions.php
+++ b/SIA_AjaxFunctions.php
@@ -1,92 +1,92 @@
-<?php
-       /**
-       * Part of SemanticImageAnnotator
-       * Provides Functions that are called from Javascript.
-       * The functions are called from the editing view as well as from query 
results with format=imageannotation
-       * @author Felix Obenauer
-       */
-function removeAnnotation($annotationID){
-       $article = new Article(Title::newFromText($annotationID));
-       $article->doDelete('ImageAnnotation removed');
-       return($annotationID);
-}
-       
-function writeAnnotationProperties($newPageName, $annotatedImage, $imageURL, 
$coords,$createdBy){
-       $newTitle = Title::newFromText($newPageName);
-       $newArticle = new Article($newTitle);
-       $content = '';
-       $content .= '{{ImageAnnotation}}';
-       $content .= '[[SIAannotatedImage::'.$annotatedImage.'| ]]'."\n";
-       $content .= '[[SIAimageURL::'.$imageURL.'| ]]'."\n";
-       $content .= '[[SIArectangleCoordinates::'.$coords.'| ]]'."\n";
-       $content .= '[[SIAcreatedBy::'.$createdBy.'| ]]'."\n";
-       $content .= '[[Category:ImageAnnotation]]'."\n";
-       $newArticle->doEdit($content, 'Created by Semantic Image Annotator');
-       return ('success');
-}
-
-//Returns a JSON object containing all shapes for the specified article.
-function getAnnotations($annotatedImage){
-       global $wgExtensionCredits;
-        $new = false;
-        foreach($wgExtensionCredits['semantic'] as $elem){
-            if($elem['name'] == 'Semantic MediaWiki'){
-                $vers = $elem['version'];
-                $new = version_compare($vers, '1.7', '>=');
-            }
-        }
-        
-        $returnString = '{"shapes":[';
-        $queryString = '[[SIAannotatedImage::'.$annotatedImage.']]';
-        $params = array();
-        $params['link'] = 'none';
-        $params['mainlabel'] = 'result';
-        #$params = ['order'];
-        #$params = ['sort'];
-        
-       if($new){
-            $params['order'] = array('asc');
-            $params['sort'] = array('SIAannotatedImage');
-        }
-        else{
-            $params['order'] = 'asc';
-            $params['sort'] = 'SIAannotatedImage';
-        }
-        
-       //Generate all the extra printouts, eg all properties to retrieve:
-       $printmode = SMWPrintRequest::PRINT_PROP;
-       $customPrintouts = array(       'coordinates'   => 
'SIArectangleCoordinates',
-                                                               'text'          
        => 'ImageAnnotationText'
-                                                       );
-       $extraprintouts = array();
-       foreach($customPrintouts as $label => $property){
-               $extraprintouts[] = new SMWPrintRequest($printmode, $label, 
SMWPropertyValue::makeUserProperty($property));
-       }
-
-       $format = 'table';
-       $context = SMWQueryProcessor::INLINE_QUERY;
-
-       $query  = SMWQueryProcessor::createQuery( $queryString, $params, 
$context, $format, $extraprintouts );
-       $store = smwfGetStore(); // default store
-       $res = $store->getQueryResult( $query );
-       
-       $shapeCounter = 0;
-       while( ($resArrayArray = $res->getNext()) != false){    //Array of 
SMWResultArray Objects, eg. all retrieved Pages
-               $shapeCounter++;
-
-               if($shapeCounter > 1) $returnString.=',';
-               $returnString.='{';
-               foreach($resArrayArray as $resArray){                           
//SMWResultArray-Object, column of resulttable (pagename or propertyvalue)      
                
-                       $currentPrintRequestLabel = 
$resArray->getPrintRequest()->getLabel();   //The label as defined in the above 
array
-                       if($currentPrintRequestLabel == 'coordinates'){
-                               $currentResultPage = 
$resArray->getResultSubject();                             
-                               $currentID = 
$currentResultPage->getTitle()->getFullText();
-                               $currentCoords = 
$resArray->getNextDataItem()->getSerialization();
-                               
$returnString.='"coords":"'.$currentCoords.'","id":"'.$currentID.'"';
-                       }
-               }
-               $returnString.='}';
-       }
-       $returnString .= ']}';
-       return($returnString);
-}
+<?php
+       /**
+       * Part of SemanticImageAnnotator
+       * Provides Functions that are called from Javascript.
+       * The functions are called from the editing view as well as from query 
results with format=imageannotation
+       * @author Felix Obenauer
+       */
+function removeAnnotation($annotationID){
+       $article = new Article(Title::newFromText($annotationID));
+       $article->doDelete('ImageAnnotation removed');
+       return($annotationID);
+}
+       
+function writeAnnotationProperties($newPageName, $annotatedImage, $imageURL, 
$coords,$createdBy){
+       $newTitle = Title::newFromText($newPageName);
+       $newArticle = new Article($newTitle);
+       $content = '';
+       $content .= '{{ImageAnnotation}}';
+       $content .= '[[SIAannotatedImage::'.$annotatedImage.'| ]]'."\n";
+       $content .= '[[SIAimageURL::'.$imageURL.'| ]]'."\n";
+       $content .= '[[SIArectangleCoordinates::'.$coords.'| ]]'."\n";
+       $content .= '[[SIAcreatedBy::'.$createdBy.'| ]]'."\n";
+       $content .= '[[Category:ImageAnnotation]]'."\n";
+       $newArticle->doEdit($content, 'Created by Semantic Image Annotator');
+       return ('success');
+}
+
+//Returns a JSON object containing all shapes for the specified article.
+function getAnnotations($annotatedImage){
+       global $wgExtensionCredits;
+        $new = false;
+        foreach($wgExtensionCredits['semantic'] as $elem){
+            if($elem['name'] == 'Semantic MediaWiki'){
+                $vers = $elem['version'];
+                $new = version_compare($vers, '1.7', '>=');
+            }
+        }
+        
+        $returnString = '{"shapes":[';
+        $queryString = '[[SIAannotatedImage::'.$annotatedImage.']]';
+        $params = array();
+        $params['link'] = 'none';
+        $params['mainlabel'] = 'result';
+        #$params = ['order'];
+        #$params = ['sort'];
+        
+       if($new){
+            $params['order'] = array('asc');
+            $params['sort'] = array('SIAannotatedImage');
+        }
+        else{
+            $params['order'] = 'asc';
+            $params['sort'] = 'SIAannotatedImage';
+        }
+        
+       //Generate all the extra printouts, eg all properties to retrieve:
+       $printmode = SMWPrintRequest::PRINT_PROP;
+       $customPrintouts = array(       'coordinates'   => 
'SIArectangleCoordinates',
+                                                               'text'          
        => 'ImageAnnotationText'
+                                                       );
+       $extraprintouts = array();
+       foreach($customPrintouts as $label => $property){
+               $extraprintouts[] = new SMWPrintRequest($printmode, $label, 
SMWPropertyValue::makeUserProperty($property));
+       }
+
+       $format = 'table';
+       $context = SMWQueryProcessor::INLINE_QUERY;
+
+       $query  = SMWQueryProcessor::createQuery( $queryString, $params, 
$context, $format, $extraprintouts );
+       $store = smwfGetStore(); // default store
+       $res = $store->getQueryResult( $query );
+       
+       $shapeCounter = 0;
+       while( ($resArrayArray = $res->getNext()) != false){    //Array of 
SMWResultArray Objects, eg. all retrieved Pages
+               $shapeCounter++;
+
+               if($shapeCounter > 1) $returnString.=',';
+               $returnString.='{';
+               foreach($resArrayArray as $resArray){                           
//SMWResultArray-Object, column of resulttable (pagename or propertyvalue)      
                
+                       $currentPrintRequestLabel = 
$resArray->getPrintRequest()->getLabel();   //The label as defined in the above 
array
+                       if($currentPrintRequestLabel == 'coordinates'){
+                               $currentResultPage = 
$resArray->getResultSubject();                             
+                               $currentID = 
$currentResultPage->getTitle()->getFullText();
+                               $currentCoords = 
$resArray->getNextDataItem()->getSerialization();
+                               
$returnString.='"coords":"'.$currentCoords.'","id":"'.$currentID.'"';
+                       }
+               }
+               $returnString.='}';
+       }
+       $returnString .= ']}';
+       return($returnString);
+}
diff --git a/SIA_AnnotationPrinter.php b/SIA_AnnotationPrinter.php
index c0963c4..545caa0 100644
--- a/SIA_AnnotationPrinter.php
+++ b/SIA_AnnotationPrinter.php
@@ -1,129 +1,129 @@
-<?php
-       /**
-       * Part of SemanticImageAnnotator
-       * Provides a custom ResultPrinter for displaying images with 
annotations that result from queries.
-       * @author Felix Obenauer
-       */
-
-class SIA_AnnotationPrinter extends SMWResultPrinter {
-       protected $paramWidth;
-       
-       public function __construct( $format, $inline, $useValidator = false ) {
-               parent::__construct( $format, $inline );
-               $this->mFormat = $format;
-               $this->useValidator = $useValidator;
-       }
-       
-       protected function getResultText( SMWQueryResult $res, $outputmode ){
-            if(!( isset($this->paramWidth) )){
-                    $this->paramWidth = -1;
-            }
-            $this->isHTML = true;
-            global $wgOut;
-            $wgOut->addModules('ext.SemanticImageAnnotator.ResultFormat');
-            $resultPages = $res->getResults();
-
-            $store = smwfGetStore();
-            $annotationArray = array();
-
-            foreach($resultPages as $page){
-                $namespace = $page->getNamespace();
-                if($namespace != 380) continue;
-                $coords = "";
-                $imgUrl = "";
-                $pageName = $page->getDBkey();
-                $propertyCoords = new SMWDIProperty("__SIA_RECTCOORDS");
-                $propertyImgUrl = new SMWDIProperty("__SIA_IMG_URL");
-                $coordValues = $store->getPropertyValues( $page, 
$propertyCoords );
-                $urlValues = $store->getPropertyValues( $page, $propertyImgUrl 
);
-                if(count($coordValues) == 1 && $coordValues[0] instanceof 
SMWDIString){
-                    $coords = $coordValues[0]->getString();
-                }
-                if(count($urlValues) == 1 && $coordValues[0] instanceof 
SMWDIString){
-                    $imgUrl = $urlValues[0]->getString();
-                }
-
-                if($coords != "" && $imgUrl != ""){
-                        $annotationArray[$imgUrl][] = array($pageName, 
$coords);
-                }
-            }
-
-            $returnString = "";
-            foreach($annotationArray as $image => $annotationData){
-                    $returnString .= $this->createAnnotatedImg($image, 
$annotationData);
-            }
-            return $returnString;
-       }
-       
-       protected function createAnnotatedImg( $imgUrl, array $annotationData){
-               $result = "";
-                global $IP;
-                $doc = $IP."\..".$imgUrl;
-               $imageDim = getimagesize($doc);
-               $origWidth = $imageDim[0];
-               $origHeight = $imageDim[1];
-               $scaleFactor = 1;
-               $newWidth = $origWidth;
-               $newHeight = $origHeight;
-               
-               if($this->paramWidth != -1 && $this->paramWidth != $origWidth){
-                       $scaleFactor = $this->paramWidth / $origWidth;
-                       $newWidth *= $scaleFactor;
-                       $newHeight *= $scaleFactor;
-               }
-               $result .= "<div style=\"position:relative;  \"><img 
src=\"".$imgUrl."\" width=\"".$newWidth."\" height=\"".$newHeight."\" >";
-               foreach($annotationData as $data){
-                       $imageAnnotation = $data[0];
-                       $coordinate = $data[1];
-                       $coords = explode(";", $coordinate);
-                       
-                       if($scaleFactor != 1){
-                               foreach($coords as $k => $v){
-                                       $coords[$k] = round($coords[$k] * 
$scaleFactor); 
-                               }
-                       }
-                       
-                       $width  = $coords[2] - $coords[0];
-                       $height = $coords[3] - $coords[1];
-                        global $wgExtensionAssetsPath;
-                       $style = "top: ".$coords[1]."px; left: 
".$coords[0]."px; width: ".$width."px; height: ".$height."px;";
-                        $style .= "position:absolute; cursor:pointer; 
background: 
url(".$wgExtensionAssetsPath."/SemanticImageAnnotator/images/transparentbg.gif);";
-                       $annoDiv = "<div 
targetannotation=\"ImageAnnotation:".$imageAnnotation."\" 
class=\"ImageAnnotationDiv\" style=\"".$style."\"></div>";
-                       $result .= $annoDiv;
-               }
-               $result .= "</img></div>";
-               return $result;
-       }
-       
-       protected function handleParameters( array $params, $outputmode ) {
-               //Existence of these array keys is not checked in 
SMW_QueryPrinter.php
-               //If they are not specified, they should default to the values 
given
-               //They are, however, not of interest to this specific 
QueryPrinter      
-               
-               if ( !(array_key_exists( 'headers', $params ) ) ) {
-                       $params['headers'] = 'hide';
-               }
-               
-               if ( !(array_key_exists( 'link', $params ) ) ) {
-                       $params['link'] = 'none';
-               }
-               
-               parent::handleParameters( $params, $outputmode );
-               $this->paramWidth = $params['width'];
-       }
-       
-       protected function readParameters( $params, $outputmode ) {
-               parent::readParameters( $params, $outputmode );
-               if ( array_key_exists( 'width', $params ) ) {
-                       $this->paramWidth = $params['width'];
-               }
-       }
-       //FIXME: Umstellen auf getPAramDefs
-       public function getParameters() {
-               $params['width'] = new Parameter( 'width', 
Parameter::TYPE_INTEGER );
-               $params['width']->setMessage( 'Width of image' );
-               $params['width']->setDefault( -1 );
-               return $params;
-       }
-}
-
+<?php
+       /**
+       * Part of SemanticImageAnnotator
+       * Provides a custom ResultPrinter for displaying images with 
annotations that result from queries.
+       * @author Felix Obenauer
+       */
+
+class SIA_AnnotationPrinter extends SMWResultPrinter {
+       protected $paramWidth;
+       
+       public function __construct( $format, $inline, $useValidator = false ) {
+               parent::__construct( $format, $inline );
+               $this->mFormat = $format;
+               $this->useValidator = $useValidator;
+       }
+       
+       protected function getResultText( SMWQueryResult $res, $outputmode ){
+            if(!( isset($this->paramWidth) )){
+                    $this->paramWidth = -1;
+            }
+            $this->isHTML = true;
+            global $wgOut;
+            $wgOut->addModules('ext.SemanticImageAnnotator.ResultFormat');
+            $resultPages = $res->getResults();
+
+            $store = smwfGetStore();
+            $annotationArray = array();
+
+            foreach($resultPages as $page){
+                $namespace = $page->getNamespace();
+                if($namespace != 380) continue;
+                $coords = "";
+                $imgUrl = "";
+                $pageName = $page->getDBkey();
+                $propertyCoords = new SMWDIProperty("__SIA_RECTCOORDS");
+                $propertyImgUrl = new SMWDIProperty("__SIA_IMG_URL");
+                $coordValues = $store->getPropertyValues( $page, 
$propertyCoords );
+                $urlValues = $store->getPropertyValues( $page, $propertyImgUrl 
);
+                if(count($coordValues) == 1 && $coordValues[0] instanceof 
SMWDIString){
+                    $coords = $coordValues[0]->getString();
+                }
+                if(count($urlValues) == 1 && $coordValues[0] instanceof 
SMWDIString){
+                    $imgUrl = $urlValues[0]->getString();
+                }
+
+                if($coords != "" && $imgUrl != ""){
+                        $annotationArray[$imgUrl][] = array($pageName, 
$coords);
+                }
+            }
+
+            $returnString = "";
+            foreach($annotationArray as $image => $annotationData){
+                    $returnString .= $this->createAnnotatedImg($image, 
$annotationData);
+            }
+            return $returnString;
+       }
+       
+       protected function createAnnotatedImg( $imgUrl, array $annotationData){
+               $result = "";
+                global $IP;
+                $doc = $IP."\..".$imgUrl;
+               $imageDim = getimagesize($doc);
+               $origWidth = $imageDim[0];
+               $origHeight = $imageDim[1];
+               $scaleFactor = 1;
+               $newWidth = $origWidth;
+               $newHeight = $origHeight;
+               
+               if($this->paramWidth != -1 && $this->paramWidth != $origWidth){
+                       $scaleFactor = $this->paramWidth / $origWidth;
+                       $newWidth *= $scaleFactor;
+                       $newHeight *= $scaleFactor;
+               }
+               $result .= "<div style=\"position:relative;  \"><img 
src=\"".$imgUrl."\" width=\"".$newWidth."\" height=\"".$newHeight."\" >";
+               foreach($annotationData as $data){
+                       $imageAnnotation = $data[0];
+                       $coordinate = $data[1];
+                       $coords = explode(";", $coordinate);
+                       
+                       if($scaleFactor != 1){
+                               foreach($coords as $k => $v){
+                                       $coords[$k] = round($coords[$k] * 
$scaleFactor); 
+                               }
+                       }
+                       
+                       $width  = $coords[2] - $coords[0];
+                       $height = $coords[3] - $coords[1];
+                        global $wgExtensionAssetsPath;
+                       $style = "top: ".$coords[1]."px; left: 
".$coords[0]."px; width: ".$width."px; height: ".$height."px;";
+                        $style .= "position:absolute; cursor:pointer; 
background: 
url(".$wgExtensionAssetsPath."/SemanticImageAnnotator/images/transparentbg.gif);";
+                       $annoDiv = "<div 
targetannotation=\"ImageAnnotation:".$imageAnnotation."\" 
class=\"ImageAnnotationDiv\" style=\"".$style."\"></div>";
+                       $result .= $annoDiv;
+               }
+               $result .= "</img></div>";
+               return $result;
+       }
+       
+       protected function handleParameters( array $params, $outputmode ) {
+               //Existence of these array keys is not checked in 
SMW_QueryPrinter.php
+               //If they are not specified, they should default to the values 
given
+               //They are, however, not of interest to this specific 
QueryPrinter      
+               
+               if ( !(array_key_exists( 'headers', $params ) ) ) {
+                       $params['headers'] = 'hide';
+               }
+               
+               if ( !(array_key_exists( 'link', $params ) ) ) {
+                       $params['link'] = 'none';
+               }
+               
+               parent::handleParameters( $params, $outputmode );
+               $this->paramWidth = $params['width'];
+       }
+       
+       protected function readParameters( $params, $outputmode ) {
+               parent::readParameters( $params, $outputmode );
+               if ( array_key_exists( 'width', $params ) ) {
+                       $this->paramWidth = $params['width'];
+               }
+       }
+       //FIXME: Umstellen auf getPAramDefs
+       public function getParameters() {
+               $params['width'] = new Parameter( 'width', 
Parameter::TYPE_INTEGER );
+               $params['width']->setMessage( 'Width of image' );
+               $params['width']->setDefault( -1 );
+               return $params;
+       }
+}
+
diff --git a/SemanticImageAnnotator.php b/SemanticImageAnnotator.php
index 456fe99..308d06c 100644
--- a/SemanticImageAnnotator.php
+++ b/SemanticImageAnnotator.php
@@ -1,111 +1,111 @@
-<?php
-/**
-* SemanticImageAnnotator
-* An Extension to Semantic Mediawiki which allows users to semantically 
annotate image files.
-* @author Felix Obenauer
-*/
-if( !defined( 'MEDIAWIKI' ) ) {
-       die( 'Not an entry point.' );
-}
-/**
- * For older versions of mediawiki, which don't support NS_FILE.
- */
-if (!defined('NS_FILE')) {
-       define('NS_FILE', NS_IMAGE);
-}
-
-$wgExtensionCredits['semantic'][] = array(
-       'path' => __FILE__,
-       'name' => 'Semantic Image Annotator',
-       'version' => '0.5',
-       'author' => 'Felix Obenauer',
-       'url' => 
'http://www.mediawiki.org/wiki/Extension:Semantic_Image_Annotator',
-       'descriptionmsg'  => 'sia-description',
-);
-
-$dir = dirname(__FILE__);
-$wgExtensionMessagesFiles['SemanticImageAnnotator'] = 
"$dir/languages/SIA_Messages.php";
-
-include_once('SIA_AjaxFunctions.php');
-
-//Register the ResultFormatter and add the Class to the autoloaded classes
-$smwgResultFormats['imageannotation'] = 'SIA_AnnotationPrinter';
-$wgAutoloadClasses['SIA_AnnotationPrinter'] = dirname( __FILE__ ) . 
'/SIA_AnnotationPrinter.php';
-
-//Add the ImageAnnotation Namespace to the Wiki:
-$wgExtraNamespaces[380] = "ImageAnnotation";
-define("NS_IMAGEANNOTATION", 380);
-$wgExtraNamespaces[NS_IMAGEANNOTATION] = "ImageAnnotation";
-
-$smwgNamespacesWithSemanticLinks += array( NS_IMAGEANNOTATION => true );
-
-
-//Resources for the ResourceLoader:
-$wgResourceModules['ext.SemanticImageAnnotator'] = array(
-       'scripts' => array(
-               'scripts/SIA_Constants.js',
-               'scripts/SIA_removeAnnotation.js',
-               'scripts/SIA_fileNS.js',
-               'scripts/jquery.draw.js',
-               'scripts/SIA_getAnnotations.js'
-       ),
-       'styles' => array('styles/SIA.css'),
-       'dependencies' => array( 'ext.semanticforms.main', 
'ext.semanticforms.popupformedit' ),
-       'localBasePath' => dirname( __FILE__ ),
-       'remoteExtPath' => 'SemanticImageAnnotator',
-       'messages'              => array(
-                                               'sia-buttonannotate',
-                                               'sia-resize',
-       ),
-);
-
-$wgResourceModules['ext.SemanticImageAnnotator.ResultFormat'] = array(
-       'scripts' => array( 'scripts/SIA_ResultScript.js' ),
-       'styles' => array( 'styles/SIA.css'),
-       'dependencies' => array('jquery.ui.draggable', 'jquery.ui.resizable'),
-       'localBasePath' => dirname( __FILE__ ),
-       'remoteExtPath' => 'SemanticImageAnnotator'
-);
-
-$wgResourceModules['ext.SemanticImageAnnotator.SemanticFormsAssets'] = array(
-       'scripts' => 'external/SF_popupform.js',
-       'styles'  => array( 'external/skins/SF_popupform.css' ),
-       'localBasePath' => dirname( __FILE__ ),
-       'remoteExtPath' => 'SemanticImageAnnotator'
-);
-
-
-global $wgAjaxExportList;
-// register ajax functions
-$wgAjaxExportList[] = 'getAnnotations';
-$wgAjaxExportList[] = 'writeAnnotationProperties';
-$wgAjaxExportList[] = 'removeAnnotation';
-
-// register MediaWiki hooks
-$wgHooks['OutputPageBeforeHTML'][] = 'hookOutputPageBeforeHTML';
-$wgHooks['smwInitProperties'][] = 'initProperties';
-
-function hookOutputPageBeforeHTML ( OutputPage &$out, &$text ) {
-
-       if( $out->getTitle()->getNamespace() == 6 ) {           //6 is the File 
Namespace
-               $out->includeJQuery();
-               $out->addModules('ext.SemanticImageAnnotator');
-       }
-
-       return true;
-}
-
-function initProperties(){
-       if ( class_exists( 'SMWDIProperty' ) ) {
-               SMWDIProperty::registerProperty( "__SIA_RECTCOORDS", '_str', 
"SIArectangleCoordinates", true );
-               SMWDIProperty::registerProperty( "__SIA_IMG_URL", '_str', 
"SIAimageURL", true );
-               SMWDIProperty::registerProperty( "__SIA_ANNOTATED", '_str', 
"SIAannotatedImage", true );
-                                       SMWDIProperty::registerProperty( 
"__SIA_CREATED_BY", '_str', "SIAcreatedBy", true );
-       } else {
-               SMWPropertyValue::registerProperty( "__SIA_RECTCOORDS", '_str', 
"SIArectangleCoordinates", true );
-               SMWPropertyValue::registerProperty( "__SIA_IMG_URL", '_str', 
"SIAimageURL", true );
-               SMWPropertyValue::registerProperty( "__SIA_ANNOTATED", '_str', 
"SIAannotatedImage", true );
-                                       SMWPropertyValue::registerProperty( 
"__SIA_CREATED_BY", '_str', "SIAcreatedBy", true );
-       }
-       return true;
-}
+<?php
+/**
+* SemanticImageAnnotator
+* An Extension to Semantic Mediawiki which allows users to semantically 
annotate image files.
+* @author Felix Obenauer
+*/
+if( !defined( 'MEDIAWIKI' ) ) {
+       die( 'Not an entry point.' );
+}
+/**
+ * For older versions of mediawiki, which don't support NS_FILE.
+ */
+if (!defined('NS_FILE')) {
+       define('NS_FILE', NS_IMAGE);
+}
+
+$wgExtensionCredits['semantic'][] = array(
+       'path' => __FILE__,
+       'name' => 'Semantic Image Annotator',
+       'version' => '0.6.0',
+       'author' => 'Felix Obenauer',
+       'url' => 
'http://www.mediawiki.org/wiki/Extension:Semantic_Image_Annotator',
+       'descriptionmsg'  => 'sia-description',
+);
+
+$wgMessagesDirs['SemanticImageAnnotator'] = __DIR__ . '/i18n';
+$wgExtensionMessagesFiles['SemanticImageAnnotator'] = __DIR__ . 
"/languages/SIA_Messages.php";
+
+include_once('SIA_AjaxFunctions.php');
+
+//Register the ResultFormatter and add the Class to the autoloaded classes
+$smwgResultFormats['imageannotation'] = 'SIA_AnnotationPrinter';
+$wgAutoloadClasses['SIA_AnnotationPrinter'] = dirname( __FILE__ ) . 
'/SIA_AnnotationPrinter.php';
+
+//Add the ImageAnnotation Namespace to the Wiki:
+$wgExtraNamespaces[380] = "ImageAnnotation";
+define("NS_IMAGEANNOTATION", 380);
+$wgExtraNamespaces[NS_IMAGEANNOTATION] = "ImageAnnotation";
+
+$smwgNamespacesWithSemanticLinks += array( NS_IMAGEANNOTATION => true );
+
+
+//Resources for the ResourceLoader:
+$wgResourceModules['ext.SemanticImageAnnotator'] = array(
+       'scripts' => array(
+               'scripts/SIA_Constants.js',
+               'scripts/SIA_removeAnnotation.js',
+               'scripts/SIA_fileNS.js',
+               'scripts/jquery.draw.js',
+               'scripts/SIA_getAnnotations.js'
+       ),
+       'styles' => array('styles/SIA.css'),
+       'dependencies' => array( 'ext.semanticforms.main', 
'ext.semanticforms.popupformedit' ),
+       'localBasePath' => dirname( __FILE__ ),
+       'remoteExtPath' => 'SemanticImageAnnotator',
+       'messages'              => array(
+                                               'sia-buttonannotate',
+                                               'sia-resize',
+       ),
+);
+
+$wgResourceModules['ext.SemanticImageAnnotator.ResultFormat'] = array(
+       'scripts' => array( 'scripts/SIA_ResultScript.js' ),
+       'styles' => array( 'styles/SIA.css'),
+       'dependencies' => array('jquery.ui.draggable', 'jquery.ui.resizable'),
+       'localBasePath' => dirname( __FILE__ ),
+       'remoteExtPath' => 'SemanticImageAnnotator'
+);
+
+$wgResourceModules['ext.SemanticImageAnnotator.SemanticFormsAssets'] = array(
+       'scripts' => 'external/SF_popupform.js',
+       'styles'  => array( 'external/skins/SF_popupform.css' ),
+       'localBasePath' => dirname( __FILE__ ),
+       'remoteExtPath' => 'SemanticImageAnnotator'
+);
+
+
+global $wgAjaxExportList;
+// register ajax functions
+$wgAjaxExportList[] = 'getAnnotations';
+$wgAjaxExportList[] = 'writeAnnotationProperties';
+$wgAjaxExportList[] = 'removeAnnotation';
+
+// register MediaWiki hooks
+$wgHooks['OutputPageBeforeHTML'][] = 'hookOutputPageBeforeHTML';
+$wgHooks['smwInitProperties'][] = 'initProperties';
+
+function hookOutputPageBeforeHTML ( OutputPage &$out, &$text ) {
+
+       if( $out->getTitle()->getNamespace() == 6 ) {           //6 is the File 
Namespace
+               $out->includeJQuery();
+               $out->addModules('ext.SemanticImageAnnotator');
+       }
+
+       return true;
+}
+
+function initProperties(){
+       if ( class_exists( 'SMWDIProperty' ) ) {
+               SMWDIProperty::registerProperty( "__SIA_RECTCOORDS", '_str', 
"SIArectangleCoordinates", true );
+               SMWDIProperty::registerProperty( "__SIA_IMG_URL", '_str', 
"SIAimageURL", true );
+               SMWDIProperty::registerProperty( "__SIA_ANNOTATED", '_str', 
"SIAannotatedImage", true );
+                                       SMWDIProperty::registerProperty( 
"__SIA_CREATED_BY", '_str', "SIAcreatedBy", true );
+       } else {
+               SMWPropertyValue::registerProperty( "__SIA_RECTCOORDS", '_str', 
"SIArectangleCoordinates", true );
+               SMWPropertyValue::registerProperty( "__SIA_IMG_URL", '_str', 
"SIAimageURL", true );
+               SMWPropertyValue::registerProperty( "__SIA_ANNOTATED", '_str', 
"SIAannotatedImage", true );
+                                       SMWPropertyValue::registerProperty( 
"__SIA_CREATED_BY", '_str', "SIAcreatedBy", true );
+       }
+       return true;
+}
diff --git a/i18n/de.json b/i18n/de.json
new file mode 100644
index 0000000..39234da
--- /dev/null
+++ b/i18n/de.json
@@ -0,0 +1,11 @@
+{
+    "@metadata": {
+        "authors": [
+            "Felix Obenauer"
+        ]
+    },
+    "sia-description": "Füge Bildern semantische Annotationen hinzu und frage 
diese ab",
+    "sia-comment": "Kommentar",
+    "sia-buttonannotate": "Dieses Bild annotieren",
+    "sia-resize": "Bildgröße ändern"
+}
diff --git a/i18n/en.json b/i18n/en.json
new file mode 100644
index 0000000..eb08864
--- /dev/null
+++ b/i18n/en.json
@@ -0,0 +1,11 @@
+{
+    "@metadata": {
+        "authors": [
+            "Felix Obenauer"
+        ]
+    },
+    "sia-description": "Semantically annotate images and query for 
annotations",
+    "sia-comment": "comment",
+    "sia-buttonannotate": "Annotate this image",
+    "sia-resize": "Resize image"
+}
diff --git a/languages/SIA_Messages.php b/languages/SIA_Messages.php
index 608e0f1..fc65d35 100644
--- a/languages/SIA_Messages.php
+++ b/languages/SIA_Messages.php
@@ -1,25 +1,31 @@
 <?php
 /**
- * Internationalization file for Semantic Image Annotator
+ * This is a backwards-compatibility shim, generated by:
+ * 
https://git.wikimedia.org/blob/mediawiki%2Fcore.git/HEAD/maintenance%2FgenerateJsonI18n.php
+ *
+ * Beginning with MediaWiki 1.23, translation strings are stored in json files,
+ * and the EXTENSION.i18n.php file only exists to provide compatibility with
+ * older releases of MediaWiki. For more information about this migration, see:
+ * https://www.mediawiki.org/wiki/Requests_for_comment/Localisation_format
+ *
+ * This shim maintains compatibility back to MediaWiki 1.17.
  */
 $messages = array();
- /**
-  * English
-  * @author Felix Obenauer
-  */
-$messages['en'] = array(
-       'sia-description' => 'Semantically annotate images and query for 
annotations',
-       'sia-comment' => 'comment',
-       'sia-buttonannotate'=>  'Annotate this image',
-       'sia-resize' => 'Resize image'
-);
-  /**
-  * German
-  * @author Felix Obenauer
-  */
-$messages['de'] = array(
-       'sia-description' => 'Füge Bildern semantische Annotationen hinzu und 
frage diese ab',
-       'sia-comment' => 'Kommentar',
-       'sia-buttonannotate'=> 'Dieses Bild annotieren',
-       'sia-resize' => 'Bildgröße ändern'
-);
+$GLOBALS['wgHooks']['LocalisationCacheRecache'][] = function ( $cache, $code, 
&$cachedData ) {
+       $codeSequence = array_merge( array( $code ), 
$cachedData['fallbackSequence'] );
+       foreach ( $codeSequence as $csCode ) {
+               $fileName = __DIR__ . "/../i18n/$csCode.json";
+               if ( is_readable( $fileName ) ) {
+                       $data = FormatJson::decode( file_get_contents( 
$fileName ), true );
+                       foreach ( array_keys( $data ) as $key ) {
+                               if ( $key === '' || $key[0] === '@' ) {
+                                       unset( $data[$key] );
+                               }
+                       }
+                       $cachedData['messages'] = array_merge( $data, 
$cachedData['messages'] );
+               }
+
+               $cachedData['deps'][] = new FileDependency( $fileName );
+       }
+       return true;
+};

-- 
To view, visit https://gerrit.wikimedia.org/r/123591
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I994098a1496fd4e69a5d1db9836028d6e9218d8b
Gerrit-PatchSet: 2
Gerrit-Project: mediawiki/extensions/SemanticImageAnnotator
Gerrit-Branch: master
Gerrit-Owner: Siebrand <[email protected]>
Gerrit-Reviewer: Nikerabbit <[email protected]>
Gerrit-Reviewer: Raimond Spekking <[email protected]>
Gerrit-Reviewer: Siebrand <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to