You are here

function _node_gallery_install_type_create in Node Gallery 6.2

Same name and namespace in other branches
  1. 6 node_gallery.install \_node_gallery_install_type_create()
1 call to _node_gallery_install_type_create()
node_gallery_install in ./node_gallery.install
Implementation of hook_install()

File

./node_gallery.install, line 123
Node gallery install file.

Code

function _node_gallery_install_type_create() {

  // During install profiles, node and user modules aren't yet loaded.
  // Ensure they're loaded before calling node_get_types().
  include_once './' . drupal_get_path('module', 'node') . '/node.module';
  include_once './' . drupal_get_path('module', 'user') . '/user.module';
  $types = node_get_types();
  $types = array_change_key_case($types, CASE_LOWER);
  if (!in_array('node_gallery_gallery', array_keys($types))) {

    // Create the comment content type.
    $node_gallery_node_type = array(
      'type' => 'node_gallery_gallery',
      'name' => t('Gallery'),
      'module' => 'node',
      'description' => t('This is a gallery (album). This will be the parent of your individual images.'),
      'title_label' => t('Gallery Name'),
      'body_label' => t('Description'),
      'custom' => TRUE,
      'modified' => TRUE,
      'locked' => FALSE,
    );
    $node_gallery_node_type = (object) _node_type_set_defaults($node_gallery_node_type);
    node_type_save($node_gallery_node_type);
    drupal_set_message(t('Node type "Gallery (Node Gallery)" created.'));
  }
  if (!in_array('node_gallery_image', array_keys($types))) {

    // Create the comment content type.
    $node_gallery_image_node_type = array(
      'type' => 'node_gallery_image',
      'name' => t('Gallery Image'),
      'module' => 'node',
      'description' => t('This is an individual image that will be linked to a gallery. This should not be accessed via node/add/node_gallery_image'),
      'title_label' => t('Title'),
      'body_label' => t('Caption'),
      'custom' => TRUE,
      'modified' => TRUE,
      'locked' => FALSE,
    );
    $node_gallery_image_node_type = (object) _node_type_set_defaults($node_gallery_image_node_type);
    node_type_save($node_gallery_image_node_type);
    drupal_set_message(t('Node type "Gallery Image (Node Gallery)" created.'));
  }
  if (!in_array('node_gallery_gallery', array_keys($types)) || !in_array('node_gallery_image', array_keys($types))) {
    cache_clear_all();
    node_types_rebuild();
  }
}