r92880 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r92879‎ | r92880 | r92881 >
Date:19:31, 22 July 2011
Author:jeroendedauw
Status:deferred
Tags:
Comment:
Fixed handling of the semantic link caption in the geographical coordinate datavalue class
Modified paths:
  • /trunk/extensions/SemanticMaps/RELEASE-NOTES (modified) (history)
  • /trunk/extensions/SemanticMaps/includes/SM_GeoCoordsValue.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SemanticMaps/RELEASE-NOTES
@@ -10,7 +10,7 @@
1111 === Semantic Maps 1.0.1 ===
1212 (2011-xx-xx)
1313
14 -*
 14+* Fixed handling of the semantic link caption in the geographical coordinate datavalue class.
1515
1616 === Semantic Maps 1.0 ===
1717 (2011-07-19)
Index: trunk/extensions/SemanticMaps/includes/SM_GeoCoordsValue.php
@@ -31,13 +31,11 @@
3232 $this->m_dataitem = $dataItem;
3333
3434 global $smgQPCoodFormat, $smgQPCoodDirectional;
35 - $this->m_caption = MapsCoordinateParser::formatCoordinates(
 35+ $this->wikiValue = MapsCoordinateParser::formatCoordinates(
3636 $dataItem->getCoordinateSet(),
3737 $smgQPCoodFormat,
3838 $smgQPCoodDirectional
3939 );
40 -
41 - $this->wikiValue = $this->m_caption;
4240 return true;
4341 } else {
4442 return false;
@@ -102,11 +100,6 @@
103101 $parsedCoords = MapsCoordinateParser::parseCoordinates( $coordinates );
104102 if ( $parsedCoords ) {
105103 $this->m_dataitem = new SMWDIGeoCoord( $parsedCoords );
106 -
107 - if ( $this->m_caption === false && !$asQuery ) {
108 - global $smgQPCoodFormat, $smgQPCoodDirectional;
109 - $this->m_caption = MapsCoordinateParser::formatCoordinates( $parsedCoords, $smgQPCoodFormat, $smgQPCoodDirectional );
110 - }
111104 } else {
112105 $this->addError( wfMsgExt( 'maps_unrecognized_coords', array( 'parsemag' ), $coordinates, 1 ) );
113106 $this->m_dataitem = new SMWDIGeoCoord( array(0, 0) ); // make sure this is always set
@@ -133,12 +126,18 @@
134127 * @since 0.6
135128 */
136129 public function getShortWikiText( $linked = null ) {
137 - if ( !$this->isValid() ) {
 130+ if ( $this->isValid() ) {
 131+ if ( $this->m_caption === false ) {
 132+ global $smgQPCoodFormat, $smgQPCoodDirectional;
 133+ return MapsCoordinateParser::formatCoordinates( $this->m_dataitem->getCoordinateSet(), $smgQPCoodFormat, $smgQPCoodDirectional );
 134+ }
 135+ else {
 136+ return $this->m_caption;
 137+ }
 138+ }
 139+ else {
138140 return $this->getErrorText();
139 - } else {
140 - global $smgQPCoodFormat, $smgQPCoodDirectional;
141 - return MapsCoordinateParser::formatCoordinates( $this->m_dataitem->getCoordinateSet(), $smgQPCoodFormat, $smgQPCoodDirectional );
142 - }
 141+ }
143142 }
144143
145144 /**
@@ -161,13 +160,16 @@
162161
163162 // TODO: fix lang keys so they include the space and coordinates.
164163 $coordinateSet = $this->m_dataitem->getCoordinateSet();
 164+
 165+ global $smgQPCoodFormat, $smgQPCoodDirectional;
 166+ $text = MapsCoordinateParser::formatCoordinates( $coordinateSet, $smgQPCoodFormat, $smgQPCoodDirectional );
165167
166 - return '<span class="smwttinline">' . htmlspecialchars( $this->m_caption ) . '<span class="smwttcontent">' .
 168+ return '<span class="smwttinline">' . htmlspecialchars( $text ) . '<span class="smwttcontent">' .
167169 htmlspecialchars ( wfMsgForContent( 'maps-latitude' ) . ' ' . $coordinateSet['lat'] ) . '<br />' .
168170 htmlspecialchars ( wfMsgForContent( 'maps-longitude' ) . ' ' . $coordinateSet['lon'] ) .
169171 '</span></span>';
170172 } else {
171 - return htmlspecialchars( $this->m_caption );
 173+ return $this->getErrorText();
172174 }
173175 }
174176