Index: trunk/extensions/Wikidata/OmegaWiki/SpecialSuggest.php |
— | — | @@ -103,35 +103,44 @@ |
104 | 104 | } |
105 | 105 | |
106 | 106 | if ( $search != '' ) { |
107 | | - if ( $query == 'transaction' ) |
| 107 | + if ( $query == 'transaction' ) { |
108 | 108 | $searchCondition = " AND $rowText LIKE " . $dbr->addQuotes( "%$search%" ); |
109 | | - else if ( $query == 'class' ) |
| 109 | + } |
| 110 | + elseif ( $query == 'class' ) { |
110 | 111 | $searchCondition = " AND $rowText LIKE " . $dbr->addQuotes( "$search%" ); |
111 | | - else if ( $query == "$wgDefinedMeaningAttributes" or // should be 'relation-type' in html, there is a bug I cannot find |
| 112 | + } |
| 113 | + elseif ( $query == "$wgDefinedMeaningAttributes" or // should be 'relation-type' in html, there is a bug I cannot find |
112 | 114 | $query == "$wgLinkAttribute" or |
113 | 115 | $query == "$wgOptionAttribute" or |
114 | 116 | $query == 'translated-text-attribute' or |
115 | 117 | $query == 'text-attribute' ) |
| 118 | + { |
116 | 119 | $searchCondition = " HAVING $rowText LIKE " . $dbr->addQuotes( "$search%" ); |
117 | | - else if ( $query == 'language' ) |
| 120 | + } |
| 121 | + elseif ( $query == 'language' ) { |
118 | 122 | $searchCondition = " HAVING $rowText LIKE " . $dbr->addQuotes( "%$search%" ); |
119 | | - else if ( $query == 'relation-type' ) // not sure in which case 'relation-type' happens... |
| 123 | + } |
| 124 | + elseif ( $query == 'relation-type' ) { // not sure in which case 'relation-type' happens... |
120 | 125 | $searchCondition = " WHERE $rowText LIKE " . $dbr->addQuotes( "$search%" ); |
121 | | - else |
| 126 | + } |
| 127 | + else { |
122 | 128 | $searchCondition = " AND $rowText LIKE " . $dbr->addQuotes( "$search%" ); |
| 129 | + } |
| 130 | + } else { |
| 131 | + $searchCondition = ""; |
123 | 132 | } |
124 | | - else |
125 | | - $searchCondition = ""; |
126 | 133 | |
127 | | - if ( $query == 'transaction' ) |
| 134 | + if ( $query == 'transaction' ) { |
128 | 135 | $orderBy = 'transaction_id DESC'; |
129 | | - else |
| 136 | + } else { |
130 | 137 | $orderBy = $rowText; |
| 138 | + } |
131 | 139 | |
132 | 140 | $sql .= $searchCondition . " ORDER BY $orderBy LIMIT "; |
133 | 141 | |
134 | | - if ( $offset > 0 ) |
| 142 | + if ( $offset > 0 ) { |
135 | 143 | $sql .= " $offset, "; |
| 144 | + } |
136 | 145 | |
137 | 146 | // print only 10 results |
138 | 147 | $sql .= "10"; |
— | — | @@ -184,8 +193,7 @@ |
185 | 194 | |
186 | 195 | $dbr->freeResult( $queryResult ); |
187 | 196 | $output = $editor->view( new IdStack( $prefix . 'table' ), $recordSet ); |
188 | | - // $output="<table><tr><td>HELLO ERIK!</td></tr></table>"; |
189 | | - // wfDebug($output); |
| 197 | + |
190 | 198 | echo $output; |
191 | 199 | } |
192 | 200 | |
Index: trunk/extensions/Wikidata/OmegaWiki/Controller.php |
— | — | @@ -111,12 +111,14 @@ |
112 | 112 | $languageId = $definitionRecord->language; |
113 | 113 | $text = $definitionRecord->text; |
114 | 114 | |
115 | | - if ( $languageId != 0 && $text != '' ) |
| 115 | + if ( $languageId != 0 && $text != '' ) { |
116 | 116 | addDefinedMeaningAlternativeDefinition( $definedMeaningId, $languageId, $text, $sourceId ); |
| 117 | + } |
117 | 118 | } |
118 | 119 | } |
119 | | - else if ( $alternativeDefinition != '' ) |
| 120 | + elseif ( $alternativeDefinition != '' ) { |
120 | 121 | addDefinedMeaningAlternativeDefinition( $definedMeaningId, $this->filterLanguageId, $alternativeDefinition, $sourceId ); |
| 122 | + } |
121 | 123 | } |
122 | 124 | |
123 | 125 | public function remove( $keyPath ) { |
— | — | @@ -286,12 +288,14 @@ |
287 | 289 | $text = $definitionRecord->text; |
288 | 290 | $languageId = $definitionRecord->language; |
289 | 291 | |
290 | | - if ( $languageId != 0 && $text != "" ) |
| 292 | + if ( $languageId != 0 && $text != "" ) { |
291 | 293 | createNewDefinedMeaning( $expressionId, $languageId, $text ); |
| 294 | + } |
292 | 295 | } |
293 | 296 | } |
294 | | - else if ( $translatedContent != "" ) |
| 297 | + elseif ( $translatedContent != "" ) { |
295 | 298 | createNewDefinedMeaning( $expressionId, $this->filterLanguageId, $translatedContent ); |
| 299 | + } |
296 | 300 | } |
297 | 301 | } |
298 | 302 | |
— | — | @@ -331,7 +335,7 @@ |
332 | 336 | } |
333 | 337 | } |
334 | 338 | } |
335 | | - else if ( $translatedContent != "" ) { |
| 339 | + elseif ( $translatedContent != "" ) { |
336 | 340 | $expression = findOrCreateExpression( $this->spelling, $expressionLanguageId ); |
337 | 341 | createNewDefinedMeaning( $expression->id, $this->filterLanguageId, $translatedContent ); |
338 | 342 | } |
— | — | @@ -463,12 +467,14 @@ |
464 | 468 | $languageId = $textValueRecord->language; |
465 | 469 | $text = $textValueRecord->text; |
466 | 470 | |
467 | | - if ( $languageId != 0 && $text != '' ) |
| 471 | + if ( $languageId != 0 && $text != '' ) { |
468 | 472 | addTranslatedTextAttributeValue( $objectId, $textAttributeId, $languageId, $text ); |
| 473 | + } |
469 | 474 | } |
470 | 475 | } |
471 | | - else if ( $textValue != '' ) |
| 476 | + elseif ( $textValue != '' ) { |
472 | 477 | addTranslatedTextAttributeValue( $objectId, $textAttributeId, $this->filterLanguageId, $textValue ); |
| 478 | + } |
473 | 479 | } |
474 | 480 | } |
475 | 481 | |
Index: trunk/extensions/Wikidata/OmegaWiki/SpecialTransaction.php |
— | — | @@ -1354,14 +1354,16 @@ |
1355 | 1355 | |
1356 | 1356 | $version = (int) $_POST[$idStack->getId()]; |
1357 | 1357 | |
1358 | | - if ( $version > 0 ) |
| 1358 | + if ( $version > 0 ) { |
1359 | 1359 | rollBackTranslatedContentToVersion( $translatedContentId, $languageId, $version ); |
| 1360 | + } |
1360 | 1361 | |
1361 | 1362 | $idStack->popAttribute(); |
1362 | 1363 | $idStack->popAttribute(); |
1363 | 1364 | } |
1364 | | - else if ( $rollBackAction == 'remove' ) |
| 1365 | + elseif ( $rollBackAction == 'remove' ) { |
1365 | 1366 | removeTranslatedText( $translatedContentId, $languageId ); |
| 1367 | + } |
1366 | 1368 | } |
1367 | 1369 | |
1368 | 1370 | function getTranslatedContentFromHistory( $translatedContentId, $languageId, $addTransactionId ) { |
— | — | @@ -1427,10 +1429,12 @@ |
1428 | 1430 | } |
1429 | 1431 | |
1430 | 1432 | function rollBackRelation( $rollBackAction, $relationId, $firstMeaningId, $relationTypeId, $secondMeaningId, $operation ) { |
1431 | | - if ( shouldRemove( $rollBackAction, $operation ) ) |
| 1433 | + if ( shouldRemove( $rollBackAction, $operation ) ) { |
1432 | 1434 | removeRelationWithId( $relationId ); |
1433 | | - else if ( shouldRestore( $rollBackAction, $operation ) ) |
| 1435 | + } |
| 1436 | + elseif ( shouldRestore( $rollBackAction, $operation ) ) { |
1434 | 1437 | addRelation( $firstMeaningId, $relationTypeId, $secondMeaningId ); |
| 1438 | + } |
1435 | 1439 | } |
1436 | 1440 | |
1437 | 1441 | function rollBackClassMemberships( $idStack, $classMemberships ) { |
— | — | @@ -1462,10 +1466,12 @@ |
1463 | 1467 | } |
1464 | 1468 | |
1465 | 1469 | function rollBackClassMembership( $rollBackAction, $classMembershipId, $classId, $classMemberId, $operation ) { |
1466 | | - if ( shouldRemove( $rollBackAction, $operation ) ) |
| 1470 | + if ( shouldRemove( $rollBackAction, $operation ) ) { |
1467 | 1471 | removeClassMembershipWithId( $classMembershipId ); |
1468 | | - else if ( shouldRestore( $rollBackAction, $operation ) ) |
| 1472 | + } |
| 1473 | + elseif ( shouldRestore( $rollBackAction, $operation ) ) { |
1469 | 1474 | addClassMembership( $classMemberId, $classId ); |
| 1475 | + } |
1470 | 1476 | } |
1471 | 1477 | |
1472 | 1478 | function rollBackClassAttributes( $idStack, $classAttributes ) { |
— | — | @@ -1499,10 +1505,12 @@ |
1500 | 1506 | } |
1501 | 1507 | |
1502 | 1508 | function rollBackClassAttribute( $rollBackAction, $classAttributeId, $classId, $levelId, $attributeId, $type, $operation ) { |
1503 | | - if ( shouldRemove( $rollBackAction, $operation ) ) |
| 1509 | + if ( shouldRemove( $rollBackAction, $operation ) ) { |
1504 | 1510 | removeClassAttributeWithId( $classAttributeId ); |
1505 | | - else if ( shouldRestore( $rollBackAction, $operation ) ) |
| 1511 | + } |
| 1512 | + elseif ( shouldRestore( $rollBackAction, $operation ) ) { |
1506 | 1513 | addClassAttribute( $classId, $levelId, $attributeId, $type ); |
| 1514 | + } |
1507 | 1515 | } |
1508 | 1516 | |
1509 | 1517 | function rollBackTranslatedTextProperties( $idStack, $translatedTextProperties ) { |
— | — | @@ -1535,10 +1543,12 @@ |
1536 | 1544 | } |
1537 | 1545 | |
1538 | 1546 | function rollBackTranslatedTextProperty( $rollBackAction, $valueId, $objectId, $attributeId, $translatedContentId, $operation ) { |
1539 | | - if ( shouldRemove( $rollBackAction, $operation ) ) |
| 1547 | + if ( shouldRemove( $rollBackAction, $operation ) ) { |
1540 | 1548 | removeTranslatedTextAttributeValue( $valueId ); |
1541 | | - else if ( shouldRestore( $rollBackAction, $operation ) ) |
| 1549 | + } |
| 1550 | + elseif ( shouldRestore( $rollBackAction, $operation ) ) { |
1542 | 1551 | createTranslatedTextAttributeValue( $valueId, $objectId, $attributeId, $translatedContentId ); |
| 1552 | + } |
1543 | 1553 | } |
1544 | 1554 | |
1545 | 1555 | function rollBackLinkAttributes( $idStack, $linkAttributes ) { |
— | — | @@ -1573,10 +1583,12 @@ |
1574 | 1584 | } |
1575 | 1585 | |
1576 | 1586 | function rollBackLinkAttribute( $rollBackAction, $valueId, $objectId, $attributeId, $url, $label, $operation ) { |
1577 | | - if ( shouldRemove( $rollBackAction, $operation ) ) |
| 1587 | + if ( shouldRemove( $rollBackAction, $operation ) ) { |
1578 | 1588 | removeLinkAttributeValue( $valueId ); |
1579 | | - else if ( shouldRestore( $rollBackAction, $operation ) ) |
| 1589 | + } |
| 1590 | + elseif ( shouldRestore( $rollBackAction, $operation ) ) { |
1580 | 1591 | createLinkAttributeValue( $valueId, $objectId, $attributeId, $url, $label ); |
| 1592 | + } |
1581 | 1593 | } |
1582 | 1594 | |
1583 | 1595 | function rollBackTextAttributes( $idStack, $textAttributes ) { |
— | — | @@ -1609,10 +1621,12 @@ |
1610 | 1622 | } |
1611 | 1623 | |
1612 | 1624 | function rollBackTextAttribute( $rollBackAction, $valueId, $objectId, $attributeId, $text, $operation ) { |
1613 | | - if ( shouldRemove( $rollBackAction, $operation ) ) |
| 1625 | + if ( shouldRemove( $rollBackAction, $operation ) ) { |
1614 | 1626 | removeTextAttributeValue( $valueId ); |
1615 | | - else if ( shouldRestore( $rollBackAction, $operation ) ) |
| 1627 | + } |
| 1628 | + elseif ( shouldRestore( $rollBackAction, $operation ) ) { |
1616 | 1629 | createTextAttributeValue( $valueId, $objectId, $attributeId, $text ); |
| 1630 | + } |
1617 | 1631 | } |
1618 | 1632 | |
1619 | 1633 | function rollBackSyntranses( $idStack, $syntranses ) { |
— | — | @@ -1645,10 +1659,12 @@ |
1646 | 1660 | } |
1647 | 1661 | |
1648 | 1662 | function rollBackSyntrans( $rollBackAction, $syntransId, $definedMeaningId, $expressionId, $identicalMeaning, $operation ) { |
1649 | | - if ( shouldRemove( $rollBackAction, $operation ) ) |
| 1663 | + if ( shouldRemove( $rollBackAction, $operation ) ) { |
1650 | 1664 | removeSynonymOrTranslationWithId( $syntransId ); |
1651 | | - else if ( shouldRestore( $rollBackAction, $operation ) ) |
| 1665 | + } |
| 1666 | + elseif ( shouldRestore( $rollBackAction, $operation ) ) { |
1652 | 1667 | createSynonymOrTranslation( $definedMeaningId, $expressionId, $identicalMeaning ); |
| 1668 | + } |
1653 | 1669 | } |
1654 | 1670 | |
1655 | 1671 | function rollBackAlternativeDefinitionTexts( $idStack, $alternativeDefinitionTexts ) { |
— | — | @@ -1710,10 +1726,12 @@ |
1711 | 1727 | } |
1712 | 1728 | |
1713 | 1729 | function rollBackAlternativeDefinition( $rollBackAction, $definedMeaningId, $translatedContentId, $sourceId, $operation ) { |
1714 | | - if ( shouldRemove( $rollBackAction, $operation ) ) |
| 1730 | + if ( shouldRemove( $rollBackAction, $operation ) ) { |
1715 | 1731 | removeDefinedMeaningAlternativeDefinition( $definedMeaningId, $translatedContentId ); |
1716 | | - else if ( shouldRestore( $rollBackAction, $operation ) ) |
| 1732 | + } |
| 1733 | + elseif ( shouldRestore( $rollBackAction, $operation ) ) { |
1717 | 1734 | createDefinedMeaningAlternativeDefinition( $definedMeaningId, $translatedContentId, $sourceId ); |
| 1735 | + } |
1718 | 1736 | } |
1719 | 1737 | |
1720 | 1738 | function rollBackCollectionMemberships( $idStack, $collectionMemberships ) { |
— | — | @@ -1746,10 +1764,12 @@ |
1747 | 1765 | } |
1748 | 1766 | |
1749 | 1767 | function rollBackCollectionMembership( $rollBackAction, $collectionId, $collectionMemberId, $sourceIdentifier, $operation ) { |
1750 | | - if ( shouldRemove( $rollBackAction, $operation ) ) |
| 1768 | + if ( shouldRemove( $rollBackAction, $operation ) ) { |
1751 | 1769 | removeDefinedMeaningFromCollection( $collectionMemberId, $collectionId ); |
1752 | | - else if ( shouldRestore( $rollBackAction, $operation ) ) |
| 1770 | + } |
| 1771 | + elseif ( shouldRestore( $rollBackAction, $operation ) ) { |
1753 | 1772 | addDefinedMeaningToCollection( $collectionMemberId, $collectionId, $sourceIdentifier ); |
| 1773 | + } |
1754 | 1774 | } |
1755 | 1775 | |
1756 | 1776 | |
Index: trunk/extensions/Wikidata/OmegaWiki/WikiDataAPI.php |
— | — | @@ -344,7 +344,9 @@ |
345 | 345 | $dbr = wfGetDB( DB_SLAVE ); |
346 | 346 | if ( $relationTypeId == null ) { |
347 | 347 | if ( $lhs == null ) { |
348 | | - if ( $rhs == null ) return $result; |
| 348 | + if ( $rhs == null ) { |
| 349 | + return $result; |
| 350 | + } |
349 | 351 | $query = "SELECT rel.relationtype_mid FROM {$dc}_meaning_relations rel " . |
350 | 352 | "INNER JOIN {$dc}_defined_meaning dm ON rel.relationtype_mid=dm.defined_meaning_id " . |
351 | 353 | "WHERE rel.meaning2_mid={$rhs} " . |
— | — | @@ -352,7 +354,7 @@ |
353 | 355 | "AND" . getLatestTransactionRestriction( 'dm' ) . |
354 | 356 | "GROUP BY rel.relationtype_mid"; |
355 | 357 | } |
356 | | - else if ( $rhs == null ) { |
| 358 | + elseif ( $rhs == null ) { |
357 | 359 | $query = "SELECT rel.relationtype_mid FROM {$dc}_meaning_relations rel " . |
358 | 360 | "INNER JOIN {$dc}_defined_meaning dm ON rel.relationtype_mid=dm.defined_meaning_id " . |
359 | 361 | "WHERE rel.meaning1_mid={$lhs} " . |
— | — | @@ -368,8 +370,10 @@ |
369 | 371 | "AND" . getLatestTransactionRestriction( 'dm' ); |
370 | 372 | } |
371 | 373 | } |
372 | | - else if ( $lhs == null ) { |
373 | | - if ( $rhs == null ) return $result; |
| 374 | + elseif ( $lhs == null ) { |
| 375 | + if ( $rhs == null ) { |
| 376 | + return $result; |
| 377 | + } |
374 | 378 | $query = "SELECT rel.meaning1_mid FROM {$dc}_meaning_relations rel " . |
375 | 379 | "INNER JOIN {$dc}_defined_meaning dm ON rel.meaning1_mid=dm.defined_meaning_id " . |
376 | 380 | "WHERE rel.meaning2_mid={$rhs} AND rel.relationtype_mid={$relationTypeId} " . |
— | — | @@ -395,8 +399,9 @@ |
396 | 400 | } |
397 | 401 | |
398 | 402 | function addClassAttribute( $classMeaningId, $levelMeaningId, $attributeMeaningId, $attributeType ) { |
399 | | - if ( !classAttributeExists( $classMeaningId, $levelMeaningId, $attributeMeaningId, $attributeType ) ) |
| 403 | + if ( !classAttributeExists( $classMeaningId, $levelMeaningId, $attributeMeaningId, $attributeType ) ) { |
400 | 404 | createClassAttribute( $classMeaningId, $levelMeaningId, $attributeMeaningId, $attributeType ); |
| 405 | + } |
401 | 406 | } |
402 | 407 | |
403 | 408 | function classAttributeExists( $classMeaningId, $levelMeaningId, $attributeMeaningId, $attributeType ) { |
— | — | @@ -414,8 +419,9 @@ |
415 | 420 | |
416 | 421 | $dc = wdGetDataSetContext(); |
417 | 422 | |
418 | | - if ( $objectId == 0 ) |
| 423 | + if ( $objectId == 0 ) { |
419 | 424 | $objectId = newObjectId( "{$dc}_class_attributes" ); |
| 425 | + } |
420 | 426 | |
421 | 427 | $dbw = wfGetDB( DB_MASTER ); |
422 | 428 | $sql = "INSERT INTO {$dc}_class_attributes(object_id, class_mid, level_mid, attribute_mid, attribute_type, add_transaction_id) " . |
— | — | @@ -429,10 +435,11 @@ |
430 | 436 | $queryResult = $dbr->query( "SELECT object_id FROM {$dc}_class_attributes " . |
431 | 437 | "WHERE class_mid=$classMeaningId AND level_mid =$levelMeaningId AND attribute_mid=$attributeMeaningId AND attribute_type = " . $dbr->addQuotes( $attributeType ) ); |
432 | 438 | |
433 | | - if ( $classAttribute = $dbr->fetchObject( $queryResult ) ) |
| 439 | + if ( $classAttribute = $dbr->fetchObject( $queryResult ) ) { |
434 | 440 | return $classAttribute->object_id; |
435 | | - else |
| 441 | + } else { |
436 | 442 | return 0; |
| 443 | + } |
437 | 444 | } |
438 | 445 | |
439 | 446 | function removeClassAttributeWithId( $classAttributeId ) { |
— | — | @@ -449,18 +456,20 @@ |
450 | 457 | $queryResult = $dbr->query( "SELECT class_membership_id FROM {$dc}_class_membership " . |
451 | 458 | "WHERE class_mid=$classId AND class_member_mid=$classMemberId LIMIT 1" ); |
452 | 459 | |
453 | | - if ( $classMembership = $dbr->fetchObject( $queryResult ) ) |
| 460 | + if ( $classMembership = $dbr->fetchObject( $queryResult ) ) { |
454 | 461 | return $classMembership->class_membership_id; |
455 | | - else |
| 462 | + } else { |
456 | 463 | return 0; |
| 464 | + } |
457 | 465 | } |
458 | 466 | |
459 | 467 | function createClassMembership( $classMemberId, $classId ) { |
460 | 468 | $dc = wdGetDataSetContext(); |
461 | 469 | $classMembershipId = getClassMembershipId( $classMemberId, $classId ); |
462 | 470 | |
463 | | - if ( $classMembershipId == 0 ) |
| 471 | + if ( $classMembershipId == 0 ) { |
464 | 472 | $classMembershipId = newObjectId( "{$dc}_class_membership" ); |
| 473 | + } |
465 | 474 | |
466 | 475 | $dbw = wfGetDB( DB_MASTER ); |
467 | 476 | $sql = "INSERT INTO {$dc}_class_membership(class_membership_id, class_mid, class_member_mid, add_transaction_id) " . |
— | — | @@ -479,8 +488,9 @@ |
480 | 489 | } |
481 | 490 | |
482 | 491 | function addClassMembership( $classMemberId, $classId ) { |
483 | | - if ( !classMembershipExists( $classMemberId, $classId ) ) |
| 492 | + if ( !classMembershipExists( $classMemberId, $classId ) ) { |
484 | 493 | createClassMembership( $classMemberId, $classId ); |
| 494 | + } |
485 | 495 | } |
486 | 496 | |
487 | 497 | function removeClassMembership( $classMemberId, $classId ) { |
— | — | @@ -526,24 +536,27 @@ |
527 | 537 | " FROM {$dc}_syntrans" . |
528 | 538 | " WHERE syntrans_sid=$syntransId AND remove_transaction_id IS NULL LIMIT 1" ); |
529 | 539 | |
530 | | - if ( $syntrans = $dbr->fetchObject( $queryResult ) ) |
| 540 | + if ( $syntrans = $dbr->fetchObject( $queryResult ) ) { |
531 | 541 | updateSynonymOrTranslation( $syntrans->defined_meaning_id, $syntrans->expression_id, $identicalMeaning ); |
| 542 | + } |
532 | 543 | } |
533 | 544 | |
534 | 545 | function updateDefinedMeaningDefinition( $definedMeaningId, $languageId, $text ) { |
535 | 546 | $definitionId = getDefinedMeaningDefinitionId( $definedMeaningId ); |
536 | 547 | |
537 | | - if ( $definitionId != 0 ) |
| 548 | + if ( $definitionId != 0 ) { |
538 | 549 | updateTranslatedText( $definitionId, $languageId, $text ); |
| 550 | + } |
539 | 551 | } |
540 | 552 | |
541 | 553 | function updateOrAddDefinedMeaningDefinition( $definedMeaningId, $languageId, $text ) { |
542 | 554 | $definitionId = getDefinedMeaningDefinitionId( $definedMeaningId ); |
543 | 555 | |
544 | | - if ( $definitionId != 0 ) |
| 556 | + if ( $definitionId != 0 ) { |
545 | 557 | updateTranslatedText( $definitionId, $languageId, $text ); |
546 | | - else |
| 558 | + } else { |
547 | 559 | addDefinedMeaningDefiningDefinition( $definedMeaningId, $languageId, $text ); |
| 560 | + } |
548 | 561 | } |
549 | 562 | |
550 | 563 | function updateTranslatedText( $setId, $languageId, $text ) { |
— | — | @@ -574,10 +587,12 @@ |
575 | 588 | function translatedTextExists( $textId, $languageId ) { |
576 | 589 | $dc = wdGetDataSetContext(); |
577 | 590 | |
578 | | - if ( is_null( $textId ) ) |
| 591 | + if ( is_null( $textId ) ) { |
579 | 592 | throw new Exception( "textId is null" ); |
580 | | - if ( is_null( $languageId ) ) |
| 593 | + } |
| 594 | + if ( is_null( $languageId ) ) { |
581 | 595 | throw new Exception( "languageId is null" ); |
| 596 | + } |
582 | 597 | |
583 | 598 | $dbr = wfGetDB( DB_SLAVE ); |
584 | 599 | $queryResult = $dbr->query( |
— | — | @@ -631,10 +646,11 @@ |
632 | 647 | function addDefinedMeaningDefinition( $definedMeaningId, $languageId, $text ) { |
633 | 648 | $definitionId = getDefinedMeaningDefinitionId( $definedMeaningId ); |
634 | 649 | |
635 | | - if ( $definitionId == 0 ) |
| 650 | + if ( $definitionId == 0 ) { |
636 | 651 | addDefinedMeaningDefiningDefinition( $definedMeaningId, $languageId, $text ); |
637 | | - else |
| 652 | + } else { |
638 | 653 | addTranslatedTextIfNotPresent( $definitionId, $languageId, $text ); |
| 654 | + } |
639 | 655 | } |
640 | 656 | |
641 | 657 | function createDefinedMeaningAlternativeDefinition( $definedMeaningId, $translatedContentId, $sourceMeaningId ) { |
— | — | @@ -704,8 +720,9 @@ |
705 | 721 | } |
706 | 722 | |
707 | 723 | function addDefinedMeaningToCollectionIfNotPresent( $definedMeaningId, $collectionId, $internalId ) { |
708 | | - if ( !definedMeaningInCollection( $definedMeaningId, $collectionId ) ) |
| 724 | + if ( !definedMeaningInCollection( $definedMeaningId, $collectionId ) ) { |
709 | 725 | addDefinedMeaningToCollection( $definedMeaningId, $collectionId, $internalId ); |
| 726 | + } |
710 | 727 | } |
711 | 728 | |
712 | 729 | function getDefinedMeaningFromCollection( $collectionId, $internalMemberId ) { |
— | — | @@ -714,10 +731,11 @@ |
715 | 732 | $query = "SELECT member_mid FROM {$dc}_collection_contents WHERE collection_id=$collectionId AND internal_member_id=" . $dbr->addQuotes( $internalMemberId ) . " AND " . getLatestTransactionRestriction( "{$dc}_collection_contents" ) . " LIMIT 1" ; |
716 | 733 | $queryResult = $dbr->query( $query ); |
717 | 734 | |
718 | | - if ( $definedMeaningObject = $dbr->fetchObject( $queryResult ) ) |
| 735 | + if ( $definedMeaningObject = $dbr->fetchObject( $queryResult ) ) { |
719 | 736 | return $definedMeaningObject->member_mid; |
720 | | - else |
| 737 | + } else { |
721 | 738 | return null; |
| 739 | + } |
722 | 740 | } |
723 | 741 | |
724 | 742 | function removeDefinedMeaningFromCollection( $definedMeaningId, $collectionId ) { |
— | — | @@ -938,8 +956,9 @@ |
939 | 957 | } |
940 | 958 | |
941 | 959 | function addOptionAttributeValue( $objectId, $optionId ) { |
942 | | - if ( !optionAttributeValueExists( $objectId, $optionId ) ) |
| 960 | + if ( !optionAttributeValueExists( $objectId, $optionId ) ) { |
943 | 961 | createOptionAttributeValue( $objectId, $optionId ); |
| 962 | + } |
944 | 963 | } |
945 | 964 | |
946 | 965 | function createOptionAttributeValue( $objectId, $optionId ) { |
— | — | @@ -977,8 +996,9 @@ |
978 | 997 | } |
979 | 998 | |
980 | 999 | function addOptionAttributeOption( $attributeId, $optionMeaningId, $languageId ) { |
981 | | - if ( !optionAttributeOptionExists( $attributeId, $optionMeaningId, $languageId ) ) |
| 1000 | + if ( !optionAttributeOptionExists( $attributeId, $optionMeaningId, $languageId ) ) { |
982 | 1001 | createOptionAttributeOption( $attributeId, $optionMeaningId, $languageId ); |
| 1002 | + } |
983 | 1003 | } |
984 | 1004 | |
985 | 1005 | function createOptionAttributeOption( $attributeId, $optionMeaningId, $languageId ) { |
— | — | @@ -1047,10 +1067,11 @@ |
1048 | 1068 | " AND dm.meaning_text_tcid=tc.translated_content_id AND tc.language_id=$languageId " . |
1049 | 1069 | " AND t.text_id=tc.text_id LIMIT 1" ); |
1050 | 1070 | |
1051 | | - if ( $definition = $dbr->fetchObject( $queryResult ) ) |
| 1071 | + if ( $definition = $dbr->fetchObject( $queryResult ) ) { |
1052 | 1072 | return $definition->text_text; |
1053 | | - else |
| 1073 | + } else { |
1054 | 1074 | return ""; |
| 1075 | + } |
1055 | 1076 | } |
1056 | 1077 | |
1057 | 1078 | /** |
— | — | @@ -1068,10 +1089,11 @@ |
1069 | 1090 | " AND dm.meaning_text_tcid=tc.translated_content_id " . |
1070 | 1091 | " AND t.text_id=tc.text_id LIMIT 1" ); |
1071 | 1092 | |
1072 | | - if ( $definition = $dbr->fetchObject( $queryResult ) ) |
| 1093 | + if ( $definition = $dbr->fetchObject( $queryResult ) ) { |
1073 | 1094 | return $definition->text_text; |
1074 | | - else |
| 1095 | + } else { |
1075 | 1096 | return ""; |
| 1097 | + } |
1076 | 1098 | } |
1077 | 1099 | |
1078 | 1100 | /** |
— | — | @@ -1083,16 +1105,17 @@ |
1084 | 1106 | global $wgLang; |
1085 | 1107 | $userLanguageId = getLanguageIdForCode( $wgLang->getCode() ) ; |
1086 | 1108 | |
1087 | | - if ( $userLanguageId > 0 ) |
| 1109 | + if ( $userLanguageId > 0 ) { |
1088 | 1110 | $result = getDefinedMeaningDefinitionForLanguage( $definedMeaningId, $userLanguageId ); |
1089 | | - else |
| 1111 | + } else { |
1090 | 1112 | $result = ""; |
1091 | | - |
| 1113 | + } |
1092 | 1114 | if ( $result == "" ) { |
1093 | 1115 | $result = getDefinedMeaningDefinitionForLanguage( $definedMeaningId, 85 ); |
1094 | 1116 | |
1095 | | - if ( $result == "" ) |
| 1117 | + if ( $result == "" ) { |
1096 | 1118 | $result = getDefinedMeaningDefinitionForAnyLanguage( $definedMeaningId ); |
| 1119 | + } |
1097 | 1120 | } |
1098 | 1121 | return $result; |
1099 | 1122 | } |
— | — | @@ -1118,7 +1141,9 @@ |
1119 | 1142 | |
1120 | 1143 | $res = $dbr->query( $actual_query ); |
1121 | 1144 | $row = $dbr->fetchObject( $res ); |
1122 | | - if ( isset( $row->spelling ) ) return $row->spelling; |
| 1145 | + if ( isset( $row->spelling ) ) { |
| 1146 | + return $row->spelling; |
| 1147 | + } |
1123 | 1148 | } |
1124 | 1149 | |
1125 | 1150 | $fallbackLanguageId = $dbr->addQuotes( $fallbackLanguageId ); |
— | — | @@ -1126,13 +1151,17 @@ |
1127 | 1152 | |
1128 | 1153 | $res = $dbr->query( $fallback_query ); |
1129 | 1154 | $row = $dbr->fetchObject( $res ); |
1130 | | - if ( isset( $row->spelling ) ) return $row->spelling; |
| 1155 | + if ( isset( $row->spelling ) ) { |
| 1156 | + return $row->spelling; |
| 1157 | + } |
1131 | 1158 | |
1132 | 1159 | $final_fallback = "select spelling from {$dc}_syntrans,{$dc}_expression where {$dc}_syntrans.defined_meaning_id=$definedMeaningId and {$dc}_expression.expression_id={$dc}_syntrans.expression_id and {$dc}_expression.remove_transaction_id is NULL LIMIT 1"; |
1133 | 1160 | |
1134 | 1161 | $res = $dbr->query( $final_fallback ); |
1135 | 1162 | $row = $dbr->fetchObject( $res ); |
1136 | | - if ( isset( $row->spelling ) ) return $row->spelling; |
| 1163 | + if ( isset( $row->spelling ) ) { |
| 1164 | + return $row->spelling; |
| 1165 | + } |
1137 | 1166 | return null; |
1138 | 1167 | |
1139 | 1168 | } |
— | — | @@ -1168,10 +1197,11 @@ |
1169 | 1198 | "(SELECT expression_id FROM {$dc}_expression WHERE spelling LIKE " . $dbr->addQuotes( $name ) . " limit 1) limit 1)"; |
1170 | 1199 | $queryResult = $dbr->query( $query ); |
1171 | 1200 | |
1172 | | - if ( $collectionObject = $dbr->fetchObject( $queryResult ) ) |
| 1201 | + if ( $collectionObject = $dbr->fetchObject( $queryResult ) ) { |
1173 | 1202 | return $collectionObject->collection_id; |
1174 | | - else |
| 1203 | + } else { |
1175 | 1204 | return null; |
| 1205 | + } |
1176 | 1206 | } |
1177 | 1207 | |
1178 | 1208 | function getCollectionContents( $collectionId ) { |
— | — | @@ -1189,8 +1219,9 @@ |
1190 | 1220 | |
1191 | 1221 | $collectionContents = array(); |
1192 | 1222 | |
1193 | | - while ( $collectionEntry = $dbr->fetchObject( $queryResult ) ) |
| 1223 | + while ( $collectionEntry = $dbr->fetchObject( $queryResult ) ) { |
1194 | 1224 | $collectionContents[$collectionEntry->internal_member_id] = $collectionEntry->member_mid; |
| 1225 | + } |
1195 | 1226 | |
1196 | 1227 | return $collectionContents; |
1197 | 1228 | } |
— | — | @@ -1219,37 +1250,39 @@ |
1220 | 1251 | } |
1221 | 1252 | |
1222 | 1253 | function getCollectionMemberId( $collectionId, $sourceIdentifier ) { |
1223 | | - $dc = wdGetDataSetContext(); |
1224 | | - $dbr = & wfGetDB( DB_SLAVE ); |
1225 | | - $queryResult = $dbr->query( |
| 1254 | + $dc = wdGetDataSetContext(); |
| 1255 | + $dbr = & wfGetDB( DB_SLAVE ); |
| 1256 | + $queryResult = $dbr->query( |
1226 | 1257 | "SELECT member_mid" . |
1227 | 1258 | " FROM {$dc}_collection_contents " . |
1228 | | - " WHERE collection_id=$collectionId" . |
1229 | | - " AND internal_member_id=" . $dbr->addQuotes( $sourceIdentifier ) . |
1230 | | - " AND " . getLatestTransactionRestriction( "{$dc}_collection_contents" ) . " LIMIT 1" |
1231 | | - ); |
| 1259 | + " WHERE collection_id=$collectionId" . |
| 1260 | + " AND internal_member_id=" . $dbr->addQuotes( $sourceIdentifier ) . |
| 1261 | + " AND " . getLatestTransactionRestriction( "{$dc}_collection_contents" ) . " LIMIT 1" |
| 1262 | + ); |
1232 | 1263 | |
1233 | | - if ( $collectionEntry = $dbr->fetchObject( $queryResult ) ) |
1234 | | - return $collectionEntry->member_mid; |
1235 | | - else |
1236 | | - return 0; |
| 1264 | + if ( $collectionEntry = $dbr->fetchObject( $queryResult ) ) { |
| 1265 | + return $collectionEntry->member_mid; |
| 1266 | + } else { |
| 1267 | + return 0; |
| 1268 | + } |
1237 | 1269 | } |
1238 | 1270 | |
1239 | 1271 | function getAnyDefinedMeaningWithSourceIdentifier( $sourceIdentifier ) { |
1240 | | - $dc = wdGetDataSetContext(); |
1241 | | - $dbr = & wfGetDB( DB_SLAVE ); |
1242 | | - $queryResult = $dbr->query( |
| 1272 | + $dc = wdGetDataSetContext(); |
| 1273 | + $dbr = & wfGetDB( DB_SLAVE ); |
| 1274 | + $queryResult = $dbr->query( |
1243 | 1275 | "SELECT member_mid" . |
1244 | 1276 | " FROM {$dc}_collection_contents " . |
1245 | | - " WHERE internal_member_id=" . $dbr->addQuotes( $sourceIdentifier ) . |
1246 | | - " AND " . getLatestTransactionRestriction( "{$dc}_collection_contents" ) . |
1247 | | - " LIMIT 1" |
1248 | | - ); |
| 1277 | + " WHERE internal_member_id=" . $dbr->addQuotes( $sourceIdentifier ) . |
| 1278 | + " AND " . getLatestTransactionRestriction( "{$dc}_collection_contents" ) . |
| 1279 | + " LIMIT 1" |
| 1280 | + ); |
1249 | 1281 | |
1250 | | - if ( $collectionEntry = $dbr->fetchObject( $queryResult ) ) |
1251 | | - return $collectionEntry->member_mid; |
1252 | | - else |
1253 | | - return 0; |
| 1282 | + if ( $collectionEntry = $dbr->fetchObject( $queryResult ) ) { |
| 1283 | + return $collectionEntry->member_mid; |
| 1284 | + } else { |
| 1285 | + return 0; |
| 1286 | + } |
1254 | 1287 | } |
1255 | 1288 | |
1256 | 1289 | function getExpressionMeaningIds( $spelling, $dc = null ) { |
— | — | @@ -1550,10 +1583,11 @@ |
1551 | 1584 | " LIMIT 1" |
1552 | 1585 | ); |
1553 | 1586 | |
1554 | | - if ( $expression = $dbr->fetchObject( $queryResult ) ) |
| 1587 | + if ( $expression = $dbr->fetchObject( $queryResult ) ) { |
1555 | 1588 | return $expression->spelling; |
1556 | | - else |
| 1589 | + } else { |
1557 | 1590 | return ""; |
| 1591 | + } |
1558 | 1592 | } |
1559 | 1593 | |
1560 | 1594 | /** |
— | — | @@ -1573,10 +1607,11 @@ |
1574 | 1608 | " AND " . getLatestTransactionRestriction( "{$dc}_expression" ) . |
1575 | 1609 | " LIMIT 1" ); |
1576 | 1610 | |
1577 | | - if ( $expression = $dbr->fetchObject( $queryResult ) ) |
| 1611 | + if ( $expression = $dbr->fetchObject( $queryResult ) ) { |
1578 | 1612 | return $expression->spelling; |
1579 | | - else |
| 1613 | + } else { |
1580 | 1614 | return ""; |
| 1615 | + } |
1581 | 1616 | } |
1582 | 1617 | |
1583 | 1618 | /** |
— | — | @@ -1593,11 +1628,11 @@ |
1594 | 1629 | |
1595 | 1630 | list( $definingExpressionId, $definingExpression, $definingExpressionLanguage ) = definingExpressionRow( $definedMeaningId ); |
1596 | 1631 | |
1597 | | - if ( $userLanguageId > 0 ) |
| 1632 | + if ( $userLanguageId > 0 ) { |
1598 | 1633 | $result = definedMeaningExpressionForLanguage( $definedMeaningId, $userLanguageId ); |
1599 | | - else |
| 1634 | + } else { |
1600 | 1635 | $result = ""; |
1601 | | - |
| 1636 | + } |
1602 | 1637 | if ( $result == "" ) { |
1603 | 1638 | // if no expression exists for the specified language : look for an expression in English |
1604 | 1639 | $result = definedMeaningExpressionForLanguage( $definedMeaningId, 85 ); |
— | — | @@ -1605,8 +1640,9 @@ |
1606 | 1641 | if ( $result == "" ) { |
1607 | 1642 | $result = definedMeaningExpressionForAnyLanguage( $definedMeaningId ); |
1608 | 1643 | |
1609 | | - if ( $result == "" ) |
| 1644 | + if ( $result == "" ) { |
1610 | 1645 | $result = $definingExpression; |
| 1646 | + } |
1611 | 1647 | } |
1612 | 1648 | } |
1613 | 1649 | |
— | — | @@ -1699,10 +1735,11 @@ |
1700 | 1736 | if ( in_array( $row['language_id'], $languages ) ) { |
1701 | 1737 | // $key becomes something like trans_23 |
1702 | 1738 | $key = 'trans_' . $row['language_id']; |
1703 | | - if ( !isset( $data[$key] ) ) |
| 1739 | + if ( !isset( $data[$key] ) ) { |
1704 | 1740 | $data[$key] = $row['spelling']; |
1705 | | - else |
| 1741 | + } else { |
1706 | 1742 | $data[$key] = $data[$key] . '|' . $row['spelling']; |
| 1743 | + } |
1707 | 1744 | } |
1708 | 1745 | } |
1709 | 1746 | $dbr->freeResult( $translations ); |
— | — | @@ -1764,26 +1801,29 @@ |
1765 | 1802 | $this->classAttributes[] = $classAttribute; |
1766 | 1803 | } |
1767 | 1804 | } |
1768 | | - |
| 1805 | + |
1769 | 1806 | public function filterClassAttributesOnLevelAndType( $levelName, $type ) { |
1770 | 1807 | $result = array(); |
1771 | 1808 | |
1772 | | - foreach ( $this->classAttributes as $classAttribute ) |
1773 | | - if ( $classAttribute->levelName == $levelName && $classAttribute->type == $type ) |
| 1809 | + foreach ( $this->classAttributes as $classAttribute ) { |
| 1810 | + if ( $classAttribute->levelName == $levelName && $classAttribute->type == $type ) { |
1774 | 1811 | $result[] = $classAttribute->attributeId; |
| 1812 | + } |
| 1813 | + } |
1775 | 1814 | |
1776 | 1815 | return $result; |
1777 | 1816 | } |
1778 | | - |
| 1817 | + |
1779 | 1818 | public function filterClassAttributesOnLevel( $levelName ) { |
1780 | 1819 | $result = array(); |
1781 | 1820 | |
1782 | | - foreach ( $this->classAttributes as $classAttribute ) |
1783 | | - if ( $classAttribute->levelName == $levelName ) |
| 1821 | + foreach ( $this->classAttributes as $classAttribute ) { |
| 1822 | + if ( $classAttribute->levelName == $levelName ) { |
1784 | 1823 | $result[] = $classAttribute->attributeId; |
| 1824 | + } |
| 1825 | + } |
1785 | 1826 | |
1786 | 1827 | return $result; |
1787 | 1828 | } |
1788 | | - |
1789 | 1829 | } |
1790 | 1830 | |
Index: trunk/extensions/Wikidata/OmegaWiki/SpecialOWStatistics.php |
— | — | @@ -26,16 +26,17 @@ |
27 | 27 | |
28 | 28 | $wgOut->addHTML( $headerText ) ; |
29 | 29 | |
30 | | - if ( $showstat == 'dm' ) |
| 30 | + if ( $showstat == 'dm' ) { |
31 | 31 | $wgOut->addHTML( $this->getDefinedMeaningPerLanguage () ); |
32 | | - else if ( $showstat == 'def' ) |
| 32 | + } elseif ( $showstat == 'def' ) { |
33 | 33 | $wgOut->addHTML( $this->getDefinitionPerLanguage () ); |
34 | | - else if ( $showstat == 'syntrans' ) |
| 34 | + } elseif ( $showstat == 'syntrans' ) { |
35 | 35 | $wgOut->addHTML( $this->getSyntransPerLanguage () ); |
36 | | - else if ( $showstat == 'exp' ) |
| 36 | + } elseif ( $showstat == 'exp' ) { |
37 | 37 | $wgOut->addHTML ( $this->getExpressionPerLanguage () ) ; |
38 | | - else if ( $showstat == 'annot' ) |
| 38 | + } elseif ( $showstat == 'annot' ) { |
39 | 39 | $wgOut->addHTML ( $this->getAnnotationStats () ) ; |
| 40 | + } |
40 | 41 | } |
41 | 42 | |
42 | 43 | function linkHeader ( $text, $val , $showstat ) { |
Index: trunk/extensions/Wikidata/OmegaWiki/OmegaWikiEditors.php |
— | — | @@ -124,14 +124,16 @@ |
125 | 125 | $attribute->type->getAttributes(), |
126 | 126 | $this->filterStructuresOnAttribute( $structures, $attribute ) |
127 | 127 | ); |
128 | | - |
129 | | - if ( count( $filteredAttributes ) > 0 ) |
| 128 | + |
| 129 | + if ( count( $filteredAttributes ) > 0 ) { |
130 | 130 | $result[] = new Attribute( $attribute->id, $attribute->name, new Structure( $filteredAttributes ) ); |
| 131 | + } |
131 | 132 | } |
132 | | - else if ( $this->attributeInStructures( $attribute, $structures ) ) |
| 133 | + elseif ( $this->attributeInStructures( $attribute, $structures ) ) { |
133 | 134 | $result[] = $attribute; |
| 135 | + } |
134 | 136 | } |
135 | | - |
| 137 | + |
136 | 138 | return $result; |
137 | 139 | } |
138 | 140 | |
— | — | @@ -141,8 +143,9 @@ |
142 | 144 | foreach ( $this->getEditors() as $editor ) { |
143 | 145 | $visibleStructure = $editor->getTableStructureForView( $idPath, $value->getAttributeValue( $editor->getAttribute() ) ); |
144 | 146 | |
145 | | - if ( count( $visibleStructure->getAttributes() ) > 0 ) |
| 147 | + if ( count( $visibleStructure->getAttributes() ) > 0 ) { |
146 | 148 | $visibleStructures[] = $visibleStructure; |
| 149 | + } |
147 | 150 | } |
148 | 151 | |
149 | 152 | return $this->filterAttributesByStructures( |
— | — | @@ -159,18 +162,20 @@ |
160 | 163 | $leadingAttributes = array(); |
161 | 164 | $childEditors = $editor->getEditors(); |
162 | 165 | |
163 | | - for ( $i = $showPropertyColumn ? 0 : 1; $i < 2; $i++ ) |
| 166 | + for ( $i = $showPropertyColumn ? 0 : 1; $i < 2; $i++ ) { |
164 | 167 | $leadingAttributes[] = $childEditors[$i]->getAttribute(); |
165 | | - |
| 168 | + } |
| 169 | + |
166 | 170 | return new Structure( array_merge( $leadingAttributes, $suffixAttributes ) ); |
167 | 171 | } |
168 | 172 | |
169 | 173 | public function view( IdStack $idPath, $value ) { |
170 | 174 | $visibleAttributes = array(); |
171 | 175 | |
172 | | - if ( $this->showPropertyColumn ) |
| 176 | + if ( $this->showPropertyColumn ) { |
173 | 177 | $visibleAttributes[] = $this->propertyAttribute; |
174 | | - |
| 178 | + } |
| 179 | + |
175 | 180 | $visibleAttributes[] = $this->valueAttribute; |
176 | 181 | |
177 | 182 | $idPath->pushAnnotationAttribute( $this->getAttribute() ); |
— | — | @@ -657,9 +662,9 @@ |
658 | 663 | $editor = new RecordSetTableEditor( $o->linkAttributeValues, new SimplePermissionController( true ), $showEditFieldChecker, new AllowAddController( true ), true, false, $controller ); |
659 | 664 | $editor->addEditor( new LinkAttributeEditor( $o->linkAttribute, new SimplePermissionController( false ), true, $attributeIDFilter, $levelDefinedMeaningName ) ); |
660 | 665 | |
661 | | - if ( $viewInformation->viewOrEdit == "view" ) |
| 666 | + if ( $viewInformation->viewOrEdit == "view" ) { |
662 | 667 | $linkEditor = new LinkEditor( $o->link, new SimplePermissionController( true ), true ); |
663 | | - else { |
| 668 | + } else { |
664 | 669 | $linkEditor = new RecordTableCellEditor( $o->link ); |
665 | 670 | $linkEditor->addEditor( new ShortTextEditor( $o->linkURL, new SimplePermissionController( true ), true ) ); |
666 | 671 | $linkEditor->addEditor( new ShortTextEditor( $o->linkLabel, new SimplePermissionController( true ), true ) ); |
Index: trunk/extensions/Wikidata/OmegaWiki/Transaction.php |
— | — | @@ -222,12 +222,13 @@ |
223 | 223 | |
224 | 224 | $action = $wgRequest->getText( 'action' ); |
225 | 225 | |
226 | | - if ( $action == 'edit' ) |
| 226 | + if ( $action == 'edit' ) { |
227 | 227 | return getLatestTransactionRestriction( $table ); |
228 | | - else if ( $action == 'history' ) |
| 228 | + } elseif ( $action == 'history' ) { |
229 | 229 | return '1'; |
230 | | - else |
| 230 | + } else { |
231 | 231 | return getLatestTransactionRestriction( $table ); |
| 232 | + } |
232 | 233 | } |
233 | 234 | |
234 | 235 | function getOperationSelectColumn( $table, $transactionId ) { |
— | — | @@ -243,19 +244,21 @@ |
244 | 245 | $dbr = wfGetDB( DB_SLAVE ); |
245 | 246 | $queryResult = $dbr->query( "SELECT user_name FROM user WHERE user_id=$userId" ); |
246 | 247 | |
247 | | - if ( $user = $dbr->fetchObject( $queryResult ) ) |
| 248 | + if ( $user = $dbr->fetchObject( $queryResult ) ) { |
248 | 249 | return $user->user_name; |
249 | | - else |
| 250 | + } else { |
250 | 251 | return ""; |
| 252 | + } |
251 | 253 | } |
252 | 254 | |
253 | 255 | function getUserLabel( $userId, $userIP ) { |
254 | | - if ( $userId > 0 ) |
| 256 | + if ( $userId > 0 ) { |
255 | 257 | return getUserName( $userId ); |
256 | | - else if ( $userIP != "" ) |
| 258 | + } elseif ( $userIP != "" ) { |
257 | 259 | return $userIP; |
258 | | - else |
| 260 | + } else { |
259 | 261 | return "Unknown"; |
| 262 | + } |
260 | 263 | } |
261 | 264 | |
262 | 265 | function expandUserIDsInRecordSet( RecordSet $recordSet, Attribute $userID, Attribute $userIP ) { |
Index: trunk/extensions/Wikidata/OmegaWiki/Editor.php |
— | — | @@ -624,13 +624,15 @@ |
625 | 625 | if ( $childEditor instanceof RecordTableCellEditor ) { |
626 | 626 | $type = $this->getTableStructureShowingData( $viewOrEdit, $childEditor, $idPath, $value, $attributePath ); |
627 | 627 | |
628 | | - if ( count( $type->getAttributes() ) > 0 ) |
| 628 | + if ( count( $type->getAttributes() ) > 0 ) { |
629 | 629 | $attributes[] = new Attribute( $childAttribute->id, $childAttribute->name, $type ); |
| 630 | + } |
630 | 631 | } |
631 | | - else if ( ( $viewOrEdit == "view" && $this->columnShowsData( $childEditor, $value, $attributePath ) ) || |
632 | | - ( $viewOrEdit == "edit" ) && $childEditor->showEditField( $idPath ) ) |
| 632 | + elseif ( ( $viewOrEdit == "view" && $this->columnShowsData( $childEditor, $value, $attributePath ) ) || |
| 633 | + ( $viewOrEdit == "edit" ) && $childEditor->showEditField( $idPath ) ) { |
633 | 634 | $attributes[] = new Attribute( $childAttribute->id, $childAttribute->name, 'short-text' ); |
634 | | - |
| 635 | + } |
| 636 | + |
635 | 637 | array_pop( $attributePath ); |
636 | 638 | } |
637 | 639 | |
— | — | @@ -640,9 +642,10 @@ |
641 | 643 | public function viewHeader( IdStack $idPath, Structure $visibleStructure ) { |
642 | 644 | $result = '<table id="' . $idPath->getId() . '" class="wiki-data-table">'; |
643 | 645 | |
644 | | - foreach ( getStructureAsTableHeaderRows( $visibleStructure, 0, $idPath ) as $headerRow ) |
| 646 | + foreach ( getStructureAsTableHeaderRows( $visibleStructure, 0, $idPath ) as $headerRow ) { |
645 | 647 | $result .= '<tr>' . $headerRow . '</tr>' . EOL; |
646 | | - |
| 648 | + } |
| 649 | + |
647 | 650 | return $result; |
648 | 651 | } |
649 | 652 | |
— | — | @@ -671,10 +674,11 @@ |
672 | 675 | } |
673 | 676 | |
674 | 677 | public function getTableStructureForView( IdStack $idPath, RecordSet $value ) { |
675 | | - if ( $this->hideEmptyColumns ) |
| 678 | + if ( $this->hideEmptyColumns ) { |
676 | 679 | return $this->getTableStructureShowingData( "view", $this, $idPath, $value ); |
677 | | - else |
| 680 | + } else { |
678 | 681 | return $this->getTableStructure( $this ); |
| 682 | + } |
679 | 683 | } |
680 | 684 | |
681 | 685 | public function getTableStructureForEdit( IdStack $idPath, RecordSet $value ) { |
Index: trunk/extensions/Wikidata/OmegaWiki/WikiDataTables.php |
— | — | @@ -133,12 +133,13 @@ |
134 | 134 | } |
135 | 135 | |
136 | 136 | public function getIndexes( $purpose ) { |
137 | | - if ( $purpose == "WebSite" ) |
| 137 | + if ( $purpose == "WebSite" ) { |
138 | 138 | return $this->getWebSiteIndexes(); |
139 | | - else if ( $purpose == "MassUpdate" ) |
| 139 | + } elseif ( $purpose == "MassUpdate" ) { |
140 | 140 | return $this->getMassUpdateIndexes(); |
141 | | - else |
| 141 | + } else { |
142 | 142 | return null; |
| 143 | + } |
143 | 144 | } |
144 | 145 | } |
145 | 146 | |
— | — | @@ -180,15 +181,15 @@ |
181 | 182 | protected function createVersionedIndexes( $name, $versionedEnd, $versionedStart, $unversioned, array $columns ) { |
182 | 183 | $result = array(); |
183 | 184 | |
184 | | - if ( $versionedEnd ) |
| 185 | + if ( $versionedEnd ) { |
185 | 186 | $result[] = new TableIndex( "versioned_end_" . $name, array_merge( array( $this->removeTransactionId ), $columns ) ); |
186 | | - |
187 | | - if ( $versionedStart ) |
| 187 | + } |
| 188 | + if ( $versionedStart ) { |
188 | 189 | $result[] = new TableIndex( "versioned_start_" . $name, array_merge( array( $this->addTransactionId ), $columns ) ); |
189 | | - |
190 | | - if ( $unversioned ) |
| 190 | + } |
| 191 | + if ( $unversioned ) { |
191 | 192 | $result[] = new TableIndex( "unversioned_" . $name, $columns ); |
192 | | - |
| 193 | + } |
193 | 194 | return $result; |
194 | 195 | } |
195 | 196 | } |
— | — | @@ -723,10 +724,11 @@ |
724 | 725 | public function getTableWithIdentifier( $identifier ) { |
725 | 726 | $prefixedIdentifier = $this->dataSetPrefix . "_" . $identifier; |
726 | 727 | |
727 | | - if ( isset( $this->tableLookupMap[$prefixedIdentifier] ) ) |
| 728 | + if ( isset( $this->tableLookupMap[$prefixedIdentifier] ) ) { |
728 | 729 | return $this->tableLookupMap[$prefixedIdentifier]; |
729 | | - else |
| 730 | + } else { |
730 | 731 | return null; |
| 732 | + } |
731 | 733 | } |
732 | 734 | } |
733 | 735 | |
— | — | @@ -740,23 +742,25 @@ |
741 | 743 | function genericSelect( $selectCommand, array $expressions, array $tables, array $restrictions ) { |
742 | 744 | $result = $selectCommand . " " . $expressions[0]->toExpression(); |
743 | 745 | |
744 | | - for ( $i = 1; $i < count( $expressions ); $i++ ) |
| 746 | + for ( $i = 1; $i < count( $expressions ); $i++ ) { |
745 | 747 | $result .= ", " . $expressions[$i]->toExpression(); |
746 | | - |
| 748 | + } |
747 | 749 | if ( count( $tables ) > 0 ) { |
748 | 750 | $result .= " FROM " . $tables[0]->getIdentifier(); |
749 | 751 | |
750 | | - for ( $i = 1; $i < count( $tables ); $i++ ) |
| 752 | + for ( $i = 1; $i < count( $tables ); $i++ ) { |
751 | 753 | $result .= ", " . $tables[$i]->getIdentifier(); |
| 754 | + } |
752 | 755 | } |
753 | 756 | |
754 | 757 | if ( count( $restrictions ) > 0 ) { |
755 | 758 | $result .= " WHERE (" . $restrictions[0] . ")"; |
756 | 759 | |
757 | | - for ( $i = 1; $i < count( $restrictions ); $i++ ) |
| 760 | + for ( $i = 1; $i < count( $restrictions ); $i++ ) { |
758 | 761 | $result .= " AND (" . $restrictions[$i] . ")"; |
| 762 | + } |
759 | 763 | } |
760 | | - |
| 764 | + |
761 | 765 | return new SelectExpression( $result ); |
762 | 766 | } |
763 | 767 | |
— | — | @@ -769,9 +773,11 @@ |
770 | 774 | } |
771 | 775 | |
772 | 776 | function genericSelectLatest( $selectCommand, array $expressions, array $tables, array $restrictions ) { |
773 | | - foreach ( $tables as $table ) |
774 | | - if ( $table->isVersioned ) |
| 777 | + foreach ( $tables as $table ) { |
| 778 | + if ( $table->isVersioned ) { |
775 | 779 | $restrictions[] = $table->removeTransactionId->toExpression() . " IS NULL"; |
| 780 | + } |
| 781 | + } |
776 | 782 | |
777 | 783 | return genericSelect( $selectCommand, $expressions, $tables, $restrictions ); |
778 | 784 | } |
— | — | @@ -785,16 +791,18 @@ |
786 | 792 | } |
787 | 793 | |
788 | 794 | function expressionToSQL( $expression ) { |
789 | | - if ( is_int( $expression ) ) |
| 795 | + if ( is_int( $expression ) ) { |
790 | 796 | return $expression; |
791 | | - else if ( is_string( $expression ) ) { |
| 797 | + } |
| 798 | + elseif ( is_string( $expression ) ) { |
792 | 799 | $dbr = wfGetDB( DB_SLAVE ); |
793 | 800 | return $dbr->addQuotes( $expression ); |
794 | 801 | } |
795 | | - else if ( is_object( $expression ) && $expression instanceof DatabaseExpression ) |
| 802 | + elseif ( is_object( $expression ) && $expression instanceof DatabaseExpression ) { |
796 | 803 | return $expression->toExpression(); |
797 | | - else |
| 804 | + } else { |
798 | 805 | throw new Exception( "Cannot convert expression to SQL: " . $expression ); |
| 806 | + } |
799 | 807 | } |
800 | 808 | |
801 | 809 | function equals( $expression1, $expression2 ) { |
— | — | @@ -808,13 +816,14 @@ |
809 | 817 | function inArray( DatabaseExpression $expression, $values ) { |
810 | 818 | $sqlValues = array(); |
811 | 819 | |
812 | | - foreach ( $values as $value ) |
| 820 | + foreach ( $values as $value ) { |
813 | 821 | $sqlValues[] = expressionToSQL( $value ); |
814 | | - |
815 | | - if ( count( $values ) > 0 ) |
| 822 | + } |
| 823 | + if ( count( $values ) > 0 ) { |
816 | 824 | return new DefaultDatabaseExpression( $expression->toExpression() . " IN (" . join( $sqlValues, ", " ) . ")" ); |
817 | | - else |
| 825 | + } else { |
818 | 826 | return new DefaultDatabaseExpression( 1 ); |
| 827 | + } |
819 | 828 | } |
820 | 829 | |
821 | 830 | function sqlOr( $expression1, $expression2 ) { |