Last modified: 2007-12-28 10:08:06 UTC
If you enter [[temperature test::-40 Celsius]] SMW 1.0-RC3 just shows the temperature, it doesn't show a tooltip with the conversions nor does it show the temperature normalized to K with other values in parentheses in the factbox. This is a change from 0.7 behavior, which always showed the conversion. The test page also shows some weirdness with bad or dubious temperature values such as [[temperature test::-43F]] , they don't output any errors.
Created attachment 4461 [details] switch on right variable, also remove unneeded case and addError (review!) I don't trust Eclipse Create patch on Windows, here's the patch. Note the last change: should SMW be aggressive on bad units or flexible? Index: C:/xampplite/htdocs/mediawiki/extensions/SemanticMediaWiki/includes/SMW_DV_Temperature.php =================================================================== --- C:/xampplite/htdocs/mediawiki/extensions/SemanticMediaWiki/includes/SMW_DV_Temperature.php (revision 28741) +++ C:/xampplite/htdocs/mediawiki/extensions/SemanticMediaWiki/includes/SMW_DV_Temperature.php (working copy) @@ -27,7 +27,7 @@ // Find current ID and covert main values to Kelvin, if possible // Note: there is no error when unknown units are used. $this->m_unitin = $this->getUnitID($this->m_unit); - switch ( $this->m_unit ) { + switch ( $this->m_unitin ) { case 'K': $this->m_unit = 'K'; break; @@ -35,7 +35,7 @@ $this->m_unit = 'K'; $this->m_value = $this->m_value + 273.15; break; - case '°F': case 'Fahrenheit': + case '°F': $this->m_unit = 'K'; $this->m_value = ($this->m_value - 32) /1.8 + 273.15; break; @@ -40,6 +40,10 @@ $this->m_value = ($this->m_value - 32) /1.8 + 273.15; break; default: //unsupported unit + // TODO: Should this be an error? Without addError(), SMW displays + // and stores your temperature, but doesn't convert it. + // Maybe have an addWarning()? + $this->addError(wfMsgForContent('smw_unsupportedunit',$this->m_unit)); $this->m_unit = $this->m_unitin; break; }
OK, I applied that patch manually. I agree that an error message is appropriate for unsupported units here, since unsupported temperature units should be due to typos in almost any case where type:temperature would be used.