Index: tagadelic.info =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/tagadelic/tagadelic.info,v retrieving revision 1.1 diff -u -r1.1 tagadelic.info --- tagadelic.info 16 Nov 2006 16:54:17 -0000 1.1 +++ tagadelic.info 7 Dec 2007 07:23:36 -0000 @@ -1,5 +1,9 @@ ; $Id: tagadelic.info,v 1.1 2006/11/16 16:54:17 ber Exp $ name = Tagadelic description = Tagadelic makes weighted tag clouds from your taxonomy terms. -dependencies = taxonomy -package = "Taxonomy" \ No newline at end of file +dependencies[] = taxonomy +package = "Taxonomy" +; Information added by drupal.org packaging script on 2007-09-03 +project = "tagadelic" +datestamp = "1188778032" +core = 6.x 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 07:02:45 -0000 @@ -1,60 +1,63 @@ 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() { + drupal_add_css(drupal_get_path('module','tagadelic') .'/tagadelic.css'); +} + /** * 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'); - - if ($may_cache) { - $items[] = array( - 'path' => 'admin/settings/tagadelic', + $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.'), - 'callback' => 'drupal_get_form', - 'callback arguments' => 'tagadelic_settings', - 'access' => user_access('administer site configuration')); - $items[] = array( + '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'), - 'path' => "tagadelic", - 'callback' => 'tagadelic_page_chunk', - 'access' => user_access('access content'), + 'page callback' => 'tagadelic_page_chunk', + 'access callback' => 'user_access', + 'access arguments' => array('access content'), 'type' => MENU_SUGGESTED_ITEM); - $items[] = array( + $items['tagadelic/list'] = array( 'title' => t('Tags'), - 'path' => "tagadelic/list", - 'callback' => 'tagadelic_page_list', - 'access' => user_access('access content'), + 'page callback' => 'tagadelic_page_list', + 'access callback' => 'user_access', + 'access arguments' => array('access content'), 'type' => MENU_CALLBACK); - $items[] = array( + $items['tagadelic/chunk'] = array( 'title' => t('Tags'), - 'path' => "tagadelic/chunk", - 'callback' => 'tagadelic_page_chunk', - 'access' => user_access('access content'), + '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[] = array( + print $vocabulary->vid . '---'; + $items['tagadelic/chunk/' . $vocabulary->vid] = array( 'title' => $vocabulary->name, - 'path' => "tagadelic/chunk/$vocabulary->vid", - 'callback' => 'tagadelic_page_chunk', - 'access' => user_access('access content'), + 'page callback' => 'tagadelic_page_chunk', + 'access callback' => 'user_access', + 'access arguments' => array('access content'), 'type' => MENU_SUGGESTED_ITEM); - } - } + } + + return $items; } @@ -145,7 +148,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 +172,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 +191,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); } @@ -207,30 +210,13 @@ * @return An unordered array with tags-objects, containing the attribute $tag->weight; */ function tagadelic_get_weighted_tags($vids, $steps = 6, $size = 60) { - // build the options so we can cache multiple versions - $options = implode($vids) .'_'. $steps .'_'. $size; - - // Check if the cache exists - $cache_name = 'tagadelic_cache_'. $options; - $cache = cache_get($cache_name); - - // make sure cache has data - if ($cache->data) { - $tags = unserialize($cache->data); + //CACHING! PLease! Send! in! your! patches! :) + if (!is_array($vids) || count($vids) == 0) { + return array(); } - else { - - if (!is_array($vids) || count($vids) == 0) { - return array(); - } - $result = db_query_range('SELECT COUNT(*) AS count, d.tid, d.name, d.vid FROM {term_data} d INNER JOIN {term_node} n ON d.tid = n.tid WHERE d.vid IN ('. substr(str_repeat('%d,', count($vids)), 0, -1) .') GROUP BY d.tid, d.name, d.vid ORDER BY count DESC', $vids, 0, $size); - - $tags = tagadelic_build_weighted_tags($result, $steps); + $result = db_query_range('SELECT COUNT(*) AS count, d.tid, d.name, d.vid FROM {term_data} d INNER JOIN {term_node} n ON d.tid = n.tid WHERE d.vid IN ('. substr(str_repeat('%d,', count($vids)), 0, -1) .') GROUP BY d.tid, d.name, d.vid ORDER BY count DESC', $vids, 0, $size); - cache_set($cache_name, 'cache', serialize($tags)); - } - - return $tags; + return tagadelic_build_weighted_tags($result, $steps); } /** @@ -305,7 +291,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; } @@ -327,18 +313,28 @@ } /** + * theme function to provide a more link + * @param $vid - vocab id for which more link is wanted + * @ingroup themable + */ +function theme_tagadelic_more($vid) { + return ""; +} + +/** * implementation of hook_block */ 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))); + 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); $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['subject'] = t('Tags for @title', array('@title' => $node->title)); $blocks['content'] = tagadelic_tags_lists($node); } } @@ -349,7 +345,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 +369,11 @@ } return $blocks; } + +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)) + ); +}