Index: trunk/extensions/SemanticDrilldown/specials/SD_BrowseData.php |
— | — | @@ -310,6 +310,25 @@ |
311 | 311 | } |
312 | 312 | |
313 | 313 | /** |
| 314 | + * Print a "nice" version of the value for a filter, if it's some |
| 315 | + * special case like 'other', 'none', a boolean, etc. |
| 316 | + */ |
| 317 | + function printFilterValue($filter, $value) { |
| 318 | + $value = str_replace('_', ' ', $value); |
| 319 | + // if it's boolean, display something nicer than "0" or "1" |
| 320 | + if ($value === ' other') |
| 321 | + return wfMsg('sd_browsedata_other'); |
| 322 | + elseif ($value === ' none') |
| 323 | + return wfMsg('sd_browsedata_none'); |
| 324 | + elseif ($filter->is_boolean) |
| 325 | + return SDUtils::booleanToString($value); |
| 326 | + elseif ($filter->is_date && strpos($value, '//T')) |
| 327 | + return str_replace('//T', '', $value); |
| 328 | + else |
| 329 | + return $value; |
| 330 | + } |
| 331 | + |
| 332 | + /** |
314 | 333 | * Print the line showing 'OR' values for a filter that already has |
315 | 334 | * at least one value set |
316 | 335 | */ |
— | — | @@ -346,16 +365,7 @@ |
347 | 366 | $or_values[] = '_none'; |
348 | 367 | foreach ($or_values as $i => $value) { |
349 | 368 | if ($i > 0) { $results_line .= " · "; } |
350 | | - $value = str_replace('_', ' ', $value); |
351 | | - // if it's boolean, display something nicer than "0" or "1" |
352 | | - if ($value === ' other') |
353 | | - $filter_text = wfMsg('sd_browsedata_other'); |
354 | | - elseif ($value === ' none') |
355 | | - $filter_text = wfMsg('sd_browsedata_none'); |
356 | | - elseif ($af->filter->is_boolean) |
357 | | - $filter_text = SDUtils::booleanToString($value); |
358 | | - else |
359 | | - $filter_text = $value; |
| 369 | + $filter_text = $this->printFilterValue($af->filter, $value); |
360 | 370 | $applied_filters = $this->applied_filters; |
361 | 371 | foreach ($applied_filters as $af2) { |
362 | 372 | if ($af->filter->name == $af2->filter->name) { |
— | — | @@ -415,15 +425,7 @@ |
416 | 426 | $num_printed_values = 0; |
417 | 427 | foreach ($filter_values as $value_str => $num_results) { |
418 | 428 | if ($num_printed_values++ > 0) { $results_line .= " · "; } |
419 | | - // if it's boolean, display something nicer than "0" or "1" |
420 | | - if ($value_str === '_other') |
421 | | - $filter_text = wfMsg('sd_browsedata_other'); |
422 | | - elseif ($value_str === '_none') |
423 | | - $filter_text = wfMsg('sd_browsedata_none'); |
424 | | - elseif ($f->is_boolean) |
425 | | - $filter_text = SDUtils::booleanToString($value_str); |
426 | | - else |
427 | | - $filter_text = str_replace('_', ' ', $value_str); |
| 429 | + $filter_text = $this->printFilterValue($f, $value_str); |
428 | 430 | $filter_text .= " ($num_results)"; |
429 | 431 | $filter_url = $cur_url . urlencode(str_replace(' ', '_', $f->name)) . '=' . urlencode(str_replace(' ', '_', $value_str)); |
430 | 432 | if ($sdgFiltersSmallestFontSize > 0 && $sdgFiltersLargestFontSize > 0) { |
— | — | @@ -693,14 +695,7 @@ |
694 | 696 | } |
695 | 697 | foreach ($af->values as $j => $fv) { |
696 | 698 | if ($j > 0) {$header .= ' <span class="drilldown-or">' . wfMsg('sd_browsedata_or') . '</span> ';} |
697 | | - if ($fv->text == ' other') |
698 | | - $filter_text = wfMsg('sd_browsedata_other'); |
699 | | - elseif ($fv->text == ' none') |
700 | | - $filter_text = wfMsg('sd_browsedata_none'); |
701 | | - elseif ($af->filter->is_boolean) |
702 | | - $filter_text = SDUtils::booleanToString($fv->text); |
703 | | - else |
704 | | - $filter_text = $fv->text; |
| 699 | + $filter_text = $this->printFilterValue($af->filter, $fv->text); |
705 | 700 | $temp_filters_array = $this->applied_filters; |
706 | 701 | $removed_values = array_splice($temp_filters_array[$i]->values, $j, 1); |
707 | 702 | $remove_filter_url = $this->makeBrowseURL($this->category, $temp_filters_array, $this->subcategory); |
— | — | @@ -859,7 +854,7 @@ |
860 | 855 | $printouts = $params = array(); |
861 | 856 | // only one set of params is handled for now |
862 | 857 | if (count($all_display_params) > 0) { |
863 | | - $display_params = $all_display_params[0]; |
| 858 | + $display_params = array_map('trim', $all_display_params[0]); |
864 | 859 | SMWQueryProcessor::processFunctionParams($display_params, $querystring, $params, $printouts); |
865 | 860 | } |
866 | 861 | if (array_key_exists('format', $params)) |