Index: views_cloud.module =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/views_cloud/views_cloud.module,v retrieving revision 1.3 diff -u -r1.3 views_cloud.module --- views_cloud.module 17 Sep 2008 16:02:42 -0000 1.3 +++ views_cloud.module 17 Nov 2009 21:22:11 -0000 @@ -53,9 +53,9 @@ } } } - + foreach ($vars['rows'] as $num => $row) { - $vars['rows'][$num]['cloud_size'] = _views_cloud_size_helper($result[$num]->{$weight_field_alias}, $min, $max); + $vars['rows'][$num]['cloud_size'] = views_cloud_size_helper($result[$num]->{$weight_field_alias}, $min, $max, 7, $view->style_plugin->options['algorithm']); $vars['rows'][$num] = (object)$vars['rows'][$num]; } @@ -106,7 +106,7 @@ } foreach ($vars['rows'] as $id => $row) { - $vars['rows'][$id]->cloud_size = _views_cloud_size_helper($vars['rows'][$id]->count, $min, $max); + $vars['rows'][$id]->cloud_size = views_cloud_size_helper($vars['rows'][$id]->count, $min, $max, 7, $view->style_plugin->options['algorithm']); } if (!empty($view->style_plugin->options['randomize'])) { @@ -114,10 +114,23 @@ } } - -function _views_cloud_size_helper($value, $min, $max, $sizes = 7) { +/** + * Algorithm for calculating relative size that is linear. + */ +function views_cloud_size_helper($value, $min, $max, $sizes = 7, $algorithm = 'log') { if ($min == $max) return 1; - $range = ($sizes - 1) / ($max - $min); - $value = ($value - $min) * $range; - return (intval($value + 1)); + + if ($algorithm == 'linear') { + $range = ($sizes - 1) / ($max - $min); + $value = ($value - $min) * $range; + return (intval($value + 1)); + } + else { + $value = log($value == 0 ? ++$value : $value); + $min = log($min == 0 ? ++$min : $min); + $max = log($max); + $range = ($sizes - 1) / ($max - $min); + $value = ($value - $min) * $range; + return (intval($value + 1)); + } } Index: views_cloud_plugin_summary_style_cloud.inc =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/views_cloud/views_cloud_plugin_summary_style_cloud.inc,v retrieving revision 1.1 diff -u -r1.1 views_cloud_plugin_summary_style_cloud.inc --- views_cloud_plugin_summary_style_cloud.inc 17 Sep 2008 16:02:42 -0000 1.1 +++ views_cloud_plugin_summary_style_cloud.inc 17 Nov 2009 21:22:11 -0000 @@ -7,6 +7,7 @@ function option_definition() { $options = parent::option_definition(); $options['randomize'] = array('default' => TRUE); + $options['algorithm'] = array('default' => 'log'); return $options; } @@ -18,7 +19,14 @@ '#title' => t('Randomize the order of items'), '#description' => t("This setting respects the View's sort order when limiting large paged lists, but shuffles each list of items when displayed on the page."), '#default_value' => $this->options['randomize'], - ); - + ); + + $form['algorithm'] = array( + '#type' => 'select', + '#title' => t('Weight to size algorithm'), + '#description' => t("Select the item weight sizing algorithm, linear or logarithmic. Logarithmic emphasizes the relative weight of items."), + '#options' => array('log' => t('Logarithmic'), 'linear' => t('Linear')), + '#default_value' => $this->options['algorithm'], + ); } } Index: views_cloud_plugin_style_cloud.inc =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/views_cloud/views_cloud_plugin_style_cloud.inc,v retrieving revision 1.2 diff -u -r1.2 views_cloud_plugin_style_cloud.inc --- views_cloud_plugin_style_cloud.inc 17 Sep 2008 16:02:42 -0000 1.2 +++ views_cloud_plugin_style_cloud.inc 17 Nov 2009 21:22:11 -0000 @@ -7,6 +7,7 @@ function option_definition() { $options = parent::option_definition(); $options['randomize'] = array('default' => TRUE); + $options['algorithm'] = array('default' => 'log'); $options['weight_field'] = array('default' => NULL); $options['hide_weight_field'] = array('default' => TRUE); return $options; @@ -37,7 +38,7 @@ '#options' => $options, '#default_value' => $this->options['weight_field'], ); - + $form['hide_weight_field'] = array( '#type' => 'checkbox', '#title' => t('Hide weight field'), @@ -51,6 +52,14 @@ '#description' => t("This setting respects the View's sort order when limiting large paged lists, but shuffles each list of items when displayed on the page."), '#default_value' => $this->options['randomize'], ); - + + $form['algorithm'] = array( + '#type' => 'select', + '#title' => t('Weight to size algorithm'), + '#description' => t("Select the item weight sizing algorithm, linear or logarithmic. Logarithmic emphasizes the relative weight of items."), + '#options' => array('log' => t('Logarithmic'), 'linear' => t('Linear')), + '#default_value' => $this->options['algorithm'], + ); + } }