? cumulus.js
Index: cumulus.info
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/cumulus/cumulus.info,v
retrieving revision 1.1.2.2
diff -u -p -r1.1.2.2 cumulus.info
--- cumulus.info	27 Jan 2009 09:01:16 -0000	1.1.2.2
+++ cumulus.info	6 Jan 2010 14:58:33 -0000
@@ -1,6 +1,6 @@
 ;$Id: cumulus.info,v 1.1.2.2 2009/01/27 09:01:16 lut4rp Exp $
 name = Cumulus
-description = "Provides a Flash-based 3D tag cloud."
+description = "Cumulus is a Views style plugin that provides a Flash-based 3D tag cloud."
 core = 6.x
-dependencies[] = tagadelic
-package = "Taxonomy"
+dependencies[] = views
+package = Views
Index: cumulus.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/cumulus/cumulus.module,v
retrieving revision 1.1.2.10
diff -u -p -r1.1.2.10 cumulus.module
--- cumulus.module	14 Apr 2009 09:04:58 -0000	1.1.2.10
+++ cumulus.module	6 Jan 2010 14:58:33 -0000
@@ -12,134 +12,93 @@
  * Implementation of hook_enable().
  */
 function cumulus_enable() {
-  drupal_set_message(t('Cumulus has now been enabled. You need to !configure the Cumulus block settings before you use it.', array('!configure' => l(t('configure and save'), 'admin/build/block'))));
+  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.', array('!add' => l(t('add'), 'admin/build/views/add'))));
 }
 
 /**
- * Implementation of hook_block().
+ * Implementation of hook_views_api().
+ * Notifies the Views module that we're compatible with a particular API revision.
  */
-function cumulus_block($op = 'list', $delta = 0, $edit = array()) {
-  switch ($op) {
-    case 'list':
-      $blocks[0]['info'] = t('Cumulus Tag Cloud');
-      $blocks[0]['cache'] = BLOCK_NO_CACHE;
-      return $blocks;
-
-    case 'configure':
-      return cumulus_block_configure();
+function cumulus_views_api() {
+  return array('api' => 2);
+}
 
-    case 'save':
-      variable_set('cumulus_vid', $edit['vid']);
-      variable_set('cumulus_tagadelic_step', $edit['tagadelic_step']);
-      variable_set('cumulus_tagadelic_limit', $edit['tagadelic_limit']);
-      variable_set('cumulus_flash_width', $edit['flash_width']);
-      variable_set('cumulus_flash_height', $edit['flash_height']);
-      variable_set('cumulus_flash_background', $edit['flash_background']);
-      variable_set('cumulus_flash_transparency', $edit['flash_transparency']);
-      variable_set('cumulus_flash_color', $edit['flash_color']);
-      variable_set('cumulus_flash_color2', $edit['flash_color2']);
-      variable_set('cumulus_flash_hicolor', $edit['flash_hicolor']);
-      variable_set('cumulus_flash_speed', $edit['flash_speed']);
-      variable_set('cumulus_flash_distribute', $edit['flash_distribute']);
-      variable_set('cumulus_flash_font_size', $edit['flash_font_size']);
-      variable_set('cumulus_flash_font_size_interval', $edit['flash_font_size_interval']);
-      return;
+/**
+ * Template function for cumulus style plugin.
+ *
+ * @param array $vars
+ *  Array of template variables.
+ *
+ * The JS file is loaded within render() in views_cumulus_style_plugin.inc.
+ */
+function template_preprocess_views_view_cumulus(&$vars) {
+  $view = $vars['view'];
+  $rows = $vars['rows'];
 
-    case 'view':
-      $vocs = variable_get('cumulus_vid', 1);
-      if (is_numeric($vocs)) {
-        $vocs = array($vocs);
-      }
-      elseif (preg_match('/^([0-9]+,){1,5}[0-9]+$/', $vocs)) {
-        $vocs = explode(',', $vocs);
-      }
-      else {
-        $vocs = array(1);
-      }
-      $tags = tagadelic_get_weighted_tags($vocs, variable_get('cumulus_tagadelic_step', 6), variable_get('cumulus_tagadelic_limit', 24));
-      $tags = tagadelic_sort_tags($tags);
-      $tags_formatted_flash = theme('cumulus_weighted', $tags);
-      $tags_formatted_alt = theme('tagadelic_weighted', $tags);
+  // Calculate weight values and font sizes based on sorting.
+  $options = $view->style_options;
+  // Range is from 1 to count($rows).
+  $range = max(.01, count($rows)) * 1.0001;
+  $index = 1;
+  $weight = 0;
+  $tags_formatted_flash = '';
+  $tags_formatted_alt = '';
 
-      $js = drupal_get_path('module', 'cumulus') .'/cumulus.js';
-      if (file_exists($js)) {
-        drupal_add_js($js, 'module', 'header', FALSE, TRUE, FALSE);
+  if (empty($options['title_field'])) {
+    drupal_set_message('You have to define a title field to display items.', 'error');
+    return;
+  }
+  $title_field = $view->field[$options['title_field']];
+  $field_options = $title_field->options;
+  $link_item = 0;
+  $item_path = '';
+  if (isset($field_options['alter']['make_link'])) {
+    $link_item = $field_options['alter']['make_link'];
+    $item_path = $field_options['alter']['path'];
+  }
+  foreach ($rows as $id => $row) {
+    $tokens = array();
+    // Get token replacements.
+    foreach ($view->display_handler->get_handlers('field') as $field => $handler) {
+      if (isset($row->{$handler->field_alias})) {
+        $tokens["[$field]"] = $row->{$handler->field_alias};
       }
       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');
-      }
-      if (!(variable_get('cumulus_vid', 1))) {
-        drupal_set_message(t('You haven\'t yet configured and saved the Cumulus settings on !link. Cumulus might not work properly!', array('!link' => l('your blocks configuration page', 'admin/build/block/configure/cumulus/0'))), 'warning');
-      }
-      // Flash params
-      $param = array(
-        'path_to_flash' => base_path() . drupal_get_path('module', 'cumulus') .'/cumulus.swf',
-        'width' => variable_get('cumulus_flash_width', 1),
-        'height' => variable_get('cumulus_flash_height', 1),
-        'background' => variable_get('cumulus_flash_background', 'ffffff'),
-        'color' => '0x'. variable_get('cumulus_flash_color', '000000'),
-        'color2' => '0x'. variable_get('cumulus_flash_color2', 'ff0000'),
-        'hicolor' => '0x'. variable_get('cumulus_flash_hicolor', '666666'),
-        'speed' => variable_get('cumulus_flash_speed', 220),
-        'distribute' => variable_get('cumulus_flash_distribute', 'true'),
-      );
-      if (variable_get('cumulus_flash_transparency', 'false') == 'true' ) {
-        $param['transparency'] = 'widget_so.addParam("wmode", "transparent");';
+        $tokens["[$field]"] = '';
       }
-      // link to view with additional tags
-      $links['more'] = l(t('more tags'), 'tagadelic/chunk/'. variable_get('cumulus_vid', 1));
-      // output content
-      $blocks['subject'] = t('Cumulus Tag Cloud');
-      // param with value 9 indicates required version of flash player - see http://blog.deconcept.com/swfobject/
-      $blocks['content'] = <<<EOT
-        <div id="tags">
-        {$tags_formatted_alt}
-        <script type="text/javascript">
-          var rnumber = Math.floor(Math.random()*9999999);
-          var widget_so = new SWFObject("{$param['path_to_flash']}?r="+rnumber, "cumulusflash", "{$param['width']}", "{$param['height']}", "9", "{$param['background']}");
-          {$param['transparency']}
-          widget_so.addParam("allowScriptAccess", "always");
-          widget_so.addVariable("tcolor", "{$param['color']}");
-          widget_so.addVariable("tcolor2", "{$param['color2']}");
-          widget_so.addVariable("hicolor", "{$param['hicolor']}");
-          widget_so.addVariable("tspeed", "{$param['speed']}");
-          widget_so.addVariable("distr", "{$param['distribute']}");
-          widget_so.addVariable("mode", "tags");
-          widget_so.addVariable("tagcloud", "{$tags_formatted_flash}");
-          widget_so.write("tags");
-        </script>
-        </div>
-        <div class="more-link">{$links['more']}</div>
-EOT;
-      return $blocks;
+    }
+    $path = strip_tags(html_entity_decode(strtr($item_path, $tokens)));
+    if (empty($options['use_field_as_weight']['weight_text'])) {
+      // Use item sort order for weight calculation.
+      $weight = 1 + floor($options['size_interval'] * $index / $range);
+    }
+    else if (isset($row->{$view->field[$options['use_field_as_weight']['weight_field']]->field_alias})) {
+      // Use (int) value of selected field for weight calculation.
+      $weight = 1 + floor($options['size_interval'] * intval($row->{$view->field[$options['use_field_as_weight']['weight_field']]->field_alias}) / $range);
+    }
+    $font_size = (intval($weight) * $options['flash_font_size_interval']) + ($options['flash_font_size'] - $options['flash_font_size_interval']);
+    $tags_formatted_flash .= l($row->{$title_field->field_alias}, $path, array('attributes' => array('style' => 'font-size: '. $font_size .'px;'))) ." \n";
+    $tags_formatted_alt .= l($row->{$title_field->field_alias}, $path, array('attributes' => array('class' => 'tagadelic level'. $weight, 'rel' => 'tag', 'title' => $row->{$title_field->field_alias}))) ." \n";
+    $index++;
   }
-}
-
-/**
- * Implementation for hook_theme().
- */
-function cumulus_theme() {
-  return array(
-    'cumulus_weighted' => array(
-      'arguments' => array('terms' => NULL),
-    ),
+  // Flash params
+  $params = array(
+    'path_to_flash' => base_path() . drupal_get_path('module', 'cumulus') .'/cumulus.swf',
+    'width' => $options['flash_width'],
+    'height' => $options['flash_height'],
+    'background' => $options['flash_background'],
+    'color' => '0x'. $options['flash_color'],
+    'color2' => '0x'. $options['flash_color2'],
+    'hicolor' => '0x'. $options['flash_hicolor'],
+    'speed' => $options['flash_speed'],
+    'distribute' => $options['flash_distribute'],
   );
-}
-
-/**
- * Themeing function.
- */
-function theme_cumulus_weighted($terms) {
-  $output = '<tags>';
-  foreach ($terms as $term) {
-    // assign font size
-    $font_size = (intval($term->weight) * variable_get('cumulus_flash_font_size_interval', 2)) + (variable_get('cumulus_flash_font_size', 10) - variable_get('cumulus_flash_font_size_interval', 2));
-    $output .= l($term->name, taxonomy_term_path($term), array('attributes' => array('style' => '"font-size: '. $font_size .'px;"'))) ." \n";
+  if ('true' == $options['flash_transparency']) {
+    $params['transparency'] = 'widget_so.addParam("wmode", "transparent");';
   }
-  $output .= '</tags>';
-  $output = urlencode($output);
-
-  return $output;
+  $vars['params'] = $params;
+  $vars['tags_formatted_flash'] = urlencode('<tags>'. $tags_formatted_flash .'</tags>');
+  $vars['tags_formatted_alt'] = $tags_formatted_alt;
 }
 
 /**
@@ -149,171 +108,7 @@ function cumulus_help($path, $arg) {
   switch ($path) {
     case 'admin/help#cumulus':
       $output = '<p>'. t('Cumulus allows you to display a taxonomy\'s terms using a Flash movie that rotates them in 3D. This way, you can set it up like a 3D tag cloud. It works just like a regular tag cloud, but is more visually exciting!') .'</p>';
-      $output .= '<p>'.'<strong>'. t('Configuring Cumulus: ') .'</strong>'.'<br />';
-      $output .= t('By default, Cumulus is rendered as a block. You need to enable and configure that block to see it. If you don\'t configure and save the Cumulus block settings once, it will not work! Do that before wondering what\'s wrong :-)') .'</p>';
       return $output;
   }
 }
 
-/**
- * Implementation of hook_menu().
- */
-function cumulus_menu() {
-  $items = array();
-  $items['admin/settings/cumulus'] = array(
-    'title' => 'Cumulus',
-    'description' => 'Cumulus settings',
-    'page callback' => 'drupal_get_form',
-    'page arguments' => array('cumulus_admin_settings'),
-    'access arguments' => array('administer cumulus'),
-    'type' => MENU_NORMAL_ITEM,
-  );
-  return $items;
-}
-
-/**
- * Implementation of hook_settings().
- */
-function cumulus_admin_settings() {
-  $form['settings'] = array(
-    '#type'  => 'fieldset',
-    '#title' => t('Clear the Cumulus cache'),
-    '#description' => t('If you see older terms, or are unable to see terms from newly added vocabularies, try clearing the cache.<br />This will only clear the Cumulus related data from the cache. It will not clear the full Drupal cache.'),
-  );
-  $form['settings']['clear_cache'] = array(
-    '#type' => 'submit',
-    '#value' => t('Click to clear'),
-    '#submit' => array('cumulus_clear_cache'),
-  );
-
-  return system_settings_form($form);
-}
-
-/**
- * Clear the cache of all Cumulus (in effect, Tagadelic) data.
- */
-function cumulus_clear_cache() {
-  $cid = "tagadelic";
-  $table = "cache";
-  $wildcard = TRUE;
-  cache_clear_all($cid, $table, $wildcard);
-  drupal_set_message(t('The module\'s cache has been cleared'), 'status');
-}
-
-/**
- * Implementation of hook_perm().
- */
-function cumulus_perm() {
-  return array('administer cumulus');
-}
-
-/**
- * Implementation of hook_configure().
- */
-function cumulus_block_configure() {
-  $form['vid'] = array(
-    '#type' => 'textfield',
-    '#title' => t('Vocabulary IDs to be included'),
-    '#default_value' => variable_get('cumulus_vid', 1),
-    '#maxlength' => 10,
-    '#description' => t('The IDs of the vocabularies that will be displayed. Separate the IDs by commas only (eg: 1, 3, 4)'),
-  );
-  $form['tagadelic_step'] = array(
-    '#type' => 'textfield',
-    '#title' => t('Tag size interval'),
-    '#default_value' => variable_get('cumulus_tagadelic_step', 6),
-    '#maxlength' => 2,
-    '#description' => t('The number of tag sizes you want to use.'),
-  );
-  $form['tagadelic_limit'] = array(
-    '#type' => 'textfield',
-    '#title' => t('Number of tags to display'),
-    '#default_value' => variable_get('cumulus_tagadelic_limit', 24),
-    '#maxlength' => 2,
-    '#description' => t('The maximum number of tags that will be displayed.'),
-  );
-  $form['flash_width'] = array(
-    '#type' => 'textfield',
-    '#title' => t('Width of cumulus'),
-    '#default_value' => variable_get('cumulus_flash_width', 200),
-    '#maxlength' => 3,
-    '#description' => t('The width of the cumulus in pixels.'),
-  );
-  $form['flash_height'] = array(
-    '#type' => 'textfield',
-    '#title' => t('Height of cumulus'),
-    '#default_value' => variable_get('cumulus_flash_height', 150),
-    '#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' => variable_get('cumulus_flash_background', 'ffffff'),
-    '#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_transparency'] = array(
-    '#type' => 'select',
-    '#title' => t('Background transparency'),
-    '#default_value' => variable_get('cumulus_flash_transparency', 'false'),
-    '#options' => array(
-      'false' => t('no'),
-      'true' => t('yes'),
-    ),
-    '#description' => t('Enabling background transparency might cause issues with some (mostly older) browsers.<br />Under Linux, transparency doesn\'t work at all due to a known limitation in the current Flash player.'),
-  );
-  $form['flash_color'] = array(
-    '#type' => 'textfield',
-    '#title' => t('Font color of cumulus'),
-    '#default_value' => variable_get('cumulus_flash_color', 'ff0000'),
-    '#maxlength' => 6,
-    '#description' => t('The hex color value you would like to use for the tags. E.g. 000000.'),
-  );
-  $form['flash_color2'] = array(
-    '#type' => 'textfield',
-    '#title' => t('Second font color of cumulus'),
-    '#default_value' => variable_get('cumulus_flash_color2', '000000'),
-    '#maxlength' => 6,
-    '#description' => t('Second tag color. If supplied, tags will get a color from a gradient between both colors based on their popularity.'),
-  );
-  $form['flash_hicolor'] = array(
-    '#type' => 'textfield',
-    '#title' => t('Highlight color of cumulus'),
-    '#default_value' => variable_get('cumulus_flash_hicolor', '666666'),
-    '#maxlength' => 6,
-    '#description' => t('The hex color value you would like to use for the tag mouseover/hover color'),
-  );
-  $form['flash_speed'] = array(
-    '#type' => 'textfield',
-    '#title' => t('Rotation speed'),
-    '#default_value' => variable_get('cumulus_flash_speed', 100),
-    '#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 tags evenly on cumulus'),
-    '#default_value' => variable_get('cumulus_flash_distribute', 'true'),
-    '#options' => array(
-      'false' => t('no'),
-      'true' => t('yes'),
-    ),
-    '#description' => t('When enabled, the movie will attempt to distribute the tags evenly over the surface of the cumulus.'),
-  );
-  $form['flash_font_size'] = array(
-    '#type' => 'textfield',
-    '#title' => t('Font size'),
-    '#default_value' => variable_get('cumulus_flash_font_size', 10),
-    '#maxlength' => 2,
-    '#description' => t('Set the font size of the tag with the lowest tag-size in pixels (level 1).'),
-  );
-  $form['flash_font_size_interval'] = array(
-    '#type' => 'textfield',
-    '#title' => t('Font size interval'),
-    '#default_value' => variable_get('cumulus_flash_font_size_interval', 2),
-    '#maxlength' => 1,
-    '#description' => t('Set the font size interval used for the different tag-sizes (level 2 and higher).'),
-  );
-  return $form;
-}
\ No newline at end of file
Index: cumulus.views.inc
===================================================================
RCS file: cumulus.views.inc
diff -N cumulus.views.inc
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ cumulus.views.inc	6 Jan 2010 14:58:33 -0000
@@ -0,0 +1,29 @@
+<?php
+// $Id$
+/**
+ * @file
+ * Provide an cumulus style plugin for Views. This file is autoloaded by views.
+ */
+
+/**
+ * Implementation of hook_views_plugins().
+ *
+ * Add cumulus style plugin.
+ */
+function cumulus_views_plugins() {
+  return array(
+    'style' => array(
+      'cumulus' => array(
+        'title' => t('Cumulus cloud'),
+        'help' => t('Displays rows as an flash-based 3D "tag"-cloud.'),
+        'handler' => 'views_cumulus_style_plugin',
+        'theme' => 'views_view_cumulus',
+        'uses row plugin' => FALSE,
+        'uses options' => TRUE,
+        'uses fields' => TRUE,
+        'uses grouping' => FALSE,
+        'type' => 'normal',
+      ),
+    ),
+  );
+}
Index: views-view-cumulus.tpl.php
===================================================================
RCS file: views-view-cumulus.tpl.php
diff -N views-view-cumulus.tpl.php
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ views-view-cumulus.tpl.php	6 Jan 2010 14:58:33 -0000
@@ -0,0 +1,26 @@
+<?php
+// $Id$
+/**
+ * @file
+ * Displays the items of the cloud.
+ *
+ * @ingroup views_templates
+ */
+?>
+<div id="tags">
+  <?php print $tags_formatted_alt; ?>
+  <script type="text/javascript">
+    var rnumber = Math.floor(Math.random()*9999999);
+    var widget_so = new SWFObject("<?php print $params['path_to_flash']; ?>?r="+rnumber, "cumulusflash", "<?php print $params['width']; ?>", "<?php print $params['height']; ?>", "9", "<?php print $params['background']; ?>");
+    <?php print $param['transparency']; ?>
+    widget_so.addParam("allowScriptAccess", "always");
+    widget_so.addVariable("tcolor", "<?php print $params['color']; ?>");
+    widget_so.addVariable("tcolor2", "<?php print $params['color2']; ?>");
+    widget_so.addVariable("hicolor", "<?php print $params['hicolor']; ?>");
+    widget_so.addVariable("tspeed", "<?php print $params['speed']; ?>");
+    widget_so.addVariable("distr", "<?php print $params['distribute']; ?>");
+    widget_so.addVariable("mode", "tags");
+    widget_so.addVariable("tagcloud", "<?php print $tags_formatted_flash; ?>");
+    widget_so.write("tags");
+  </script>
+</div>
Index: views_cumulus_style_plugin.inc
===================================================================
RCS file: views_cumulus_style_plugin.inc
diff -N views_cumulus_style_plugin.inc
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ views_cumulus_style_plugin.inc	6 Jan 2010 14:58:34 -0000
@@ -0,0 +1,194 @@
+<?php
+// $Id$
+
+/**
+ * @file
+ * Contains the cumulus style plugin.
+ */
+
+/**
+ * Style plugin to render the results as a 3D Flash-cloud.
+ *
+ * @ingroup views_style_plugins
+ */
+class views_cumulus_style_plugin extends views_plugin_style {
+  /**
+   * Set default options
+   */
+  function option_definition() {
+    $options = parent::option_definition();
+
+    $options['title_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;
+  }
+
+  /**
+   * Render the given style.
+   */
+  function options_form(&$form, &$form_state) {
+    parent::options_form($form, $form_state);
+
+    $fields = $this->view->display_handler->get_handlers('field');
+    if (count($fields)) {
+      $options = array('' => t('<None>'));
+      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' => $this->options['title_field'],
+        '#description' => t('Select the field that should be used as the items title 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' => $this->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' => $this->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 one field to set up a cumulus cloud view.', 'error'));
+    }
+    $form['size_interval'] = array(
+      '#type' => 'textfield',
+      '#title' => t('Item size interval'),
+      '#default_value' => $this->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' => $this->options['flash_transparency'],
+      '#options' => array(
+        'false' => t('no'),
+        'true' => t('yes'),
+      ),
+      '#description' => t('Enabling background transparency might cause issues with some (mostly older) browsers.<br />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' => $this->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' => $this->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' => $this->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' => $this->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' => $this->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' => $this->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' => $this->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' => $this->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' => $this->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' => $this->options['flash_font_size_interval'],
+      '#maxlength' => 1,
+      '#description' => t('Set the font size interval used for the different item-sizes (level 2 and higher).'),
+    );
+  }
+
+  /**
+   * Render the display in this style.
+   */
+  function render() {
+    $output = parent::render();
+    $js = drupal_get_path('module', 'cumulus') .'/cumulus.js';
+    if (file_exists($js)) {
+      drupal_add_js($js, 'module', 'header', FALSE, TRUE, 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');
+    }
+
+    return $output;
+  }
+}
+
