Index: trunk/extensions/SemanticMediaWiki/includes/SMW_Datatype.php |
— | — | @@ -166,7 +166,6 @@ |
167 | 167 | SMWTypeHandlerFactory::$typeHandlersByLabel[$typelabel] = $instance; |
168 | 168 | return SMWTypeHandlerFactory::$typeHandlersByLabel[$typelabel]; |
169 | 169 | } |
170 | | - // if (count($conversionFactors) == 0) print "DEBUG: in getTypeHandlerByLabel(), tried and failed to find conversionFactors for $typelabel, this shouldn't happen!!?'\n<br />"; |
171 | 170 | |
172 | 171 | return new SMWErrorTypeHandler(wfMsgForContent('smw_unknowntype',$typelabel)); |
173 | 172 | } |
— | — | @@ -187,7 +186,6 @@ |
188 | 187 | if (count($typearray)==1) { |
189 | 188 | SMWTypeHandlerFactory::$typeHandlersByAttribute[$attribute] = |
190 | 189 | SMWTypeHandlerFactory::getTypeHandlerByLabel($typearray[0]); |
191 | | - // print "DEBUG: getTypeHandler() found value $typearray[0] with new smwfGetSpecialPropertyValues\n<br />"; |
192 | 190 | } elseif (count($typearray)==0) { |
193 | 191 | SMWTypeHandlerFactory::$typeHandlersByAttribute[$attribute] = |
194 | 192 | new SMWErrorTypeHandler(wfMsgForContent('smw_notype')); |
— | — | @@ -248,7 +246,6 @@ |
249 | 247 | if ( ($ttitle !== NULL) && ($ttitle->exists()) ) { |
250 | 248 | $result = smwfGetSpecialPropertyValues($ttitle, SMW_SP_CONVERSION_FACTOR); |
251 | 249 | if (count($result) == 0) { |
252 | | - // print "DEBUG: getConversionFactors() for $type found nothing!<br />\n"; |
253 | 250 | $result = array(); |
254 | 251 | } |
255 | 252 | } |
— | — | @@ -281,7 +278,10 @@ |
282 | 279 | } // SMWTypeHandlerFactory |
283 | 280 | |
284 | 281 | //*** Make other typehandlers known that are shipped with SMW ***// |
285 | | - |
| 282 | +/** |
| 283 | + * If you add a typehandler in a separate file from this one (SMW_Datatype.php) |
| 284 | + * then you must add it to this list! |
| 285 | + */ |
286 | 286 | // Integer |
287 | 287 | SMWTypeHandlerFactory::announceTypeHandler($smwgContLang->getDatatypeLabel('smw_int'),'int','Integer','SMWIntegerTypeHandler'); |
288 | 288 | // URLs etc. |
— | — | @@ -546,6 +546,7 @@ |
547 | 547 | $xsdvalue = -1; // initialize to failure |
548 | 548 | // See http://en.wikipedia.org/wiki/Boolean_datatype |
549 | 549 | // TODO: To save code, trim values before they get to processValue(). |
| 550 | + |
550 | 551 | $vlc = strtolower(trim($value)); |
551 | 552 | if ($vlc!='') { //do not accept empty strings |
552 | 553 | // Look for universal true/false and 1/0, |
— | — | @@ -564,10 +565,23 @@ |
565 | 566 | } else { |
566 | 567 | $datavalue->setError(wfMsgForContent('smw_emptystring')); |
567 | 568 | } |
| 569 | + |
568 | 570 | if ($xsdvalue === 'true' || $xsdvalue === 'false') { |
569 | 571 | // Store numeric 1 or 0 as number. |
570 | 572 | $datavalue->setProcessedValues($value, $xsdvalue, $xsdvalue === 'true' ? 1 : 0); |
571 | | - $datavalue->setPrintoutString($xsdvalue); |
| 573 | + // For a boolean, "units" is really a format from an inline query |
| 574 | + // rather than the units of a float. |
| 575 | + $desiredUnits = $datavalue->getDesiredUnits(); |
| 576 | + // Determine the user-visible string. |
| 577 | + if (count($desiredUnits) ==0) { |
| 578 | + $datavalue->setPrintoutString($xsdvalue); |
| 579 | + } else { |
| 580 | + // The units is a string for 'true', a comma, and a string for 'false'. |
| 581 | + foreach ($desiredUnits as $wantedFormat) { |
| 582 | + list($true_text, $false_text) = explode(',', $wantedFormat, 2); |
| 583 | + $datavalue->setPrintoutString($xsdvalue === 'true' ? $true_text : $false_text); |
| 584 | + } |
| 585 | + } |
572 | 586 | $datavalue->addQuicksearchLink(); |
573 | 587 | } |
574 | 588 | return true; |