function tagadelic_block in Tagadelic 5
Same name and namespace in other branches
- 6 tagadelic.module \tagadelic_block()
implementation of hook_block
File
- ./
tagadelic.module, line 337
Code
function tagadelic_block($op = 'list', $delta = O, $edit = array()) {
if ($op == 'view') {
if ($voc = taxonomy_get_vocabulary($delta)) {
$blocks['subject'] = variable_get('tagadelic_block_title_' . $delta, t('Tags in @voc', array(
'@voc' => $voc->name,
)));
$tags = tagadelic_get_weighted_tags(array(
$voc->vid,
), variable_get('tagadelic_levels', 6), variable_get('tagadelic_block_tags_' . $delta, 12));
$tags = tagadelic_sort_tags($tags);
$blocks['content'] = theme('tagadelic_weighted', $tags);
//return a chunk of 12 tags
$blocks['content'] .= theme('tagadelic_more', $voc->vid);
//add more link
}
elseif (arg(0) == 'node' && is_numeric(arg(1)) && ($node = node_load(arg(1)))) {
$blocks['subject'] = t('Tags for @title', array(
'@title' => $node->title,
));
$blocks['content'] = tagadelic_tags_lists($node);
}
}
elseif ($op == 'list') {
foreach (taxonomy_get_vocabularies() as $voc) {
$blocks[$voc->vid]['info'] = variable_get('tagadelic_block_title_' . $voc->vid, t('Tags in @voc', array(
'@voc' => $voc->name,
)));
}
$blocks[0]['info'] = t('Tags for the current post');
}
elseif ($op == 'configure') {
$voc = taxonomy_get_vocabulary($delta);
$form['title'] = array(
'#type' => 'textfield',
'#title' => t('Block title'),
'#default_value' => variable_get('tagadelic_block_title_' . $delta, t('Tags in @voc', array(
'@voc' => $voc->name,
))),
'#maxlength' => 64,
'#description' => t('The title of the block as shown to the user.'),
);
$form['tags'] = array(
'#type' => 'textfield',
'#title' => t('Tags to show'),
'#default_value' => variable_get('tagadelic_block_tags_' . $delta, 12),
'#maxlength' => 3,
'#description' => t('The number of tags to show in this block.'),
);
return $form;
}
elseif ($op == 'save') {
variable_set('tagadelic_block_title_' . $delta, $edit['title']);
variable_set('tagadelic_block_tags_' . $delta, $edit['tags']);
return;
}
return $blocks;
}