Index: tagadelic.module =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/tagadelic/tagadelic.module,v retrieving revision 1.38 diff -u -r1.38 tagadelic.module --- tagadelic.module 15 Sep 2007 09:29:12 -0000 1.38 +++ tagadelic.module 7 Dec 2007 15:38:40 -0000 @@ -1,60 +1,67 @@ Visit example.com/tagadelic/list/2,1,5 to get the vocabularies 2,1 and 5 listed as tag groups.
Visit example.com/tagadelic/chunk/2,1,5 to get a tag cloud of the terms in the vocabularies 2,1 and 5.
Note that we limit to five vocabularies.'); } } +function tagadelic_init() { + $stylesheet = drupal_get_path('module','tagadelic') .'/tagadelic.css'; + drupal_add_css($stylesheet, 'all'); +} + /** * Implementation of hook_menu */ -function tagadelic_menu($may_cache) { +function tagadelic_menu() { $items = array(); - $stylesheet = drupal_get_path('module','tagadelic') .'/tagadelic.css'; - drupal_add_css($stylesheet, 'all'); + $items['admin/settings/tagadelic'] = array( + 'title' => t('Tagadelic configuration'), + 'description' => t('Configure the tag clouds. Set the order, the number of tags, and the depth of the clouds.'), + 'page callback' => 'drupal_get_form', + 'page arguments' => array('tagadelic_settings'), + 'access callback' => 'user_access', + 'access arguments' => array('administer site configuration'), + ); + $items['tagadelic'] = array( + 'title' => t('Tags'), + 'page callback' => 'tagadelic_page_chunk', + 'access callback' => 'user_access', + 'access arguments' => array('access content'), + 'type' => MENU_SUGGESTED_ITEM, + ); + $items['tagadelic/list'] = array( + 'title' => t('Tags'), + 'page callback' => 'tagadelic_page_list', + 'access callback' => 'user_access', + 'access arguments' => array('access content'), + 'type' => MENU_CALLBACK, + ); + $items['tagadelic/chunk'] = array( + 'title' => t('Tags'), + 'page callback' => 'tagadelic_page_chunk', + 'access callback' => 'user_access', + 'access arguments' => array('access content'), + 'type' => MENU_CALLBACK, + ); + foreach (taxonomy_get_vocabularies($type = NULL) as $vocabulary) { + $items['tagadelic/chunk/' . $vocabulary->vid] = array( + 'title' => $vocabulary->name, + 'page callback' => 'tagadelic_page_chunk', + 'access callback' => 'user_access', + 'access arguments' => array('access content'), + 'type' => MENU_SUGGESTED_ITEM, + ); + } + - if ($may_cache) { - $items[] = array( - 'path' => 'admin/settings/tagadelic', - 'title' => t('Tagadelic configuration'), - 'description' => t('Configure the tag clouds. Set the order, the number of tags, and the depth of the clouds.'), - 'callback' => 'drupal_get_form', - 'callback arguments' => 'tagadelic_settings', - 'access' => user_access('administer site configuration')); - $items[] = array( - 'title' => t('Tags'), - 'path' => "tagadelic", - 'callback' => 'tagadelic_page_chunk', - 'access' => user_access('access content'), - 'type' => MENU_SUGGESTED_ITEM); - $items[] = array( - 'title' => t('Tags'), - 'path' => "tagadelic/list", - 'callback' => 'tagadelic_page_list', - 'access' => user_access('access content'), - 'type' => MENU_CALLBACK); - $items[] = array( - 'title' => t('Tags'), - 'path' => "tagadelic/chunk", - 'callback' => 'tagadelic_page_chunk', - 'access' => user_access('access content'), - 'type' => MENU_CALLBACK); - foreach (taxonomy_get_vocabularies($type = NULL) as $vocabulary) { - $items[] = array( - 'title' => $vocabulary->name, - 'path' => "tagadelic/chunk/$vocabulary->vid", - 'callback' => 'tagadelic_page_chunk', - 'access' => user_access('access content'), - 'type' => MENU_SUGGESTED_ITEM); - } - } return $items; } @@ -145,7 +152,7 @@ } foreach ($vocs as $vid) { - $vocabulary = taxonomy_get_vocabulary($vid); + $vocabulary = taxonomy_vocabulary_load($vid); $tags = tagadelic_get_weighted_tags(array($vocabulary->vid), variable_get('tagadelic_levels', 6), variable_get('tagadelic_page_amount', '60')); $tags = tagadelic_sort_tags($tags); @@ -169,7 +176,7 @@ * @param $node. A node object. */ function tagadelic_node_get_terms($node) { - if ($terms = taxonomy_node_get_terms($node->nid, 'tid')) { + if ($terms = taxonomy_node_get_terms($node, 'tid')) { $vocs = taxonomy_get_vocabularies($node->type); foreach ($terms as $tid => $term) { if ($vocs[$term->vid]->tags) { @@ -188,11 +195,11 @@ function tagadelic_tags_lists($node) { if (is_array($node->tags)) { foreach($node->tags as $vid => $terms) { - $vocabulary = taxonomy_get_vocabulary($vid); + $vocabulary = taxonomy_vocabulary_load($vid); $title = l($vocabulary->name, "tagadelic/chunk/$vid"); $items = array(); foreach ($terms as $term) { - $items[] = l($term->name, taxonomy_term_path($term), array('title' => t('view all posts tagged with "@tag"', array('@tag' => $term->name)))); + $items[] = l($term->name, taxonomy_term_path($term), array('attributes' => array('title' => t('view all posts tagged with "@tag"', array('@tag' => $term->name))))); } $output .= theme('item_list', $items, $title); } @@ -216,7 +223,7 @@ // make sure cache has data if ($cache->data) { - $tags = unserialize($cache->data); + $tags = $cache->data; } else { @@ -227,7 +234,7 @@ $tags = tagadelic_build_weighted_tags($result, $steps); - cache_set($cache_name, 'cache', serialize($tags)); + cache_set($cache_name, $tags); } return $tags; @@ -305,7 +312,7 @@ */ function theme_tagadelic_weighted($terms) { foreach ($terms as $term) { - $output .= l($term->name, taxonomy_term_path($term), array('class'=>"tagadelic level$term->weight")) ." \n"; + $output .= l($term->name, taxonomy_term_path($term), array('attributes' => array('class'=>"tagadelic level$term->weight"))) ." \n"; } return $output; } @@ -331,7 +338,7 @@ */ function tagadelic_block($op = 'list', $delta = O, $edit = array()) { if ($op == 'view') { - if ($voc = taxonomy_get_vocabulary($delta)) { + if ($voc = taxonomy_vocabulary_load($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),6, variable_get('tagadelic_block_tags_'. $delta, 12)); $tags = tagadelic_sort_tags($tags); @@ -349,7 +356,7 @@ $blocks[0]['info'] = t('tags for the current post'); } elseif ($op == 'configure') { - $voc = taxonomy_get_vocabulary($delta); + $voc = taxonomy_vocabulary_load($delta); $form['title'] = array( '#type' => 'textfield', '#title' => t('Block title'), @@ -373,3 +380,14 @@ } return $blocks; } + +/** + * Implementation of hook_theme + */ +function tagadelic_theme() { + return array ( + 'tagadelic_list_box' => array('arguments' => array('vocabulary' => NULL, 'tags' => NULL)), + 'tagadelic_more' => array('arguments' => array('vid' => NULL)), + 'tagadelic_weighted' => array('arguments' => array('terms' => NULL)) + ); +}