http://www.mediawiki.org/wiki/Special:Code/MediaWiki/88316
Revision: 88316
Author: mkroetzsch
Date: 2011-05-17 15:16:08 +0000 (Tue, 17 May 2011)
Log Message:
-----------
removed obsolete methods, and renamed setDataItem() into loadDataItem()
Modified Paths:
--------------
trunk/extensions/SemanticMaps/includes/SM_GeoCoordsValue.php
Modified: trunk/extensions/SemanticMaps/includes/SM_GeoCoordsValue.php
===================================================================
--- trunk/extensions/SemanticMaps/includes/SM_GeoCoordsValue.php
2011-05-17 15:07:21 UTC (rev 88315)
+++ trunk/extensions/SemanticMaps/includes/SM_GeoCoordsValue.php
2011-05-17 15:16:08 UTC (rev 88316)
@@ -26,17 +26,17 @@
*
* @return boolean
*/
- public function setDataItem( SMWDataItem $dataItem ) {
+ protected function loadDataItem( SMWDataItem $dataItem ) {
if ( $dataItem->getDIType() == SMWDataItem::TYPE_GEO ) {
$this->m_dataitem = $dataItem;
-
+
global $smgQPCoodFormat, $smgQPCoodDirectional;
$this->m_caption =
MapsCoordinateParser::formatCoordinates(
$dataItem->getCoordinateSet(),
$smgQPCoodFormat,
$smgQPCoodDirectional
);
-
+
$this->wikiValue = $this->m_caption;
return true;
} else {
@@ -77,9 +77,9 @@
*/
protected function parseUserValueOrQuery( $value, $asQuery = false ) {
$this->wikiValue = $value;
-
+
$comparator = SMW_CMP_EQ;
-
+
if ( $value == '' ) {
$this->addError( wfMsg( 'smw_novalues' ) );
} else {
@@ -101,69 +101,33 @@
$parsedCoords = MapsCoordinateParser::parseCoordinates(
$coordinates );
if ( $parsedCoords ) {
- $this->m_dataitem = new SMWDIGeoCoord( $parsedCoords,
$this->m_typeid );
+ $this->m_dataitem = new SMWDIGeoCoord(
$parsedCoords );
if ( $this->m_caption === false && !$asQuery ) {
global $smgQPCoodFormat,
$smgQPCoodDirectional;
$this->m_caption =
MapsCoordinateParser::formatCoordinates( $parsedCoords, $smgQPCoodFormat,
$smgQPCoodDirectional );
- }
+ }
} else {
$this->addError( wfMsgExt(
'maps_unrecognized_coords', array( 'parsemag' ), $coordinates, 1 ) );
- $this->m_dataitem = new SMWDIGeoCoord( array(0, 0),
$this->m_typeid ); // make sure this is always set
+ $this->m_dataitem = new SMWDIGeoCoord( array(0,
0) ); // make sure this is always set
}
}
if ( $asQuery ) {
$this->setUserValue( $value );
-
+
switch ( true ) {
case !$this->isValid() :
return new SMWThingDescription();
- break;
case $distance !== false :
return new SMAreaValueDescription(
$this, $comparator, $distance );
- break;
default :
return new SMGeoCoordsValueDescription(
$this, $comparator );
- break;
- }
+ }
}
}
-
- /**
- * @see SMWDataValue::parseDBkeys
- *
- * @since 0.6
- */
- protected function parseDBkeys( $args ) {
- $this->setDataItem( new SMWDIGeoCoord( array( 'lat' =>
(float)$args[0], 'lon' => (float)$args[1] ), $this->m_typeid ) );
- }
-
- /**
- * @see SMWDataValue::getDBkeys
- *
- * @since 0.6
- */
- public function getDBkeys() {
- $this->unstub();
- $coordinateSet = $this->m_dataitem->getCoordinateSet();
- return array(
- $coordinateSet['lat'],
- $coordinateSet['lon']
- );
- }
-
/**
- * @see SMWDataValue::getSignature
- *
- * @since 0.6
- */
- public function getSignature() {
- return 'ff';
- }
-
- /**
* @see SMWDataValue::getShortWikiText
*
* @since 0.6
@@ -172,7 +136,7 @@
if ( $this->isValid() && ( $linked !== null ) && ( $linked !==
false ) ) {
SMWOutputs::requireHeadItem( SMW_HEADER_TOOLTIP );
-
+
// TODO: fix lang keys so they include the space and
coordinates.
$coordinateSet = $this->m_dataitem->getCoordinateSet();
@@ -180,8 +144,7 @@
htmlspecialchars ( wfMsgForContent( 'maps-latitude' ) .
' ' . $coordinateSet['lat'] ) . '<br />' .
htmlspecialchars ( wfMsgForContent( 'maps-longitude' )
. ' ' . $coordinateSet['lon'] ) .
'</span></span>';
- }
- else {
+ } else {
return htmlspecialchars( $this->m_caption );
}
}
@@ -203,8 +166,7 @@
public function getLongWikiText( $linked = null ) {
if ( !$this->isValid() ) {
return $this->getErrorText();
- }
- else {
+ } else {
global $smgQPCoodFormat, $smgQPCoodDirectional;
return MapsCoordinateParser::formatCoordinates(
$this->m_dataitem->getCoordinateSet(), $smgQPCoodFormat, $smgQPCoodDirectional
);
}
@@ -225,7 +187,6 @@
* @since 0.6
*/
public function getWikiValue() {
- $this->unstub();
return $this->wikiValue;
}
@@ -262,7 +223,7 @@
* @return array
*/
protected function getServiceLinkParams() {
- $coordinateSet = $this->m_dataitem->getCoordinateSet();
+ $coordinateSet = $this->m_dataitem->getCoordinateSet();
return array(
MapsCoordinateParser::formatCoordinates(
$coordinateSet, 'float', false ),
MapsCoordinateParser::formatCoordinates(
$coordinateSet, 'dms', true ),
@@ -270,27 +231,5 @@
$coordinateSet['lon']
);
}
-
- /**
- * @see SMWDataValue::getValueIndex
- *
- * @since 0.6
- *
- * @return integer
- */
- public function getValueIndex() {
- return 0;
- }
- /**
- * @see SMWDataValue::getLabelIndex
- *
- * @since 0.6
- *
- * @return integer
- */
- public function getLabelIndex() {
- return 0;
- }
-
}
_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs