/[drupal]/contributions/modules/taxonomy_breadcrumb/taxonomy_breadcrumb.module
ViewVC logotype

Diff of /contributions/modules/taxonomy_breadcrumb/taxonomy_breadcrumb.module

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph | View Patch Patch

revision 1.7, Mon Jan 12 02:19:26 2009 UTC revision 1.7.2.1, Fri Mar 13 16:46:03 2009 UTC
# Line 1  Line 1 
1  <?php  <?php
2  // $Id: taxonomy_breadcrumb.module,v 1.6 2008/03/15 17:48:12 craig Exp $.  // $Id: taxonomy_breadcrumb.module,v 1.7 2009/01/12 02:19:26 mgn Exp $.
3    
4  /**  /**
5   * @file   * @file
# Line 78  function taxonomy_breadcrumb_nodeapi(&$n Line 78  function taxonomy_breadcrumb_nodeapi(&$n
78      include_once drupal_get_path('module', 'taxonomy_breadcrumb') .'/taxonomy_breadcrumb.inc';      include_once drupal_get_path('module', 'taxonomy_breadcrumb') .'/taxonomy_breadcrumb.inc';
79    
80      // See if the node type of the current node is part of the node types listed on the advanced settings page.      // See if the node type of the current node is part of the node types listed on the advanced settings page.
81      $array_of_types = explode(' ', variable_get('taxonomy_breadcrumb_node_types', TAXONOMY_BREADCRUMB_NODE_TYPES_DEFAULT));      $array_of_types = array_filter((array)variable_get('taxonomy_breadcrumb_node_types', TAXONOMY_BREADCRUMB_NODE_TYPES_DEFAULT));
82      $in_list = in_array($node->type, $array_of_types);      $in_list = in_array($node->type, $array_of_types);
83    
84      // if the node type IS IN     the node types list and the list IS     inclusive OR      // if the node type IS IN     the node types list and the list IS     inclusive OR
# Line 89  function taxonomy_breadcrumb_nodeapi(&$n Line 89  function taxonomy_breadcrumb_nodeapi(&$n
89        // Extract lightest term from lightest vocabulary assosciated with node.        // Extract lightest term from lightest vocabulary assosciated with node.
90        $term = _taxonomy_breadcrumb_node_get_lightest_term($node->nid);        $term = _taxonomy_breadcrumb_node_get_lightest_term($node->nid);
91        $breadcrumb = _taxonomy_breadcrumb_generate_breadcrumb($term->tid);        $breadcrumb = _taxonomy_breadcrumb_generate_breadcrumb($term->tid);
92          if (variable_get('taxonomy_breadcrumb_include_node_title', FALSE)) {
93            $breadcrumb[] = $node->title;
94          }
95        drupal_set_breadcrumb($breadcrumb);        drupal_set_breadcrumb($breadcrumb);
96      }      }
97    }    }
# Line 180  function taxonomy_breadcrumb_taxonomy($o Line 183  function taxonomy_breadcrumb_taxonomy($o
183    
184      // Set variables to used in SQL query to reflect if vocabulary or term is      // Set variables to used in SQL query to reflect if vocabulary or term is
185      // being updated.      // being updated.
186    
187      if ($type == 'vocabulary') {      if ($type == 'vocabulary') {
188        $table = '{taxonomy_breadcrumb_vocabulary}';        $table = '{taxonomy_breadcrumb_vocabulary}';
189        $key_type = 'vid';        $key_type = 'vid';
# Line 190  function taxonomy_breadcrumb_taxonomy($o Line 194  function taxonomy_breadcrumb_taxonomy($o
194        $key_type = 'tid';        $key_type = 'tid';
195        $old_path = _taxonomy_breadcrumb_get_term_path($object['tid']);        $old_path = _taxonomy_breadcrumb_get_term_path($object['tid']);
196      }      }
197      $key = $object[$key_type];      $key = isset($object[$key_type]) ? $object[$key_type] : NULL;
198      $new_path = $object['taxonomy_breadcrumb_path'];      $new_path = isset($object['taxonomy_breadcrumb_path']) ? $object['taxonomy_breadcrumb_path'] : NULL;
   
     // Delete record from taxonomy_breadcrumb_vocabulary or taxonomy_breadcrumb_term  
     if (drupal_strlen($new_path) == 0 && $old_path !== NULL) {  
       db_query("DELETE FROM $table WHERE $key_type = %d", $key);  
     }  
199    
200      // Update existing record in taxonomy_breadcrumb_vocabulary or taxonomy_breadcrumb_term      if (!is_null($new_path)) { // Only modify database when the object has the 'taxonomy_breadcrumb_path' field
     elseif (drupal_strlen($new_path) != 0 && $old_path != NULL) {  
       db_query("UPDATE $table SET path = '%s' WHERE $key_type = %d", $new_path, $key );  
     }  
201    
202      // Create new record in taxonomy_breadcrumb_vocabulary or taxonomy_breadcrumb_term      // Delete record from taxonomy_breadcrumb_vocabulary or taxonomy_breadcrumb_term
203      elseif (drupal_strlen($new_path) != 0 && $old_path == NULL) {        if (drupal_strlen($new_path) == 0 && $old_path !== NULL) {
204        db_query("INSERT INTO $table ($key_type, path) VALUES (%d, '%s')", $key, $new_path);          db_query("DELETE FROM $table WHERE $key_type = %d", $key);
205          }
206    
207          // Update existing record in taxonomy_breadcrumb_vocabulary or taxonomy_breadcrumb_term
208          elseif (drupal_strlen($new_path) != 0 && $old_path != NULL) {
209            db_query("UPDATE $table SET path = '%s' WHERE $key_type = %d", $new_path, $key );
210          }
211    
212          // Create new record in taxonomy_breadcrumb_vocabulary or taxonomy_breadcrumb_term
213          elseif (drupal_strlen($new_path) != 0 && $old_path == NULL) {
214            db_query("INSERT INTO $table ($key_type, path) VALUES (%d, '%s')", $key, $new_path);
215          }
216      }      }
217    }    }
218  }  }

Legend:
Removed from v.1.7  
changed lines
  Added in v.1.7.2.1

  ViewVC Help
Powered by ViewVC 1.1.2