r24746 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r24745‎ | r24746 | r24747 >
Date:13:21, 13 August 2007
Author:proes
Status:old
Tags:
Comment:
Solved bug that prevented translated text attribute values from being added
Modified paths:
  • /trunk/extensions/Wikidata/OmegaWiki/Controller.php (modified) (history)
  • /trunk/extensions/Wikidata/OmegaWiki/OmegaWikiAttributes.php (modified) (history)
  • /trunk/extensions/Wikidata/OmegaWiki/OmegaWikiRecordSets.php (modified) (history)
  • /trunk/extensions/Wikidata/OmegaWiki/Record.php (modified) (history)

Diff [purge]

Index: trunk/extensions/Wikidata/OmegaWiki/OmegaWikiAttributes.php
@@ -204,12 +204,16 @@
205205 $synonymsAndTranslationsAttribute = new Attribute(null, "$synonymsAndTranslationsCaption", $synonymsTranslationsStructure);
206206
207207 global
 208+ $attributeObjectAttribute;
 209+
 210+ $attributeObjectAttribute = new Attribute("attribute-object-id", "Attribute object", "object-id");
 211+
 212+ global
208213 $translatedTextAttributeIdAttribute, $translatedTextValueIdAttribute,
209 - $translatedTextAttributeObjectAttribute, $translatedTextAttributeAttribute, $translatedTextValueAttribute, $translatedTextAttributeValuesAttribute,
 214+ $translatedTextAttributeAttribute, $translatedTextValueAttribute, $translatedTextAttributeValuesAttribute,
210215 $translatedTextAttributeValuesStructure, $wgTranslatedTextAttributeValuesAttributeName, $wgTranslatedTextAttributeAttributeName, $wgTranslatedTextAttributeValueAttributeName;
211216
212217 $translatedTextAttributeIdAttribute = new Attribute("translated-text-attribute-id", "Attribute identifier", "object-id");
213 - $translatedTextAttributeObjectAttribute = new Attribute("translated-text-attribute-object-id", "Attribute object", "object-id");
214218 $translatedTextAttributeAttribute = new Attribute("translated-text-attribute", $wgTranslatedTextAttributeAttributeName, $definedMeaningReferenceType);
215219 $translatedTextValueIdAttribute = new Attribute("translated-text-value-id", "Translated text value identifier", "translated-text-value-id");
216220
@@ -218,7 +222,7 @@
219223 else
220224 $translatedTextValueAttribute = new Attribute("translated-text", $wgTranslatedTextAttributeValueAttributeName, $translatedTextStructure);
221225
222 - $translatedTextAttributeValuesStructure = new Structure("translated-text-attribute-values",$translatedTextAttributeIdAttribute, $translatedTextAttributeObjectAttribute, $translatedTextAttributeAttribute, $translatedTextValueIdAttribute, $translatedTextValueAttribute, $objectAttributesAttribute);
 226+ $translatedTextAttributeValuesStructure = new Structure("translated-text-attribute-values",$translatedTextAttributeIdAttribute, $attributeObjectAttribute, $translatedTextAttributeAttribute, $translatedTextValueIdAttribute, $translatedTextValueAttribute, $objectAttributesAttribute);
223227 $translatedTextAttributeValuesAttribute = new Attribute(null, $wgTranslatedTextAttributeValuesAttributeName, $translatedTextAttributeValuesStructure);
224228
225229 global
@@ -426,6 +430,7 @@
427431 $t->class = new Attribute("class", "Class", $t->definedMeaningReferenceStructure);
428432 $t->classMembershipStructure = new Structure("class-membership", $t->classMembershipId, $t->class);
429433 $t->classMembership = new Attribute(null, wfMsg("ClassMembership"), $t->classMembershipStructure);
 434+
430435 global
431436 $wgPossiblySynonymousAttributeId;
432437
@@ -437,14 +442,14 @@
438443 $t->possiblySynonymous = new Attribute(null, wfMsg("PossiblySynonymous"), $t->possiblySynonymousStructure);
439444
440445 global
441 - $relationTypeType;
 446+ $relationTypeType;
442447
443448 $t->relationId = new Attribute("relation-id", "Relation identifier", "object-id");
444449 $t->relationType = new Attribute("relation-type", wfMsg("RelationType"), $t->definedMeaningReferenceStructure);
445450 $t->otherDefinedMeaning = new Attribute("other-defined-meaning", wfMsg("OtherDefinedMeaning"), $definedMeaningReferenceType);
446451
447452 global
448 - $wgRelationsAttributeId, $wgIncomingRelationsAttributeId ;
 453+ $wgRelationsAttributeId, $wgIncomingRelationsAttributeId ;
449454
450455 $t->relationStructure = new Structure("relations", $t->relationId, $t->relationType, $t->otherDefinedMeaning, $t->objectAttributes);
451456 $t->relations = new Attribute(null, wfMsg("Relations"), $t->relationStructure);
@@ -476,11 +481,12 @@
477482 else
478483 $synonymsAndTranslationsCaption = wfMsg("SynonymsAndTranslations");
479484
 485+ $t->attributeObjectId = new Attribute("attributeObjectId", "Attribute object", "object-id");
 486+
480487 $t->syntransId = new Attribute("syntrans-id", "$synonymsAndTranslationsCaption identifier", "integer");
481488 $t->synonymsTranslationsStructure = new Structure("synonyms-translations", $t->syntransId, $t->expression, $t->identicalMeaning, $t->objectAttributes);
482489 $t->synonymsAndTranslations = new Attribute(null, "$synonymsAndTranslationsCaption", $t->synonymsTranslationsStructure);
483490 $t->translatedTextAttributeId = new Attribute("translated-text-attribute-id", "Attribute identifier", "object-id");
484 - $t->translatedTextAttributeObject = new Attribute("translated-text-attribute-object-id", "Attribute object", "object-id");
485491 $t->translatedTextAttribute = new Attribute("translated-text-attribute", wfMsg("TranslatedTextAttribute"), $definedMeaningReferenceType);
486492 $t->translatedTextValueId = new Attribute("translated-text-value-id", "Translated text value identifier", "translated-text-value-id");
487493
@@ -489,7 +495,7 @@
490496 else
491497 $t->translatedTextValue = new Attribute("translated-text", wfMsg("TranslatedTextAttributeValue"), $t->translatedTextStructure);
492498
493 - $t->translatedTextAttributeValuesStructure = new Structure("translated-text-attribute-values",$t->translatedTextAttributeId, $t->translatedTextAttributeObject, $t->translatedTextAttribute, $t->translatedTextValueId, $t->translatedTextValue, $t->objectAttributes);
 499+ $t->translatedTextAttributeValuesStructure = new Structure("translated-text-attribute-values",$t->translatedTextAttributeId, $t->attributeObjectId, $t->translatedTextAttribute, $t->translatedTextValueId, $t->translatedTextValue, $t->objectAttributes);
494500 $t->translatedTextAttributeValues = new Attribute(null, wfMsg("TranslatedTextAttributeValues"), $t->translatedTextAttributeValuesStructure);
495501 $t->textAttributeId = new Attribute("text-attribute-id", "Attribute identifier", "object-id");
496502 $t->textAttributeObject = new Attribute("text-attribute-object-id", "Attribute object", "object-id");
@@ -514,6 +520,7 @@
515521 $t->optionAttributeOptionId = new Attribute('option-attribute-option-id', 'Option identifier', 'object-id');
516522 $t->optionAttributeOptionsStructure = new Structure('option-attribute-options', $t->optionAttributeOptionId, $t->optionAttribute, $t->optionAttributeOption, $t->language);
517523 $t->optionAttributeOptions = new Attribute(null, wfMsg("OptionAttributeOptions"), $t->optionAttributeOptionsStructure);
 524+
518525 if ($viewInformation->filterOnLanguage() && !$viewInformation->hasMetaDataAttributes())
519526 $t->translatedText = new Attribute("translated-text", wfMsg("Text"), "text");
520527 else
@@ -582,7 +589,7 @@
583590 public function __get($key) {
584591 $attributes=&$this->attributes;
585592 if (!array_key_exists($key, $attributes)) {
586 - throw new Exception("Key does not exist");
 593+ throw new Exception("Key does not exist: " . $key);
587594 }
588595 return $attributes[$key];
589596 }
Index: trunk/extensions/Wikidata/OmegaWiki/Controller.php
@@ -586,8 +586,8 @@
587587 if ($textValue->getRecordCount() > 0) {
588588 $textValueRecord = $textValue->getRecord(0);
589589
590 - $languageId = $textValueRecord->languageAttribute;
591 - $text = $textValueRecord->textAttribute;
 590+ $languageId = $textValueRecord->language;
 591+ $text = $textValueRecord->text;
592592
593593 if ($languageId != 0 && $text != '')
594594 addTranslatedTextAttributeValue($objectId, $textAttributeId, $languageId, $text);
Index: trunk/extensions/Wikidata/OmegaWiki/OmegaWikiRecordSets.php
@@ -745,7 +745,7 @@
746746 function expandObjectAttributesAttribute(RecordSet $recordSet, Attribute $attributeToExpand, Attribute $objectIdAttribute, ViewInformation $viewInformation) {
747747 global
748748 $textAttributeObjectAttribute, $textAttributeValuesAttribute,
749 - $translatedTextAttributeObjectAttribute, $translatedTextAttributeValuesAttribute,
 749+ $attributeObjectAttribute, $translatedTextAttributeValuesAttribute,
750750 $linkAttributeObjectAttribute, $linkAttributeValuesAttribute,
751751 $optionAttributeObjectAttribute, $optionAttributeValuesAttribute;
752752
@@ -777,7 +777,7 @@
778778 $translatedTextAttributeValuesRecordSets =
779779 splitRecordSet(
780780 $allTranslatedTextAttributeValuesRecordSet,
781 - $translatedTextAttributeObjectAttribute
 781+ $attributeObjectAttribute
782782 );
783783
784784 $emptyTranslatedTextAttributesRecordSet = new ArrayRecordSet($allTranslatedTextAttributeValuesRecordSet->getStructure(), $allTranslatedTextAttributeValuesRecordSet->getKey());
@@ -1037,7 +1037,7 @@
10381038 function getTranslatedTextAttributeValuesRecordSet(array $objectIds, ViewInformation $viewInformation) {
10391039 global
10401040 $translatedTextAttributeIdAttribute, $translatedContentAttributeValuesTable, $translatedTextAttributeAttribute,
1041 - $objectAttributesAttribute, $translatedTextAttributeObjectAttribute, $translatedTextValueAttribute, $translatedTextValueIdAttribute,
 1041+ $objectAttributesAttribute, $attributeObjectAttribute, $translatedTextValueAttribute, $translatedTextValueIdAttribute,
10421042 $translatedTextAttributeValuesStructure;
10431043
10441044 $recordSet = queryRecordSet(
@@ -1046,7 +1046,7 @@
10471047 $translatedTextAttributeIdAttribute,
10481048 new TableColumnsToAttributesMapping(
10491049 new TableColumnsToAttribute(array('value_id'), $translatedTextAttributeIdAttribute),
1050 - new TableColumnsToAttribute(array('object_id'), $translatedTextAttributeObjectAttribute),
 1050+ new TableColumnsToAttribute(array('object_id'), $attributeObjectAttribute),
10511051 new TableColumnsToAttribute(array('attribute_mid'), $translatedTextAttributeAttribute),
10521052 new TableColumnsToAttribute(array('value_tcid'), $translatedTextValueIdAttribute)
10531053 ),
Index: trunk/extensions/Wikidata/OmegaWiki/Record.php
@@ -30,23 +30,22 @@
3131 return @$this->values[$attribute->id];
3232 }
3333
34 -
3534 /**
3635 * Look up the correct attribute using omegaWikiAttributes
3736 * and return its value
3837 */
39 - public function __get($attribute_name){
40 - $o=OmegaWikiAttributes::getInstance();
41 - return $this->getAttributeValue($o->$attribute_name);
 38+ public function __get($attributeName) {
 39+ $o = OmegaWikiAttributes::getInstance();
 40+ return $this->getAttributeValue($o->$attributeName);
4241 }
4342
4443 /**
4544 * Look up the correct attribute using omegaWikiAttributes
4645 * and set its value
4746 */
48 - public function __set($attribute_name, $value){
49 - $o=OmegaWikiAttributes::getInstance();
50 - return $this->setAttributeValue ($o->$attribute_name, $value);
 47+ public function __set($attributeName, $value) {
 48+ $o = OmegaWikiAttributes::getInstance();
 49+ return $this->setAttributeValue($o->$attributeName, $value);
5150 }
5251 /**
5352 * Obtains a value based on the provided key.
@@ -55,7 +54,7 @@
5655 * For now, this just does a direct lookup.
5756 * @deprecated use __get and __set instead
5857 */
59 - public function getValue ($key) {
 58+ public function getValue($key) {
6059 return @$this->values[$key];
6160 }
6261

Status & tagging log