Tobias Gritschacher has submitted this change and it was merged.

Change subject: (bug 52501) handle GlobeCoordinateValue in diff display
......................................................................


(bug 52501) handle GlobeCoordinateValue in diff display

Change-Id: Ia6bcb546760468430e7cc046bf082a1b0ccbb0b9
---
M lib/includes/ClaimDifferenceVisualizer.php
1 file changed, 28 insertions(+), 14 deletions(-)

Approvals:
  Tobias Gritschacher: Verified; Looks good to me, approved



diff --git a/lib/includes/ClaimDifferenceVisualizer.php 
b/lib/includes/ClaimDifferenceVisualizer.php
index 87abdc9..0aa9800 100644
--- a/lib/includes/ClaimDifferenceVisualizer.php
+++ b/lib/includes/ClaimDifferenceVisualizer.php
@@ -1,6 +1,8 @@
 <?php
 namespace Wikibase;
 
+use DataValues\DataValue;
+use DataValues\GlobeCoordinateValue;
 use DataValues\TimeValue;
 use Html;
 use Diff\Diff;
@@ -289,26 +291,38 @@
                $snakType = $snak->getType();
 
                if ( $snakType === 'value' ) {
-                       $dataValue = $snak->getDataValue();
-
-                       // FIXME! should use some value formatter
-                       if ( $dataValue instanceof EntityId ) {
-                               $diffValueString = $this->getEntityLabel( 
$dataValue );
-                       } else if ( $dataValue instanceof TimeValue ) {
-                               // TODO: this will just display the plain 
ISO8601-string,
-                               // we should instead use a decent formatter
-                               $diffValueString = $dataValue->getTime();
-                       } else {
-                               $diffValueString = $dataValue->getValue();
-                       }
-
-                       return $diffValueString;
+                       return $this->formatDataValue( $snak->getDataValue() );
                } else {
                        return $snakType;
                }
        }
 
        /**
+        * Format DataValue for diff view
+        *
+        * @todo use value formatters!
+        *
+        * @param DataValue $dataValue
+        *
+        * @return string;
+        */
+       protected function formatDataValue( DataValue $dataValue ) {
+               if ( $dataValue instanceof EntityId ) {
+                       $diffValueString = $this->getEntityLabel( $dataValue );
+               } elseif ( $dataValue instanceof TimeValue ) {
+                       // TODO: this will just display the plain 
ISO8601-string,
+                       // we should instead use a decent formatter
+                       $diffValueString = $dataValue->getTime();
+               } elseif ( $dataValue instanceof GlobeCoordinateValue ) {
+                       $diffValueString = $dataValue->getLatitude() . ', ' . 
$dataValue->getLongitude();
+               } else {
+                       $diffValueString = $dataValue->getValue();
+               }
+
+               return $diffValueString;
+       }
+
+       /**
         * Get an entity label
         *
         * @since 0.4

-- 
To view, visit https://gerrit.wikimedia.org/r/81551
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: Ia6bcb546760468430e7cc046bf082a1b0ccbb0b9
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Wikibase
Gerrit-Branch: mw1.22-wmf14
Gerrit-Owner: Aude <[email protected]>
Gerrit-Reviewer: Aude <[email protected]>
Gerrit-Reviewer: Jeroen De Dauw <[email protected]>
Gerrit-Reviewer: Tobias Gritschacher <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to