### Eclipse Workspace Patch 1.0
#P [drupal.org HEAD] modules
Index: tagadelic_views/tagadelic_views.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/tagadelic_views/tagadelic_views.module,v
retrieving revision 1.1
diff -u -r1.1 tagadelic_views.module
--- tagadelic_views/tagadelic_views.module	12 Mar 2007 14:53:49 -0000	1.1
+++ tagadelic_views/tagadelic_views.module	8 May 2007 19:04:36 -0000
@@ -12,6 +12,12 @@
     'summary_theme' => 'tagadelic_display',
     'validate' => 'tagadelic_views_validate',
   );
+  $plugins['tagadelic_xml'] = array(
+    'name' => t('Tagadelic XML'),
+    'theme' => 'tagadelic_display_xml',
+    'summary_theme' => 'tagadelic_display_xml',
+    'validate' => 'tagadelic_views_validate',
+  );
   return $plugins;
 }
 
@@ -26,7 +32,7 @@
   form_error($form[$type .'-info'][$type .'_type'], t('The Tagadelic View requires one vocabulary field.'));
 }
 
-function theme_tagadelic_display(&$view, &$items, $type) {
+function tagadelic_views_get_tags(&$view, &$items, $type) {
   // get the views query and query parts (join and where) that we'll need
   $query = _tagadelic_build_query($view, $type);
   _tagadelic_views_parse_query($query, $join, $where);
@@ -46,15 +52,51 @@
   $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 INNER JOIN {node} node ON n.nid=node.nid '. $join .' WHERE d.vid IN ('. substr(str_repeat('%d,', count($vids)), 0, -1) .') '. $where .' GROUP BY d.tid, d.name, d.vid ORDER BY count DESC', $vids, 0, $size);
   $tags = tagadelic_build_weighted_tags($result, $steps);
   $tags = tagadelic_sort_tags($tags);
+  
+  return $tags;
+}
 
+function theme_tagadelic_display(&$view, &$items, $type) {
+  // get the tags
+  $tags = tagadelic_views_get_tags($view, $items, $type);
   // theme the output
   $output = theme('tagadelic_weighted', $tags);
-/*if ($type == 'block' && !$view->block_more && $view->page) {
-    $output .= '<div class="more-link">' . l(t('more'), $view->url) . '</div>';
-  }*/
+
   return $output;
 }
 
+function theme_tagadelic_display_xml(&$view, &$items, $type) {
+  $xml = array();
+  // get the tags
+  $tags = tagadelic_views_get_tags($view, $items, $type);
+  
+  // create a well-formed xml array object
+  foreach ($tags as $key => $tag) {
+  	$terms = array();
+  	$tag = is_object($tag) ? get_object_vars($tag) : $tag; 
+    foreach ($tag as $key => $value) {
+      $terms[] = array(
+        'key' => $key,
+        'value' => $value,
+      );
+    }
+    $xml['terms'][] = array(
+      'key' => 'term',
+      'value' => $terms,
+    );
+  }
+  
+  // create xml list
+  $output = format_xml_elements($xml);
+  
+  // set header to xml
+  drupal_set_header('Content-Type: text/xml; charset=utf-8');
+  print $output;
+  exit;
+}
+
+
+
 function _tagadelic_build_query(&$view, $type) {
   // if the query doesn't exist
   if (!$view->query) {
