Index: trunk/extensions/Wikidata/OmegaWiki/Controller.php |
— | — | @@ -184,6 +184,9 @@ |
185 | 185 | } |
186 | 186 | |
187 | 187 | public function add( IdStack $idPath, $record ) { |
| 188 | + if ( ! $record->expression ) { |
| 189 | + return; |
| 190 | + } |
188 | 191 | $definedMeaningId = $idPath->getKeyStack()->peek( 0 )->definedMeaningId; |
189 | 192 | $expressionValue = $record->expression; |
190 | 193 | |
— | — | @@ -308,6 +311,11 @@ |
309 | 312 | } |
310 | 313 | } |
311 | 314 | |
| 315 | +/* |
| 316 | + * Controller to add a new expression directly |
| 317 | + * i.e. not by translating an existing DM, |
| 318 | + * but by adding a new word + language + definition |
| 319 | + */ |
312 | 320 | class ExpressionController extends DefaultUpdateController { |
313 | 321 | protected $spelling; |
314 | 322 | protected $filterLanguageId; |
— | — | @@ -319,6 +327,9 @@ |
320 | 328 | |
321 | 329 | public function add( IdStack $idPath, $record ) { |
322 | 330 | if ( $this->filterLanguageId == 0 ) { |
| 331 | + if ( ! $record->expression ) { |
| 332 | + return; |
| 333 | + } |
323 | 334 | $expressionLanguageId = $record->expression->language; |
324 | 335 | } else { |
325 | 336 | $expressionLanguageId = $this->filterLanguageId; |
— | — | @@ -433,6 +444,9 @@ |
434 | 445 | } |
435 | 446 | |
436 | 447 | public function add( IdStack $idPath, $record ) { |
| 448 | + if ( ! $record->link ) { |
| 449 | + return; |
| 450 | + } |
437 | 451 | $objectId = $this->objectIdFetcher->fetch( $idPath->getKeyStack() ); |
438 | 452 | $linkAttributeId = $this->determineAttributeId( $idPath, "URL", $record->linkAttribute ); |
439 | 453 | $linkValue = $record->link; |
Index: trunk/extensions/Wikidata/OmegaWiki/SpecialImportTSV.php |
— | — | @@ -225,12 +225,5 @@ |
226 | 226 | } |
227 | 227 | |
228 | 228 | } |
229 | | - |
230 | | - |
231 | | - /* HELPER METHODS START HERE */ |
232 | | - |
233 | | - function getLanguage( $columnName ) { |
234 | | - |
235 | | - } |
236 | | - |
| 229 | + |
237 | 230 | } |
Index: trunk/extensions/Wikidata/OmegaWiki/Record.php |
— | — | @@ -88,8 +88,11 @@ |
89 | 89 | */ |
90 | 90 | public function setAttributeValuesByOrder( $values ) { |
91 | 91 | $atts = $this->structure->getAttributes(); |
92 | | - for ( $i = 0; $i < count( $atts ); $i++ ) |
93 | | - $this->values[$atts[$i]->id] = $values[$i]; |
| 92 | + for ( $i = 0; $i < count( $atts ); $i++ ) { |
| 93 | + if ( array_key_exists ( $i, $values ) ) { |
| 94 | + $this->values[$atts[$i]->id] = $values[$i]; |
| 95 | + } |
| 96 | + } |
94 | 97 | } |
95 | 98 | |
96 | 99 | /* |