Index: trunk/extensions/Wikidata/OmegaWiki/OmegaWikiAttributes2.php |
— | — | @@ -39,38 +39,51 @@ |
40 | 40 | class OmegaWikiAttributes { |
41 | 41 | protected $attributes = null; |
42 | 42 | function __construct(ViewInformation $viewInformation) { |
43 | | - $a=$this->attributes; # <- wrist/RSI protection |
| 43 | + $this->hardValues(); |
| 44 | + } |
44 | 45 | |
| 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 |
45 | 56 | global |
46 | | - $languageAttribute, $spellingAttribute, $textAttribute, |
47 | 57 | $wgLanguageAttributeName, $wgSpellingAttributeName, $wgTextAttributeName; |
48 | 58 | |
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"); |
52 | 62 | |
| 63 | + #TODO replace with i18n |
53 | 64 | global |
54 | | - $objectAttributesAttribute, $definedMeaningAttributesAttribute, |
55 | 65 | $wgDefinedMeaningAttributesAttributeName, |
56 | | - $wgDefinedMeaningAttributesAttributeName, $wgDefinedMeaningAttributesAttributeId, $wgAnnotationAttributeName; |
| 66 | + $wgDefinedMeaningAttributesAttributeName, |
| 67 | + $wgAnnotationAttributeName; |
57 | 68 | |
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 |
61 | 73 | global |
62 | | - $expressionIdAttribute, $identicalMeaningAttribute, $wgIdenticalMeaningAttributeName; |
| 74 | + $expressionIdAttribute, $identicalMeaningAttribute; |
63 | 75 | |
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"); |
66 | 78 | |
| 79 | + #TODO replace with i18n |
67 | 80 | global |
68 | | - $expressionStructure, $expressionAttribute, $wgExpressionAttributeName; |
| 81 | + $wgExpressionAttributeName; |
69 | 82 | |
70 | 83 | if ($viewInformation->filterOnLanguage()) |
71 | | - $expressionAttribute = new Attribute("expression", $wgSpellingAttributeName, "spelling"); |
| 84 | + $a["expression"] = new Attribute("expression", $wgSpellingAttributeName, "spelling"); |
72 | 85 | 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); |
75 | 88 | } |
76 | 89 | |
77 | 90 | global |
— | — | @@ -78,18 +91,21 @@ |
79 | 92 | $definedMeaningCompleteDefiningExpressionStructure, |
80 | 93 | $definedMeaningCompleteDefiningExpressionAttribute; |
81 | 94 | |
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"); |
84 | 97 | |
85 | | - $definedMeaningCompleteDefiningExpressionStructure = |
| 98 | + $a["definedMeaningCompleteDefiningExpressionStructure"] = |
86 | 99 | new Structure("defined-meaning-full-defining-expression", |
87 | 100 | $definedMeaningDefiningExpressionAttribute, |
88 | 101 | $expressionIdAttribute, |
89 | 102 | $languageAttribute |
90 | 103 | ); |
91 | | - $definedMeaningCompleteDefiningExpressionAttribute=new Attribute(null, "Defining expression", $definedMeaningCompleteDefiningExpressionStructure); |
| 104 | + $a["definedMeaningCompleteDefiningExpression"]=new Attribute(null, "Defining expression", $definedMeaningCompleteDefiningExpressionStructure); |
92 | 105 | |
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 | + # =============================================== |
94 | 110 | |
95 | 111 | global |
96 | 112 | $definedMeaningReferenceStructure, $definedMeaningLabelAttribute, $definedMeaningReferenceType, |
— | — | @@ -346,6 +362,11 @@ |
347 | 363 | $definedMeaningAttributesAttribute->id |
348 | 364 | ); |
349 | 365 | } |
| 366 | + |
| 367 | + function getAttribute($key) { |
| 368 | + $attributes=$this->attributes; |
| 369 | + return $attributes[$key]; |
| 370 | + } |
350 | 371 | } |
351 | 372 | |
352 | 373 | |