r23904 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r23903‎ | r23904 | r23905 >
Date:14:33, 9 July 2007
Author:proes
Status:old
Tags:
Comment:
Now links can have both a URL and an optional label.
Modified paths:
  • /trunk/extensions/Wikidata/OmegaWiki/Controller.php (modified) (history)
  • /trunk/extensions/Wikidata/OmegaWiki/Editor.php (modified) (history)
  • /trunk/extensions/Wikidata/OmegaWiki/OmegaWikiAttributes.php (modified) (history)
  • /trunk/extensions/Wikidata/OmegaWiki/OmegaWikiEditors.php (modified) (history)
  • /trunk/extensions/Wikidata/OmegaWiki/OmegaWikiRecordSets.php (modified) (history)
  • /trunk/extensions/Wikidata/OmegaWiki/SpecialTransaction.php (modified) (history)
  • /trunk/extensions/Wikidata/OmegaWiki/ViewInformation.php (modified) (history)
  • /trunk/extensions/Wikidata/OmegaWiki/WikiDataAPI.php (modified) (history)
  • /trunk/extensions/Wikidata/OmegaWiki/Wikidata.php (modified) (history)

Diff [purge]

Index: trunk/extensions/Wikidata/OmegaWiki/OmegaWikiRecordSets.php
@@ -1020,7 +1020,7 @@
10211021 new TableColumnsToAttribute(array('value_id'), $linkAttributeIdAttribute),
10221022 new TableColumnsToAttribute(array('object_id'), $linkAttributeObjectAttribute),
10231023 new TableColumnsToAttribute(array('attribute_mid'), $linkAttributeAttribute),
1024 - new TableColumnsToAttribute(array('url'), $linkAttribute)
 1024+ new TableColumnsToAttribute(array('label', 'url'), $linkAttribute)
10251025 ),
10261026 $linkAttributeValuesTable,
10271027 array("object_id IN (" . implode(", ", $objectIds) . ")")
Index: trunk/extensions/Wikidata/OmegaWiki/ViewInformation.php
@@ -16,6 +16,7 @@
1717 public $possiblySynonymousRelationTypeId;
1818 public $queryTransactionInformation;
1919 public $showRecordLifeSpan;
 20+ public $viewOrEdit;
2021
2122 protected $propertyToColumnFilters;
2223
@@ -25,6 +26,7 @@
2627 $this->queryTransactionInformation;
2728 $this->showRecordLifeSpan = false;
2829 $this->propertyToColumnFilters = array();
 30+ $this->viewOrEdit = "view";
2931 }
3032
3133 public function hasMetaDataAttributes() {
Index: trunk/extensions/Wikidata/OmegaWiki/Controller.php
@@ -521,14 +521,16 @@
522522 class LinkAttributeValuesController extends ObjectAttributeValuesController {
523523 public function add($keyPath, $record) {
524524 global
525 - $linkAttribute, $linkAttributeAttribute;
 525+ $linkAttribute, $linkAttributeAttribute, $linkLabelAttribute, $linkURLAttribute;
526526
527527 $objectId = $this->objectIdFetcher->fetch($keyPath);
528528 $linkAttributeId = $record->getAttributeValue($linkAttributeAttribute);
529 - $url = $record->getAttributeValue($linkAttribute);
 529+ $linkValue = $record->getAttributeValue($linkAttribute);
 530+ $label = $linkValue->getAttributeValue($linkLabelAttribute);
 531+ $url = $linkValue->getAttributeValue($linkURLAttribute);
530532
531 - if ($linkAttributeId != 0 && $url != '')
532 - addLinkAttributeValue($objectId, $linkAttributeId, $url);
 533+ if ($linkAttributeId != 0 && $url != "")
 534+ addLinkAttributeValue($objectId, $linkAttributeId, $url, $label);
533535 }
534536
535537 public function remove($keyPath) {
@@ -541,12 +543,15 @@
542544
543545 public function update($keyPath, $record) {
544546 global
545 - $linkAttributeIdAttribute, $linkAttribute;
 547+ $linkAttributeIdAttribute, $linkAttribute, $linkLabelAttribute, $linkURLAttribute;
546548
547549 $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);
551556 }
552557 }
553558
Index: trunk/extensions/Wikidata/OmegaWiki/SpecialTransaction.php
@@ -249,21 +249,19 @@
250250 $attributeAttribute = new Attribute('attribute', 'Attribute', $definedMeaningReferenceStructure);
251251
252252 global
253 - $updatedURLAttribute, $updatedURLStructure, $URLAttribute;
 253+ $updatedLinkAttribute, $updatedLinkStructure, $linkAttribute;
254254
255 - $URLAttribute = new Attribute('url', 'URL', 'url');
256 -
257 - $updatedURLStructure = new Structure(
 255+ $updatedLinkStructure = new Structure(
258256 $rollBackAttribute,
259257 $valueIdAttribute,
260258 $objectIdAttribute,
261259 $attributeAttribute,
262 - $URLAttribute,
 260+ $linkAttribute,
263261 $operationAttribute,
264262 $isLatestAttribute
265263 );
266264
267 - $updatedURLAttribute = new Attribute('updated-url', 'URL properties', $updatedURLStructure);
 265+ $updatedLinkAttribute = new Attribute('updated-link', 'Link properties', $updatedLinkStructure);
268266
269267 global
270268 $updatedTextAttribute, $updatedTextStructure, $textAttribute;
@@ -382,7 +380,7 @@
383381 $updatedSyntransesAttribute,
384382 $updatedRelationsAttribute,
385383 $updatedClassMembershipAttribute,
386 - $updatedURLAttribute,
 384+ $updatedLinkAttribute,
387385 $updatedTextAttribute,
388386 $updatedTranslatedTextAttribute,
389387 $updatedAlternativeDefinitionsAttribute
@@ -430,7 +428,7 @@
431429 $transactionAttribute, $userAttribute, $timestampAttribute, $summaryAttribute,
432430 $updatesInTransactionAttribute, $updatedDefinitionAttribute, $updatedSyntransesAttribute,
433431 $updatedRelationsAttribute, $updatedClassMembershipAttribute, $updatedCollectionMembershipAttribute,
434 - $updatedURLAttribute, $updatedTextAttribute, $updatedTranslatedTextAttribute, $updatedClassAttributesAttribute,
 432+ $updatedLinkAttribute, $updatedTextAttribute, $updatedTranslatedTextAttribute, $updatedClassAttributesAttribute,
435433 $updatedAlternativeDefinitionsAttribute, $updatedAlternativeDefinitionTextAttribute,
436434 $updatedTranslatedTextPropertyAttribute;
437435
@@ -448,7 +446,7 @@
449447 $valueEditor->addEditor(getUpdatedClassAttributesEditor($updatedClassAttributesAttribute, $showRollBackOptions));
450448 $valueEditor->addEditor(getUpdatedClassMembershipEditor($updatedClassMembershipAttribute, $showRollBackOptions));
451449 $valueEditor->addEditor(getUpdatedCollectionMembershipEditor($updatedCollectionMembershipAttribute, $showRollBackOptions));
452 - $valueEditor->addEditor(getUpdatedURLEditor($updatedURLAttribute, $showRollBackOptions));
 450+ $valueEditor->addEditor(getUpdatedLinkEditor($updatedLinkAttribute, $showRollBackOptions));
453451 $valueEditor->addEditor(getUpdatedTextEditor($updatedTextAttribute, $showRollBackOptions));
454452 $valueEditor->addEditor(getUpdatedTranslatedTextPropertyEditor($updatedTranslatedTextPropertyAttribute, $showRollBackOptions));
455453 $valueEditor->addEditor(getUpdatedTranslatedTextEditor($updatedTranslatedTextAttribute, $showRollBackOptions));
@@ -477,7 +475,7 @@
478476 global
479477 $updatesInTransactionAttribute, $updatedDefinitionAttribute, $updatedSyntransesAttribute,
480478 $updatedRelationsAttribute, $updatedClassMembershipAttribute, $updatedCollectionMembershipAttribute,
481 - $updatedURLAttribute, $updatedTextAttribute, $updatedTranslatedTextAttribute, $updatedClassAttributesAttribute,
 479+ $updatedLinkAttribute, $updatedTextAttribute, $updatedTranslatedTextAttribute, $updatedClassAttributesAttribute,
482480 $updatedAlternativeDefinitionsAttribute, $updatedAlternativeDefinitionTextAttribute,
483481 $updatedTranslatedTextPropertyAttribute;
484482
@@ -489,7 +487,7 @@
490488 $record->setAttributeValue($updatedRelationsAttribute, getUpdatedRelationsRecordSet($transactionId));
491489 $record->setAttributeValue($updatedClassMembershipAttribute, getUpdatedClassMembershipRecordSet($transactionId));
492490 $record->setAttributeValue($updatedCollectionMembershipAttribute, getUpdatedCollectionMembershipRecordSet($transactionId));
493 - $record->setAttributeValue($updatedURLAttribute, getUpdatedURLRecordSet($transactionId));
 491+ $record->setAttributeValue($updatedLinkAttribute, getUpdatedLinkRecordSet($transactionId));
494492 $record->setAttributeValue($updatedTextAttribute, getUpdatedTextRecordSet($transactionId));
495493 $record->setAttributeValue($updatedTranslatedTextPropertyAttribute, getUpdatedTranslatedTextPropertyRecordSet($transactionId));
496494 $record->setAttributeValue($updatedTranslatedTextAttribute, getUpdatedTranslatedTextRecordSet($transactionId));
@@ -857,30 +855,41 @@
858856 return $recordSet;
859857 }
860858
861 -function getUpdatedURLRecordSet($transactionId) {
 859+function createLinkRecord($url, $label) {
862860 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,
865874 $rollBackAttribute, $rollBackStructure;
866875
867876 $dc=wdGetDataSetContext();
868877 $dbr = &wfGetDB(DB_SLAVE);
869878 $queryResult = $dbr->query(
870 - "SELECT value_id, object_id, attribute_mid, url, " .
 879+ "SELECT value_id, object_id, attribute_mid, url, label, " .
871880 getOperationSelectColumn("{$dc}_url_attribute_values", $transactionId) . ', ' .
872881 getIsLatestSelectColumn("{$dc}_url_attribute_values", array('value_id'), $transactionId) .
873882 " FROM {$dc}_url_attribute_values " .
874883 " WHERE " . getInTransactionRestriction("{$dc}_url_attribute_values", $transactionId)
875884 );
876885
877 - $recordSet = new ArrayRecordSet($updatedURLStructure, new Structure($valueIdAttribute));
 886+ $recordSet = new ArrayRecordSet($updatedLinkStructure, new Structure($valueIdAttribute));
878887
879888 while ($row = $dbr->fetchObject($queryResult)) {
880 - $record = new ArrayRecord($updatedURLStructure);
 889+ $record = new ArrayRecord($updatedLinkStructure);
881890 $record->setAttributeValue($valueIdAttribute, $row->value_id);
882891 $record->setAttributeValue($objectIdAttribute, $row->object_id);
883892 $record->setAttributeValue($attributeAttribute, getDefinedMeaningReferenceRecord($row->attribute_mid));
884 - $record->setAttributeValue($URLAttribute, $row->url);
 893+ $record->setAttributeValue($linkAttribute, createLinkRecord($row->url, $row->label));
885894 $record->setAttributeValue($operationAttribute, $row->operation);
886895 $record->setAttributeValue($isLatestAttribute, $row->is_latest);
887896 $record->setAttributeValue($rollBackAttribute, simpleRecord($rollBackStructure, array($row->is_latest, $row->operation)));
@@ -1157,9 +1166,9 @@
11581167 return $editor;
11591168 }
11601169
1161 -function getUpdatedURLEditor($attribute, $showRollBackOptions) {
 1170+function getUpdatedLinkEditor($attribute, $showRollBackOptions) {
11621171 global
1163 - $objectIdAttribute, $valueIdAttribute, $attributeAttribute, $URLAttribute,
 1172+ $objectIdAttribute, $valueIdAttribute, $attributeAttribute, $linkAttribute,
11641173 $rollBackAttribute, $operationAttribute, $isLatestAttribute;
11651174
11661175 $editor = createTableViewer($attribute);
@@ -1169,7 +1178,7 @@
11701179
11711180 $editor->addEditor(new ObjectPathEditor($objectIdAttribute));
11721181 $editor->addEditor(createDefinedMeaningReferenceViewer($attributeAttribute));
1173 - $editor->addEditor(createLinkViewer($URLAttribute));
 1182+ $editor->addEditor(createLinkViewer($linkAttribute));
11741183 $editor->addEditor(createShortTextViewer($operationAttribute));
11751184 $editor->addEditor(createBooleanViewer($isLatestAttribute));
11761185
@@ -1274,7 +1283,7 @@
12751284 $transactionIdAttribute, $updatesInTransactionAttribute,
12761285 $updatedDefinitionAttribute, $updatedRelationsAttribute, $updatedClassMembershipAttribute,
12771286 $updatedTranslatedTextAttribute, $updatedClassAttributesAttribute, $updatedTranslatedTextPropertyAttribute,
1278 - $updatedURLAttribute, $updatedTextAttribute, $updatedSyntransesAttribute,
 1287+ $updatedLinkAttribute, $updatedTextAttribute, $updatedSyntransesAttribute,
12791288 $updatedAlternativeDefinitionTextAttribute, $updatedAlternativeDefinitionsAttribute,
12801289 $updatedCollectionMembershipAttribute;
12811290
@@ -1323,9 +1332,9 @@
13241333 rollBackTranslatedTextProperties($idStack, $updatedTranslatedTextProperties);
13251334 $idStack->popAttribute();
13261335
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);
13301339 $idStack->popAttribute();
13311340
13321341 $updatedTextAttributes = $updatesInTransaction->getAttributeValue($updatedTextAttribute);
@@ -1634,29 +1643,32 @@
16351644 createTranslatedTextAttributeValue($valueId, $objectId, $attributeId, $translatedContentId);
16361645 }
16371646
1638 -function rollBackURLAttributes($idStack, $urlAttributes) {
 1647+function rollBackLinkAttributes($idStack, $linkAttributes) {
16391648 global
1640 - $isLatestAttribute, $operationAttribute, $rollBackAttribute, $URLAttribute,
1641 - $valueIdAttribute, $objectIdAttribute, $attributeAttribute, $translatedContentIdAttribute;
 1649+ $isLatestAttribute, $operationAttribute, $rollBackAttribute, $linkAttribute,
 1650+ $valueIdAttribute, $objectIdAttribute, $attributeAttribute, $translatedContentIdAttribute,
 1651+ $linkURLAttribute, $linkLabelAttribute;
16421652
1643 - $urlAttributesKeyStructure = $urlAttributes->getKey();
 1653+ $linkAttributesKeyStructure = $linkAttributes->getKey();
16441654
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);
16471657
1648 - $valueId = $urlAttributeRecord->getAttributeValue($valueIdAttribute);
1649 - $isLatest = $urlAttributeRecord->getAttributeValue($isLatestAttribute);
 1658+ $valueId = $linkAttributeRecord->getAttributeValue($valueIdAttribute);
 1659+ $isLatest = $linkAttributeRecord->getAttributeValue($isLatestAttribute);
16501660
16511661 if ($isLatest) {
1652 - $idStack->pushKey(simpleRecord($urlAttributesKeyStructure, array($valueId)));
 1662+ $idStack->pushKey(simpleRecord($linkAttributesKeyStructure, array($valueId)));
 1663+ $link = $linkAttributeRecord->getAttributeValue($linkAttribute);
16531664
1654 - rollBackURLAttribute(
 1665+ rollBackLinkAttribute(
16551666 getRollBackAction($idStack, $rollBackAttribute),
16561667 $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)
16611673 );
16621674
16631675 $idStack->popKey();
@@ -1664,11 +1676,11 @@
16651677 }
16661678 }
16671679
1668 -function rollBackURLAttribute($rollBackAction, $valueId, $objectId, $attributeId, $url, $operation) {
 1680+function rollBackLinkAttribute($rollBackAction, $valueId, $objectId, $attributeId, $url, $label, $operation) {
16691681 if (shouldRemove($rollBackAction, $operation))
16701682 removeLinkAttributeValue($valueId);
16711683 else if (shouldRestore($rollBackAction, $operation))
1672 - createLinkAttributeValue($valueId, $objectId, $attributeId, $url);
 1684+ createLinkAttributeValue($valueId, $objectId, $attributeId, $url, $label);
16731685 }
16741686
16751687 function rollBackTextAttributes($idStack, $textAttributes) {
Index: trunk/extensions/Wikidata/OmegaWiki/Wikidata.php
@@ -129,6 +129,7 @@
130130 $viewInformation->filterLanguageId = $this->filterLanguageId;
131131 $viewInformation->possiblySynonymousRelationTypeId = $this->possiblySynonymousRelationTypeId;
132132 $viewInformation->queryTransactionInformation = $referenceQueryTransactionInformation;
 133+ $viewInformation->viewOrEdit = "edit";
133134
134135 $this->viewInformation = $viewInformation;
135136
@@ -183,6 +184,7 @@
184185 $viewInformation->possiblySynonymousRelationTypeId = $this->possiblySynonymousRelationTypeId;
185186 $viewInformation->showRecordLifeSpan = false;
186187 $viewInformation->queryTransactionInformation = new QueryLatestTransactionInformation();
 188+ $viewInformation->viewOrEdit = "edit";
187189
188190 $this->viewInformation = $viewInformation;
189191
Index: trunk/extensions/Wikidata/OmegaWiki/OmegaWikiEditors.php
@@ -364,11 +364,20 @@
365365 function getLinkAttributeValuesEditor(ViewInformation $viewInformation, UpdateController $controller, $levelDefinedMeaningName, Fetcher $objectIdFetcher) {
366366 global
367367 $linkAttributeAttribute, $linkAttribute, $linkAttributeValuesAttribute, $linkValueObjectAttributesEditor,
368 - $wgPopupAnnotationName;
 368+ $wgPopupAnnotationName, $linkLabelAttribute, $linkURLAttribute;
369369
370370 $editor = new RecordSetTableEditor($linkAttributeValuesAttribute, new SimplePermissionController(true), new ShowEditFieldChecker(true), new AllowAddController(true), true, false, $controller);
371371 $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);
373382 $editor->addEditor(new PopUpEditor($linkValueObjectAttributesEditor, $wgPopupAnnotationName));
374383
375384 addTableMetadataEditors($editor, $viewInformation);
Index: trunk/extensions/Wikidata/OmegaWiki/OmegaWikiAttributes.php
@@ -221,7 +221,7 @@
222222
223223 $linkLabelAttribute = new Attribute("label", "Label", "short-text");
224224 $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));
226226
227227 $linkAttributeIdAttribute = new Attribute("link-attribute-id", "Attribute identifier", "object-id");
228228 $linkAttributeObjectAttribute = new Attribute("link-attribute-object-id", "Attribute object", "object-id");
Index: trunk/extensions/Wikidata/OmegaWiki/Editor.php
@@ -1019,11 +1019,16 @@
10201020 class LinkEditor extends ShortTextEditor {
10211021 public function getViewHTML(IdStack $idPath, $value) {
10221022 global
1023 - $escapedValue;
 1023+ $linkLabelAttribute, $linkURLAttribute;
10241024
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;
10281033 }
10291034 }
10301035
@@ -1903,7 +1908,11 @@
19041909
19051910 class RecordSetRecordSelector extends WrappingEditor {
19061911 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+ );
19081917 }
19091918 }
19101919
Index: trunk/extensions/Wikidata/OmegaWiki/WikiDataAPI.php
@@ -730,43 +730,43 @@
731731 return $dbr->fetchObject($queryResult);
732732 }
733733
734 -function addLinkAttributeValue($objectId, $linkAttributeId, $url) {
 734+function addLinkAttributeValue($objectId, $linkAttributeId, $url, $label = "") {
735735 $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);
738738 }
739739
740 -function createLinkAttributeValue($urlValueAttributeId, $objectId, $linkAttributeId, $url) {
 740+function createLinkAttributeValue($linkValueAttributeId, $objectId, $linkAttributeId, $url, $label = "") {
741741 $dc=wdGetDataSetContext();
742742 $dbr = &wfGetDB(DB_MASTER);
743743 $dbr->query(
744744 "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() .")"
746746 );
747747 }
748748
749 -function removeLinkAttributeValue($urlValueAttributeId) {
 749+function removeLinkAttributeValue($linkValueAttributeId) {
750750 $dc=wdGetDataSetContext();
751751 $dbr = &wfGetDB(DB_MASTER);
752752 $dbr->query(
753753 "UPDATE {$dc}_url_attribute_values SET remove_transaction_id=". getUpdateTransactionId() .
754 - " WHERE value_id=$urlValueAttributeId" .
 754+ " WHERE value_id=$linkValueAttributeId" .
755755 " AND remove_transaction_id IS NULL"
756756 );
757757 }
758758
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);
763763 }
764764
765 -function getURLValueAttribute($urlValueAttributeId) {
 765+function getLinkValueAttribute($linkValueAttributeId) {
766766 $dc=wdGetDataSetContext();
767767 $dbr = &wfGetDB(DB_SLAVE);
768768 $queryResult = $dbr->query(
769769 "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 " .
771771 " AND " . getLatestTransactionRestriction("{$dc}_url_attribute_values")
772772 );
773773

Status & tagging log