[MediaWiki-commits] [Gerrit] Fixes for new logarithmic tag cloud display - change (mediawiki...SemanticDrilldown)
Yaron Koren has submitted this change and it was merged. Change subject: Fixes for new logarithmic tag cloud display .. Fixes for new logarithmic tag cloud display The logarithmic display is now the only option (the LocalSettings.php setting was removed), the display is now correct for subcategories as well (before, it was just for filter values), and handling was fixed if there's no difference between the lowest and highest number of values. Change-Id: Ic6a7f38063d60b1b611a263a8e7f2a27e9f494a8 --- M SemanticDrilldown.php M specials/SD_BrowseData.php 2 files changed, 17 insertions(+), 16 deletions(-) Approvals: Yaron Koren: Verified; Looks good to me, approved jenkins-bot: Checked diff --git a/SemanticDrilldown.php b/SemanticDrilldown.php index 98f05a5..1b0c58b 100644 --- a/SemanticDrilldown.php +++ b/SemanticDrilldown.php @@ -121,8 +121,6 @@ // set these to a positive value to trigger the "tag cloud" display $sdgFiltersSmallestFontSize = - 1; $sdgFiltersLargestFontSize = - 1; -// logarithmic scale? -$sdgFiltersLogScale = 0; // print categories list as tabs $sdgShowCategoriesAsTabs = false; diff --git a/specials/SD_BrowseData.php b/specials/SD_BrowseData.php index 7eeca19..7aa980a 100644 --- a/specials/SD_BrowseData.php +++ b/specials/SD_BrowseData.php @@ -587,7 +587,7 @@ } function printUnappliedFilterValues( $cur_url, $f, $filter_values ) { - global $sdgFiltersSmallestFontSize, $sdgFiltersLargestFontSize, $sdgFiltersLogScale; + global $sdgFiltersSmallestFontSize, $sdgFiltersLargestFontSize; $results_line = ""; // set font-size values for filter "tag cloud", if the @@ -595,10 +595,9 @@ if ( $sdgFiltersSmallestFontSize > 0 && $sdgFiltersLargestFontSize > 0 ) { $lowest_num_results = min( $filter_values ); $highest_num_results = max( $filter_values ); - $scale_factor = ( $sdgFiltersLargestFontSize - $sdgFiltersSmallestFontSize ) / ( $highest_num_results - $lowest_num_results ); -if( $sdgFiltersLogScale ){ - $scale_factor = ( $sdgFiltersLargestFontSize - $sdgFiltersSmallestFontSize ) / ( log($highest_num_results) - log($lowest_num_results) ); -} + if ( $lowest_num_results != $highest_num_results ) { + $scale_factor = ( $sdgFiltersLargestFontSize - $sdgFiltersSmallestFontSize ) / ( log($highest_num_results) - log($lowest_num_results) ); + } } // now print the values $num_printed_values = 0; @@ -608,10 +607,11 @@ $filter_text .= " ($num_results)"; $filter_url = $cur_url . urlencode( str_replace( ' ', '_', $f->name ) ) . '=' . urlencode( str_replace( ' ', '_', $value_str ) ); if ( $sdgFiltersSmallestFontSize > 0 && $sdgFiltersLargestFontSize > 0 ) { - $font_size = round( (($num_results - $lowest_num_results) * $scale_factor ) + $sdgFiltersSmallestFontSize ); -if( $sdgFiltersLogScale ){ - $font_size = round( ((log($num_results) - log($lowest_num_results)) * $scale_factor ) + $sdgFiltersSmallestFontSize ); -} + if ( $lowest_num_results != $highest_num_results ) { + $font_size = round( ((log($num_results) - log($lowest_num_results)) * $scale_factor ) + $sdgFiltersSmallestFontSize ); + } else { + $font_size = ( $sdgFiltersSmallestFontSize + $sdgFiltersLargestFontSize ) / 2; + } $results_line .= "\n " . '' . $filter_text . ''; } else { $results_line .= "\n " . '' . $filter_text . ''; @@ -900,10 +900,9 @@ if ( $sdgFiltersSmallestFontSize > 0 && $sdgFiltersLargestFontSize > 0 ) { $lowest_num_results = min( $subcat_values ); $highest_num_results = max( $subcat_values ); - $num_results_midpoint = ( $lowest_num_results + $highest_num_results ) / 2; - $font_size_midpoint = ( $sdgFiltersSmallestFontSize + $sdgFiltersLargestFontSize ) / 2; - $num_results_per_font_pixel = ( $highest_num_results + 1 - $lowest_num_results ) / - ( $sdgFiltersLargestFontSize + 1 - $sdgFiltersSmallestFontSize ); +
[MediaWiki-commits] [Gerrit] Fixes for new logarithmic tag cloud display - change (mediawiki...SemanticDrilldown)
Yaron Koren has uploaded a new change for review. https://gerrit.wikimedia.org/r/64925 Change subject: Fixes for new logarithmic tag cloud display .. Fixes for new logarithmic tag cloud display The logarithmic display is now the only option (the LocalSettings.php setting was removed), the display is now correct for subcategories as well (before, it was just for filter values), and handling was fixed if there's no difference between the lowest and highest number of values. Change-Id: Ic6a7f38063d60b1b611a263a8e7f2a27e9f494a8 --- M SemanticDrilldown.php M specials/SD_BrowseData.php 2 files changed, 17 insertions(+), 16 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/SemanticDrilldown refs/changes/25/64925/1 diff --git a/SemanticDrilldown.php b/SemanticDrilldown.php index 98f05a5..1b0c58b 100644 --- a/SemanticDrilldown.php +++ b/SemanticDrilldown.php @@ -121,8 +121,6 @@ // set these to a positive value to trigger the "tag cloud" display $sdgFiltersSmallestFontSize = - 1; $sdgFiltersLargestFontSize = - 1; -// logarithmic scale? -$sdgFiltersLogScale = 0; // print categories list as tabs $sdgShowCategoriesAsTabs = false; diff --git a/specials/SD_BrowseData.php b/specials/SD_BrowseData.php index 7eeca19..7aa980a 100644 --- a/specials/SD_BrowseData.php +++ b/specials/SD_BrowseData.php @@ -587,7 +587,7 @@ } function printUnappliedFilterValues( $cur_url, $f, $filter_values ) { - global $sdgFiltersSmallestFontSize, $sdgFiltersLargestFontSize, $sdgFiltersLogScale; + global $sdgFiltersSmallestFontSize, $sdgFiltersLargestFontSize; $results_line = ""; // set font-size values for filter "tag cloud", if the @@ -595,10 +595,9 @@ if ( $sdgFiltersSmallestFontSize > 0 && $sdgFiltersLargestFontSize > 0 ) { $lowest_num_results = min( $filter_values ); $highest_num_results = max( $filter_values ); - $scale_factor = ( $sdgFiltersLargestFontSize - $sdgFiltersSmallestFontSize ) / ( $highest_num_results - $lowest_num_results ); -if( $sdgFiltersLogScale ){ - $scale_factor = ( $sdgFiltersLargestFontSize - $sdgFiltersSmallestFontSize ) / ( log($highest_num_results) - log($lowest_num_results) ); -} + if ( $lowest_num_results != $highest_num_results ) { + $scale_factor = ( $sdgFiltersLargestFontSize - $sdgFiltersSmallestFontSize ) / ( log($highest_num_results) - log($lowest_num_results) ); + } } // now print the values $num_printed_values = 0; @@ -608,10 +607,11 @@ $filter_text .= " ($num_results)"; $filter_url = $cur_url . urlencode( str_replace( ' ', '_', $f->name ) ) . '=' . urlencode( str_replace( ' ', '_', $value_str ) ); if ( $sdgFiltersSmallestFontSize > 0 && $sdgFiltersLargestFontSize > 0 ) { - $font_size = round( (($num_results - $lowest_num_results) * $scale_factor ) + $sdgFiltersSmallestFontSize ); -if( $sdgFiltersLogScale ){ - $font_size = round( ((log($num_results) - log($lowest_num_results)) * $scale_factor ) + $sdgFiltersSmallestFontSize ); -} + if ( $lowest_num_results != $highest_num_results ) { + $font_size = round( ((log($num_results) - log($lowest_num_results)) * $scale_factor ) + $sdgFiltersSmallestFontSize ); + } else { + $font_size = ( $sdgFiltersSmallestFontSize + $sdgFiltersLargestFontSize ) / 2; + } $results_line .= "\n " . '' . $filter_text . ''; } else { $results_line .= "\n " . '' . $filter_text . ''; @@ -900,10 +900,9 @@ if ( $sdgFiltersSmallestFontSize > 0 && $sdgFiltersLargestFontSize > 0 ) { $lowest_num_results = min( $subcat_values ); $highest_num_results = max( $subcat_values ); - $num_results_midpoint = ( $lowest_num_results + $highest_num_results ) / 2; - $font_size_midpoint = ( $sdgFiltersSmallestFontSize + $sdgFiltersLargestFontSize ) / 2; - $num_results_per_font_pixel = ( $highest_num_results + 1 - $lowest_num_results ) / - ( $sdgFiltersLargestFontSize + 1 - $sdgFi