--- taxonomy_breadcrumb.module.old	2006-11-10 04:16:25.000000000 +0100
+++ taxonomy_breadcrumb.module	2007-01-02 10:09:46.000000000 +0100
@@ -71,6 +71,17 @@ function taxonomy_breadcrumb_get_vocabul
   return $path;
 } 
 
+/**
+ * Return the name of a flexinode
+ *
+ */
+
+function taxonomy_breadcrumb_get_flexinode_type($ctype) {
+  $result = db_query('SELECT name FROM {flexinode_type} WHERE ctype_id = %d', $ctype);
+  $row = db_fetch_array($result);
+  return $row['name'];
+  }
+
 
 /**
  * Return the administrator defined term path for a given term ($tid).
@@ -90,13 +101,20 @@ function taxonomy_breadcrumb_get_term_pa
  * If the current drupal path (q=) is /node/nid, generate the breadcrumb trail 
  * based on nid.
  */
-function taxonomy_breadcrumb_generate_breadcrumb($nid) {
+function taxonomy_breadcrumb_generate_breadcrumb($nid, $is_vocabulary = FALSE) {
 
   // Load node from database, we will need to know the node type (page, book, etc.)
   $node = node_load($nid);
   
   // See if the node type of the current node is part of the node types listed on the advanced settings page.
   $array_of_types = explode(' ', variable_get('taxonomy_breadcrumb_node_types', TAXONOMY_BREADCRUMB_NODE_TYPES_DEFAULT));
+
+  // Check if it's a flexinode
+  $flexidata = explode("-", $node->type);
+  if ($flexidata[0] == "flexinode") {
+    $node->type = taxonomy_breadcrumb_get_flexinode_type($flexidata[1]);
+  }
+
   $in_list = in_array($node->type, $array_of_types);
   
   // if the node type IS IN     the node types list and the list IS     inclusive OR 
@@ -139,6 +157,17 @@ function taxonomy_breadcrumb_generate_br
   }
 }
 
+
+/**
+ * Generate a breadcrumb for views pages, for example, wich aren't associated with
+ * a term. This function will return a breadcrumb that can be aplied to all nodes
+ * that this page shows.
+ */
+function taxonomy_breadcrumb_generate_breadcrumb_for_vocabulary($nid) {
+  
+  return 1;
+  }
+
 /**
  * Implementation of hook_settings().
  */
@@ -202,11 +231,13 @@ function taxonomy_breadcrumb_settings() 
   // node module!), but I don't have much choice.  I can't get all base type names at once from 
   // the function node_get_base (the function node_get_names provides all names, but not bases).
   // Hack might be a strong word to describe the next few lines of code, but they do the job.
-  $node_bases = array();
-  $node_names = module_invoke_all('node_info'); 
-  foreach ($node_names as $value) {
-    $node_bases[] = $value['base'];
-  }
+#  $node_bases = array();
+#  $node_names = module_invoke_all('node_info'); 
+#  foreach ($node_names as $value) {
+#    $node_bases[] = $value['base'];
+#  }
+$node_bases = array();
+$node_bases = node_get_types();
 
   $form['advanced']['taxonomy_breadcrumb_node_types'] = array(
     '#type' => 'textfield',
@@ -222,11 +253,32 @@ function taxonomy_breadcrumb_settings() 
 /**
  * Implementation of hook_nodeapi().
  */
+
 function taxonomy_breadcrumb_nodeapi(&$node, $op, $a3 = NULL, $a4 = NULL) { 
+
+static $matrix = array();
+static $final_matrix = array();
+
   // If we are on a page view (not just a teaser), set the breadcrumb
   // $a4 contains TRUE if we are on a page view
   if ($op == 'view' && $a4) {
     taxonomy_breadcrumb_generate_breadcrumb($node->nid);
+
+  // If we want to set the breadcrumb for pages generated by views module for vocabularies or terms
+  // we set the breadcrumb in a way that it fits for all nodes displayed
+  // $a4 isn't set
+  } else if ($op == 'view' && $node->nid) {
+    taxonomy_breadcrumb_generate_breadcrumb($node->nid);
+
+    $parts = drupal_get_breadcrumb();
+    $matrix[] = $parts;
+    if (count($matrix) > 1) {
+      $final_matrix = array_intersect_assoc($matrix[0],$matrix[1]);
+    } else {
+      $final_matrix = $matrix[0];
+    }
+    //array_pop($final_matrix);
+    drupal_set_breadcrumb($final_matrix);
   }
 }
 
