diff --git a/cumulus.info b/cumulus.info
index 431aac9..856e23a 100644
--- a/cumulus.info
+++ b/cumulus.info
@@ -1,5 +1,8 @@
name = Cumulus
description = "Cumulus is a Views style plugin that provides a Flash-based 3D tag cloud."
-core = 6.x
+core = 7.x
dependencies[] = views
package = Views
+files[] = includes/views/cumulus.views.inc
+files[] = includes/views/views_cumulus_style_plugin.inc
+files[] = includes/views/views_cumulus_summary_style_plugin.inc
\ No newline at end of file
diff --git a/cumulus.module b/cumulus.module
index 27a7703..29adc77 100644
--- a/cumulus.module
+++ b/cumulus.module
@@ -9,7 +9,7 @@
*/
/**
- * Implementation of hook_enable().
+ * Implements hook_enable().
*/
function cumulus_enable() {
drupal_set_message(t('Cumulus has now been enabled. You need to !add a view with cumulus selected as output style to display the cloud. Or !activate the example view for a taxonomy cumulus block.', array('!add' => l(t('add'), 'admin/build/views/add'), '!activate' => l(t('activate'), 'admin/build/views'))));
@@ -19,12 +19,12 @@ function cumulus_enable() {
}
/**
- * Implementation of hook_views_api().
+ * Implements hook_views_api().
* Notifies the Views module that we're compatible with a particular API revision.
*/
function cumulus_views_api() {
return array(
- 'api' => 2,
+ 'api' => 3,
'path' => drupal_get_path('module', 'cumulus') . '/includes/views',
);
}
@@ -36,13 +36,65 @@ function cumulus_views_api() {
* Array of template variables.
*/
function template_preprocess_views_view_cumulus(&$vars) {
+ $cumulus = array();
+ foreach($vars['view']->style_plugin->rendered_fields as $item) {
+ if (isset($cumulus[$item[$vars['view']->style_options['unique_id']]])) {
+ $cumulus[$item[$vars['view']->style_options['unique_id']]]['#count']++;
+ }
+ else {
+ $cumulus[$item[$vars['view']->style_options['unique_id']]] = (object) $item;
+ $cumulus[$item[$vars['view']->style_options['unique_id']]]->__count = 1;
+ }
+ }
+
+ $fields = array(
+ 'title' => $vars['view']->style_options['title_field'],
+ 'href' => $vars['view']->style_options['link_field'],
+ );
+ $vars['cumulus'] = theme('cumulus_embed', array('tags' => $cumulus, 'fields' => $fields, 'config' => $vars['view']->style_options));
+}
- dpm($vars['view']->style_plugin->rendered_fields);
+/**
+ * API that returns an array with weighted tags
+ * This is the hard part. People with better ideas are very very welcome to
+ * send these to ber@webschuur.com. Distribution is one thing that needs
+ * attention.
+ *
+ * @param $tags
+ * Alist of objects with the following attributes: $tag->count,
+ * $tag->tid, $tag->name and $tag->vid. Each Tag will be calculated and
+ * turned into a tag. Refer to tagadelic_get_weighted_tags() for an example.
+ * @param $steps
+ * The amount of tag-sizes you will be using. If you give "12" you sill get
+ * six different "weights". Defaults to 6 and is optional.
+ * @return
+ * An unordered array with tags-objects, containing the attribute
+ * $tag->weight;
+ */
+function cumulus_build_weighted_tags($tags, $steps = 6) {
+ // Find minimum and maximum log-count. By our MatheMagician Steven Wittens aka UnConeD.
+ $tags_tmp = array();
+ $min = 1e9;
+ $max = -1e9;
+ foreach ($tags as $id => $tag) {
+ $tag->__number_of_posts = $tag->__count;
+ $tag->__count = log($tag->__count);
+ $min = min($min, $tag->__count);
+ $max = max($max, $tag->__count);
+ $tags_tmp[$id] = $tag;
+ }
+ // Note: we need to ensure the range is slightly too large to make sure even
+ // the largest element is rounded down.
+ $range = max(.01, $max - $min) * 1.0001;
+ foreach ($tags_tmp as $key => $value) {
+ $tags[$key]->__weight = 1 + floor($steps * ($value->__count - $min) / $range);
+ }
+ return $tags;
}
/**
- * Implementation of hook_help().
+ * Implements hook_help().
*/
function cumulus_help($path, $arg) {
switch ($path) {
@@ -53,165 +105,123 @@ function cumulus_help($path, $arg) {
}
function cumulus_views_options() {
- $options = array();
- $options['title_field'] = array('default' => '');
- $options['link_field'] = array('default' => '');
- $options['use_field_as_weight']['weight_text'] = array('default' => 0);
- $options['use_field_as_weight']['weight_field'] = array('default' => '');
- $options['size_interval'] = array('default' => 6);
- $options['flash_width'] = array('default' => 200);
- $options['flash_height'] = array('default' => 150);
- $options['flash_background'] = array('default' => 'ffffff');
- $options['flash_transparency'] = array('default' => 'false');
- $options['flash_color'] = array('default' => 'ff0000');
- $options['flash_color2'] = array('default' => '000000');
- $options['flash_hicolor'] = array('default' => '666666');
- $options['flash_speed'] = array('default' => 100);
- $options['flash_distribute'] = array('default' => 'true');
- $options['flash_font_size'] = array('default' => 10);
- $options['flash_font_size_interval'] = array('default' => 2);
- return $options;
-}
-
-function cumulus_views_options_form(&$form, &$form_state, $view) {
-
- if ($view->definition['type'] === 'normal') {
- $fields = $view->view->display_handler->get_handlers('field');
- if (count($fields)) {
- $options = array('' => t(''));
- foreach ($fields as $field => $handler) {
- if ($label = $handler->label()) {
- $options[$field] = $label;
- }
- else {
- $options[$field] = $handler->ui_name();
- }
- }
- $form['title_field'] = array(
- '#type' => 'select',
- '#title' => t('Title field'),
- '#options' => $options,
- '#default_value' => $view->options['title_field'],
- '#description' => t('Select the field that should be used as the items title in the cloud.'),
- );
- $form['link_field'] = array(
- '#type' => 'select',
- '#title' => t('Link field'),
- '#options' => $options,
- '#default_value' => $view->options['link_field'],
- '#description' => t('Select the field that should be used as the items link in the cloud.'),
- );
- $form['use_field_as_weight']['#tree'] = TRUE;
- $form['use_field_as_weight']['weight_text'] = array(
- '#type' => 'checkbox',
- '#title' => t('Use a field as source for weight calculation'),
- '#description' => t('If checked, you can select a field that is use as source for weight calculation instead of using the sort order.'),
- '#default_value' => $view->options['use_field_as_weight']['weight_text'],
- );
- $form['use_field_as_weight']['weight_field'] = array(
- '#type' => 'select',
- '#title' => t('Weight field'),
- '#options' => $options,
- '#default_value' => $view->options['use_field_as_weight']['weight_field'],
- '#description' => t('Select the field that should be used for weight calculation.'),
- '#process' => array('views_process_dependency'),
- '#dependency' => array(
- 'edit-style-options-use-field-as-weight-weight-text' => array(1)
- ),
- );
- }
- else {
- drupal_set_message(t('You need to define at least two fields to set up a cumulus cloud view. 1. Name of the link. 2. URL for the link. And 3. Optional weight.', 'error'));
- }
- }
- $form['size_interval'] = array(
- '#type' => 'textfield',
- '#title' => t('Item size interval'),
- '#default_value' => $view->options['size_interval'],
- '#maxlength' => 2,
- '#description' => t('The number of item sizes you want to use.'),
- );
- $form['flash_transparency'] = array(
- '#type' => 'select',
- '#title' => t('Background transparency'),
- '#default_value' => $view->options['flash_transparency'],
- '#options' => array(
- 'false' => t('no'),
- 'true' => t('yes'),
+ return array(
+ 'unique_id' => array('default' => ''),
+ 'title_field' => array('default' => ''),
+ 'link_field' => array('default' => ''),
+ 'use_field_as_weight' => array(
+ 'weight_text' => array('default' => 0),
+ 'weight_field' => array('default' => ''),
),
- '#description' => t('Enabling background transparency might cause issues with some (mostly older) browsers.
Under Linux, transparency doesn\'t work at all due to a known limitation in the current Flash player.'),
- );
- $form['flash_width'] = array(
- '#type' => 'textfield',
- '#title' => t('Width of cumulus'),
- '#default_value' => $view->options['flash_width'],
- '#maxlength' => 3,
- '#description' => t('The width of the cumulus in pixels.'),
- );
- $form['flash_height'] = array(
- '#type' => 'textfield',
- '#title' => t('Height of cumulus'),
- '#default_value' => $view->options['flash_height'],
- '#maxlength' => 3,
- '#description' => t('The height of the cumulus in pixels.'),
- );
- $form['flash_background'] = array(
- '#type' => 'textfield',
- '#title' => t('Background color of cumulus'),
- '#default_value' => $view->options['flash_background'],
- '#maxlength' => 6,
- '#description' => t('The hex color value for the background of the cumulus. E.g. ffffff. If "Background transparency" is enabled, this option will have no effect.'),
- );
- $form['flash_color'] = array(
- '#type' => 'textfield',
- '#title' => t('Font color of cumulus'),
- '#default_value' => $view->options['flash_color'],
- '#maxlength' => 6,
- '#description' => t('The hex color value you would like to use for the items. E.g. 000000.'),
- );
- $form['flash_color2'] = array(
- '#type' => 'textfield',
- '#title' => t('Second font color of cumulus'),
- '#default_value' => $view->options['flash_color2'],
- '#maxlength' => 6,
- '#description' => t('Second item color. If supplied, items will get a color from a gradient between both colors based on their sorting.'),
- );
- $form['flash_hicolor'] = array(
- '#type' => 'textfield',
- '#title' => t('Highlight color of cumulus'),
- '#default_value' => $view->options['flash_hicolor'],
- '#maxlength' => 6,
- '#description' => t('The hex color value you would like to use for the item mouseover/hover color'),
- );
- $form['flash_speed'] = array(
- '#type' => 'textfield',
- '#title' => t('Rotation speed'),
- '#default_value' => $view->options['flash_speed'],
- '#maxlength' => 3,
- '#description' => t('Set the speed of the cumulus. Options between 25 and 500 work best.'),
+ 'size_interval' => array('default' => 6),
+ 'flash_width' => array('default' => 200),
+ 'flash_height' => array('default' => 150),
+ 'flash_background' => array('default' => 'ffffff'),
+ 'flash_transparency' => array('default' => 'false'),
+ 'flash_color' => array('default' => 'ff0000'),
+ 'flash_color2' => array('default' => '000000'),
+ 'flash_hicolor' => array('default' => '666666'),
+ 'flash_speed' => array('default' => 100),
+ 'flash_distribute' => array('default' => 'true'),
+ 'flash_font_size' => array('default' => 10),
+ 'flash_font_size_interval' => array('default' => 2),
);
- $form['flash_distribute'] = array(
- '#type' => 'select',
- '#title' => t('Distribute items evenly on cumulus'),
- '#default_value' => $view->options['flash_distribute'],
- '#options' => array(
- 'false' => t('no'),
- 'true' => t('yes'),
+}
+
+/**
+ * Implements hook_theme().
+ */
+function cumulus_theme() {
+ return array(
+ 'cumulus_weighted' => array(
+ 'variables' => array('tags' => NULL, 'fields' => array(), 'config' => array()),
),
- '#description' => t('When enabled, the movie will attempt to distribute the items evenly over the surface of the cumulus.'),
- );
- $form['flash_font_size'] = array(
- '#type' => 'textfield',
- '#title' => t('Font size'),
- '#default_value' => $view->options['flash_font_size'],
- '#maxlength' => 2,
- '#description' => t('Set the font size of the tag with the lowest item-size in pixels (level 1).'),
+ 'cumulus_embed' => array(
+ 'variables' => array('tags' => NULL, 'fields' => array(), 'config' => array()),
+ )
);
- $form['flash_font_size_interval'] = array(
- '#type' => 'textfield',
- '#title' => t('Font size interval'),
- '#default_value' => $view->options['flash_font_size_interval'],
- '#maxlength' => 1,
- '#description' => t('Set the font size interval used for the different item-sizes (level 2 and higher).'),
+}
+
+/**
+ * Include Javascript file.
+ */
+function cumulus_init_js() {
+ $js = drupal_get_path('module', 'cumulus') . '/cumulus.js';
+ if (file_exists($js)) {
+ drupal_add_js($js, array('preprocess' => FALSE));
+ }
+ else {
+ drupal_set_message(t('The file @folder is missing. Please download it from !link, and add it to the Cumulus module folder!', array('@folder' => $js, '!link' => l('http://pratul.in/files/cumulus.js', 'http://pratul.in/files/cumulus.js'))), 'error');
+ }
+}
+
+/**
+ * Themeing function.
+ */
+function theme_cumulus_embed($variables) {
+ cumulus_init_js();
+ $config = $variables['config'];
+ $variables['tags'] = cumulus_build_weighted_tags($variables['tags']);
+ $variables['flash_tags'] = theme('cumulus_weighted', $variables);
+
+ // TODO: Implement flash alternative.
+ $variables['alt'] = '';
+
+ if ($config['flash_transparency'] == 'true') {
+ $param['transparency'] = 'widget_so.addParam("wmode", "transparent");';
+ }
+
+ // Flash params
+ $param = array(
+ 'path_to_flash' => base_path() . drupal_get_path('module', 'cumulus') . '/includes/tagcloud.swf',
+ 'width' => $config['flash_width'],
+ 'height' => $config['flash_height'],
+ 'background' => $config['flash_background'],
+ 'color' => '0x' . $config['flash_color'],
+ 'color2' => '0x' . $config['flash_color2'],
+ 'hicolor' => '0x' . $config['flash_hicolor'],
+ 'speed' => $config['flash_speed'],
+ 'distribute' => $config['flash_distribute'],
+ 'transparency' => $config['flash_transparency'],
);
+
+ $return = <<
+ {$variables['alt']}
+
+
+EOT;
+ return $return;
+}
+
+/**
+ * Themeing function.
+ */
+function theme_cumulus_weighted($variables) {
+ $tags = $variables['tags'];
+ $fields = $variables['fields'];
+ $config = $variables['config'];
+
+ $output = '';
+ foreach ($tags as $tag) {
+ // assign font size
+ $font_size = (intval($tag->__weight) * $config['flash_font_size_interval']) + ($config['flash_font_size'] - $config['flash_font_size_interval']);
+ $output .= l($tag->{$fields['title']}, $tag->{$fields['href']}, array('attributes' => array('style' => '"font-size: ' . $font_size . 'px;"'))) . " \n";
+ }
+ $output .= '';
+ $output = urlencode($output);
+ return $output;
}
diff --git a/cumulus_feature/cumulus_feature.features.inc b/cumulus_feature/cumulus_feature.features.inc
new file mode 100644
index 0000000..530a3b8
--- /dev/null
+++ b/cumulus_feature/cumulus_feature.features.inc
@@ -0,0 +1,10 @@
+ '3.0-alpha1',
+ );
+}
diff --git a/cumulus_feature/cumulus_feature.info b/cumulus_feature/cumulus_feature.info
new file mode 100644
index 0000000..82f24e9
--- /dev/null
+++ b/cumulus_feature/cumulus_feature.info
@@ -0,0 +1,10 @@
+core = "7.x"
+dependencies[] = "cumulus"
+dependencies[] = "taxonomy"
+description = "Cumulus demo"
+features[views][] = "cumulus_node"
+features[views_api][] = "api:3.0-alpha1"
+name = "Cumulus feature"
+package = "Features"
+project = "cumulus_feature"
+version = "7.x-1.0"
diff --git a/cumulus_feature/cumulus_feature.module b/cumulus_feature/cumulus_feature.module
new file mode 100644
index 0000000..6254e43
--- /dev/null
+++ b/cumulus_feature/cumulus_feature.module
@@ -0,0 +1,3 @@
+name = 'cumulus_node';
+ $view->description = '';
+ $view->tag = '';
+ $view->base_table = 'node';
+ $view->human_name = 'cumulus_node';
+ $view->core = 7;
+ $view->api_version = '3.0-alpha1';
+ $view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */
+
+ /* Display: Defaults */
+ $handler = $view->new_display('default', 'Defaults', 'default');
+ $handler->display->display_options['access']['type'] = 'none';
+ $handler->display->display_options['cache']['type'] = 'none';
+ $handler->display->display_options['query']['type'] = 'views_query';
+ $handler->display->display_options['exposed_form']['type'] = 'basic';
+ $handler->display->display_options['pager']['type'] = 'none';
+ $handler->display->display_options['pager']['options']['offset'] = '0';
+ $handler->display->display_options['style_plugin'] = 'cumulus';
+ $handler->display->display_options['style_options']['title_field'] = 'name';
+ $handler->display->display_options['style_options']['link_field'] = 'tid_1';
+ $handler->display->display_options['style_options']['use_field_as_weight'] = array(
+ 'weight_text' => 0,
+ 'weight_field' => '',
+ );
+ $handler->display->display_options['style_options']['size_interval'] = '6';
+ $handler->display->display_options['style_options']['flash_width'] = '200';
+ $handler->display->display_options['style_options']['flash_height'] = '150';
+ $handler->display->display_options['style_options']['flash_speed'] = '100';
+ $handler->display->display_options['style_options']['flash_font_size'] = '10';
+ $handler->display->display_options['style_options']['flash_font_size_interval'] = '2';
+ /* Relationship: Taxonomy: Node */
+ $handler->display->display_options['relationships']['nid']['id'] = 'nid';
+ $handler->display->display_options['relationships']['nid']['table'] = 'taxonomy_index';
+ $handler->display->display_options['relationships']['nid']['field'] = 'nid';
+ $handler->display->display_options['relationships']['nid']['required'] = 1;
+ /* Field: Taxonomy: Term */
+ $handler->display->display_options['fields']['name']['id'] = 'name';
+ $handler->display->display_options['fields']['name']['table'] = 'taxonomy_term_data';
+ $handler->display->display_options['fields']['name']['field'] = 'name';
+ $handler->display->display_options['fields']['name']['alter']['alter_text'] = 0;
+ $handler->display->display_options['fields']['name']['alter']['make_link'] = 0;
+ $handler->display->display_options['fields']['name']['alter']['absolute'] = 0;
+ $handler->display->display_options['fields']['name']['alter']['external'] = 0;
+ $handler->display->display_options['fields']['name']['alter']['trim'] = 0;
+ $handler->display->display_options['fields']['name']['alter']['nl2br'] = 0;
+ $handler->display->display_options['fields']['name']['alter']['word_boundary'] = 1;
+ $handler->display->display_options['fields']['name']['alter']['ellipsis'] = 1;
+ $handler->display->display_options['fields']['name']['alter']['strip_tags'] = 0;
+ $handler->display->display_options['fields']['name']['alter']['html'] = 0;
+ $handler->display->display_options['fields']['name']['element_label_colon'] = 1;
+ $handler->display->display_options['fields']['name']['element_default_classes'] = 1;
+ $handler->display->display_options['fields']['name']['hide_empty'] = 0;
+ $handler->display->display_options['fields']['name']['empty_zero'] = 0;
+ $handler->display->display_options['fields']['name']['link_to_taxonomy'] = 0;
+ /* Field: Taxonomy: Term ID */
+ $handler->display->display_options['fields']['tid']['id'] = 'tid';
+ $handler->display->display_options['fields']['tid']['table'] = 'taxonomy_term_data';
+ $handler->display->display_options['fields']['tid']['field'] = 'tid';
+ $handler->display->display_options['fields']['tid']['alter']['alter_text'] = 0;
+ $handler->display->display_options['fields']['tid']['alter']['make_link'] = 0;
+ $handler->display->display_options['fields']['tid']['alter']['absolute'] = 0;
+ $handler->display->display_options['fields']['tid']['alter']['external'] = 0;
+ $handler->display->display_options['fields']['tid']['alter']['trim'] = 0;
+ $handler->display->display_options['fields']['tid']['alter']['nl2br'] = 0;
+ $handler->display->display_options['fields']['tid']['alter']['word_boundary'] = 1;
+ $handler->display->display_options['fields']['tid']['alter']['ellipsis'] = 1;
+ $handler->display->display_options['fields']['tid']['alter']['strip_tags'] = 0;
+ $handler->display->display_options['fields']['tid']['alter']['html'] = 0;
+ $handler->display->display_options['fields']['tid']['element_label_colon'] = 1;
+ $handler->display->display_options['fields']['tid']['element_default_classes'] = 1;
+ $handler->display->display_options['fields']['tid']['hide_empty'] = 0;
+ $handler->display->display_options['fields']['tid']['empty_zero'] = 0;
+ $handler->display->display_options['fields']['tid']['format_plural'] = 0;
+ /* Field: Taxonomy: Term ID */
+ $handler->display->display_options['fields']['tid_1']['id'] = 'tid_1';
+ $handler->display->display_options['fields']['tid_1']['table'] = 'taxonomy_term_data';
+ $handler->display->display_options['fields']['tid_1']['field'] = 'tid';
+ $handler->display->display_options['fields']['tid_1']['label'] = 'Link';
+ $handler->display->display_options['fields']['tid_1']['alter']['alter_text'] = 1;
+ $handler->display->display_options['fields']['tid_1']['alter']['text'] = 'taxonomy/term/[tid_1]';
+ $handler->display->display_options['fields']['tid_1']['alter']['make_link'] = 0;
+ $handler->display->display_options['fields']['tid_1']['alter']['absolute'] = 0;
+ $handler->display->display_options['fields']['tid_1']['alter']['external'] = 0;
+ $handler->display->display_options['fields']['tid_1']['alter']['trim'] = 0;
+ $handler->display->display_options['fields']['tid_1']['alter']['nl2br'] = 0;
+ $handler->display->display_options['fields']['tid_1']['alter']['word_boundary'] = 1;
+ $handler->display->display_options['fields']['tid_1']['alter']['ellipsis'] = 1;
+ $handler->display->display_options['fields']['tid_1']['alter']['strip_tags'] = 0;
+ $handler->display->display_options['fields']['tid_1']['alter']['html'] = 0;
+ $handler->display->display_options['fields']['tid_1']['element_label_colon'] = 1;
+ $handler->display->display_options['fields']['tid_1']['element_default_classes'] = 1;
+ $handler->display->display_options['fields']['tid_1']['hide_empty'] = 0;
+ $handler->display->display_options['fields']['tid_1']['empty_zero'] = 0;
+ $handler->display->display_options['fields']['tid_1']['format_plural'] = 0;
+
+ /* Display: Block */
+ $handler = $view->new_display('block', 'Block', 'block_1');
+ $translatables['cumulus_node'] = array(
+ t('Defaults'),
+ t('more'),
+ t('Apply'),
+ t('Reset'),
+ t('Sort By'),
+ t('Asc'),
+ t('Desc'),
+ t('node'),
+ t('Term'),
+ t('Term ID'),
+ t('.'),
+ t(','),
+ t('Link'),
+ t('taxonomy/term/[tid_1]'),
+ t('Block'),
+ );
+
+ $views[$view->name] = $view;
+
+ return $views;
+}
diff --git a/includes/views/cumulus.views.inc b/includes/views/cumulus.views.inc
index fe38555..7f7befc 100644
--- a/includes/views/cumulus.views.inc
+++ b/includes/views/cumulus.views.inc
@@ -11,6 +11,7 @@
* Add cumulus style plugin.
*/
function cumulus_views_plugins() {
+ $path = drupal_get_path('module', 'cumulus') . '/includes/views';
return array(
'style' => array(
'cumulus' => array(
@@ -18,13 +19,13 @@ function cumulus_views_plugins() {
'help' => t('Displays rows as an flash-based 3D "tag"-cloud.'),
'handler' => 'views_cumulus_style_plugin',
'theme' => 'views_view_cumulus',
- 'theme path' => drupal_get_path('module', 'cumulus') . '/includes/views',
+ 'theme path' => $path,
'uses row plugin' => FALSE,
'uses options' => TRUE,
'uses fields' => TRUE,
'uses grouping' => FALSE,
'type' => 'normal',
- 'path' => drupal_get_path('module', 'cumulus') . '/includes/views',
+ 'path' => $path,
),
'cumulus_summary' => array(
'title' => t('Cumulus cloud'),
@@ -32,11 +33,163 @@ function cumulus_views_plugins() {
'handler' => 'views_cumulus_summary_style_plugin',
'parent' => 'default_summary',
'theme' => 'views_view_cumulus',
- 'theme path' => drupal_get_path('module', 'cumulus') . '/includes/views',
+ 'theme path' => $path,
'type' => 'summary', // only shows up as a summary style
'uses options' => TRUE,
- 'path' => drupal_get_path('module', 'cumulus') . '/includes/views',
+ 'path' => $path,
),
),
);
}
+
+function cumulus_views_options_form(&$form, &$form_state, $view) {
+ if ($view->definition['type'] === 'normal') {
+ $fields = $view->view->display_handler->get_handlers('field');
+ if (count($fields)) {
+ $options = array('' => t(''));
+ foreach ($fields as $field => $handler) {
+ if ($label = $handler->label()) {
+ $options[$field] = $label;
+ }
+ else {
+ $options[$field] = $handler->ui_name();
+ }
+ }
+ $form['unique_id'] = array(
+ '#type' => 'select',
+ '#title' => t('Unique ID'),
+ '#options' => $options,
+ '#default_value' => $view->options['unique_id'],
+ '#description' => t('Select the field that should be used to be unqiue (e.g. Entitiy ID like Term ID or User ID.)'),
+ );
+ $form['title_field'] = array(
+ '#type' => 'select',
+ '#title' => t('Title field'),
+ '#options' => $options,
+ '#default_value' => $view->options['title_field'],
+ '#description' => t('Select the field that should be used as the items title in the cloud.'),
+ );
+ $form['link_field'] = array(
+ '#type' => 'select',
+ '#title' => t('Link field'),
+ '#options' => $options,
+ '#default_value' => $view->options['link_field'],
+ '#description' => t('Select the field that should be used as the items link in the cloud.'),
+ );
+ $form['use_field_as_weight']['#tree'] = TRUE;
+ $form['use_field_as_weight']['weight_text'] = array(
+ '#type' => 'checkbox',
+ '#title' => t('Use a field as source for weight calculation'),
+ '#description' => t('If checked, you can select a field that is use as source for weight calculation instead of using the sort order.'),
+ '#default_value' => $view->options['use_field_as_weight']['weight_text'],
+ );
+ $form['use_field_as_weight']['weight_field'] = array(
+ '#type' => 'select',
+ '#title' => t('Weight field'),
+ '#options' => $options,
+ '#default_value' => $view->options['use_field_as_weight']['weight_field'],
+ '#description' => t('Select the field that should be used for weight calculation.'),
+ /*
+ // TODO: use drupal form states
+ '#process' => array('views_process_dependency'),
+ '#dependency' => array(
+ 'edit-style-options-use-field-as-weight-weight-text' => array(1)
+ ),
+ */
+ );
+ }
+ else {
+ drupal_set_message(t('You need to define at least two fields to set up a cumulus cloud view. 1. Name of the link. 2. URL for the link. And 3. Optional weight.', 'error'));
+ }
+ }
+ $form['size_interval'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Item size interval'),
+ '#default_value' => $view->options['size_interval'],
+ '#maxlength' => 2,
+ '#description' => t('The number of item sizes you want to use.'),
+ );
+ $form['flash_transparency'] = array(
+ '#type' => 'select',
+ '#title' => t('Background transparency'),
+ '#default_value' => $view->options['flash_transparency'],
+ '#options' => array(
+ 'false' => t('no'),
+ 'true' => t('yes'),
+ ),
+ '#description' => t('Enabling background transparency might cause issues with some (mostly older) browsers.
Under Linux, transparency doesn\'t work at all due to a known limitation in the current Flash player.'),
+ );
+ $form['flash_width'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Width of cumulus'),
+ '#default_value' => $view->options['flash_width'],
+ '#maxlength' => 3,
+ '#description' => t('The width of the cumulus in pixels.'),
+ );
+ $form['flash_height'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Height of cumulus'),
+ '#default_value' => $view->options['flash_height'],
+ '#maxlength' => 3,
+ '#description' => t('The height of the cumulus in pixels.'),
+ );
+ $form['flash_background'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Background color of cumulus'),
+ '#default_value' => $view->options['flash_background'],
+ '#maxlength' => 6,
+ '#description' => t('The hex color value for the background of the cumulus. E.g. ffffff. If "Background transparency" is enabled, this option will have no effect.'),
+ );
+ $form['flash_color'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Font color of cumulus'),
+ '#default_value' => $view->options['flash_color'],
+ '#maxlength' => 6,
+ '#description' => t('The hex color value you would like to use for the items. E.g. 000000.'),
+ );
+ $form['flash_color2'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Second font color of cumulus'),
+ '#default_value' => $view->options['flash_color2'],
+ '#maxlength' => 6,
+ '#description' => t('Second item color. If supplied, items will get a color from a gradient between both colors based on their sorting.'),
+ );
+ $form['flash_hicolor'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Highlight color of cumulus'),
+ '#default_value' => $view->options['flash_hicolor'],
+ '#maxlength' => 6,
+ '#description' => t('The hex color value you would like to use for the item mouseover/hover color'),
+ );
+ $form['flash_speed'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Rotation speed'),
+ '#default_value' => $view->options['flash_speed'],
+ '#maxlength' => 3,
+ '#description' => t('Set the speed of the cumulus. Options between 25 and 500 work best.'),
+ );
+ $form['flash_distribute'] = array(
+ '#type' => 'select',
+ '#title' => t('Distribute items evenly on cumulus'),
+ '#default_value' => $view->options['flash_distribute'],
+ '#options' => array(
+ 'false' => t('no'),
+ 'true' => t('yes'),
+ ),
+ '#description' => t('When enabled, the movie will attempt to distribute the items evenly over the surface of the cumulus.'),
+ );
+ $form['flash_font_size'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Font size'),
+ '#default_value' => $view->options['flash_font_size'],
+ '#maxlength' => 2,
+ '#description' => t('Set the font size of the tag with the lowest item-size in pixels (level 1).'),
+ );
+ $form['flash_font_size_interval'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Font size interval'),
+ '#default_value' => $view->options['flash_font_size_interval'],
+ '#maxlength' => 1,
+ '#description' => t('Set the font size interval used for the different item-sizes (level 2 and higher).'),
+ );
+}
diff --git a/includes/views/views-view-cumulus.tpl.php b/includes/views/views-view-cumulus.tpl.php
index ed3be93..7f349ea 100644
--- a/includes/views/views-view-cumulus.tpl.php
+++ b/includes/views/views-view-cumulus.tpl.php
@@ -7,5 +7,7 @@
*/
?>
-
+
diff --git a/includes/views/views_cumulus_style_plugin.inc b/includes/views/views_cumulus_style_plugin.inc
index 8c4f4e5..9fdca15 100644
--- a/includes/views/views_cumulus_style_plugin.inc
+++ b/includes/views/views_cumulus_style_plugin.inc
@@ -54,11 +54,15 @@ class views_cumulus_style_plugin extends views_plugin_style {
$this->rendered_fields[$count][$id] = $this->view->field[$id]->theme($row);
}
}
+
unset($this->view->row_index);
- //dpm($this->rendered_fields);
- $output .= theme($this->theme_functions(), $this->view, $this->options, $rows, $title);
+ $output = theme($this->theme_functions(),
+ array(
+ 'view' => $this->view,
+ 'options' => $this->options,
+ )
+ );
return $output;
}
-
}
diff --git a/includes/views/views_cumulus_summary_style_plugin.inc b/includes/views/views_cumulus_summary_style_plugin.inc
index dd4b14b..ba37ea1 100644
--- a/includes/views/views_cumulus_summary_style_plugin.inc
+++ b/includes/views/views_cumulus_summary_style_plugin.inc
@@ -27,7 +27,14 @@ class views_cumulus_summary_style_plugin extends views_plugin_style_summary {
'weight' => $row->num_records,
);
}
- $output .= theme($this->theme_functions(), $this->view, $this->options, $rows, $title);
+ $output .= theme($this->theme_functions(),
+ array(
+ 'view' => $this->view,
+ 'options' => $this->options,
+ 'rows' => array(),
+ 'title' => $title
+ )
+ );
return $output;
}