l(t('configure and save'), 'admin/build/block')))); } /** * Implementation of hook_block(). */ function cumulus_No2_block($op = 'list', $delta = 0, $edit = array()) { switch ($op) { case 'list': $blocks[0]['info'] = t('Cumulus_No2 Tag Cloud'); $blocks[0]['cache'] = BLOCK_NO_CACHE; return $blocks; case 'configure': return cumulus_No2_block_configure(); case 'save': variable_set('cumulus_No2_vid', $edit['vid']); variable_set('cumulus_No2_tagadelic_step', $edit['tagadelic_step']); variable_set('cumulus_No2_tagadelic_limit', $edit['tagadelic_limit']); variable_set('cumulus_No2_flash_width', $edit['flash_width']); variable_set('cumulus_No2_flash_height', $edit['flash_height']); variable_set('cumulus_No2_flash_background', $edit['flash_background']); variable_set('cumulus_No2_flash_transparency', $edit['flash_transparency']); variable_set('cumulus_No2_flash_color', $edit['flash_color']); variable_set('cumulus_No2_flash_color2', $edit['flash_color2']); variable_set('cumulus_No2_flash_hicolor', $edit['flash_hicolor']); variable_set('cumulus_No2_flash_speed', $edit['flash_speed']); variable_set('cumulus_No2_flash_distribute', $edit['flash_distribute']); variable_set('cumulus_No2_flash_font_size', $edit['flash_font_size']); variable_set('cumulus_No2_flash_font_size_interval', $edit['flash_font_size_interval']); return; case 'view': $vocs = variable_get('cumulus_No2_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_No2 = tagadelic_get_weighted_tags($vocs, variable_get('cumulus_No2_tagadelic_step', 6), variable_get('cumulus_No2_tagadelic_limit', 24)); $tags_No2 = tagadelic_sort_tags($tags_No2); $tags_No2_formatted_flash = theme('cumulus_No2_weighted', $tags_No2); $tags_No2_formatted_alt = theme('tagadelic_weighted', $tags_No2); $js = drupal_get_path('module', 'cumulus_No2') .'/cumulus_No2.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_No2 module folder!', array('@folder' => $js, '!link' => l('http://pratul.in/files/cumulus_No2.js', 'http://pratul.in/files/cumulus_No2.js'))), 'error'); } if (!(variable_get('cumulus_No2_vid', 1))) { drupal_set_message(t('You haven\'t yet configured and saved the Cumulus_No2 settings on !link. Cumulus_No2 might not work properly!', array('!link' => l('your blocks configuration page', 'admin/build/block/configure/cumulus_No2/0'))), 'warning'); } // Flash params $param = array( 'path_to_flash' => base_path() . drupal_get_path('module', 'cumulus_No2') .'/cumulus_No2.swf', 'width' => variable_get('cumulus_No2_flash_width', 1), 'height' => variable_get('cumulus_No2_flash_height', 1), 'background' => variable_get('cumulus_No2_flash_background', 'ffffff'), 'color' => '0x'. variable_get('cumulus_No2_flash_color', '000000'), 'color2' => '0x'. variable_get('cumulus_No2_flash_color2', 'cccccc'), 'hicolor' => '0x'. variable_get('cumulus_No2_flash_hicolor', 'ff0000'), 'speed' => variable_get('cumulus_No2_flash_speed', 220), 'distribute' => variable_get('cumulus_No2_flash_distribute', 'true'), ); if (variable_get('cumulus_No2_flash_transparency', 'true') == 'true' ) { $param['transparency'] = 'widget_so.addParam("wmode", "transparent");'; } // link to view with additional tags_No2 //$links['more'] = l(t('more tags_No2'), 'tagadelic/chunk/'. variable_get('cumulus_No2_vid', 1)); // output content $blocks['subject'] = t('Cumulus_No2 Tag Cloud'); // param with value 9 indicates required version of flash player - see http://blog.deconcept.com/swfobject/ $blocks['content'] = << {$tags_No2_formatted_alt} EOT; return $blocks; } } /** * Implementation for hook_theme(). */ function cumulus_No2_theme() { return array( 'cumulus_No2_weighted' => array( 'arguments' => array('terms' => NULL), ), ); } /** * Themeing function. */ function theme_cumulus_No2_weighted($terms) { $output = ''; foreach ($terms as $term) { // assign font size $font_size = (intval($term->weight) * variable_get('cumulus_No2_flash_font_size_interval', 2)) + (variable_get('cumulus_No2_flash_font_size', 10) - variable_get('cumulus_No2_flash_font_size_interval', 2)); $output .= l($term->name, taxonomy_term_path($term), array('attributes' => array('style' => '"font-size: '. $font_size .'px;"'))) ." \n"; } $output .= ''; $output = urlencode($output); return $output; } /** * Implementation of hook_help(). */ function cumulus_No2_help($path, $arg) { switch ($path) { case 'admin/help#cumulus_No2': $output = '

'. t('Cumulus_No2 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!') .'

'; $output .= '

'.''. t('Configuring Cumulus_No2: ') .''.'
'; $output .= t('By default, Cumulus_No2 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_No2 block settings once, it will not work! Do that before wondering what\'s wrong :-)') .'

'; return $output; } } /** * Implementation of hook_menu(). */ function cumulus_No2_menu() { $items = array(); $items['admin/settings/cumulus_No2'] = array( 'title' => 'Cumulus_No2', 'description' => 'Cumulus_No2 settings', 'page callback' => 'drupal_get_form', 'page arguments' => array('cumulus_No2_admin_settings'), 'access arguments' => array('administer cumulus_No2'), 'type' => MENU_NORMAL_ITEM, ); return $items; } /** * Implementation of hook_settings(). */ function cumulus_No2_admin_settings() { $form['settings'] = array( '#type' => 'fieldset', '#title' => t('Clear the Cumulus_No2 cache'), '#description' => t('If you see older terms, or are unable to see terms from newly added vocabularies, try clearing the cache.
This will only clear the Cumulus_No2 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_No2_clear_cache'), ); return system_settings_form($form); } /** * Clear the cache of all Cumulus_No2 (in effect, Tagadelic) data. */ function cumulus_No2_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_No2_perm() { return array('administer cumulus_No2'); } /** * Implementation of hook_configure(). */ function cumulus_No2_block_configure() { $form['vid'] = array( '#type' => 'textfield', '#title' => t('Vocabulary IDs to be included'), '#default_value' => variable_get('cumulus_No2_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_No2_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_No2 to display'), '#default_value' => variable_get('cumulus_No2_tagadelic_limit', 24), '#maxlength' => 2, '#description' => t('The maximum number of tags_No2 that will be displayed.'), ); $form['flash_width'] = array( '#type' => 'textfield', '#title' => t('Width of cumulus_No2'), '#default_value' => variable_get('cumulus_No2_flash_width', 200), '#maxlength' => 3, '#description' => t('The width of the cumulus_No2 in pixels.'), ); $form['flash_height'] = array( '#type' => 'textfield', '#title' => t('Height of cumulus_No2'), '#default_value' => variable_get('cumulus_No2_flash_height', 150), '#maxlength' => 3, '#description' => t('The height of the cumulus_No2 in pixels.'), ); $form['flash_background'] = array( '#type' => 'textfield', '#title' => t('Background color of cumulus_No2'), '#default_value' => variable_get('cumulus_No2_flash_background', 'ffffff'), '#maxlength' => 6, '#description' => t('The hex color value for the background of the cumulus_No2. 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_No2_flash_transparency', 'true'), '#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_color'] = array( '#type' => 'textfield', '#title' => t('Font color of cumulus_No2'), '#default_value' => variable_get('cumulus_No2_flash_color', '000000'), '#maxlength' => 6, '#description' => t('The hex color value you would like to use for the tags_No2. E.g. 000000.'), ); $form['flash_color2'] = array( '#type' => 'textfield', '#title' => t('Second font color of cumulus_No2'), '#default_value' => variable_get('cumulus_No2_flash_color2', 'cccccc'), '#maxlength' => 6, '#description' => t('Second tag color. If supplied, tags_No2 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_No2'), '#default_value' => variable_get('cumulus_No2_flash_hicolor', 'ff0000'), '#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_No2_flash_speed', 100), '#maxlength' => 3, '#description' => t('Set the speed of the cumulus_No2. Options between 25 and 500 work best.'), ); $form['flash_distribute'] = array( '#type' => 'select', '#title' => t('Distribute tags_No2 evenly on cumulus_No2'), '#default_value' => variable_get('cumulus_No2_flash_distribute', 'true'), '#options' => array( 'false' => t('no'), 'true' => t('yes'), ), '#description' => t('When enabled, the movie will attempt to distribute the tags_No2 evenly over the surface of the cumulus_No2.'), ); $form['flash_font_size'] = array( '#type' => 'textfield', '#title' => t('Font size'), '#default_value' => variable_get('cumulus_No2_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_No2_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; }