--- tagadelic.module	2005-10-27 08:07:40.000000000 -0500
+++ tagadelic.2.module	2006-01-20 22:30:22.000000000 -0600
@@ -1,5 +1,6 @@
 <?php
 // $Id: tagadelic.module,v 1.12.2.2 2005/10/27 13:07:40 ber Exp $
+// modified by vph (01.20.2006)
 
 /**
  * Implementation of hook_help
@@ -23,7 +24,7 @@
   if ($may_cache) {
      $items[] = array('title' => t('tags'),
                       'path' => "tagadelic",
-                      'callback' => 'tagadelic_page_chunk',
+                      'callback' => 'tagadelic_page_all',
                       'access' => user_access('access content'),
                       'type' => MENU_SUGGESTED_ITEM);
      $items[] = array('title' => t('tags'),
@@ -58,6 +59,45 @@
 }
 
 /**
+ * menu callback renders a  page containing all tags in different colors
+ */
+function tagadelic_page_all() {
+  $vocs = arg(2);
+
+  if (is_numeric($vocs)) {
+    $vocs = array($vocs);
+  }
+  elseif (preg_match('/^([0-9]+,){1,5}[0-9]+$/', $vocs)) {
+    $vocs = explode(',', $vocs);
+  }
+  elseif($vocs == NULL) { //create a chunk from all free tagging vocs
+   foreach (taxonomy_get_vocabularies(NULL) as $vocabulary) {
+      $vocs[] = $vocabulary->vid;
+    }
+  }
+
+  if (is_array($vocs) && count($vocs) != 0) {
+    $all_tags = array();
+    $color_code = 1;
+    foreach ($vocs as $voc) {
+      $tags = tagadelic_get_weighted_tags(array($voc), 6, 20, $color_code);
+      $all_tags = array_merge($all_tags, $tags);
+      $color_code += 1;
+    }
+    usort($all_tags, "_tagadelic_sort_by_title");
+    $output = theme('tagadelic_weighted', $all_tags);
+  }
+  
+  if (!$output) {
+    return drupal_not_found();
+  }
+
+  $output = "<div class=\"wrapper tagadelic\">$output</div>";
+
+  print theme('page', $output);
+}
+
+/**
  * menu callback renders a tagadelic page
  */
 function tagadelic_page_chunk() {
@@ -159,7 +199,7 @@
  * API that returns an array with weighted tags
  * This is the hard part. People with better ideas are very very welcome to send these to ber@webschuur.com. Distribution is one thing that needs attention.
  */
-function tagadelic_get_weighted_tags($vids, $steps = 6, $size = 60) {
+function tagadelic_get_weighted_tags($vids, $steps = 6, $size = 60, $color_code='') {
   if (!is_array($vids) || count($vids) == 0) {
     return array();
   }
@@ -183,6 +223,7 @@
 
   foreach ($tags as $key => $value) {
     $tags[$key]->weight = 1 + floor($steps * ($value->count - $min) / $range);
+    $tags[$key]->color_code = $color_code;
   }
 
   // Sort by title
@@ -190,6 +231,7 @@
   return $tags;
 }
 
+
 /**
  * callback for usort, sort by count
  */
@@ -210,7 +252,7 @@
  */
 function theme_tagadelic_weighted($terms) {
   foreach ($terms as $term) {
-    $output .= l($term->name,"taxonomy/term/$term->tid", array('class'=>"tagadelic level$term->weight")) ." \n";
+    $output .= l($term->name,"taxonomy/term/$term->tid", array('class'=>"tagadelic level$term->weight$term->color_code")) ." \n";
   }
   return $output;
 }
@@ -232,4 +274,4 @@
   }
   return $blocks;
 }
-?>
\ No newline at end of file
+?>
