r23747 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r23746‎ | r23747 | r23748 >
Date:17:45, 5 July 2007
Author:kim
Status:old
Tags:
Comment:
Partial refactor of OmegaWikiAttributes2
Modified paths:
  • /trunk/extensions/Wikidata/OmegaWiki/OmegaWikiAttributes2.php (modified) (history)

Diff [purge]

Index: trunk/extensions/Wikidata/OmegaWiki/OmegaWikiAttributes2.php
@@ -39,38 +39,51 @@
4040 class OmegaWikiAttributes {
4141 protected $attributes = null;
4242 function __construct(ViewInformation $viewInformation) {
43 - $a=$this->attributes; # <- wrist/RSI protection
 43+ $this->hardValues();
 44+ }
4445
 46+ /** Hardcoded schema for now. Later refactor to load from file or DB
 47+ *
 48+ * Naming: keys are previous name minus -"Attribute"
 49+ * (-"Structure" is retained)
 50+ */
 51+ private function hardValues() {
 52+
 53+ $a=$this->attributes; # <- wrist/RSI protection
 54+
 55+ # TODO these will be replaced with i18n
4556 global
46 - $languageAttribute, $spellingAttribute, $textAttribute,
4757 $wgLanguageAttributeName, $wgSpellingAttributeName, $wgTextAttributeName;
4858
49 - $languageAttribute = new Attribute("language", $wgLanguageAttributeName, "language");
50 - $spellingAttribute = new Attribute("spelling", $wgSpellingAttributeName, "spelling");
51 - $textAttribute = new Attribute("text", $wgTextAttributeName, "text");
 59+ $a["language"] = new Attribute("language", $wgLanguageAttributeName, "language");
 60+ $a["spelling"] = new Attribute("spelling", $wgSpellingAttributeName, "spelling");
 61+ $a["text"] = new Attribute("text", $wgTextAttributeName, "text");
5262
 63+ #TODO replace with i18n
5364 global
54 - $objectAttributesAttribute, $definedMeaningAttributesAttribute,
5565 $wgDefinedMeaningAttributesAttributeName,
56 - $wgDefinedMeaningAttributesAttributeName, $wgDefinedMeaningAttributesAttributeId, $wgAnnotationAttributeName;
 66+ $wgDefinedMeaningAttributesAttributeName,
 67+ $wgAnnotationAttributeName;
5768
58 - $definedMeaningAttributesAttribute = new Attribute("defined-meaning-attributes", $wgDefinedMeaningAttributesAttributeName, "will-be-specified-below");
59 - $objectAttributesAttribute = new Attribute("object-attributes", $wgAnnotationAttributeName, "will-be-specified-below");
60 -
 69+ $a["definedMeaningAttributes"] = new Attribute("defined-meaning-attributes", $wgDefinedMeaningAttributesAttributeName, "will-be-specified-below");
 70+ $a["objectAttributes"] = new Attribute("object-attributes", $wgAnnotationAttributeName, "will-be-specified-below");
 71+
 72+ # TODO replace with i18n
6173 global
62 - $expressionIdAttribute, $identicalMeaningAttribute, $wgIdenticalMeaningAttributeName;
 74+ $expressionIdAttribute, $identicalMeaningAttribute;
6375
64 - $expressionIdAttribute = new Attribute("expression-id", "Expression Id", "expression-id");
65 - $identicalMeaningAttribute = new Attribute("indentical-meaning", $wgIdenticalMeaningAttributeName, "boolean");
 76+ $a["expressionId"] = new Attribute("expression-id", "Expression Id", "expression-id");
 77+ $a["identicalMeaning"] = new Attribute("indentical-meaning", $wgIdenticalMeaningAttributeName, "boolean");
6678
 79+ #TODO replace with i18n
6780 global
68 - $expressionStructure, $expressionAttribute, $wgExpressionAttributeName;
 81+ $wgExpressionAttributeName;
6982
7083 if ($viewInformation->filterOnLanguage())
71 - $expressionAttribute = new Attribute("expression", $wgSpellingAttributeName, "spelling");
 84+ $a["expression"] = new Attribute("expression", $wgSpellingAttributeName, "spelling");
7285 else {
73 - $expressionStructure = new Structure("expression", $languageAttribute, $spellingAttribute);
74 - $expressionAttribute = new Attribute(null, $wgExpressionAttributeName, $expressionStructure);
 86+ $a["expressionStructure"] = new Structure("expression", $languageAttribute, $spellingAttribute);
 87+ $a["expression"] = new Attribute(null, $wgExpressionAttributeName, $expressionStructure);
7588 }
7689
7790 global
@@ -78,18 +91,21 @@
7992 $definedMeaningCompleteDefiningExpressionStructure,
8093 $definedMeaningCompleteDefiningExpressionAttribute;
8194
82 - $definedMeaningIdAttribute = new Attribute("defined-meaning-id", "Defined meaning identifier", "defined-meaning-id");
83 - $definedMeaningDefiningExpressionAttribute = new Attribute("defined-meaning-defining-expression", "Defined meaning defining expression", "short-text");
 95+ $a["definedMeaningId"] = new Attribute("defined-meaning-id", "Defined meaning identifier", "defined-meaning-id");
 96+ $a["definedMeaningDefiningExpression"] = new Attribute("defined-meaning-defining-expression", "Defined meaning defining expression", "short-text");
8497
85 - $definedMeaningCompleteDefiningExpressionStructure =
 98+ $a["definedMeaningCompleteDefiningExpressionStructure"] =
8699 new Structure("defined-meaning-full-defining-expression",
87100 $definedMeaningDefiningExpressionAttribute,
88101 $expressionIdAttribute,
89102 $languageAttribute
90103 );
91 - $definedMeaningCompleteDefiningExpressionAttribute=new Attribute(null, "Defining expression", $definedMeaningCompleteDefiningExpressionStructure);
 104+ $a["definedMeaningCompleteDefiningExpression"]=new Attribute(null, "Defining expression", $definedMeaningCompleteDefiningExpressionStructure);
92105
93 -
 106+ #==============================================
 107+ # Done refactoring up to here (to maintain sanity, will do a little every day
 108+ # if you want to do a good deed, shift this line down please)
 109+ # ===============================================
94110
95111 global
96112 $definedMeaningReferenceStructure, $definedMeaningLabelAttribute, $definedMeaningReferenceType,
@@ -346,6 +362,11 @@
347363 $definedMeaningAttributesAttribute->id
348364 );
349365 }
 366+
 367+ function getAttribute($key) {
 368+ $attributes=$this->attributes;
 369+ return $attributes[$key];
 370+ }
350371 }
351372
352373

Status & tagging log