Index: trunk/extensions/Wikidata/OmegaWiki/OmegaWikiRecordSets.php |
— | — | @@ -1020,7 +1020,7 @@ |
1021 | 1021 | new TableColumnsToAttribute(array('value_id'), $linkAttributeIdAttribute), |
1022 | 1022 | new TableColumnsToAttribute(array('object_id'), $linkAttributeObjectAttribute), |
1023 | 1023 | new TableColumnsToAttribute(array('attribute_mid'), $linkAttributeAttribute), |
1024 | | - new TableColumnsToAttribute(array('url'), $linkAttribute) |
| 1024 | + new TableColumnsToAttribute(array('label', 'url'), $linkAttribute) |
1025 | 1025 | ), |
1026 | 1026 | $linkAttributeValuesTable, |
1027 | 1027 | array("object_id IN (" . implode(", ", $objectIds) . ")") |
Index: trunk/extensions/Wikidata/OmegaWiki/ViewInformation.php |
— | — | @@ -16,6 +16,7 @@ |
17 | 17 | public $possiblySynonymousRelationTypeId; |
18 | 18 | public $queryTransactionInformation; |
19 | 19 | public $showRecordLifeSpan; |
| 20 | + public $viewOrEdit; |
20 | 21 | |
21 | 22 | protected $propertyToColumnFilters; |
22 | 23 | |
— | — | @@ -25,6 +26,7 @@ |
26 | 27 | $this->queryTransactionInformation; |
27 | 28 | $this->showRecordLifeSpan = false; |
28 | 29 | $this->propertyToColumnFilters = array(); |
| 30 | + $this->viewOrEdit = "view"; |
29 | 31 | } |
30 | 32 | |
31 | 33 | public function hasMetaDataAttributes() { |
Index: trunk/extensions/Wikidata/OmegaWiki/Controller.php |
— | — | @@ -521,14 +521,16 @@ |
522 | 522 | class LinkAttributeValuesController extends ObjectAttributeValuesController { |
523 | 523 | public function add($keyPath, $record) { |
524 | 524 | global |
525 | | - $linkAttribute, $linkAttributeAttribute; |
| 525 | + $linkAttribute, $linkAttributeAttribute, $linkLabelAttribute, $linkURLAttribute; |
526 | 526 | |
527 | 527 | $objectId = $this->objectIdFetcher->fetch($keyPath); |
528 | 528 | $linkAttributeId = $record->getAttributeValue($linkAttributeAttribute); |
529 | | - $url = $record->getAttributeValue($linkAttribute); |
| 529 | + $linkValue = $record->getAttributeValue($linkAttribute); |
| 530 | + $label = $linkValue->getAttributeValue($linkLabelAttribute); |
| 531 | + $url = $linkValue->getAttributeValue($linkURLAttribute); |
530 | 532 | |
531 | | - if ($linkAttributeId != 0 && $url != '') |
532 | | - addLinkAttributeValue($objectId, $linkAttributeId, $url); |
| 533 | + if ($linkAttributeId != 0 && $url != "") |
| 534 | + addLinkAttributeValue($objectId, $linkAttributeId, $url, $label); |
533 | 535 | } |
534 | 536 | |
535 | 537 | public function remove($keyPath) { |
— | — | @@ -541,12 +543,15 @@ |
542 | 544 | |
543 | 545 | public function update($keyPath, $record) { |
544 | 546 | global |
545 | | - $linkAttributeIdAttribute, $linkAttribute; |
| 547 | + $linkAttributeIdAttribute, $linkAttribute, $linkLabelAttribute, $linkURLAttribute; |
546 | 548 | |
547 | 549 | $linkId = $keyPath->peek(0)->getAttributeValue($linkAttributeIdAttribute); |
548 | | - $url = $record->getAttributeValue($linkAttribute); |
549 | | - |
550 | | - updateLinkAttributeValue($url, $linkId); |
| 550 | + $linkValue = $record->getAttributeValue($linkAttribute); |
| 551 | + $label = $linkValue->getAttributeValue($linkLabelAttribute); |
| 552 | + $url = $linkValue->getAttributeValue($linkURLAttribute); |
| 553 | + |
| 554 | + if ($url != "") |
| 555 | + updateLinkAttributeValue($linkId, $url, $label); |
551 | 556 | } |
552 | 557 | } |
553 | 558 | |
Index: trunk/extensions/Wikidata/OmegaWiki/SpecialTransaction.php |
— | — | @@ -249,21 +249,19 @@ |
250 | 250 | $attributeAttribute = new Attribute('attribute', 'Attribute', $definedMeaningReferenceStructure); |
251 | 251 | |
252 | 252 | global |
253 | | - $updatedURLAttribute, $updatedURLStructure, $URLAttribute; |
| 253 | + $updatedLinkAttribute, $updatedLinkStructure, $linkAttribute; |
254 | 254 | |
255 | | - $URLAttribute = new Attribute('url', 'URL', 'url'); |
256 | | - |
257 | | - $updatedURLStructure = new Structure( |
| 255 | + $updatedLinkStructure = new Structure( |
258 | 256 | $rollBackAttribute, |
259 | 257 | $valueIdAttribute, |
260 | 258 | $objectIdAttribute, |
261 | 259 | $attributeAttribute, |
262 | | - $URLAttribute, |
| 260 | + $linkAttribute, |
263 | 261 | $operationAttribute, |
264 | 262 | $isLatestAttribute |
265 | 263 | ); |
266 | 264 | |
267 | | - $updatedURLAttribute = new Attribute('updated-url', 'URL properties', $updatedURLStructure); |
| 265 | + $updatedLinkAttribute = new Attribute('updated-link', 'Link properties', $updatedLinkStructure); |
268 | 266 | |
269 | 267 | global |
270 | 268 | $updatedTextAttribute, $updatedTextStructure, $textAttribute; |
— | — | @@ -382,7 +380,7 @@ |
383 | 381 | $updatedSyntransesAttribute, |
384 | 382 | $updatedRelationsAttribute, |
385 | 383 | $updatedClassMembershipAttribute, |
386 | | - $updatedURLAttribute, |
| 384 | + $updatedLinkAttribute, |
387 | 385 | $updatedTextAttribute, |
388 | 386 | $updatedTranslatedTextAttribute, |
389 | 387 | $updatedAlternativeDefinitionsAttribute |
— | — | @@ -430,7 +428,7 @@ |
431 | 429 | $transactionAttribute, $userAttribute, $timestampAttribute, $summaryAttribute, |
432 | 430 | $updatesInTransactionAttribute, $updatedDefinitionAttribute, $updatedSyntransesAttribute, |
433 | 431 | $updatedRelationsAttribute, $updatedClassMembershipAttribute, $updatedCollectionMembershipAttribute, |
434 | | - $updatedURLAttribute, $updatedTextAttribute, $updatedTranslatedTextAttribute, $updatedClassAttributesAttribute, |
| 432 | + $updatedLinkAttribute, $updatedTextAttribute, $updatedTranslatedTextAttribute, $updatedClassAttributesAttribute, |
435 | 433 | $updatedAlternativeDefinitionsAttribute, $updatedAlternativeDefinitionTextAttribute, |
436 | 434 | $updatedTranslatedTextPropertyAttribute; |
437 | 435 | |
— | — | @@ -448,7 +446,7 @@ |
449 | 447 | $valueEditor->addEditor(getUpdatedClassAttributesEditor($updatedClassAttributesAttribute, $showRollBackOptions)); |
450 | 448 | $valueEditor->addEditor(getUpdatedClassMembershipEditor($updatedClassMembershipAttribute, $showRollBackOptions)); |
451 | 449 | $valueEditor->addEditor(getUpdatedCollectionMembershipEditor($updatedCollectionMembershipAttribute, $showRollBackOptions)); |
452 | | - $valueEditor->addEditor(getUpdatedURLEditor($updatedURLAttribute, $showRollBackOptions)); |
| 450 | + $valueEditor->addEditor(getUpdatedLinkEditor($updatedLinkAttribute, $showRollBackOptions)); |
453 | 451 | $valueEditor->addEditor(getUpdatedTextEditor($updatedTextAttribute, $showRollBackOptions)); |
454 | 452 | $valueEditor->addEditor(getUpdatedTranslatedTextPropertyEditor($updatedTranslatedTextPropertyAttribute, $showRollBackOptions)); |
455 | 453 | $valueEditor->addEditor(getUpdatedTranslatedTextEditor($updatedTranslatedTextAttribute, $showRollBackOptions)); |
— | — | @@ -477,7 +475,7 @@ |
478 | 476 | global |
479 | 477 | $updatesInTransactionAttribute, $updatedDefinitionAttribute, $updatedSyntransesAttribute, |
480 | 478 | $updatedRelationsAttribute, $updatedClassMembershipAttribute, $updatedCollectionMembershipAttribute, |
481 | | - $updatedURLAttribute, $updatedTextAttribute, $updatedTranslatedTextAttribute, $updatedClassAttributesAttribute, |
| 479 | + $updatedLinkAttribute, $updatedTextAttribute, $updatedTranslatedTextAttribute, $updatedClassAttributesAttribute, |
482 | 480 | $updatedAlternativeDefinitionsAttribute, $updatedAlternativeDefinitionTextAttribute, |
483 | 481 | $updatedTranslatedTextPropertyAttribute; |
484 | 482 | |
— | — | @@ -489,7 +487,7 @@ |
490 | 488 | $record->setAttributeValue($updatedRelationsAttribute, getUpdatedRelationsRecordSet($transactionId)); |
491 | 489 | $record->setAttributeValue($updatedClassMembershipAttribute, getUpdatedClassMembershipRecordSet($transactionId)); |
492 | 490 | $record->setAttributeValue($updatedCollectionMembershipAttribute, getUpdatedCollectionMembershipRecordSet($transactionId)); |
493 | | - $record->setAttributeValue($updatedURLAttribute, getUpdatedURLRecordSet($transactionId)); |
| 491 | + $record->setAttributeValue($updatedLinkAttribute, getUpdatedLinkRecordSet($transactionId)); |
494 | 492 | $record->setAttributeValue($updatedTextAttribute, getUpdatedTextRecordSet($transactionId)); |
495 | 493 | $record->setAttributeValue($updatedTranslatedTextPropertyAttribute, getUpdatedTranslatedTextPropertyRecordSet($transactionId)); |
496 | 494 | $record->setAttributeValue($updatedTranslatedTextAttribute, getUpdatedTranslatedTextRecordSet($transactionId)); |
— | — | @@ -857,30 +855,41 @@ |
858 | 856 | return $recordSet; |
859 | 857 | } |
860 | 858 | |
861 | | -function getUpdatedURLRecordSet($transactionId) { |
| 859 | +function createLinkRecord($url, $label) { |
862 | 860 | global |
863 | | - $objectIdAttribute, $valueIdAttribute, $attributeAttribute, $URLAttribute, |
864 | | - $updatedURLStructure, $operationAttribute, $isLatestAttribute, |
| 861 | + $linkAttribute, $linkLabelAttribute, $linkURLAttribute; |
| 862 | + |
| 863 | + $result = new ArrayRecord($linkAttribute->type); |
| 864 | + $result->setAttributeValue($linkLabelAttribute, $label); |
| 865 | + $result->setAttributeValue($linkURLAttribute, $url); |
| 866 | + |
| 867 | + return $result; |
| 868 | +} |
| 869 | + |
| 870 | +function getUpdatedLinkRecordSet($transactionId) { |
| 871 | + global |
| 872 | + $objectIdAttribute, $valueIdAttribute, $attributeAttribute, $linkAttribute, |
| 873 | + $updatedLinkStructure, $operationAttribute, $isLatestAttribute, |
865 | 874 | $rollBackAttribute, $rollBackStructure; |
866 | 875 | |
867 | 876 | $dc=wdGetDataSetContext(); |
868 | 877 | $dbr = &wfGetDB(DB_SLAVE); |
869 | 878 | $queryResult = $dbr->query( |
870 | | - "SELECT value_id, object_id, attribute_mid, url, " . |
| 879 | + "SELECT value_id, object_id, attribute_mid, url, label, " . |
871 | 880 | getOperationSelectColumn("{$dc}_url_attribute_values", $transactionId) . ', ' . |
872 | 881 | getIsLatestSelectColumn("{$dc}_url_attribute_values", array('value_id'), $transactionId) . |
873 | 882 | " FROM {$dc}_url_attribute_values " . |
874 | 883 | " WHERE " . getInTransactionRestriction("{$dc}_url_attribute_values", $transactionId) |
875 | 884 | ); |
876 | 885 | |
877 | | - $recordSet = new ArrayRecordSet($updatedURLStructure, new Structure($valueIdAttribute)); |
| 886 | + $recordSet = new ArrayRecordSet($updatedLinkStructure, new Structure($valueIdAttribute)); |
878 | 887 | |
879 | 888 | while ($row = $dbr->fetchObject($queryResult)) { |
880 | | - $record = new ArrayRecord($updatedURLStructure); |
| 889 | + $record = new ArrayRecord($updatedLinkStructure); |
881 | 890 | $record->setAttributeValue($valueIdAttribute, $row->value_id); |
882 | 891 | $record->setAttributeValue($objectIdAttribute, $row->object_id); |
883 | 892 | $record->setAttributeValue($attributeAttribute, getDefinedMeaningReferenceRecord($row->attribute_mid)); |
884 | | - $record->setAttributeValue($URLAttribute, $row->url); |
| 893 | + $record->setAttributeValue($linkAttribute, createLinkRecord($row->url, $row->label)); |
885 | 894 | $record->setAttributeValue($operationAttribute, $row->operation); |
886 | 895 | $record->setAttributeValue($isLatestAttribute, $row->is_latest); |
887 | 896 | $record->setAttributeValue($rollBackAttribute, simpleRecord($rollBackStructure, array($row->is_latest, $row->operation))); |
— | — | @@ -1157,9 +1166,9 @@ |
1158 | 1167 | return $editor; |
1159 | 1168 | } |
1160 | 1169 | |
1161 | | -function getUpdatedURLEditor($attribute, $showRollBackOptions) { |
| 1170 | +function getUpdatedLinkEditor($attribute, $showRollBackOptions) { |
1162 | 1171 | global |
1163 | | - $objectIdAttribute, $valueIdAttribute, $attributeAttribute, $URLAttribute, |
| 1172 | + $objectIdAttribute, $valueIdAttribute, $attributeAttribute, $linkAttribute, |
1164 | 1173 | $rollBackAttribute, $operationAttribute, $isLatestAttribute; |
1165 | 1174 | |
1166 | 1175 | $editor = createTableViewer($attribute); |
— | — | @@ -1169,7 +1178,7 @@ |
1170 | 1179 | |
1171 | 1180 | $editor->addEditor(new ObjectPathEditor($objectIdAttribute)); |
1172 | 1181 | $editor->addEditor(createDefinedMeaningReferenceViewer($attributeAttribute)); |
1173 | | - $editor->addEditor(createLinkViewer($URLAttribute)); |
| 1182 | + $editor->addEditor(createLinkViewer($linkAttribute)); |
1174 | 1183 | $editor->addEditor(createShortTextViewer($operationAttribute)); |
1175 | 1184 | $editor->addEditor(createBooleanViewer($isLatestAttribute)); |
1176 | 1185 | |
— | — | @@ -1274,7 +1283,7 @@ |
1275 | 1284 | $transactionIdAttribute, $updatesInTransactionAttribute, |
1276 | 1285 | $updatedDefinitionAttribute, $updatedRelationsAttribute, $updatedClassMembershipAttribute, |
1277 | 1286 | $updatedTranslatedTextAttribute, $updatedClassAttributesAttribute, $updatedTranslatedTextPropertyAttribute, |
1278 | | - $updatedURLAttribute, $updatedTextAttribute, $updatedSyntransesAttribute, |
| 1287 | + $updatedLinkAttribute, $updatedTextAttribute, $updatedSyntransesAttribute, |
1279 | 1288 | $updatedAlternativeDefinitionTextAttribute, $updatedAlternativeDefinitionsAttribute, |
1280 | 1289 | $updatedCollectionMembershipAttribute; |
1281 | 1290 | |
— | — | @@ -1323,9 +1332,9 @@ |
1324 | 1333 | rollBackTranslatedTextProperties($idStack, $updatedTranslatedTextProperties); |
1325 | 1334 | $idStack->popAttribute(); |
1326 | 1335 | |
1327 | | - $updatedURLAttributes = $updatesInTransaction->getAttributeValue($updatedURLAttribute); |
1328 | | - $idStack->pushAttribute($updatedURLAttribute); |
1329 | | - rollBackURLAttributes($idStack, $updatedURLAttributes); |
| 1336 | + $updatedLinkAttributes = $updatesInTransaction->getAttributeValue($updatedLinkAttribute); |
| 1337 | + $idStack->pushAttribute($updatedLinkAttribute); |
| 1338 | + rollBackLinkAttributes($idStack, $updatedLinkAttributes); |
1330 | 1339 | $idStack->popAttribute(); |
1331 | 1340 | |
1332 | 1341 | $updatedTextAttributes = $updatesInTransaction->getAttributeValue($updatedTextAttribute); |
— | — | @@ -1634,29 +1643,32 @@ |
1635 | 1644 | createTranslatedTextAttributeValue($valueId, $objectId, $attributeId, $translatedContentId); |
1636 | 1645 | } |
1637 | 1646 | |
1638 | | -function rollBackURLAttributes($idStack, $urlAttributes) { |
| 1647 | +function rollBackLinkAttributes($idStack, $linkAttributes) { |
1639 | 1648 | global |
1640 | | - $isLatestAttribute, $operationAttribute, $rollBackAttribute, $URLAttribute, |
1641 | | - $valueIdAttribute, $objectIdAttribute, $attributeAttribute, $translatedContentIdAttribute; |
| 1649 | + $isLatestAttribute, $operationAttribute, $rollBackAttribute, $linkAttribute, |
| 1650 | + $valueIdAttribute, $objectIdAttribute, $attributeAttribute, $translatedContentIdAttribute, |
| 1651 | + $linkURLAttribute, $linkLabelAttribute; |
1642 | 1652 | |
1643 | | - $urlAttributesKeyStructure = $urlAttributes->getKey(); |
| 1653 | + $linkAttributesKeyStructure = $linkAttributes->getKey(); |
1644 | 1654 | |
1645 | | - for ($i = 0; $i < $urlAttributes->getRecordCount(); $i++) { |
1646 | | - $urlAttributeRecord = $urlAttributes->getRecord($i); |
| 1655 | + for ($i = 0; $i < $linkAttributes->getRecordCount(); $i++) { |
| 1656 | + $linkAttributeRecord = $linkAttributes->getRecord($i); |
1647 | 1657 | |
1648 | | - $valueId = $urlAttributeRecord->getAttributeValue($valueIdAttribute); |
1649 | | - $isLatest = $urlAttributeRecord->getAttributeValue($isLatestAttribute); |
| 1658 | + $valueId = $linkAttributeRecord->getAttributeValue($valueIdAttribute); |
| 1659 | + $isLatest = $linkAttributeRecord->getAttributeValue($isLatestAttribute); |
1650 | 1660 | |
1651 | 1661 | if ($isLatest) { |
1652 | | - $idStack->pushKey(simpleRecord($urlAttributesKeyStructure, array($valueId))); |
| 1662 | + $idStack->pushKey(simpleRecord($linkAttributesKeyStructure, array($valueId))); |
| 1663 | + $link = $linkAttributeRecord->getAttributeValue($linkAttribute); |
1653 | 1664 | |
1654 | | - rollBackURLAttribute( |
| 1665 | + rollBackLinkAttribute( |
1655 | 1666 | getRollBackAction($idStack, $rollBackAttribute), |
1656 | 1667 | $valueId, |
1657 | | - $urlAttributeRecord->getAttributeValue($objectIdAttribute), |
1658 | | - getMeaningId($urlAttributeRecord, $attributeAttribute), |
1659 | | - $urlAttributeRecord->getAttributeValue($URLAttribute), |
1660 | | - $urlAttributeRecord->getAttributeValue($operationAttribute) |
| 1668 | + $linkAttributeRecord->getAttributeValue($objectIdAttribute), |
| 1669 | + getMeaningId($linkAttributeRecord, $attributeAttribute), |
| 1670 | + $link->getAttributeValue($linkURLAttribute), |
| 1671 | + $link->getAttributeValue($linkLabelAttribute), |
| 1672 | + $linkAttributeRecord->getAttributeValue($operationAttribute) |
1661 | 1673 | ); |
1662 | 1674 | |
1663 | 1675 | $idStack->popKey(); |
— | — | @@ -1664,11 +1676,11 @@ |
1665 | 1677 | } |
1666 | 1678 | } |
1667 | 1679 | |
1668 | | -function rollBackURLAttribute($rollBackAction, $valueId, $objectId, $attributeId, $url, $operation) { |
| 1680 | +function rollBackLinkAttribute($rollBackAction, $valueId, $objectId, $attributeId, $url, $label, $operation) { |
1669 | 1681 | if (shouldRemove($rollBackAction, $operation)) |
1670 | 1682 | removeLinkAttributeValue($valueId); |
1671 | 1683 | else if (shouldRestore($rollBackAction, $operation)) |
1672 | | - createLinkAttributeValue($valueId, $objectId, $attributeId, $url); |
| 1684 | + createLinkAttributeValue($valueId, $objectId, $attributeId, $url, $label); |
1673 | 1685 | } |
1674 | 1686 | |
1675 | 1687 | function rollBackTextAttributes($idStack, $textAttributes) { |
Index: trunk/extensions/Wikidata/OmegaWiki/Wikidata.php |
— | — | @@ -129,6 +129,7 @@ |
130 | 130 | $viewInformation->filterLanguageId = $this->filterLanguageId; |
131 | 131 | $viewInformation->possiblySynonymousRelationTypeId = $this->possiblySynonymousRelationTypeId; |
132 | 132 | $viewInformation->queryTransactionInformation = $referenceQueryTransactionInformation; |
| 133 | + $viewInformation->viewOrEdit = "edit"; |
133 | 134 | |
134 | 135 | $this->viewInformation = $viewInformation; |
135 | 136 | |
— | — | @@ -183,6 +184,7 @@ |
184 | 185 | $viewInformation->possiblySynonymousRelationTypeId = $this->possiblySynonymousRelationTypeId; |
185 | 186 | $viewInformation->showRecordLifeSpan = false; |
186 | 187 | $viewInformation->queryTransactionInformation = new QueryLatestTransactionInformation(); |
| 188 | + $viewInformation->viewOrEdit = "edit"; |
187 | 189 | |
188 | 190 | $this->viewInformation = $viewInformation; |
189 | 191 | |
Index: trunk/extensions/Wikidata/OmegaWiki/OmegaWikiEditors.php |
— | — | @@ -364,11 +364,20 @@ |
365 | 365 | function getLinkAttributeValuesEditor(ViewInformation $viewInformation, UpdateController $controller, $levelDefinedMeaningName, Fetcher $objectIdFetcher) { |
366 | 366 | global |
367 | 367 | $linkAttributeAttribute, $linkAttribute, $linkAttributeValuesAttribute, $linkValueObjectAttributesEditor, |
368 | | - $wgPopupAnnotationName; |
| 368 | + $wgPopupAnnotationName, $linkLabelAttribute, $linkURLAttribute; |
369 | 369 | |
370 | 370 | $editor = new RecordSetTableEditor($linkAttributeValuesAttribute, new SimplePermissionController(true), new ShowEditFieldChecker(true), new AllowAddController(true), true, false, $controller); |
371 | 371 | $editor->addEditor(new LinkAttributeEditor($linkAttributeAttribute, new SimplePermissionController(false), true, $levelDefinedMeaningName, $objectIdFetcher)); |
372 | | - $editor->addEditor(new LinkEditor($linkAttribute, new SimplePermissionController(true), true)); |
| 372 | + |
| 373 | + if ($viewInformation->viewOrEdit == "view") |
| 374 | + $linkEditor = new LinkEditor($linkAttribute, new SimplePermissionController(true), true); |
| 375 | + else { |
| 376 | + $linkEditor = new RecordTableCellEditor($linkAttribute); |
| 377 | + $linkEditor->addEditor(new ShortTextEditor($linkURLAttribute, new SimplePermissionController(true), true)); |
| 378 | + $linkEditor->addEditor(new ShortTextEditor($linkLabelAttribute, new SimplePermissionController(true), true)); |
| 379 | + } |
| 380 | + |
| 381 | + $editor->addEditor($linkEditor); |
373 | 382 | $editor->addEditor(new PopUpEditor($linkValueObjectAttributesEditor, $wgPopupAnnotationName)); |
374 | 383 | |
375 | 384 | addTableMetadataEditors($editor, $viewInformation); |
Index: trunk/extensions/Wikidata/OmegaWiki/OmegaWikiAttributes.php |
— | — | @@ -221,7 +221,7 @@ |
222 | 222 | |
223 | 223 | $linkLabelAttribute = new Attribute("label", "Label", "short-text"); |
224 | 224 | $linkURLAttribute = new Attribute("url", "URL", "url"); |
225 | | - $linkAttribute = new Attribute("link", "Link", "url");// new Structure($linkLabelAttribute, $linkURLAttribute)); |
| 225 | + $linkAttribute = new Attribute("link", "Link", new Structure($linkLabelAttribute, $linkURLAttribute)); |
226 | 226 | |
227 | 227 | $linkAttributeIdAttribute = new Attribute("link-attribute-id", "Attribute identifier", "object-id"); |
228 | 228 | $linkAttributeObjectAttribute = new Attribute("link-attribute-object-id", "Attribute object", "object-id"); |
Index: trunk/extensions/Wikidata/OmegaWiki/Editor.php |
— | — | @@ -1019,11 +1019,16 @@ |
1020 | 1020 | class LinkEditor extends ShortTextEditor { |
1021 | 1021 | public function getViewHTML(IdStack $idPath, $value) { |
1022 | 1022 | global |
1023 | | - $escapedValue; |
| 1023 | + $linkLabelAttribute, $linkURLAttribute; |
1024 | 1024 | |
1025 | | - $escapedValue = htmlspecialchars($value); |
1026 | | - |
1027 | | - return '<a href="' . $escapedValue . '">' . $escapedValue . '</a>' . EOL; |
| 1025 | + $label = htmlspecialchars($value->getAttributeValue($linkLabelAttribute)); |
| 1026 | + $url = htmlspecialchars($value->getAttributeValue($linkURLAttribute)); |
| 1027 | + |
| 1028 | + if ($label == "") |
| 1029 | + $label = $url; |
| 1030 | + |
| 1031 | + return |
| 1032 | + '<a href="' . $url . '">' . $label . '</a>' . EOL; |
1028 | 1033 | } |
1029 | 1034 | } |
1030 | 1035 | |
— | — | @@ -1903,7 +1908,11 @@ |
1904 | 1909 | |
1905 | 1910 | class RecordSetRecordSelector extends WrappingEditor { |
1906 | 1911 | public function view(IdStack $idPath, $value) { |
1907 | | - return getStaticSuggest($idPath->getId(), $this->wrappedEditor->view($idPath, $value), count($value->getKey()->attributes)); |
| 1912 | + return getStaticSuggest( |
| 1913 | + $idPath->getId(), |
| 1914 | + $this->wrappedEditor->view($idPath, $value), |
| 1915 | + count($value->getKey()->getAttributes()) |
| 1916 | + ); |
1908 | 1917 | } |
1909 | 1918 | } |
1910 | 1919 | |
Index: trunk/extensions/Wikidata/OmegaWiki/WikiDataAPI.php |
— | — | @@ -730,43 +730,43 @@ |
731 | 731 | return $dbr->fetchObject($queryResult); |
732 | 732 | } |
733 | 733 | |
734 | | -function addLinkAttributeValue($objectId, $linkAttributeId, $url) { |
| 734 | +function addLinkAttributeValue($objectId, $linkAttributeId, $url, $label = "") { |
735 | 735 | $dc=wdGetDataSetContext(); |
736 | | - $urlValueAttributeId = newObjectId("{$dc}_url_attribute_values"); |
737 | | - createLinkAttributeValue($urlValueAttributeId, $objectId, $linkAttributeId, $url); |
| 736 | + $linkValueAttributeId = newObjectId("{$dc}_url_attribute_values"); |
| 737 | + createLinkAttributeValue($linkValueAttributeId, $objectId, $linkAttributeId, $url, $label); |
738 | 738 | } |
739 | 739 | |
740 | | -function createLinkAttributeValue($urlValueAttributeId, $objectId, $linkAttributeId, $url) { |
| 740 | +function createLinkAttributeValue($linkValueAttributeId, $objectId, $linkAttributeId, $url, $label = "") { |
741 | 741 | $dc=wdGetDataSetContext(); |
742 | 742 | $dbr = &wfGetDB(DB_MASTER); |
743 | 743 | $dbr->query( |
744 | 744 | "INSERT INTO {$dc}_url_attribute_values (value_id, object_id, attribute_mid, url, label, add_transaction_id) " . |
745 | | - "VALUES ($urlValueAttributeId, $objectId, $linkAttributeId, " . $dbr->addQuotes($url) . ", " . $dbr->addQuotes($url) . ", ". getUpdateTransactionId() .")" |
| 745 | + "VALUES ($linkValueAttributeId, $objectId, $linkAttributeId, " . $dbr->addQuotes($url) . ", " . $dbr->addQuotes($label) . ", ". getUpdateTransactionId() .")" |
746 | 746 | ); |
747 | 747 | } |
748 | 748 | |
749 | | -function removeLinkAttributeValue($urlValueAttributeId) { |
| 749 | +function removeLinkAttributeValue($linkValueAttributeId) { |
750 | 750 | $dc=wdGetDataSetContext(); |
751 | 751 | $dbr = &wfGetDB(DB_MASTER); |
752 | 752 | $dbr->query( |
753 | 753 | "UPDATE {$dc}_url_attribute_values SET remove_transaction_id=". getUpdateTransactionId() . |
754 | | - " WHERE value_id=$urlValueAttributeId" . |
| 754 | + " WHERE value_id=$linkValueAttributeId" . |
755 | 755 | " AND remove_transaction_id IS NULL" |
756 | 756 | ); |
757 | 757 | } |
758 | 758 | |
759 | | -function updateLinkAttributeValue($url, $urlValueAttributeId) { |
760 | | - $urlValueAttribute = getURLValueAttribute($urlValueAttributeId); |
761 | | - removeLinkAttributeValue($urlValueAttributeId); |
762 | | - createLinkAttributeValue($urlValueAttributeId, $urlValueAttribute->object_id, $urlValueAttribute->attribute_mid, $url); |
| 759 | +function updateLinkAttributeValue($linkValueAttributeId, $url, $label = "") { |
| 760 | + $linkValueAttribute = getLinkValueAttribute($linkValueAttributeId); |
| 761 | + removeLinkAttributeValue($linkValueAttributeId); |
| 762 | + createLinkAttributeValue($linkValueAttributeId, $linkValueAttribute->object_id, $linkValueAttribute->attribute_mid, $url, $label); |
763 | 763 | } |
764 | 764 | |
765 | | -function getURLValueAttribute($urlValueAttributeId) { |
| 765 | +function getLinkValueAttribute($linkValueAttributeId) { |
766 | 766 | $dc=wdGetDataSetContext(); |
767 | 767 | $dbr = &wfGetDB(DB_SLAVE); |
768 | 768 | $queryResult = $dbr->query( |
769 | 769 | "SELECT object_id, attribute_mid, url" . |
770 | | - " FROM {$dc}_url_attribute_values WHERE value_id=$urlValueAttributeId " . |
| 770 | + " FROM {$dc}_url_attribute_values WHERE value_id=$linkValueAttributeId " . |
771 | 771 | " AND " . getLatestTransactionRestriction("{$dc}_url_attribute_values") |
772 | 772 | ); |
773 | 773 | |