Kipcool has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/50189


Change subject: More visible Syntrans annotations for the syntrans being viewed.
......................................................................

More visible Syntrans annotations for the syntrans being viewed.

Change-Id: I76783e95a22bb4d526637c8411ba15d0e4bb45e0
---
M OmegaWiki/Controller.php
M OmegaWiki/DefinedMeaning.php
M OmegaWiki/DefinedMeaningModel.php
M OmegaWiki/Editor.php
M OmegaWiki/OmegaWikiAttributes.php
M OmegaWiki/OmegaWikiEditors.php
M OmegaWiki/OmegaWikiRecordSets.php
M OmegaWiki/PropertyToColumnFilter.php
M OmegaWiki/SpecialConceptMapping.php
M OmegaWiki/Test.skeleton.php
M OmegaWiki/WikiDataAPI.php
M OmegaWiki/WikiDataGlobals.php
12 files changed, 232 insertions(+), 70 deletions(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/WikiLexicalData 
refs/changes/89/50189/1

diff --git a/OmegaWiki/Controller.php b/OmegaWiki/Controller.php
index 891bf8f..adfb60e 100644
--- a/OmegaWiki/Controller.php
+++ b/OmegaWiki/Controller.php
@@ -352,7 +352,10 @@
                $objectId = $this->objectIdFetcher->fetch( 
$idPath->getKeyStack() );
                $textAttributeId = $this->determineAttributeId( $idPath, 
"TEXT", $record->textAttribute );
                $text = $record->text;
-               
+
+               if ( !$objectId ) {
+                       throw new MWException( "TextAttributeValuesController: 
objectId is null, idpath: $idPath" );
+               }
                if ( $textAttributeId != 0 && $text != '' ) {
                        addTextAttributeValue( $objectId, $textAttributeId, 
$text );
                }
diff --git a/OmegaWiki/DefinedMeaning.php b/OmegaWiki/DefinedMeaning.php
index ff150dd..f4002c0 100644
--- a/OmegaWiki/DefinedMeaning.php
+++ b/OmegaWiki/DefinedMeaning.php
@@ -24,30 +24,29 @@
                        return false;
                }
                parent::view();
-               $definedMeaningModel = new DefinedMeaningModel( $dmNumber, 
$this->viewInformation );
-               $this->definedMeaningModel = $definedMeaningModel; # TODO if I 
wasn't so sleepy I'd make this consistent
+               $this->definedMeaningModel = new DefinedMeaningModel( 
$dmNumber, array( "viewinformation" => $this->viewInformation ) );
 
                if ( !empty( $dmInfo["expression"] ) ) {
-                       $definedMeaningModel->setDefiningExpression( 
$dmInfo["expression"] );
+                       $this->definedMeaningModel->setDefiningExpression( 
$dmInfo["expression"] );
                }
 
 
                // check that the constructed DM actually exists in the database
-               $match = $definedMeaningModel->checkExistence( true, true );
+               $match = $this->definedMeaningModel->checkExistence( true, true 
);
 
                // The defining expression is likely incorrect for some reason. 
Let's just
                // try looking up the number.
                if ( is_null( $match ) && !empty( $dmInfo["expression"] ) ) {
-                       $definedMeaningModel->setDefiningExpression( null );
+                       $this->definedMeaningModel->setDefiningExpression( null 
);
                        $dmInfo["expression"] = null;
-                       $match = $definedMeaningModel->checkExistence( true, 
true );
+                       $match = $this->definedMeaningModel->checkExistence( 
true, true );
                }
                
                // The defining expression is either bad or missing. Let's 
redirect
                // to the correct URL.
                if ( empty( $dmInfo["expression"] ) && !is_null( $match ) ) {
-                       $definedMeaningModel->loadRecord();
-                       $title = Title::newFromText( 
$definedMeaningModel->getWikiTitle() );
+                       $this->definedMeaningModel->loadRecord();
+                       $title = Title::newFromText( 
$this->definedMeaningModel->getWikiTitle() );
                        $url = $title->getFullURL();
                        $wgOut->disable();
                        header( "Location: $url" );
@@ -66,7 +65,7 @@
                # Raw mode
                $view_as = $wgRequest->getText( 'view_as' );
                if ( $view_as == "raw" ) {
-                       $wgOut->addHTML( "<pre>" . 
$definedMeaningModel->getRecord() . "</pre>" );
+                       $wgOut->addHTML( "<pre>" . 
$this->definedMeaningModel->getRecord() . "</pre>" );
                        # $wgOut->disable();
                        return;
                }
@@ -99,7 +98,7 @@
                }
 
                $this->outputEditHeader();
-               $dmModel = new DefinedMeaningModel( $definedMeaningId, 
$this->viewInformation );
+               $dmModel = new DefinedMeaningModel( $definedMeaningId, array( 
"viewinformation" => $this->viewInformation ) );
 
                // check that the constructed DM actually exists in the database
                $match = $dmModel->checkExistence( true, true );
@@ -135,7 +134,7 @@
 
                parent::history();
 
-               $dmModel = new DefinedMeaningModel( $definedMeaningId, 
$this->viewInformation );
+               $dmModel = new DefinedMeaningModel( $definedMeaningId, array ( 
"viewinformation" => $this->viewInformation ) );
 
                // check that the constructed DM actually exists in the database
                $match = $dmModel->checkExistence( true, true );
@@ -167,7 +166,7 @@
                        return false;
                }
 
-               $dmModel = new DefinedMeaningModel( $definedMeaningId, 
$this->viewInformation );
+               $dmModel = new DefinedMeaningModel( $definedMeaningId, array ( 
"viewinformation" => $this->viewInformation ) );
 
                getDefinedMeaningEditor( $this->viewInformation )->save(
                        $this->getIdStack( $definedMeaningId ),
diff --git a/OmegaWiki/DefinedMeaningModel.php 
b/OmegaWiki/DefinedMeaningModel.php
index 37bd970..8b622bd 100644
--- a/OmegaWiki/DefinedMeaningModel.php
+++ b/OmegaWiki/DefinedMeaningModel.php
@@ -21,30 +21,41 @@
        protected $definingExpression = null; # String
        protected $dataset = null;
        protected $syntrans = array();
+       // optionally, a syntransId can be given to see syntrans annotations
+       // inside of the DM Editor (e.g. when viewing a DM inside an expression 
page).
+       protected $syntransId = null;
        protected $titleObject = null;
 
        /**
         * Construct a new DefinedMeaningModel for a particular DM.
         * You need to call loadRecord() to load the actual data.
         *
-        * @param Integer         the database ID of the DM 
-        * @param ViewInformation optional
-        * @param DataSet         where to look for the DM by default
-         */
-       public function __construct( $definedMeaningId, $viewInformation = 
null, DataSet $dc = null ) {
+        * @param $definedMeaningId Integer: the database ID of the DM
+        * @param $params Array: optional parameters to pass to the constructor
+        * can be "viewinformation" of type ViewInformation, or "dataset" of 
type DataSet
+        * or "syntransid" which is an integer
+        */
+       public function __construct( $definedMeaningId, $params = array() ) {
 
                if ( !$definedMeaningId ) throw new Exception( "DM needs at 
least a DMID!" );
                $this->setId( $definedMeaningId );
 
-               if ( is_null( $viewInformation ) ) {
+               if ( array_key_exists ( "viewinformation", $params ) ) {
+                       $this->viewInformation = $params["viewinformation"];
+               } else {
                        $viewInformation = new ViewInformation();
                        $viewInformation->queryTransactionInformation = new 
QueryLatestTransactionInformation();
                }
-               $this->viewInformation = $viewInformation;
-               if ( is_null( $dc ) ) {
-                       $dc = wdGetDataSetContext();
+
+               if ( array_key_exists ( "dataset", $params ) ) {
+                       $this->dataset = $params["dataset"];
+               } else {
+                       $this->dataset = wdGetDataSetContext();
                }
-               $this->dataset = $dc;
+
+               if ( array_key_exists ( "syntransid", $params ) ) {
+                       $this->syntransId = $params["syntransid"];
+               }
        }
 
        /**
@@ -162,16 +173,27 @@
                $record->definition = getDefinedMeaningDefinitionRecord( $id, 
$view );
                $record->classAttributes = getClassAttributesRecordSet( $id, 
$view );
                $record->alternativeDefinitions = 
getAlternativeDefinitionsRecordSet( $id, $view );
-               $record->synonymsAndTranslations = 
getSynonymAndTranslationRecordSet( $id, $view );
+
+               // exclude the current syntrans from the list of Synonyms
+               $excludeSyntransId = null;
+               if ( $this->syntransId ) {
+                       $excludeSyntransId = $this->syntransId;
+               }
+               $record->synonymsAndTranslations = 
getSynonymAndTranslationRecordSet( $id, $view, $excludeSyntransId );
                $record->reciprocalRelations = 
getDefinedMeaningReciprocalRelationsRecordSet( $id, $view );
                $record->classMembership = 
getDefinedMeaningClassMembershipRecordSet( $id, $view );
                $record->collectionMembership = 
getDefinedMeaningCollectionMembershipRecordSet( $id, $view );
                // Adds Annotation at a DM level
-               $objectAttributesRecord = getObjectAttributesRecord( $id, $view 
);
+               $objectAttributesRecord = getObjectAttributesRecord( $id, 
$view, null, "DM" );
                $record->definedMeaningAttributes = $objectAttributesRecord;
                // what this does is not clear...
 //             applyPropertyToColumnFiltersToRecord( $record, 
$objectAttributesRecord, $view );
 
+               // if syntransAttributes should be displayed, get them
+               if ( $this->syntransId ) {
+                       $record->syntransAttributes = 
getObjectAttributesRecord( $this->syntransId, $view, null, "SYNT" );
+               }
+
                $this->record = $record;
                $this->recordIsLoaded = true;
                return true;
diff --git a/OmegaWiki/Editor.php b/OmegaWiki/Editor.php
index fee9c7b..f951fad 100644
--- a/OmegaWiki/Editor.php
+++ b/OmegaWiki/Editor.php
@@ -151,7 +151,7 @@
        }
 
        public function __tostring() {
-               return "<object of class IdStack>";
+               return "IdStack(" . $this->getId() . ")\n" ;
        }
 }
 
@@ -1979,7 +1979,11 @@
        }
 
        protected function editChild( Editor $editor, IdStack $idPath, $value, 
Attribute $attribute, $class, $attributeId ) {
-               return '<div id="collapsable-' . $attributeId . '" 
class="expand-' . $class . '">' . $editor->edit( $idPath, 
$value->getAttributeValue( $attribute ) ) . '</div>' . EOL;
+               $divid = 'collapsable-' . $attributeId ;
+               $divclass = 'expand-' . $class;
+               $divattribs = array('id' => $divid, 'class' => $divclass );
+               $divcontent = $editor->edit( $idPath, 
$value->getAttributeValue( $attribute ) );
+               return HTML::rawElement ('div', $divattribs, $divcontent);
        }
 
        protected function addChild( Editor $editor, IdStack $idPath, Attribute 
$attribute, $class, $attributeId ) {
@@ -2886,3 +2890,62 @@
                $idPath->popDefinedMeaningId();
        }
 }
+
+
+class ObjectContextEditor extends WrappingEditor {
+       public function view( IdStack $idPath, $value ) {
+               if ( is_null( $value ) ) {
+                       return;
+               }
+               $o = OmegaWikiAttributes::getInstance();
+
+               $objectId = (int) $value->objectId;
+               $objectIdRecord = new ArrayRecord( new Structure( "noname", 
$o->objectId) ) ;
+               $objectIdRecord->setAttributeValue( $o->objectId, $objectId );
+
+               $idPath->pushKey( $objectIdRecord );
+
+               $result = $this->wrappedEditor->view( $idPath, $value );
+
+               $idPath->popKey();
+
+               return $result;
+       }
+
+       public function edit( IdStack $idPath, $value ) {
+               if ( is_null( $idPath ) ) {
+                       throw new Exception( "SyntransContextEditor: Null 
provided for idPath while trying to edit()" );
+               }
+
+               if ( is_null( $value ) ) {
+                       throw new Exception( "SyntransContextEditor: Null 
provided for value while trying to edit()" );
+               }
+
+               $o = OmegaWikiAttributes::getInstance();
+               $objectId = (int) $value->objectId;
+               $objectIdRecord = new ArrayRecord( new Structure( "noname", 
$o->objectId) ) ;
+               $objectIdRecord->setAttributeValue( $o->objectId, $objectId );
+
+               $idPath->pushKey( $objectIdRecord );
+
+               $result = $this->wrappedEditor->edit( $idPath, $value );
+
+               $idPath->popKey();
+
+               return $result;
+       }
+
+       public function save( IdStack $idPath, $value ) {
+               $o = OmegaWikiAttributes::getInstance();
+
+               $objectId = (int) $value->objectId;
+               $objectIdRecord = new ArrayRecord( new Structure( "noname", 
$o->objectId) ) ;
+               $objectIdRecord->setAttributeValue( $o->objectId, $objectId );
+
+               $idPath->pushKey( $objectIdRecord );
+
+               $this->wrappedEditor->save( $idPath, $value );
+
+               $idPath->popKey();
+       }
+}
diff --git a/OmegaWiki/OmegaWikiAttributes.php 
b/OmegaWiki/OmegaWikiAttributes.php
index f7777fb..b212d7c 100644
--- a/OmegaWiki/OmegaWikiAttributes.php
+++ b/OmegaWiki/OmegaWikiAttributes.php
@@ -99,7 +99,9 @@
                $this->classMembershipId = new Attribute( 
"class-membership-id", "Class membership id", "integer" );
                $this->collectionId = new Attribute( "collection", 
"Collection", "collection-id" );
 
-               $this->definedMeaningAttributes = new Attribute( 
WLD_DM_ATTRIBUTES, wfMsgSc( "DefinedMeaningAttributes" ), 
"will-be-specified-below" );
+               // text was wfMsgSc( "DefinedMeaningAttributes" ).
+               // Using a non-i18n text until we agree on a label
+               $this->definedMeaningAttributes = new Attribute( 
WLD_DM_ATTRIBUTES, "Semantic annotations", "will-be-specified-below" );
                $this->definedMeaningDefiningExpression = new Attribute( 
"defined-meaning-defining-expression", "Defined meaning defining expression", 
"short-text" );
                $this->definedMeaningLabel = new Attribute( 
"defined-meaning-label", "Defined meaning label", "short-text" );
                $this->definedMeaningId = new Attribute( "defined-meaning-id", 
"Defined meaning identifier", "defined-meaning-id" );
@@ -230,30 +232,6 @@
                $this->classAttributesStructure = new Structure( 
WLD_CLASS_ATTRIBUTES, $this->classAttributeId, $this->classAttributeAttribute, 
$this->classAttributeLevel, $this->classAttributeType, 
$this->optionAttributeOptions );
                $this->classAttributes = new Attribute( null, wfMsgSc( 
"ClassAttributes" ), $this->classAttributesStructure );
 
-               $this->definedMeaning = new Attribute( null, wfMsgSc( 
"DefinedMeaning" ),
-                       new Structure(
-                               WLD_DEFINED_MEANING,
-                               $this->definedMeaningId,
-                               $this->definedMeaningCompleteDefiningExpression,
-                               $this->definition,
-                               $this->classAttributes,
-                               $this->alternativeDefinitions,
-                               $this->synonymsAndTranslations,
-                               $this->reciprocalRelations,
-                               $this->classMembership,
-                               $this->collectionMembership,
-                               $this->definedMeaningAttributes
-                       )
-               );
-
-               $this->expressionMeaningStructure = new Structure( 
$this->definedMeaningId, $this->text, $this->definedMeaning );
-               $this->expressionExactMeanings = new Attribute( 
WLD_EXPRESSION_EXACT_MEANINGS, wfMsgSc( "ExactMeanings" ), 
$this->expressionMeaningStructure );
-               $this->expressionApproximateMeanings = new Attribute( 
WLD_EXPRESSION_APPROX_MEANINGS, wfMsgSc( "ApproximateMeanings" ), 
$this->expressionMeaningStructure );
-               $this->expressionMeaningsStructure = new Structure( 
WLD_EXPRESSION_MEANINGS, $this->expressionExactMeanings, 
$this->expressionApproximateMeanings );
-               $this->expressionMeanings = new Attribute( null, wfMsgSc( 
"ExpressionMeanings" ), $this->expressionMeaningsStructure );
-               $this->expressionsStructure = new Structure( "expressions", 
$this->expressionId, $this->expression, $this->expressionMeanings );
-               $this->expressions = new Attribute( null, wfMsgSc( 
"Expressions" ), $this->expressionsStructure );
-               
                $this->objectAttributesStructure = new Structure( 
"object-attributes",
                        $this->objectId,
                        $this->relations,
@@ -265,6 +243,33 @@
                
                $this->objectAttributes->setAttributeType( 
$this->objectAttributesStructure );
                $this->definedMeaningAttributes->setAttributeType( 
$this->objectAttributesStructure );
+
+               // TODO: use i18n text when we agree on a label
+               $this->syntransAttributes = new Attribute( WLD_SYNT_ATTRIBUTES, 
"Lexical annotations", $this->objectAttributesStructure );
+
+               $this->definedMeaningStructure = new Structure(
+                       WLD_DEFINED_MEANING,
+                       $this->definedMeaningId,
+                       $this->definedMeaningCompleteDefiningExpression,
+                       $this->definition,
+                       $this->classAttributes,
+                       $this->alternativeDefinitions,
+                       $this->synonymsAndTranslations,
+                       $this->reciprocalRelations,
+                       $this->classMembership,
+                       $this->collectionMembership,
+                       $this->definedMeaningAttributes,
+                       $this->syntransAttributes
+               );
+               $this->definedMeaning = new Attribute( null, wfMsgSc( 
"DefinedMeaning" ), $this->definedMeaningStructure );
+
+               $this->expressionMeaningStructure = new Structure( 
$this->definedMeaningId, $this->text, $this->definedMeaning );
+               $this->expressionExactMeanings = new Attribute( 
WLD_EXPRESSION_EXACT_MEANINGS, wfMsgSc( "ExactMeanings" ), 
$this->expressionMeaningStructure );
+               $this->expressionApproximateMeanings = new Attribute( 
WLD_EXPRESSION_APPROX_MEANINGS, wfMsgSc( "ApproximateMeanings" ), 
$this->expressionMeaningStructure );
+               $this->expressionMeaningsStructure = new Structure( 
WLD_EXPRESSION_MEANINGS, $this->expressionExactMeanings, 
$this->expressionApproximateMeanings );
+               $this->expressionMeanings = new Attribute( null, wfMsgSc( 
"ExpressionMeanings" ), $this->expressionMeaningsStructure );
+               $this->expressionsStructure = new Structure( "expressions", 
$this->expressionId, $this->expression, $this->expressionMeanings );
+               $this->expressions = new Attribute( null, wfMsgSc( 
"Expressions" ), $this->expressionsStructure );
                
                $annotatedAttributes = array(
                        $this->definedMeaning,
diff --git a/OmegaWiki/OmegaWikiEditors.php b/OmegaWiki/OmegaWikiEditors.php
index 588e23f..6990d30 100644
--- a/OmegaWiki/OmegaWikiEditors.php
+++ b/OmegaWiki/OmegaWikiEditors.php
@@ -537,6 +537,9 @@
        return $tableEditor;
 }
 
+/**
+* the corresponding recordSet function is getSynonymAndTranslationRecordSet
+*/
 function getSynonymsAndTranslationsEditor( ViewInformation $viewInformation ) {
        $o = OmegaWikiAttributes::getInstance();
 
@@ -626,10 +629,10 @@
        // ClassAttributesTypeEditor in Editor.php
        $relationLevel = "";
 
-       if ( $levelDefinedMeaningName == "DefinedMeaning" ) {
+       if ( $levelDefinedMeaningName == WLD_DM_MEANING_NAME ) {
                // DM-DM relations
                $relationLevel = "DM";
-       } elseif ( $levelDefinedMeaningName == "SynTrans" ) {
+       } elseif ( $levelDefinedMeaningName == WLD_SYNTRANS_MEANING_NAME ) {
                // Syntrans-Syntrans relations
                $relationLevel = "SYNT";
        }
@@ -803,10 +806,14 @@
        return $editor;
 }
 
+/**
+* The corresponding RecordSet function is getExpressionMeaningsRecordSet
+*/
 function getExpressionMeaningsEditor( Attribute $attribute, $allowAdd, 
ViewInformation $viewInformation ) {
        $o = OmegaWikiAttributes::getInstance();
        
-       $definedMeaningEditor = getDefinedMeaningEditor( $viewInformation );
+       $insideExpression = true;
+       $definedMeaningEditor = getDefinedMeaningEditor( $viewInformation, 
$insideExpression );
 
        $definedMeaningCaptionEditor = new DefinedMeaningHeaderEditor( 
$o->definedMeaningId, new SimplePermissionController( false ), false, 75 );
        $definedMeaningCaptionEditor->setAddText( wfMsg( 'ow_NewExactMeaning' ) 
);
@@ -818,6 +825,9 @@
        return $expressionMeaningsEditor;
 }
 
+/**
+ * the corresponding RecordSet function is getExpressionMeaningsRecord
+ */
 function getExpressionsEditor( $spelling, ViewInformation $viewInformation ) {
        $o = OmegaWikiAttributes::getInstance();
 
@@ -858,7 +868,11 @@
        return $expressionsEditor;
 }
 
-function getDefinedMeaningEditor( ViewInformation $viewInformation ) {
+/**
+* The corresponding RecordSet function is loadRecord in DefinedMeaningModel.php
+* @param $insideExpression boolean, indicates if the DM Editor is called 
inside an Expression Editor
+*/
+function getDefinedMeaningEditor( ViewInformation $viewInformation, 
$insideExpression = null ) {
        global $wdDefinedMeaningAttributesOrder, $wgUser;
                
        $o = OmegaWikiAttributes::getInstance();
@@ -889,8 +903,27 @@
        
        $availableEditors->addEditor( createObjectAttributesEditor( 
$viewInformation, $o->definedMeaningAttributes, wfMsgSc( "Property" ), wfMsgSc( 
"Value" ), $o->definedMeaningId, WLD_DM_MEANING_NAME, 
$viewInformation->getLeftOverAttributeFilter() ) );
 
+       // if we come from Expression, or a syntransId is given, also add a 
syntrans annotations editor
+       if ( $insideExpression ) {
+               $syntransAttributesEditor = new ObjectAttributeValuesEditor( 
$o->syntransAttributes, wfMsgSc( "Property" ), wfMsgSc( "Value" ), 
$viewInformation, WLD_SYNTRANS_MEANING_NAME, 
$viewInformation->getLeftOverAttributeFilter() );
+
+               addObjectAttributesEditors(
+                       $syntransAttributesEditor,
+                       $viewInformation,
+                       new ObjectIdFetcher( 0, $o->objectId )
+               );
+               // we need to wrap the editor to geth the "objectId" (i.e. 
syntransId) in the idPath
+               // Otherwise, saving new data does not work
+               $syntransAttributesWrappedEditor = new ObjectContextEditor ( 
$syntransAttributesEditor ) ;
+
+               $availableEditors->addEditor( $syntransAttributesWrappedEditor 
);
+       }
+
        $definedMeaningEditor = new RecordUnorderedListEditor( 
$o->definedMeaning, 4 );
-       
+
+
+       // put all of the above editors in the right order.
+       // the default order is defined in WikiDataGlobals.php but can be 
reconfigured
        foreach ( $wdDefinedMeaningAttributesOrder as $attributeId ) {
                $editor = $availableEditors->getEditorForAttributeId( 
$attributeId );
                
@@ -900,7 +933,11 @@
 
        $definedMeaningEditor->expandEditor( $definitionEditor );
        $definedMeaningEditor->expandEditor( $synonymsAndTranslationsEditor );
-       
+
+       if ( $insideExpression ) {
+               $definedMeaningEditor->expandEditor( 
$syntransAttributesWrappedEditor );
+       }
+
        return new DefinedMeaningContextEditor( $definedMeaningEditor );
 }
 
diff --git a/OmegaWiki/OmegaWikiRecordSets.php 
b/OmegaWiki/OmegaWikiRecordSets.php
index 418bcc4..043a6c6 100644
--- a/OmegaWiki/OmegaWikiRecordSets.php
+++ b/OmegaWiki/OmegaWikiRecordSets.php
@@ -391,7 +391,8 @@
        }
 }
 
-/*
+/**
+* The corresponding Editor function is getExpressionMeaningsEditor
 * $exactMeaning is a boolean
 */
 function getExpressionMeaningsRecordSet( $expressionId, $exactMeaning, 
ViewInformation $viewInformation ) {
@@ -404,14 +405,16 @@
 
        $dbr = wfGetDB( DB_SLAVE );
        $queryResult = $dbr->query(
-               "SELECT defined_meaning_id FROM {$dc}_syntrans" .
+               "SELECT defined_meaning_id, syntrans_sid FROM {$dc}_syntrans" .
                " WHERE expression_id=$expressionId AND identical_meaning=" . 
$identicalMeaning .
                " AND {$dc}_syntrans.remove_transaction_id IS NULL "
        );
 
-       while ( $definedMeaning = $dbr->fetchObject( $queryResult ) ) {
-               $definedMeaningId = $definedMeaning->defined_meaning_id;
-               $dmModel = new DefinedMeaningModel( $definedMeaningId, 
$viewInformation );
+       while ( $syntrans = $dbr->fetchObject( $queryResult ) ) {
+               $definedMeaningId = $syntrans->defined_meaning_id;
+               $syntransId = $syntrans->syntrans_sid;
+               $dmModelParams = array( "viewinformation" => $viewInformation, 
"syntransid" => $syntransId );
+               $dmModel = new DefinedMeaningModel( $definedMeaningId, 
$dmModelParams );
                $recordSet->addRecord(
                        array(
                                $definedMeaningId,
@@ -424,6 +427,9 @@
        return $recordSet;
 }
 
+/**
+* The corresponding Editor function is getExpressionsEditor
+*/
 function getExpressionMeaningsRecord( $expressionId, ViewInformation 
$viewInformation ) {
        $o = OmegaWikiAttributes::getInstance();
                
@@ -747,7 +753,10 @@
        return $recordSet;
 }
 
-function getSynonymAndTranslationRecordSet( $definedMeaningId, ViewInformation 
$viewInformation ) {
+/**
+* the corresponding Editor is getSynonymsAndTranslationsEditor
+*/
+function getSynonymAndTranslationRecordSet( $definedMeaningId, ViewInformation 
$viewInformation, $excludeSyntransId = null ) {
        $o = OmegaWikiAttributes::getInstance();
        $dc = wdGetDataSetContext();
        $dbr = wfGetDB( DB_SLAVE );
@@ -795,9 +804,12 @@
 
        $queryResult = $dbr->query( $getSynTransSQL );
        while ( $row = $dbr->fetchObject( $queryResult ) ) {
-               $record = new ArrayRecord( $structure );
-
                $syntransId = $row->syntrans_sid;
+               if ( $syntransId == $excludeSyntransId ) {
+                       continue;
+               }
+
+               $record = new ArrayRecord( $structure );
                $record->syntransId = $syntransId;
                $record->identicalMeaning = $row->identical_meaning;
 
diff --git a/OmegaWiki/PropertyToColumnFilter.php 
b/OmegaWiki/PropertyToColumnFilter.php
index 8982ab4..99f2039 100644
--- a/OmegaWiki/PropertyToColumnFilter.php
+++ b/OmegaWiki/PropertyToColumnFilter.php
@@ -27,6 +27,15 @@
        public function leavesOnlyOneOption() {
                return count( $this->attributeIDsToInclude ) == 1;
        }
+
+       public function __tostring() {
+               $string = "IncludeAttributeIDsFilter (";
+               foreach ( $this->attributeIDsToInclude as $included ) {
+                       $string.= " $included ; ";
+               }
+               $string.= ")\n";
+               return $string;
+       }
 }
 
 class ExcludeAttributeIDsFilter implements AttributeIDFilter {
@@ -49,6 +58,16 @@
        public function leavesOnlyOneOption() {
                return false;
        }
+
+       public function __tostring() {
+               $string = "ExcludeAttributeIDsFilter (";
+               foreach ( $this->attributeIDsToExclude as $excluded ) {
+                       $string.= " $excluded ; ";
+               }
+               $string.= ")\n";
+               return $string;
+       }
+
 }
 
 /**
diff --git a/OmegaWiki/SpecialConceptMapping.php 
b/OmegaWiki/SpecialConceptMapping.php
index 922446b..a974205 100644
--- a/OmegaWiki/SpecialConceptMapping.php
+++ b/OmegaWiki/SpecialConceptMapping.php
@@ -67,7 +67,7 @@
                        $rq[$set] = trim( $rq[$set] );
                        $rq[$set] = (int)$rq[$set];
                        if ( $rq[$set] ) {
-                               $dmModel = new DefinedMeaningModel( $rq[$set], 
null, $setObject );
+                               $dmModel = new DefinedMeaningModel( $rq[$set], 
array( "dataset" => $setObject ) );
                                $defaultSel = 
$dmModel->getSyntransByLanguageCode( $lang );
                                $options[$setObject->fetchName()] = getSuggest( 
"set_$set", WLD_DEFINED_MEANING, array(), $rq[$set], $defaultSel, array( 0 ), 
$setObject );
                        } else {
@@ -83,7 +83,7 @@
                        if ( !$rq[$set] ) {
                                $wgOut->addHTML( ' <span 
style="color:yellow">[' . wfMsgSc( "dm_not_present" ) . ']</span>' );
                        } else  {
-                               $dmModel = new DefinedMeaningModel( $rq[$set], 
null, $setObject );
+                               $dmModel = new DefinedMeaningModel( $rq[$set], 
array( "dataset" => $setObject ) );
                                $dmModel->checkExistence();
                                if ( $dmModel->exists() ) {
                                        $id = $dmModel->getId();
diff --git a/OmegaWiki/Test.skeleton.php b/OmegaWiki/Test.skeleton.php
index 3e389ed..62dae60 100644
--- a/OmegaWiki/Test.skeleton.php
+++ b/OmegaWiki/Test.skeleton.php
@@ -46,7 +46,7 @@
                $viewInformation = new ViewInformation();
                $viewInformation->queryTransactionInformation = new 
QueryLatestTransactionInformation();
 
-               $model = new DefinedMeaningModel( $definedMeaningId, 
$viewInformation );
+               $model = new DefinedMeaningModel( $definedMeaningId, array( 
"viewinformation" => $viewInformation ) );
                $testRecord = $model->getRecord();
        }
        
diff --git a/OmegaWiki/WikiDataAPI.php b/OmegaWiki/WikiDataAPI.php
index 943b730..50ee0bd 100644
--- a/OmegaWiki/WikiDataAPI.php
+++ b/OmegaWiki/WikiDataAPI.php
@@ -1572,7 +1572,7 @@
        $map = getDataSetsAssociatedByConcept( $dm, $dc );
        $dm_map = getAssociatedByConcept( $dm, $dc );
        foreach ( $map as $map_dc => $map_dataset ) {
-               $dmModel = new DefinedMeaningModel( $dm_map[$map_dc], null, 
$map_dataset );
+               $dmModel = new DefinedMeaningModel( $dm_map[$map_dc], array( 
"dataset" => $map_dataset ) );
                $meanings[$map_dc] = $dmModel;
        }
        return $meanings;
diff --git a/OmegaWiki/WikiDataGlobals.php b/OmegaWiki/WikiDataGlobals.php
index ac56c21..4b7bbc2 100644
--- a/OmegaWiki/WikiDataGlobals.php
+++ b/OmegaWiki/WikiDataGlobals.php
@@ -37,6 +37,7 @@
 define ( 'WLD_OTHER_OBJECT', "otherObj" );
 define ( 'WLD_RELATIONS', "rel" );
 define ( 'WLD_SYNONYMS_TRANSLATIONS', "syntrans" );
+define ( 'WLD_SYNT_ATTRIBUTES', "syntAtt" );
 define ( 'WLD_TEXT_ATTRIBUTES_VALUES', "txtAttVal" );
 define ( 'WLD_TRANSLATED_TEXT', "transl" );
 
@@ -51,6 +52,7 @@
 global $wdDefinedMeaningAttributesOrder;
        
 $wdDefinedMeaningAttributesOrder = array(
+       WLD_SYNT_ATTRIBUTES,
        WLD_DEFINITION,
        WLD_ALTERNATIVE_DEFINITIONS,
        WLD_SYNONYMS_TRANSLATIONS,

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I76783e95a22bb4d526637c8411ba15d0e4bb45e0
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/WikiLexicalData
Gerrit-Branch: master
Gerrit-Owner: Kipcool <[email protected]>

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

Reply via email to