function cumulus_block_view in Cumulus 7
Implements hook_block_view().
File
- ./
cumulus.module, line 108 - The brain of Cumulus.
Code
function cumulus_block_view($delta) {
$config = cumulus_get_config($delta);
$vocs = $config['vid'];
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, $config['tagadelic_step'], $config['tagadelic_limit']);
$tags = tagadelic_sort_tags($tags);
$tags_formatted_flash = theme('cumulus_weighted', array(
'terms' => $tags,
'config' => $config,
));
$tags_formatted_alt = theme('tagadelic_weighted', array(
'terms' => $tags,
));
$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 swfobject v1.x and add it to the Cumulus module folder! Download links are listed in the README.txt', array(
'@folder' => $js,
)), 'error');
}
if (!$config['vid']) {
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/structure/block/configure/cumulus/0'),
)), 'warning');
}
// Flash params
$param = array(
'path_to_flash' => base_path() . drupal_get_path('module', 'cumulus') . '/cumulus.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'],
);
if ($config['flash_transparency'] == 'true') {
$param['transparency'] = 'widget_so.addParam("wmode", "transparent");';
}
// link to view with additional tags
$links['more'] = l(t('more tags'), 'tagadelic/chunk/' . $config['vid']);
// 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">
{<span class="php-variable">$tags_formatted_alt</span>}
<script type="text/javascript">
var rnumber = Math.floor(Math.random()*9999999);
var widget_so = new SWFObject("{<span class="php-variable">$param</span>[<span class="php-string">'path_to_flash'</span>]}?r="+rnumber, "cumulusflash", "{<span class="php-variable">$param</span>[<span class="php-string">'width'</span>]}", "{<span class="php-variable">$param</span>[<span class="php-string">'height'</span>]}", "9", "{<span class="php-variable">$param</span>[<span class="php-string">'background'</span>]}");
{<span class="php-variable">$param</span>[<span class="php-string">'transparency'</span>]}
widget_so.addParam("allowScriptAccess", "always");
widget_so.addVariable("tcolor", "{<span class="php-variable">$param</span>[<span class="php-string">'color'</span>]}");
widget_so.addVariable("tcolor2", "{<span class="php-variable">$param</span>[<span class="php-string">'color2'</span>]}");
widget_so.addVariable("hicolor", "{<span class="php-variable">$param</span>[<span class="php-string">'hicolor'</span>]}");
widget_so.addVariable("tspeed", "{<span class="php-variable">$param</span>[<span class="php-string">'speed'</span>]}");
widget_so.addVariable("distr", "{<span class="php-variable">$param</span>[<span class="php-string">'distribute'</span>]}");
widget_so.addVariable("mode", "tags");
widget_so.addVariable("tagcloud", "{<span class="php-variable">$tags_formatted_flash</span>}");
widget_so.write("tags");
</script>
</div>
<div class="more-link">{<span class="php-variable">$links</span>[<span class="php-string">'more'</span>]}</div>
EOT;
return $blocks;
}