From f691f25e2cad25e255ee1b9c42b89e2168689c19 Mon Sep 17 00:00:00 2001
From: david <david@david-laptop.(none)>
Date: Wed, 29 Sep 2010 16:57:59 +0100
Subject: [PATCH] Another attempt at creating a patch for adding vocublaries to page titles in Tagadelic

---
 tagadelic.module |   33 +++++++++++++++++++++++++++++++++
 1 files changed, 33 insertions(+), 0 deletions(-)

diff --git a/tagadelic.module b/tagadelic.module
index f2dcf79..4c30548 100644
--- a/tagadelic.module
+++ b/tagadelic.module
@@ -50,6 +50,8 @@ function tagadelic_menu() {
   );
   $items['tagadelic/chunk/%tagadelic_vocs'] = array(
     'title' => 'Tags',
+    'title callback' => 'tagadelic_page_title_callback',
+    'title arguments' => array(2),
     'page callback' => 'tagadelic_page_chunk',
     'page arguments' => array(2),
     'access callback' => 'user_access',
@@ -112,6 +114,36 @@ function tagadelic_vocs_load($vocs) {
 }
 
 /**
+* menu callback to render the tagadelic title
+* @param $vocs. an array of taxonomy vocabulary IDs
+*/
+function tagadelic_page_title_callback($vocs) {
+  $title = '';
+
+  if (empty($vocs)) {
+    $title = t('Tags');
+  }
+  else {
+    $title = t('Tags in @vocabularies', array('@vocabularies' => theme('tagadelic_list_vocs', $vocs)));
+  }
+
+  return $title;
+}
+
+/**
+ * theme function that creates a comma separted list of vocubulary terms
+ * @params $vocs. an array of taxonomy vocabulary ids
+ * @ingroup themable
+ */
+function theme_tagadelic_list_vocs($vocs) {
+  foreach ($vocs as $vid) {
+    $vocabulary = taxonomy_vocabulary_load($vid);
+    $voc_names[] = $vocabulary->name;
+  }
+  return join(', ', $voc_names);
+} 
+
+/**
  * menu callback renders a tagadelic page
  */
 function tagadelic_page_chunk($vocs) {
@@ -407,6 +439,7 @@ function tagadelic_block($op = 'list', $delta = 0, $edit = array()) {
  */
 function tagadelic_theme() {
   return array(
+    'tagadelic_list_vocs' => array('arguments' => array('vocs' => NULL)),
     'tagadelic_list_box' => array('arguments' => array('vocabulary' => NULL, 'tags' => NULL)),
     'tagadelic_more' => array('arguments' => array('vid' => NULL)),
     'tagadelic_weighted' => array('arguments' => array('terms' => NULL))
-- 
1.7.0.4

