r58435 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r58434‎ | r58435 | r58436 >
Date:18:28, 2 November 2009
Author:yaron
Status:deferred
Tags:
Comment:
Added printFilterValue() helper function, fixed problem with whitespaces in 'Has display parameters' causing printout properties to get ignored
Modified paths:
  • /trunk/extensions/SemanticDrilldown/specials/SD_BrowseData.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SemanticDrilldown/specials/SD_BrowseData.php
@@ -310,6 +310,25 @@
311311 }
312312
313313 /**
 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+ /**
314333 * Print the line showing 'OR' values for a filter that already has
315334 * at least one value set
316335 */
@@ -346,16 +365,7 @@
347366 $or_values[] = '_none';
348367 foreach ($or_values as $i => $value) {
349368 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);
360370 $applied_filters = $this->applied_filters;
361371 foreach ($applied_filters as $af2) {
362372 if ($af->filter->name == $af2->filter->name) {
@@ -415,15 +425,7 @@
416426 $num_printed_values = 0;
417427 foreach ($filter_values as $value_str => $num_results) {
418428 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);
428430 $filter_text .= " ($num_results)";
429431 $filter_url = $cur_url . urlencode(str_replace(' ', '_', $f->name)) . '=' . urlencode(str_replace(' ', '_', $value_str));
430432 if ($sdgFiltersSmallestFontSize > 0 && $sdgFiltersLargestFontSize > 0) {
@@ -693,14 +695,7 @@
694696 }
695697 foreach ($af->values as $j => $fv) {
696698 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);
705700 $temp_filters_array = $this->applied_filters;
706701 $removed_values = array_splice($temp_filters_array[$i]->values, $j, 1);
707702 $remove_filter_url = $this->makeBrowseURL($this->category, $temp_filters_array, $this->subcategory);
@@ -859,7 +854,7 @@
860855 $printouts = $params = array();
861856 // only one set of params is handled for now
862857 if (count($all_display_params) > 0) {
863 - $display_params = $all_display_params[0];
 858+ $display_params = array_map('trim', $all_display_params[0]);
864859 SMWQueryProcessor::processFunctionParams($display_params, $querystring, $params, $printouts);
865860 }
866861 if (array_key_exists('format', $params))

Status & tagging log