You are here

function _image_gallery_get_vid in Image 6

Same name and namespace in other branches
  1. 5.2 contrib/image_gallery/image_gallery.module \_image_gallery_get_vid()
  2. 5 contrib/image_gallery/image_gallery.module \_image_gallery_get_vid()
  3. 7 contrib/image_gallery/image_gallery.module \_image_gallery_get_vid()

Returns (and possibly creates) a new vocabulary for Image galleries.

10 calls to _image_gallery_get_vid()
ImageGalleryTest::testBasic in contrib/image_gallery/tests/image_gallery.test
image_gallery_admin in contrib/image_gallery/image_gallery.admin.inc
Menu callback for gallery admin.
image_gallery_admin_edit in contrib/image_gallery/image_gallery.admin.inc
Menu callback for editing or adding a gallery.
image_gallery_admin_form in contrib/image_gallery/image_gallery.admin.inc
Form for editing or adding a gallery.
image_gallery_handler_field_gallery_cover::init in contrib/image_gallery/views/image_gallery_handler_field_gallery_cover.inc

... See full list

File

contrib/image_gallery/image_gallery.module, line 182

Code

function _image_gallery_get_vid() {
  $vid = variable_get('image_gallery_nav_vocabulary', NULL);

  // This is invoked from many locations and only D7 ensures that required
  // modules are installed/enabled first.
  // @todo Perhaps also disable image_gallery module and report an error?
  if (!module_exists('taxonomy')) {
    return $vid;
  }
  if (empty($vid) || !($vocabulary = taxonomy_vocabulary_load($vid))) {

    // Check to see if an image gallery vocabulary exists.
    $vid = db_result(db_query("SELECT vid FROM {vocabulary} WHERE module = 'image_gallery'"));
    if (!$vid && !$vocabulary) {
      $vocabulary = array(
        'name' => t('Image Galleries'),
        'multiple' => 0,
        'required' => 0,
        'hierarchy' => 1,
        'relations' => 0,
        'module' => 'image_gallery',
        'nodes' => array(
          'image' => 1,
        ),
      );
      taxonomy_save_vocabulary($vocabulary);
      $vid = $vocabulary['vid'];
    }
    elseif ($vocabulary) {

      // Existing install; ensure that image node type is still assigned.
      // Keep all other node types intact there.
      $vocabulary = (array) $vocabulary;
      $vocabulary['nodes']['image'] = 1;
      taxonomy_save_vocabulary($vocabulary);
      $vid = $vocabulary['vid'];
    }
    variable_set('image_gallery_nav_vocabulary', $vid);
  }
  return $vid;
}