r65328 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r65327‎ | r65328 | r65329 >
Date:15:27, 20 April 2010
Author:jeroendedauw
Status:deferred
Tags:
Comment:
Changes for 0.6 - fixed compatibility issue with SMW 1.5.1.
Note: this version is unstable and will not work properly with the latest Maps version.
Modified paths:
  • /trunk/extensions/SemanticMaps/FormInputs/SM_FormInput.php (modified) (history)
  • /trunk/extensions/SemanticMaps/FormInputs/SM_FormInputs.php (modified) (history)
  • /trunk/extensions/SemanticMaps/GeoCoords/SM_GeoCoordsValue.php (modified) (history)
  • /trunk/extensions/SemanticMaps/QueryPrinters/SM_MapPrinter.php (modified) (history)
  • /trunk/extensions/SemanticMaps/QueryPrinters/SM_QueryPrinters.php (modified) (history)
  • /trunk/extensions/SemanticMaps/SemanticMaps.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SemanticMaps/GeoCoords/SM_GeoCoordsValue.php
@@ -85,10 +85,10 @@
8686 * @see SMWDataValue::parseDBkeys
8787 */
8888 protected function parseDBkeys( $args ) {
89 - list( $this->mCoordinateSet['lat'], $this->mCoordinateSet['lon'] ) = explode( ',', $args[0] );
 89+ $this->mCoordinateSet['lat'] = $args[0];
 90+ $this->mCoordinateSet['lon'] = $args[1];
9091
91 - // TODO: parse coodinates to some notation, depending on a new setting
92 - $this->m_caption = $this->mCoordinateSet['lat'] . ', ' . $this->mCoordinateSet['lon'];
 92+ $this->m_caption = MapsCoordinateParser::formatCoordinates( $this->mCoordinateSet );
9393 $this->mWikivalue = $this->m_caption;
9494 }
9595
@@ -97,21 +97,21 @@
9898 */
9999 public function getDBkeys() {
100100 $this->unstub();
101 - return array( $this->mCoordinateSet['lat'] . ',' . $this->mCoordinateSet['lon'] );
 101+ return array( $this->mCoordinateSet['lat'], $this->mCoordinateSet['lon'] );
102102 }
103103
104104 /**
105105 * @see SMWDataValue::getShortWikiText
106106 *
107 - * TODO: make the output here more readible (and iff possible informative)
 107+ * TODO: make the output here more readible (and if possible informative)
108108 */
109109 public function getShortWikiText( $linked = null ) {
110110 if ( $this->isValid() && ( $linked !== null ) && ( $linked !== false ) ) {
111111 SMWOutputs::requireHeadItem( SMW_HEADER_TOOLTIP );
112112 return '<span class="smwttinline">' . $this->m_caption . '<span class="smwttcontent">' .
113 - wfMsgForContent( 'maps-latitude' ) . ' ' . $this->mCoordinateSet['lat'] . '<br />' .
114 - wfMsgForContent( 'maps-longitude' ) . ' ' . $this->mCoordinateSet['lon'] .
115 - '</span></span>';
 113+ wfMsgForContent( 'maps-latitude' ) . ' ' . $this->mCoordinateSet['lat'] . '<br />' .
 114+ wfMsgForContent( 'maps-longitude' ) . ' ' . $this->mCoordinateSet['lon'] .
 115+ '</span></span>';
116116 } else {
117117 return $this->m_caption;
118118 }
@@ -132,8 +132,7 @@
133133 if ( !$this->isValid() ) {
134134 return $this->getErrorText();
135135 } else {
136 - // TODO: parse coodinates to some notation, depending on a new setting
137 - return $this->mCoordinateSet['lat'] . ', ' . $this->mCoordinateSet['lon'];
 136+ return MapsCoordinateParser::formatCoordinates( $this->mCoordinateSet );
138137 }
139138 }
140139
@@ -158,8 +157,11 @@
159158 */
160159 public function getExportData() {
161160 if ( $this->isValid() ) {
162 - // TODO: parse coodinates to some notation, depending on a new setting
163 - $lit = new SMWExpLiteral( $this->mCoordinateSet['lat'] . ', ' . $this->mCoordinateSet['lon'], $this, 'http://www.w3.org/2001/XMLSchema#string' );
 161+ $lit = new SMWExpLiteral(
 162+ MapsCoordinateParser::formatCoordinates( $this->mCoordinateSet ),
 163+ $this,
 164+ 'http://www.w3.org/2001/XMLSchema#string'
 165+ );
164166 return new SMWExpData( $lit );
165167 } else {
166168 return null;
@@ -170,7 +172,7 @@
171173 * Create links to mapping services based on a wiki-editable message. The parameters
172174 * available to the message are:
173175 *
174 - *
 176+ * @return array
175177 */
176178 protected function getServiceLinkParams() {
177179 return array( ); // TODO
Index: trunk/extensions/SemanticMaps/FormInputs/SM_FormInput.php
@@ -52,34 +52,32 @@
5353
5454 $this->setMapSettings();
5555
56 - $this->featureParameters = SMFormInputs::$parameters;
 56+ parent::setMapProperties( $field_args, __CLASS__ );
5757
5858 $this->doMapServiceLoad();
5959
6060 $this->manageGeocoding();
6161
62 - if ( parent::manageMapProperties( $field_args, __CLASS__ ) ) {
63 - $this->setCoordinates();
64 - $this->setCentre();
65 - $this->setZoom();
66 -
67 - // Create html element names.
68 - $this->setMapName();
69 - $this->mapName .= '_' . $sfgTabIndex;
70 - $this->geocodeFieldName = $this->elementNamePrefix . '_geocode_' . $this->elementNr . '_' . $sfgTabIndex;
71 - $this->coordsFieldName = $this->elementNamePrefix . '_coords_' . $this->elementNr . '_' . $sfgTabIndex;
72 - $this->infoFieldName = $this->elementNamePrefix . '_info_' . $this->elementNr . '_' . $sfgTabIndex;
73 -
74 - // Create the non specific form HTML.
75 - $this->output .= "
76 - <input id='" . $this->coordsFieldName . "' name='$input_name' type='text' value='$this->startingCoords' size='40' tabindex='$sfgTabIndex'>
77 - <span id='" . $this->infoFieldName . "' class='error_message'></span>";
78 -
79 - if ( $this->enableGeocoding ) $this->addGeocodingField();
80 -
81 - $this->addSpecificMapHTML( $wgParser );
82 - }
 62+ $this->setCoordinates();
 63+ $this->setCentre();
 64+ $this->setZoom();
8365
 66+ // Create html element names.
 67+ $this->setMapName();
 68+ $this->mapName .= '_' . $sfgTabIndex;
 69+ $this->geocodeFieldName = $this->elementNamePrefix . '_geocode_' . $this->elementNr . '_' . $sfgTabIndex;
 70+ $this->coordsFieldName = $this->elementNamePrefix . '_coords_' . $this->elementNr . '_' . $sfgTabIndex;
 71+ $this->infoFieldName = $this->elementNamePrefix . '_info_' . $this->elementNr . '_' . $sfgTabIndex;
 72+
 73+ // Create the non specific form HTML.
 74+ $this->output .= "
 75+ <input id='" . $this->coordsFieldName . "' name='$input_name' type='text' value='$this->startingCoords' size='40' tabindex='$sfgTabIndex'>
 76+ <span id='" . $this->infoFieldName . "' class='error_message'></span>";
 77+
 78+ if ( $this->enableGeocoding ) $this->addGeocodingField();
 79+
 80+ $this->addSpecificMapHTML( $wgParser );
 81+
8482 return array( $this->output . $this->errorList, '' );
8583 }
8684
Index: trunk/extensions/SemanticMaps/FormInputs/SM_FormInputs.php
@@ -57,35 +57,33 @@
5858 }
5959
6060 private static function initializeParams() {
61 - global $egMapsAvailableServices, $egMapsDefaultServices, $egMapsDefaultCentre, $egMapsAvailableGeoServices, $egMapsDefaultGeoService;
 61+ global $egMapsAvailableServices, $egMapsDefaultServices, $egMapsAvailableGeoServices, $egMapsDefaultGeoService;
6262
6363 self::$parameters = array(
6464 'centre' => array(
6565 'aliases' => array( 'center' ),
66 - 'default' => $egMapsDefaultCentre
67 - ),
 66+ ),
6867 'geoservice' => array(
6968 'criteria' => array(
7069 'in_array' => array_keys( $egMapsAvailableGeoServices )
71 - ),
72 - 'default' => $egMapsDefaultGeoService
7370 ),
 71+ 'default' => $egMapsDefaultGeoService
 72+ ),
7473 'service_name' => array(),
7574 'part_of_multiple' => array(),
7675 'possible_values' => array(
7776 'type' => array( 'string', 'array' ),
78 - ),
 77+ ),
7978 'is_list' => array(),
8079 'semantic_property' => array(),
8180 'value_labels' => array(),
82 - );
 81+ );
8382 }
8483
8584 /**
8685 * Adds a mapping service's form hook.
8786 *
8887 * @param string $inputName The name of the form input.
89 - * @param array $fi
9088 * @param strig $mainName
9189 */
9290 private static function initFormHook( $inputName, $mainName = '' ) {
@@ -102,10 +100,10 @@
103101 /**
104102 * Calls the relevant form input class depending on the provided service.
105103 *
106 - * @param unknown_type $coordinates
107 - * @param unknown_type $input_name
108 - * @param unknown_type $is_mandatory
109 - * @param unknown_type $is_disabled
 104+ * @param string $coordinates
 105+ * @param string $input_name
 106+ * @param boolean $is_mandatory
 107+ * @param boolean $is_disabled
110108 * @param array $field_args
111109 *
112110 * @return array
Index: trunk/extensions/SemanticMaps/SemanticMaps.php
@@ -35,7 +35,7 @@
3636
3737 // Only initialize the extension when all dependencies are present.
3838 if ( defined( 'Maps_VERSION' ) && defined( 'SMW_VERSION' ) ) {
39 - define( 'SM_VERSION', '0.6 a13' );
 39+ define( 'SM_VERSION', '0.6 a15' );
4040
4141 $smgScriptPath = ( isset( $wgExtensionAssetsPath ) && $wgExtensionAssetsPath ? $wgExtensionAssetsPath : $wgScriptPath . '/extensions' ) . '/SemanticMaps';
4242 $smgDir = dirname( __FILE__ ) . '/';
Index: trunk/extensions/SemanticMaps/QueryPrinters/SM_QueryPrinters.php
@@ -55,7 +55,7 @@
5656 }
5757
5858 private static function initializeParams() {
59 - global $egMapsDefaultServices, $egMapsDefaultCentre, $egMapsAvailableGeoServices, $egMapsDefaultGeoService;
 59+ global $egMapsDefaultServices, $egMapsAvailableGeoServices, $egMapsDefaultGeoService;
6060 global $smgQPForceShow, $smgQPShowTitle, $smgQPTemplate;
6161
6262 self::$parameters = array(
@@ -71,7 +71,6 @@
7272 ),
7373 'centre' => array(
7474 'aliases' => array( 'center' ),
75 - 'default' => $egMapsDefaultCentre
7675 ),
7776 'forceshow' => array(
7877 'type' => 'boolean',
Index: trunk/extensions/SemanticMaps/QueryPrinters/SM_MapPrinter.php
@@ -125,7 +125,7 @@
126126 * again overidden by the service parameters (the ones spesific to the service),
127127 * and finally by the spesific parameters (the ones spesific to a service-feature combination).
128128 */
129 - $parameterInfo = array_merge( MapsMapper::getMainParams(), $this->featureParameters );
 129+ $parameterInfo = /* array_merge( MapsMapper::getMainParams(), */ $this->featureParameters /*)*/;
130130 $parameterInfo = array_merge( $parameterInfo, $egMapsServices[$this->serviceName]['parameters'] );
131131 $parameterInfo = array_merge( $parameterInfo, $this->spesificParameters );
132132
@@ -217,16 +217,17 @@
218218 }
219219
220220 if ( $pr->getMode() == SMWPrintRequest::PRINT_PROP && $pr->getTypeID() == '_geo' ) {
221 - $coords[] = explode( ',', $object->getXSDValue() );
 221+ $coords[] = $object->getDBkeys();
222222 }
223223 }
224224 }
225225
226226 foreach ( $coords as $coord ) {
227 - if ( count( $coord ) == 2 ) {
228 - list( $lat, $lon ) = $coord;
229 -
230 - if ( strlen( $lat ) > 0 && strlen( $lon ) > 0 ) {
 227+ if ( count( $coord ) >= 2 ) {
 228+ $lat = $coord[0];
 229+ $lon = $coord[1];
 230+
 231+ if ( $lat != '' && $lon != '' ) {
231232 $icon = $this->getLocationIcon( $row );
232233
233234 if ( $this->template ) {
@@ -239,7 +240,6 @@
240241 }
241242
242243 $this->m_locations[] = array(
243 - // TODO: add escaping to title and label (they are getting escaped now on some place where they shouldn't)
244244 Xml::escapeJsString( $lat ),
245245 Xml::escapeJsString( $lon ),
246246 Xml::escapeJsString( $title ),

Status & tagging log