Index: trunk/extensions/Wikidata/OmegaWiki/Record.php |
— | — | @@ -17,7 +17,6 @@ |
18 | 18 | |
19 | 19 | public function __construct($structure) { |
20 | 20 | $this->structure = $structure; |
21 | | - $this->helper=new RecordHelper($this); |
22 | 21 | } |
23 | 22 | |
24 | 23 | public function getStructure() { |
— | — | @@ -45,6 +44,7 @@ |
46 | 45 | |
47 | 46 | public function setType($type) { |
48 | 47 | $this->type=$type; |
| 48 | + $this->helper=RecordHelperFactory::getRecordHelper($this); |
49 | 49 | } |
50 | 50 | |
51 | 51 | /**only setType if it wasn't set yet. |
Index: trunk/extensions/Wikidata/OmegaWiki/RecordHelper.php |
— | — | @@ -1,23 +1,227 @@ |
2 | 2 | <?php |
3 | 3 | |
4 | 4 | class RecordHelperFactory { |
5 | | - function __construct() { |
6 | | - # --- |
7 | | - } |
8 | 5 | |
9 | | - function getRecordHelper($record) { |
10 | | - $type=$record->type(); |
| 6 | + public static function getRecordHelper($record) { |
| 7 | + $type=$record->getType(); |
11 | 8 | if (empty($type)) |
12 | 9 | return null; |
| 10 | + echo "HELPING $type .... "; |
13 | 11 | switch($type) { |
| 12 | + case "definition": |
| 13 | + return new DefinitionHelper(); |
| 14 | + case "translated-text": |
| 15 | + return new TranslatedTextHelper(); |
| 16 | + case "object-attributes": |
| 17 | + return new ObjectAttributesHelper(); |
| 18 | + case "synonyms-translations": |
| 19 | + return new SynonymsTranslationsHelper(); |
| 20 | + break; |
14 | 21 | case "expression": |
15 | | - echo "express!"; |
| 22 | + return new ExpressionHelper(); |
16 | 23 | break; |
17 | | - case "synonyms-translations": |
18 | | - echo "sinner!"; |
| 24 | + case "relations": |
| 25 | + return new RelationsHelper(); |
19 | 26 | break; |
| 27 | + case "relation-type": |
| 28 | + return new RelationTypeHelper(); |
| 29 | + break; |
| 30 | + case "other-defined-meaning": |
| 31 | + return new OtherDefinedMeaningHelper(); |
| 32 | + break; |
| 33 | + case "reciprocal-relations": |
| 34 | + return new ReciprocalRelationsHelper(); |
| 35 | + break; |
| 36 | + case "collection-membership": |
| 37 | + return new CollectionMembershipHelper(); |
| 38 | + break; |
| 39 | + case "collection-meaning": |
| 40 | + return new CollectionMeaningHelper(); |
| 41 | + case "goto-source": |
| 42 | + return new GotoSourceHelper(); |
| 43 | + case "defined-meaning-attributes": |
| 44 | + return new DefinedMeaningAttributesHelper(); |
| 45 | + default : |
| 46 | + echo "IGIVEUP ($type) I Give Up! \n"; |
| 47 | + break; |
20 | 48 | } |
21 | 49 | |
22 | 50 | } |
23 | 51 | } |
| 52 | + |
| 53 | +abstract class Helper { |
| 54 | + public function __construct() { |
| 55 | + } |
| 56 | + |
| 57 | + public abstract function save(); |
| 58 | + |
| 59 | +} |
| 60 | + |
| 61 | +class DefinitionHelper extends Helper { |
| 62 | + public function __construct() { |
| 63 | + echo "DefinitionHelper\n"; |
| 64 | + Helper::__construct(); |
| 65 | + } |
| 66 | + |
| 67 | + public function save() { |
| 68 | + /*what to do here eh?*/ |
| 69 | + } |
| 70 | + |
| 71 | + |
| 72 | +} |
| 73 | + |
| 74 | +class TranslatedTextHelper extends Helper { |
| 75 | + public function __construct() { |
| 76 | + echo "TranslatedTextHelper\n"; |
| 77 | + Helper::__construct(); |
| 78 | + } |
| 79 | + |
| 80 | + public function save() { |
| 81 | + /*what to do here eh?*/ |
| 82 | + } |
| 83 | + |
| 84 | + |
| 85 | +} |
| 86 | + |
| 87 | +class ObjectAttributesHelper extends Helper { |
| 88 | + public function __construct() { |
| 89 | + echo "ObjectAttributesHelper\n"; |
| 90 | + Helper::__construct(); |
| 91 | + } |
| 92 | + |
| 93 | + public function save() { |
| 94 | + /*what to do here eh?*/ |
| 95 | + } |
| 96 | + |
| 97 | + |
| 98 | +} |
| 99 | + |
| 100 | +class SynonymsTranslationsHelper extends Helper { |
| 101 | + public function __construct() { |
| 102 | + echo "SynonymsTranslationsHelper\n"; |
| 103 | + Helper::__construct(); |
| 104 | + } |
| 105 | + |
| 106 | + public function save() { |
| 107 | + /*what to do here eh?*/ |
| 108 | + } |
| 109 | + |
| 110 | + |
| 111 | +} |
| 112 | + |
| 113 | +class ExpressionHelper extends Helper { |
| 114 | + public function __construct() { |
| 115 | + echo "ExpressionHelper\n"; |
| 116 | + Helper::__construct(); |
| 117 | + } |
| 118 | + |
| 119 | + public function save() { |
| 120 | + /*what to do here eh?*/ |
| 121 | + } |
| 122 | + |
| 123 | + |
| 124 | +} |
| 125 | + |
| 126 | + |
| 127 | +class RelationsHelper extends Helper { |
| 128 | + public function __construct() { |
| 129 | + echo "RelationsHelper\n"; |
| 130 | + Helper::__construct(); |
| 131 | + } |
| 132 | + |
| 133 | + public function save() { |
| 134 | + /*what to do here eh?*/ |
| 135 | + } |
| 136 | + |
| 137 | + |
| 138 | +} |
| 139 | + |
| 140 | +class RelationTypeHelper extends Helper { |
| 141 | + public function __construct() { |
| 142 | + echo "RelationTypeHelper\n"; |
| 143 | + Helper::__construct(); |
| 144 | + } |
| 145 | + |
| 146 | + public function save() { |
| 147 | + /*what to do here eh?*/ |
| 148 | + } |
| 149 | +} |
| 150 | + |
| 151 | +class OtherDefinedMeaningHelper extends Helper { |
| 152 | + public function __construct() { |
| 153 | + echo "OtherDefinedMeaningHelper\n"; |
| 154 | + Helper::__construct(); |
| 155 | + } |
| 156 | + |
| 157 | + public function save() { |
| 158 | + /*what to do here eh?*/ |
| 159 | + } |
| 160 | + |
| 161 | + |
| 162 | +} |
| 163 | + |
| 164 | +class ReciprocalRelationsHelper extends Helper { |
| 165 | + public function __construct() { |
| 166 | + echo "ReciprocalRelationsHelper\n"; |
| 167 | + Helper::__construct(); |
| 168 | + } |
| 169 | + |
| 170 | + public function save() { |
| 171 | + /*what to do here eh?*/ |
| 172 | + } |
| 173 | + |
| 174 | + |
| 175 | +} |
| 176 | + |
| 177 | +class CollectionMembershipHelper extends Helper { |
| 178 | + public function __construct() { |
| 179 | + echo "CollectionMembershipHelper\n"; |
| 180 | + Helper::__construct(); |
| 181 | + } |
| 182 | + |
| 183 | + public function save() { |
| 184 | + /*what to do here eh?*/ |
| 185 | + } |
| 186 | + |
| 187 | + |
| 188 | +} |
| 189 | + |
| 190 | +class CollectionMeaningHelper extends Helper { |
| 191 | + public function __construct() { |
| 192 | + echo "CollectionMeaningHelper\n"; |
| 193 | + Helper::__construct(); |
| 194 | + } |
| 195 | + |
| 196 | + public function save() { |
| 197 | + /*what to do here eh?*/ |
| 198 | + } |
| 199 | + |
| 200 | + |
| 201 | +} |
| 202 | + |
| 203 | +class GotoSourceHelper extends Helper { |
| 204 | + public function __construct() { |
| 205 | + echo "GotoSourceHelper\n"; |
| 206 | + Helper::__construct(); |
| 207 | + } |
| 208 | + |
| 209 | + public function save() { |
| 210 | + /*what to do here eh?*/ |
| 211 | + } |
| 212 | + |
| 213 | + |
| 214 | +} |
| 215 | + |
| 216 | +class DefinedMeaningAttributesHelper extends Helper { |
| 217 | + public function __construct() { |
| 218 | + echo "DefinedMeaningAttributesHelper\n"; |
| 219 | + Helper::__construct(); |
| 220 | + } |
| 221 | + |
| 222 | + public function save() { |
| 223 | + /*what to do here eh?*/ |
| 224 | + } |
| 225 | + |
| 226 | + |
| 227 | +} |
24 | 228 | ?> |