Index: shazamgallery.module =================================================================== RCS file: /cvs/drupal/contributions/modules/shazamgallery/shazamgallery.module,v retrieving revision 1.21 diff -u -r1.21 shazamgallery.module --- shazamgallery.module 2 Mar 2006 19:34:47 -0000 1.21 +++ shazamgallery.module 23 Aug 2006 22:17:11 -0000 @@ -257,7 +257,7 @@ $types = variable_get('shazamgallery_nodes', array('image')); if ($type == "page" && user_access('access content')) { - if (_image_get_vid()) { + if (_shazamgallery_get_vid()) { $links[] = l(t("image galleries"), "gallery"); } } @@ -429,10 +429,10 @@ * Set the breadcrumb for any image node */ function _shazamgallery_set_image_breadcrumb($node) { - $terms = taxonomy_node_get_terms_by_vocabulary($node->nid, _image_get_vid()); + $terms = taxonomy_node_get_terms_by_vocabulary($node->nid, _shazamgallery_get_vid()); $term = array_pop($terms); if ($term) { - $vocabulary = taxonomy_get_vocabulary(_image_get_vid()); + $vocabulary = taxonomy_get_vocabulary(_shazamgallery_get_vid()); $breadcrumb[] = array('path' => 'gallery', 'title' => $vocabulary->name); // XXXtangent: changed this to use galleries for the breadcrumb instead of taxonomy if ($parents = shazamgallery_get_parents($node->nid)) { @@ -490,6 +490,25 @@ } /** + * Returns (and possibly creates) a new vocabulary for Image galleries. + */ +function _shazamgallery_get_vid() { + $vid = variable_get('shazamgallery_nav_vocabulary', ''); + if (empty($vid)) { + // Check to see if an image gallery vocabulary exists + $vid = db_result(db_query("SELECT vid FROM {vocabulary} WHERE module='shazamgallery'")); + if (!$vid) { + $vocabulary = array('name' => t('Image Galleries'), 'multiple' => '0', 'required' => '0', 'hierarchy' => '1', 'relations' => '0', 'module' => 'shazamgallery', 'nodes' => array('image' => 1)); + taxonomy_save_vocabulary($vocabulary); + $vid = $vocabulary['vid']; + } + variable_set('shazamgallery_nav_vocabulary', $vid); + } + + return $vid; +} + +/** * Relation APIs */ function shazamgallery_save_relation($left, $right, $weight = 0) {