r17678 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r17677‎ | r17678 | r17679 >
Date:19:06, 14 November 2006
Author:karstenuil
Status:old
Tags:
Comment:
Added user interface components for Class attributes logic. Add / edit needs to be done.
Modified paths:
  • /trunk/extensions/Wikidata/Database+scripts/Incremental/21+-+Add+class+attributes.sql (added) (history)
  • /trunk/extensions/Wikidata/WiktionaryZ/Controller.php (modified) (history)
  • /trunk/extensions/Wikidata/WiktionaryZ/Expression.php (modified) (history)
  • /trunk/extensions/Wikidata/WiktionaryZ/WikiDataTables.php (modified) (history)
  • /trunk/extensions/Wikidata/WiktionaryZ/WiktionaryZAttributes.php (modified) (history)
  • /trunk/extensions/Wikidata/WiktionaryZ/WiktionaryZEditors.php (modified) (history)
  • /trunk/extensions/Wikidata/WiktionaryZ/WiktionaryZRecordSets.php (modified) (history)

Diff [purge]

Index: trunk/extensions/Wikidata/WiktionaryZ/Expression.php
@@ -236,6 +236,14 @@
237237 " AND remove_transaction_id IS NULL");
238238 }
239239
 240+function addClassAttribute($definedMeaningId, $attibuteMeaningId) {
 241+//TODO: addClassAttribute
 242+}
 243+
 244+function removeClassAttributeWithId($classAttributeId) {
 245+//TODO: removeClassAttributeWithId
 246+}
 247+
240248 function getClassMembershipId($classMemberId, $classId) {
241249 $dbr =& wfGetDB(DB_SLAVE);
242250 $queryResult = $dbr->query("SELECT class_membership_id FROM uw_class_membership " .
Index: trunk/extensions/Wikidata/WiktionaryZ/WiktionaryZAttributes.php
@@ -129,7 +129,7 @@
130130
131131 $translatedTextAttribute = new Attribute("translated-text", "Translated text", new RecordSetType($translatedTextStructure));
132132 $definitionAttribute = new Attribute("definition", "Definition", new RecordType(new Structure($translatedTextAttribute, $objectAttributesAttribute)));
133 -$definedMeaningAttribute = new Attribute("defined-meaning", "Defined meaning", new RecordType(new Structure($definitionAttribute, $alternativeDefinitionsAttribute, $synonymsAndTranslationsAttribute, $relationsAttribute, $classMembershipAttribute, $collectionMembershipAttribute, $objectAttributesAttribute)));
 133+$definedMeaningAttribute = new Attribute("defined-meaning", "Defined meaning", new RecordType(new Structure($definitionAttribute, $classAttributesAttribute, $alternativeDefinitionsAttribute, $synonymsAndTranslationsAttribute, $relationsAttribute, $classMembershipAttribute, $collectionMembershipAttribute, $objectAttributesAttribute)));
134134
135135 global
136136 $expressionsAttribute, $expressionMeaningStructure, $expressionExactMeaningsAttribute, $expressionApproximateMeaningsAttribute;
@@ -153,4 +153,17 @@
154154 $objectAttributesStructure = new Structure($objectIdAttribute, $textAttributeValuesAttribute, $translatedTextAttributeValuesAttribute);
155155 $objectAttributesAttribute = new Attribute("object-attributes", "Annotation", new RecordType($objectAttributesStructure));
156156
 157+global
 158+ $classAttributesStructure,
 159+ $classAttributesAttribute,
 160+// $classAttributeClassAttribute,
 161+ $classAttributeIdAttribute, $classAttributeAttributeAttribute;
 162+
 163+$classAttributeIdAttribute = new Attribute("class-attribute-id", "Class attribute identifier", "object-id");
 164+//$classAttributeClassAttribute = new Attribute("class-attribute-class", "Class", "defined-meaning-id");
 165+$classAttributeAttributeAttribute = new Attribute("class-attribute-attribute", "Attribute", new RecordType($definedMeaningReferenceStructure));
 166+
 167+$classAttributesStructure = new Structure($classAttributeIdAttribute, $classAttributeAttributeAttribute);
 168+$classAttributesAttribute = new Attribute("class-attributes", "Class attributes", new RecordSetType($classAttributesStructure));
 169+
157170 ?>
Index: trunk/extensions/Wikidata/WiktionaryZ/Controller.php
@@ -178,6 +178,30 @@
179179 }
180180 }
181181
 182+class ClassAttributesController implements Controller {
 183+ public function add($keyPath, $record) {
 184+ global
 185+ $definedMeaningIdAttribute, $classAttributeAttributeAttribute;
 186+
 187+ $definedMeaningId = $keyPath->peek(0)->getAttributeValue($definedMeaningIdAttribute);
 188+ $attibuteMeaningId = $record->getAttributeValue($classAttributeAttributeAttribute);
 189+
 190+ if ($attibuteMeaningId != 0)
 191+ addClassAttribute($definedMeaningId, $attibuteMeaningId);
 192+ }
 193+
 194+ public function remove($keyPath) {
 195+ global
 196+ $classAttributeIdAttribute;
 197+
 198+ $classAttributeId = $keyPath->peek(0)->getAttributeValue($classAttributeIdAttribute);
 199+ removeClassAttributeWithId($classAttributeId);
 200+ }
 201+
 202+ public function update($keyPath, $record) {
 203+ }
 204+}
 205+
182206 class DefinedMeaningRelationController implements Controller {
183207 public function add($keyPath, $record) {
184208 global
Index: trunk/extensions/Wikidata/WiktionaryZ/WiktionaryZEditors.php
@@ -107,6 +107,16 @@
108108 return $editor;
109109 }
110110
 111+function getClassAttributesEditor($showRecordLifeSpan) {
 112+ global
 113+ $classAttributesAttribute, $classAttributeAttributeAttribute;
 114+
 115+ $tableEditor = new RecordSetTableEditor($classAttributesAttribute, new SimplePermissionController(true), true, true, false, new ClassAttributesController());
 116+ $tableEditor->addEditor(new DefinedMeaningReferenceEditor($classAttributeAttributeAttribute, new SimplePermissionController(false), true));
 117+ addTableLifeSpanEditor($tableEditor, $showRecordLifeSpan);
 118+ return $tableEditor;
 119+}
 120+
111121 function getSynonymsAndTranslationsEditor($showRecordLifeSpan) {
112122 global
113123 $synonymsAndTranslationsAttribute, $identicalMeaningAttribute, $expressionIdAttribute,
@@ -247,7 +257,8 @@
248258 global
249259 $definitionAttribute, $definedMeaningAttribute, $definedMeaningObjectAttributesEditor;
250260
251 - $definitionEditor = getDefinitionEditor($definitionAttribute, new DefinedMeaningDefinitionController(), $showRecordLifeSpan);
 261+ $definitionEditor = getDefinitionEditor($definitionAttribute, new DefinedMeaningDefinitionController(), $showRecordLifeSpan);
 262+ $classAttributesEditor = getClassAttributesEditor($showRecordLifeSpan);
252263 $synonymsAndTranslationsEditor = getSynonymsAndTranslationsEditor($showRecordLifeSpan);
253264 $relationsEditor = getDefinedMeaningRelationsEditor($showRecordLifeSpan);
254265 $reciprocalRelationsEditor = getDefinedMeaningReciprocalRelationsEditor($showRecordLifeSpan);
@@ -256,6 +267,7 @@
257268
258269 $definedMeaningEditor = new RecordUnorderedListEditor($definedMeaningAttribute, 4);
259270 $definedMeaningEditor->addEditor($definitionEditor);
 271+ $definedMeaningEditor->addEditor($classAttributesEditor);
260272 $definedMeaningEditor->addEditor(getAlternativeDefinitionsEditor($showRecordLifeSpan));
261273 $definedMeaningEditor->addEditor($synonymsAndTranslationsEditor);
262274 $definedMeaningEditor->addEditor($relationsEditor);
Index: trunk/extensions/Wikidata/WiktionaryZ/WikiDataTables.php
@@ -13,7 +13,7 @@
1414 global
1515 $tables, $meaningRelationsTable, $classMembershipsTable, $collectionMembershipsTable, $syntransTable,
1616 $translatedContentTable, $alternativeDefinitionsTable, $translatedContentAttributeValuesTable, $transactionsTable,
17 - $textAttributeValuesTable;
 17+ $textAttributeValuesTable, $classAttributesTable;
1818
1919 $transactionsTable = new Table('transactions', false);
2020 $meaningRelationsTable = new Table('uw_meaning_relations', true);
@@ -22,6 +22,7 @@
2323 $syntransTable = new Table('uw_syntrans', true);
2424 $translatedContentTable = new Table('translated_content', true);
2525 $alternativeDefinitionsTable = new Table('uw_alt_meaningtexts', true);
 26+$classAttributesTable = new Table('uw_class_attributes', true);
2627
2728 $translatedContentAttributeValuesTable = new Table('uw_translated_content_attribute_values', true);
2829 $textAttributeValuesTable = new Table('uw_text_attribute_values', true);
Index: trunk/extensions/Wikidata/WiktionaryZ/WiktionaryZRecordSets.php
@@ -405,12 +405,14 @@
406406
407407 function getDefinedMeaningRecord($definedMeaningId, $queryTransactionInformation) {
408408 global
409 - $definedMeaningAttribute, $definitionAttribute, $alternativeDefinitionsAttribute, $synonymsAndTranslationsAttribute,
 409+ $definedMeaningAttribute, $definitionAttribute, $classAttributesAttribute,
 410+ $alternativeDefinitionsAttribute, $synonymsAndTranslationsAttribute,
410411 $relationsAttribute, $reciprocalRelationsAttribute,
411412 $classMembershipAttribute, $collectionMembershipAttribute, $objectAttributesAttribute;
412413
413414 $record = new ArrayRecord($definedMeaningAttribute->type->getStructure());
414415 $record->setAttributeValue($definitionAttribute, getDefinedMeaningDefinitionRecord($definedMeaningId, $queryTransactionInformation));
 416+ $record->setAttributeValue($classAttributesAttribute, getClassAttributesRecordSet($definedMeaningId, $queryTransactionInformation));
415417 $record->setAttributeValue($alternativeDefinitionsAttribute, getAlternativeDefinitionsRecordSet($definedMeaningId, $queryTransactionInformation));
416418 $record->setAttributeValue($synonymsAndTranslationsAttribute, getSynonymAndTranslationRecordSet($definedMeaningId, $queryTransactionInformation));
417419 $record->setAttributeValue($relationsAttribute, getDefinedMeaningRelationsRecordSet($definedMeaningId, $queryTransactionInformation));
@@ -422,6 +424,25 @@
423425 return $record;
424426 }
425427
 428+function getClassAttributesRecordSet($definedMeaningId, $queryTransactionInformation) {
 429+ global
 430+ $classAttributesTable, $classAttributeIdAttribute, $classAttributeAttributeAttribute;
 431+
 432+ $recordSet = queryRecordSet(
 433+ $queryTransactionInformation,
 434+ $classAttributeIdAttribute,
 435+ array(
 436+ 'object_id' => $classAttributeIdAttribute,
 437+ 'attribute_mid' => $classAttributeAttributeAttribute
 438+ ),
 439+ $classAttributesTable,
 440+ array("class_mid=$definedMeaningId")
 441+ );
 442+
 443+ expandDefinedMeaningReferencesInRecordSet($recordSet, array($classAttributeAttributeAttribute));
 444+ return $recordSet;
 445+}
 446+
426447 function getAlternativeDefinitionsRecordSet($definedMeaningId, $queryTransactionInformation) {
427448 global
428449 $alternativeDefinitionsTable, $definitionIdAttribute, $alternativeDefinitionAttribute, $sourceAttribute;
Index: trunk/extensions/Wikidata/Database scripts/Incremental/21 - Add class attributes.sql
@@ -0,0 +1,14 @@
 2+--
 3+--Add class attributes table to store which attributes can be added to object's that belong to a class
 4+--
 5+
 6+CREATE TABLE `uw_class_attributes` (
 7+ `object_id` INT NOT NULL ,
 8+ `class_mid` INT NOT NULL DEFAULT '0',
 9+ `attribute_mid` INT NOT NULL DEFAULT '0',
 10+ `add_transaction_id` INT NOT NULL ,
 11+ `remove_transaction_id` INT NULL
 12+);
 13+
 14+INSERT INTO `script_log` (`time`, `script_name`)
 15+ VALUES (NOW(), '21 - Add class attributes.sql');
\ No newline at end of file

Status & tagging log