? node-gallery-hierarchies2.patch
Index: node_gallery.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/node_gallery/node_gallery.inc,v
retrieving revision 1.2.2.59
diff -u -p -r1.2.2.59 node_gallery.inc
--- node_gallery.inc	4 Nov 2010 14:14:00 -0000	1.2.2.59
+++ node_gallery.inc	4 Nov 2010 14:33:29 -0000
@@ -203,6 +203,93 @@ function node_gallery_get_types($type = 
 }
 
 /**
+ * Returns a hierarchical array of galleries.
+ *
+ * @param string $type
+ *   The content type name of the gallery type.
+ */
+function node_gallery_get_gallery_tree($type) {
+  // design decision: I key by type and prune the tree later for uid because of easier caching
+  if (($cache = cache_get('node_gallery:'.$type.'_gallery_hierarchy')) != NULL) {
+    $galleries = $cache->data;
+  } else {
+    $sql = "SELECT n.nid as gid, n.title, n.uid, n.status, g.parent_gid as parent FROM {node} n INNER JOIN {node_gallery_galleries} g ON n.nid = g.gid WHERE n.type = '%s'";
+    //$sql .= ' ORDER BY g.weight, n.title';
+    $result = db_query($sql, array($type));
+    $childrens = $parents = $terms = array();
+    while ($gallery = db_fetch_object($result)) {
+      // we create the tree in steps, because children might appear before parents
+      $children[$gallery->parent][] = $gallery->gid;
+      $parents[$gallery->gid][] = $gallery->parent;
+      $galleries[$gallery->gid] = $gallery;
+    }
+    foreach ($galleries as $gid => $gallery) {
+      if (isset($children[$gid])) {
+        $galleries[$gid]->children = array();
+        foreach ($children[$gid] as $child) {
+          $galleries[$gid]->children[] = $galleries[$child];
+        }
+      }
+      if (isset($parents[$gid])) {
+        $galleries[$gid]->parents = array();
+        foreach ($parents[$gid] as $parent) {
+          if ($parent != 0) {
+            $galleries[$gid]->parents[] = $galleries[$parent];
+          }
+        }
+      }
+      foreach ($galleries as $gid => $gallery) {
+        if (!empty($gallery->parents)) {
+          unset($galleries[$gid]);
+        }
+      }
+    }
+    // permanent cache: should only be reset by us, as the rest of drupal doesn't know this hierarchy.
+    cache_set('node_gallery:'.$type.'_gallery_hierarchy', $galleries, 'cache', CACHE_PERMANENT);
+  }
+
+  return $galleries;
+}
+
+/**
+ * Internal recursive function to traverse the tree of galleries.
+ *
+ * @staticvar array $galleries Gallery hierarchy, @see node_gallery_get_gallery_tree().
+ * @param string $type Content type of gallery.
+ * @param int $uid User id.
+ * @param array $prune Prune the subtrees of these nodes (to avoid loops in hierarchy)
+ * @param array $_siblings The current partial hierarchy.
+ * @param int $depth The current depth level in the hierarchy.
+ * @return partial string of gallery hierarchy for select list.
+ */
+function _node_gallery_get_gallery_list($type, $uid = NULL, $prune = array(), &$_siblings = NULL, $depth = -1) {
+  $ret = array();
+  if (!$_siblings) {
+    $_siblings =& node_gallery_get_gallery_tree($type);
+  }
+  $depth++;
+  foreach ($_siblings as $sibling) {
+    if ($uid && ($uid != $sibling->uid)) {
+      // this part of the tree doesn't belong to the user
+      continue;
+    }
+    if (!empty($prune) && in_array($sibling->gid, $prune)) {
+      // skip this part of the tree
+      continue;
+    }
+    $title = '';
+    for ($i = 0; $i < $depth; ++$i) {
+      $title .= '-';
+    }
+    $ret[$sibling->gid] = $title.$sibling->title;
+    if (!empty($sibling->children)) {
+      $ret += _node_gallery_get_gallery_list($type, $uid, $prune, $sibling->children, $depth);
+    }
+  }
+  return $ret;
+}
+
+/**
  * Returns an array of galleries, suitable for use in a form select.
  * 
  * @param $type
@@ -214,19 +301,69 @@ function node_gallery_get_types($type = 
  * @return
  *   Associative array where the keys are the nid, and the value is the node title.
  */
-function node_gallery_get_gallery_list($type, $uid = NULL) {
-  $sql = "SELECT n.nid, n.title FROM {node} n WHERE n.type = '%s'";
-  $args[] = $type;
-  $items = array();
-  if ($uid) {
-    $sql .= " AND n.uid = %d ";
-    $args[] = $uid;
+function node_gallery_get_gallery_list($type, $uid = NULL, $prune = array()) {
+  return _node_gallery_get_gallery_list($type, $uid, $prune);
+}
+
+/**
+ * Returns the tree of the gallery hierarchy with the passed GID as root (BFS).
+ *
+ * @param string $type Content type of gallery.
+ * @param int $gid Gallery id which should act as root of the tree.
+ * @param array $layer Recursion parameter, current level of tree that is traversed.
+ */
+function node_gallery_get_subgalleries($type, $gid, &$layer = array()) {
+  if (empty($layer)) {
+    // function entrance. begin with root elements.
+    $layer = node_gallery_get_gallery_tree($type);
+  }
+
+  $children = array();
+  foreach ($layer as $gallery) {
+    if ($gallery->gid == $gid) {
+      return $gallery;
+    } else {
+      if (!empty($gallery->children)) {
+        $children += $gallery->children;
+      }
+    }
   }
-  $result = db_query($sql, $args);
-  while ($r = db_fetch_array($result)) {
-    $items[$r['nid']] = $r['title'];
+  if (empty($children)) {
+    // element not in tree
+    return FALSE;
+  } else {
+    // advance to next layer of tree
+    return node_gallery_get_subgalleries($type, $gid, $children);
   }
-  return $items;
+}
+
+/**
+ * Returns a flat list of gallery ids in the passed gallery tree (DFS).
+ * 
+ * @param array $gallery_tree The hierarchical gallery tree.
+ * @return array List of gallery ids in the tree.
+ */
+function node_gallery_flatten_gallery_ids(&$gallery_tree) {
+  if (empty($gallery_tree)) {
+    return;
+  }
+  $gids = array();
+  if (is_object($gallery_tree)) {
+    // single root element (proper tree)
+    $gids[] = $gallery_tree->gid;
+    if (!empty($gallery_tree->children)) {
+      $gids = array_merge($gids, node_gallery_flatten_gallery_ids($gallery_tree->children));
+    }
+  } else {
+    // array: multiple trees
+    foreach ($gallery_tree as $gallery) {
+      $gids[] = $gallery->gid;
+      if (!empty($gallery->children)) {
+        $gids = array_merge($gids, node_gallery_flatten_gallery_ids($gallery->children));
+      }
+    }
+  }
+  return $gids;
 }
 
 /**
@@ -301,6 +438,11 @@ function node_gallery_get_cover_nid($gal
   return $cover_nid;
 }
 
+function node_gallery_attach_gallery_attributes(&$node) {
+  $extra_attributes = db_fetch_array(db_query("SELECT * FROM {node_gallery_galleries} WHERE gid = %d", $node->nid));
+  $node = (object)array_merge((array)$node, (array)$extra_attributes);
+}
+
 /**
  * Builds an array with the data necessary to navigate a gallery.
  * 
Index: node_gallery.install
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/node_gallery/node_gallery.install,v
retrieving revision 1.19.2.51
diff -u -p -r1.19.2.51 node_gallery.install
--- node_gallery.install	12 Aug 2010 22:17:18 -0000	1.19.2.51
+++ node_gallery.install	31 Oct 2010 17:11:42 -0000
@@ -98,6 +98,13 @@ function node_gallery_schema() {
         'default' => NULL,
         'description' => t('Node Id of the Cover Image')
       ),
+      'parent_gid' => array(
+        'type' => 'int',
+        'unsigned' => TRUE,
+        'not null' => TRUE,
+        'default' => 0,
+        'description' => t('Parent gallery node id.'),
+      ),
     ),
     'primary key' => array('gid'),
     'unique keys' => array(
@@ -670,3 +677,8 @@ function node_gallery_update_6300() {
   return $ret;
 } 
 
+function node_gallery_update_6301() {
+  $ret = array();
+  $ret[] = update_sql('ALTER TABLE {node_gallery_galleries} ADD COLUMN parent_gid INT UNSIGNED NOT NULL default 0');
+  return $ret;
+}
Index: node_gallery.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/node_gallery/node_gallery.module,v
retrieving revision 1.18.2.102
diff -u -p -r1.18.2.102 node_gallery.module
--- node_gallery.module	4 Nov 2010 14:14:00 -0000	1.18.2.102
+++ node_gallery.module	4 Nov 2010 14:36:31 -0000
@@ -223,9 +223,9 @@ function node_gallery_menu() {
   $items['galleries/%user/%'] = array(
     'title' => 'My Galleries',
     'title callback' => 'node_gallery_list_galleries_title',
-    'title arguments' => array(1, 2),
+    'title arguments' => array(1, 2, 3),
     'page callback' => 'node_gallery_list_galleries',
-    'page arguments' => array(1, 2),
+    'page arguments' => array(1, 2, 3),
     'access arguments' => array(NODE_GALLERY_PERM_VIEW_GALLERY),
     'file' => 'node_gallery.pages.inc',
     'type' => MENU_CALLBACK,
@@ -311,6 +311,7 @@ function node_gallery_theme() {
  * Implements hook_form_alter().
  */
 function node_gallery_form_alter(&$form, $form_state, $form_id) {
+  global $user;
   // If displaying our VBO image weight form, theme it
   if (strpos($form_id, 'views_bulk_operations_form') !== FALSE && isset($form['node_gallery_change_image_weight_action']) && isset($form['#ngtheme'])) {
     $form['#theme'] = $form['#ngtheme'];
@@ -414,7 +415,31 @@ function node_gallery_form_alter(&$form,
           }
         }
       }
-      
+    } elseif (in_array($form['type']['#value'], (array)node_gallery_get_types('gallery'))) {
+      // if displaying a gallery edit form, display a select box allowing choice of parent gallery
+      $default = 0;
+      $prune = array();
+      if (isset($form['#node']->nid)) {
+        $default = $form['#node']->parent_gid;
+        $prune = array($form['#node']->nid);
+      }
+      $galleries = array(0 => t('No parent'));
+      $galleries += node_gallery_get_gallery_list($form['type']['#value'], $user->uid, $prune);
+      $form['node_gallery_hierarchy'] = array(
+        '#type' => 'fieldset',
+        '#title' => t('Parent gallery'),
+        '#weight' => -1,
+        '#collapsible' => TRUE,
+        '#collapsed' => TRUE,
+      );
+      $form['node_gallery_hierarchy']['parent_gid'] = array(
+          '#type' => 'select',
+          '#title' => t("Parent gallery"),
+          '#options' => $galleries,
+          '#default_value' => $default,
+          '#description' => t("Choose an existing gallery under which the new gallery will appear."),
+          '#weight' => -1,
+      );
     }
   }
 }
@@ -459,7 +484,8 @@ function node_gallery_nodeapi(&$node, $o
   switch ($op) {
     case 'load':
       if (in_array($node->type, (array)node_gallery_get_types('gallery'))) {
-        $node->cover_image = node_gallery_get_cover_nid($node);
+        //$node->cover_image = node_gallery_get_cover_nid($node);
+        node_gallery_attach_gallery_attributes($node);
       }
       if (in_array($node->type, (array)node_gallery_get_types('image'))) {
         node_gallery_load_image($node);
@@ -478,6 +504,8 @@ function node_gallery_nodeapi(&$node, $o
       elseif (in_array($node->type, (array)node_gallery_get_types('gallery'))) {
         $node->gid = $node->nid;
         drupal_write_record('node_gallery_galleries', $node);
+        // clear hierarchy cache
+        cache_clear_all('node_gallery:'.$node->type.'_gallery_hierarchy', 'cache');
       }
       break;
     case 'update':
@@ -516,6 +544,10 @@ function node_gallery_nodeapi(&$node, $o
           // publish status changed
           _node_gallery_set_publish($node, $node->status);
         }
+        if ($node->parent_gid != $old_node->parent_gid) {
+          // hierarchy changed, clear cache
+          cache_clear_all('node_gallery:'.$node->type.'_gallery_hierarchy', 'cache');
+        }
         drupal_write_record('node_gallery_galleries', $node, 'gid');
       }
       break;
@@ -587,6 +619,11 @@ function _node_gallery_gallery_view(&$no
     // @todo: we should be able to programmatically set some options on the view, such as number of images, imagefield_name, etc.
     $output = views_embed_view($viewkey['name'], $viewkey['display_id'], $node->nid);
     $node->content['gallery'] = array('#value' => $output, '#weight' => -3);
+
+    // Display subgalleries.
+    $viewkey = unserialize(variable_get('node_gallery_galleries_summary_view', serialize(array('name' => 'node_gallery_gallery_summaries', 'display_id' => 'page_4'))));
+    $output = views_embed_view($viewkey['name'], $viewkey['display_id'], NULL, NULL, $node->nid);
+    $node->content['subgalleries'] = array('#value' => $output, '#weight' => -4);
   }
   else {
     $viewkey = unserialize($config['view_gallery_teaser_view_image_display']);
@@ -637,8 +674,33 @@ function _node_gallery_image_view(&$node
  *   A reference to the gallery node object
  */
 function _node_gallery_delete(&$node) {
-
+  //@todo: delete subgalleries
   if (in_array($node->type, (array)node_gallery_get_types('gallery'))) {
+    $operations = array();
+    $tree = node_gallery_get_subgalleries($node->type, $node->gid);
+    if (!empty($tree->children)) {
+      // the gallery has children, delete subgalleries in batches
+      $gallery_deletes = array_chunk($tree->children, NODE_GALLERY_BATCH_CHUNK_SIZE);
+      foreach ($gallery_deletes as $gallery_delete) {
+        $operations[] = array('node_gallery_gallery_delete_process', array($gallery_delete));
+      }
+      if (!empty($operations)) {
+        $batch = array(
+          'operations' => $operations,
+          'finished' => 'node_gallery_gallery_delete_process_finished',
+          'title' => t('Processing Gallery Delete.'),
+          'init_message' => t('Gallery deletion is cascading to subgalleries.'),
+          'progress_message' => t('Processing gallery deletions.'),
+          'error_message' => t('Gallery deletion has encountered an error.'),
+        );
+        batch_set($batch);
+      }
+    }
+    
+    // delete our related gallery entry
+    node_gallery_delete_gallery($node);
+    
+    $operations = array();
     $gid = $node->nid;
     $imagenids = node_gallery_get_all_image_nids($node);
     $total = count($imagenids);
@@ -662,10 +724,9 @@ function _node_gallery_delete(&$node) {
         'progress_message' => t('Processing image deletions.'),
         'error_message' => t('Gallery deletion has encountered an error.'),
       );
-
       batch_set($batch);
-      node_gallery_delete_gallery($node);
     }
+    cache_clear_all('node_gallery:'.$node->type.'_gallery_hierarchy', 'cache');
   }
   if (in_array($node->type, (array)node_gallery_get_types('image'))) {
     $gid = $node->gid;
@@ -747,6 +808,62 @@ function node_gallery_image_delete_proce
   }
 }
 
+
+/**
+ * Deletes batches of galleries for batch API.
+ * _node_gallery_delete
+ * @param $galleryies
+ *   Array of gallery hierarchy objects to delete.
+ * @param $context
+ *   Array provided by batch API.
+ */
+function node_gallery_gallery_delete_process($galleries, &$context) {
+  if (!isset($context['sandbox']['progress'])) {
+    $context['sandbox']['progress'] = 0;
+    $context['sandbox']['max'] = count($galleries);
+  }
+  if (!isset($context['sandbox']['galleries'])) {
+      $context['sandbox']['galleries'] = $galleries;
+  }
+  while (!empty($context['sandbox']['galleries'])) {
+    $gallery = array_shift($context['sandbox']['galleries']);
+    node_delete($gallery->gid);
+    $context['sandbox']['progress']++;
+  }
+  // Let the batch engine know how close we are to completion.
+  if ($context['sandbox']['progress'] == $context['sandbox']['max']) {
+    $context['finished'] = 1;
+  } else {
+    $context['finished'] = $context['sandbox']['progress'] / $context['sandbox']['max'];
+  }
+}
+
+/**
+ * Used as a finished callback for batch API deletion of Galleries.
+ *
+ * @param $success
+ *   Scalar provided by batch API.
+ * @param $results
+ *   Array provided by batch API.
+ * @param $operations
+ *   Array provided by batch API.
+ */
+function node_gallery_gallery_delete_process_finished($success, $results, $operations) {
+  if ($success) {
+    drupal_set_message(t('Gallery deletions complete.'));
+  }
+  else {
+    // An error occurred.
+    // $operations contains the operations that remained unprocessed.
+    $error_operation = reset($operations);
+    $operation = array_shift($error_operation);
+    $arguments = array_shift($error_operation);
+    $arguments_as_string = implode(', ', $arguments);
+    watchdog('node_gallery', "Error when calling operation '%s'('%s')", array($operation, $arguments_as_string));
+    drupal_set_message(t('An error occurred and has been recorded in the system log.'), 'error');
+  }
+}
+
 function node_gallery_batch_node_save($nodes, &$context) {
   if (!isset($context['sandbox']['progress'])) {
     $context['sandbox']['progress'] = 0;
Index: node_gallery.pages.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/node_gallery/node_gallery.pages.inc,v
retrieving revision 1.12.2.48
diff -u -p -r1.12.2.48 node_gallery.pages.inc
--- node_gallery.pages.inc	2 Nov 2010 16:24:46 -0000	1.12.2.48
+++ node_gallery.pages.inc	4 Nov 2010 08:23:02 -0000
@@ -71,8 +71,9 @@ function node_gallery_browse_images($gal
  * @return
  *   HTML Output
  */
-function node_gallery_list_galleries($user = NULL, $content_type = NULL) {
+function node_gallery_list_galleries($user = NULL, $content_type = NULL, $parent_gallery = NULL) {
   $viewkey = unserialize(variable_get('node_gallery_galleries_summary_view', serialize(array('name' => 'node_gallery_gallery_summaries', 'display_id' => 'page_1'))));
+  // @todo: I think setting the breadcrumb should be factored out globally
   $breadcrumbs[] = l(t('Home'), NULL);
   $breadcrumbs[] = l(t('Galleries'), 'galleries');
   if (isset($user->name)) {
@@ -80,8 +81,12 @@ function node_gallery_list_galleries($us
   }
   drupal_set_breadcrumb($breadcrumbs);
   // @todo: we should be able to programmatically set some options on the view, such as number of images, imagefield_name, etc.
-  $output = views_embed_view($viewkey['name'], $viewkey['display_id'], $user->uid, $content_type);
-  return $output;
+  $view = views_get_view($viewkey['name']);
+  $view->set_display($viewkey['display_id']);
+  $view->set_arguments(array($user->uid, $content_type, $parent_gallery));
+  $view->pager['use_pager'] = true;
+  $view->pager['items_per_page'] = 18;
+  return $view->render();
 }
 
 /**
Index: views2inc/node_gallery.views.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/node_gallery/views2inc/Attic/node_gallery.views.inc,v
retrieving revision 1.1.2.16
diff -u -p -r1.1.2.16 node_gallery.views.inc
--- views2inc/node_gallery.views.inc	3 Aug 2010 15:35:50 -0000	1.1.2.16
+++ views2inc/node_gallery.views.inc	3 Nov 2010 17:25:12 -0000
@@ -70,6 +70,33 @@ function node_gallery_views_data() {
       'field' => 'gid',
     ),
   );
+  // gemuend for gallery hierarchies
+  $data['node_gallery_galleries']['parent_gid'] = array(
+    'title' => t("Parent Gallery"),
+    'help' => t("The Id of the galleries parent."),
+    'field' => array(
+      'handler' => 'views_handler_field_node',
+      'click sortable' => TRUE,
+    ),
+    'relationship' => array(
+      'label' => t('Parent Gallery'),
+      'base' => 'node_gallery_galleries',
+      'base field' => 'gid',
+    ),
+    'argument' => array(
+      'handler' => 'views_handler_argument_node_nid',
+      'name field' => 'title', // the field to display in the summary.
+      'numeric' => TRUE,
+      'validate type' => 'nid',
+    ),
+    'filter' => array(
+      'handler' => 'views_handler_filter_numeric',
+    ),
+    'sort' => array(
+      'handler' => 'views_handler_sort',
+    ),
+  );
+
   // @todo the next two elements require views 2.7, we should enable them dynamically.
   $data['node_gallery_galleries']['newest_image'] = array(
     'title' => t('Gallery Newest Image'),
Index: views2inc/node_gallery.views_default.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/node_gallery/views2inc/Attic/node_gallery.views_default.inc,v
retrieving revision 1.1.2.23
diff -u -p -r1.1.2.23 node_gallery.views_default.inc
--- views2inc/node_gallery.views_default.inc	30 Oct 2010 12:52:50 -0000	1.1.2.23
+++ views2inc/node_gallery.views_default.inc	4 Nov 2010 14:16:59 -0000
@@ -414,6 +414,9 @@ function node_gallery_views_default_view
     'alignment' => 'horizontal',
   ));
   $handler = $view->new_display('page', 'View all image thumbnails', 'page_1');
+  $handler->override_option('use_ajax', TRUE);
+  $handler->override_option('items_per_page', 24);
+  $handler->override_option('use_pager', '1');
   $handler->override_option('path', 'gallery_grid/%');
   $handler->override_option('menu', array(
     'type' => 'none',
@@ -775,7 +778,6 @@ function node_gallery_views_default_view
     'weight' => 0,
     'name' => 'navigation',
   ));
-    
   $views[$view->name] = $view;
 
   /*
@@ -947,7 +949,7 @@ function node_gallery_views_default_view
   ));
   $handler->override_option('arguments', array(
     'uid' => array(
-      'default_action' => 'ignore',
+      'default_action' => 'default',
       'style_plugin' => 'default_summary',
       'style_options' => array(),
       'wildcard' => 'all',
@@ -966,19 +968,13 @@ function node_gallery_views_default_view
       'validate_user_argument_type' => 'either',
       'validate_user_roles' => array(
         '2' => 0,
-        '4' => 0,
-        '3' => 0,
       ),
       'relationship' => 'none',
       'default_options_div_prefix' => '',
       'default_argument_user' => 0,
-      'default_argument_fixed' => '',
+      'default_argument_fixed' => 'all',
       'default_argument_php' => '',
       'validate_argument_node_type' => array(
-        'product' => 0,
-        'photograph' => 0,
-        'product_kit' => 0,
-        'event' => 0,
         'node_gallery_gallery' => 0,
         'node_gallery_image' => 0,
         'page' => 0,
@@ -986,9 +982,7 @@ function node_gallery_views_default_view
       ),
       'validate_argument_node_access' => 0,
       'validate_argument_nid_type' => 'nid',
-      'validate_argument_vocabulary' => array(
-        '1' => 0,
-      ),
+      'validate_argument_vocabulary' => array(),
       'validate_argument_type' => 'tid',
       'validate_argument_transform' => 0,
       'validate_user_restrict_roles' => 0,
@@ -1004,7 +998,7 @@ function node_gallery_views_default_view
       ),
     ),
     'type' => array(
-      'default_action' => 'ignore',
+      'default_action' => 'default',
       'style_plugin' => 'default_summary',
       'style_options' => array(),
       'wildcard' => 'all',
@@ -1021,8 +1015,6 @@ function node_gallery_views_default_view
       'validate_user_argument_type' => 'uid',
       'validate_user_roles' => array(
         '2' => 0,
-        '4' => 0,
-        '3' => 0,
       ),
       'override' => array(
         'button' => 'Override',
@@ -1030,13 +1022,9 @@ function node_gallery_views_default_view
       'relationship' => 'none',
       'default_options_div_prefix' => '',
       'default_argument_user' => 0,
-      'default_argument_fixed' => '',
+      'default_argument_fixed' => 'all',
       'default_argument_php' => '',
       'validate_argument_node_type' => array(
-        'product' => 0,
-        'photograph' => 0,
-        'product_kit' => 0,
-        'event' => 0,
         'node_gallery_gallery' => 0,
         'node_gallery_image' => 0,
         'page' => 0,
@@ -1044,9 +1032,7 @@ function node_gallery_views_default_view
       ),
       'validate_argument_node_access' => 0,
       'validate_argument_nid_type' => 'nid',
-      'validate_argument_vocabulary' => array(
-        '1' => 0,
-      ),
+      'validate_argument_vocabulary' => array(),
       'validate_argument_type' => 'tid',
       'validate_argument_transform' => 0,
       'validate_user_restrict_roles' => 0,
@@ -1058,6 +1044,46 @@ function node_gallery_views_default_view
       'validate_argument_user_flag_id_type' => 'id',
       'validate_argument_php' => '',
     ),
+    'parent_gid' => array(
+      'default_action' => 'default',
+      'style_plugin' => 'default_summary',
+      'style_options' => array(),
+      'wildcard' => 'all',
+      'wildcard_substitution' => 'All',
+      'title' => '',
+      'breadcrumb' => '',
+      'default_argument_type' => 'fixed',
+      'default_argument' => '',
+      'validate_type' => 'none',
+      'validate_fail' => 'empty',
+      'break_phrase' => 0,
+      'not' => 0,
+      'id' => 'parent_gid',
+      'table' => 'node_gallery_galleries',
+      'field' => 'parent_gid',
+      'validate_user_argument_type' => 'uid',
+      'validate_user_roles' => array(
+        '2' => 0,
+      ),
+      'relationship' => 'none',
+      'default_options_div_prefix' => '',
+      'default_argument_fixed' => '0',
+      'default_argument_user' => 0,
+      'default_argument_php' => '',
+      'validate_argument_node_type' => array(
+        'node_gallery_gallery' => 0,
+        'node_gallery_image' => 0,
+        'page' => 0,
+        'story' => 0,
+      ),
+      'validate_argument_node_access' => 0,
+      'validate_argument_nid_type' => 'nid',
+      'validate_argument_vocabulary' => array(),
+      'validate_argument_type' => 'tid',
+      'validate_argument_transform' => 0,
+      'validate_user_restrict_roles' => 0,
+      'validate_argument_php' => '',
+    ),
   ));
   $handler->override_option('filters', array(
     'status' => array(
@@ -1139,6 +1165,7 @@ function node_gallery_views_default_view
     'title' => '',
     'description' => '',
     'weight' => 0,
+    'name' => 'navigation',
   ));
   $handler = $view->new_display('page', 'Galleries Cover Grid', 'page_4');
   $handler->override_option('fields', array(
@@ -1272,43 +1299,6 @@ function node_gallery_views_default_view
       'relationship' => 'cover_image',
     ),
   ));
-  $handler->override_option('filters', array(
-    'status' => array(
-      'operator' => '=',
-      'value' => '1',
-      'group' => '0',
-      'exposed' => FALSE,
-      'expose' => array(
-        'operator' => FALSE,
-        'label' => '',
-      ),
-      'id' => 'status',
-      'table' => 'node',
-      'field' => 'status',
-      'relationship' => 'none',
-    ),
-    'gid' => array(
-      'operator' => '>',
-      'value' => array(
-        'value' => '0',
-        'min' => '',
-        'max' => '',
-      ),
-      'group' => '0',
-      'exposed' => FALSE,
-      'expose' => array(
-        'operator' => FALSE,
-        'label' => '',
-      ),
-      'id' => 'gid',
-      'table' => 'node_gallery_galleries',
-      'field' => 'gid',
-      'override' => array(
-        'button' => 'Use default',
-      ),
-      'relationship' => 'none',
-    ),
-  ));
   $handler->override_option('title', 'Gallery Summary');
   $handler->override_option('style_plugin', 'grid');
   $handler->override_option('style_options', array(
@@ -1336,6 +1326,7 @@ function node_gallery_views_default_view
     'title' => '',
     'description' => '',
     'weight' => 0,
+    'name' => 'navigation',
   ));
   $handler = $view->new_display('page', 'My Galleries Grid', 'page_2');
   $handler->override_option('arguments', array(
@@ -1397,7 +1388,7 @@ function node_gallery_views_default_view
       ),
     ),
     'type' => array(
-      'default_action' => 'ignore',
+      'default_action' => 'default',
       'style_plugin' => 'default_summary',
       'style_options' => array(),
       'wildcard' => 'all',
@@ -1414,22 +1405,16 @@ function node_gallery_views_default_view
       'validate_user_argument_type' => 'uid',
       'validate_user_roles' => array(
         '2' => 0,
-        '4' => 0,
-        '3' => 0,
       ),
       'override' => array(
-        'button' => 'Override',
+        'button' => 'Use default',
       ),
       'relationship' => 'none',
       'default_options_div_prefix' => '',
       'default_argument_user' => 0,
-      'default_argument_fixed' => '',
+      'default_argument_fixed' => 'all',
       'default_argument_php' => '',
       'validate_argument_node_type' => array(
-        'product' => 0,
-        'photograph' => 0,
-        'product_kit' => 0,
-        'event' => 0,
         'node_gallery_gallery' => 0,
         'node_gallery_image' => 0,
         'page' => 0,
@@ -1437,9 +1422,7 @@ function node_gallery_views_default_view
       ),
       'validate_argument_node_access' => 0,
       'validate_argument_nid_type' => 'nid',
-      'validate_argument_vocabulary' => array(
-        '1' => 0,
-      ),
+      'validate_argument_vocabulary' => array(),
       'validate_argument_type' => 'tid',
       'validate_argument_transform' => 0,
       'validate_user_restrict_roles' => 0,
@@ -1451,6 +1434,49 @@ function node_gallery_views_default_view
       'validate_argument_user_flag_id_type' => 'id',
       'validate_argument_php' => '',
     ),
+    'parent_gid' => array(
+      'default_action' => 'default',
+      'style_plugin' => 'default_summary',
+      'style_options' => array(),
+      'wildcard' => 'all',
+      'wildcard_substitution' => 'All',
+      'title' => '',
+      'breadcrumb' => '',
+      'default_argument_type' => 'fixed',
+      'default_argument' => '',
+      'validate_type' => 'none',
+      'validate_fail' => 'ignore',
+      'break_phrase' => 0,
+      'not' => 0,
+      'id' => 'parent_gid',
+      'table' => 'node_gallery_galleries',
+      'field' => 'parent_gid',
+      'validate_user_argument_type' => 'uid',
+      'validate_user_roles' => array(
+        '2' => 0,
+      ),
+      'override' => array(
+        'button' => 'Use default',
+      ),
+      'relationship' => 'none',
+      'default_options_div_prefix' => '',
+      'default_argument_fixed' => '0',
+      'default_argument_user' => 0,
+      'default_argument_php' => '',
+      'validate_argument_node_type' => array(
+        'node_gallery_gallery' => 0,
+        'node_gallery_image' => 0,
+        'page' => 0,
+        'story' => 0,
+      ),
+      'validate_argument_node_access' => 0,
+      'validate_argument_nid_type' => 'nid',
+      'validate_argument_vocabulary' => array(),
+      'validate_argument_type' => 'tid',
+      'validate_argument_transform' => 0,
+      'validate_user_restrict_roles' => 0,
+      'validate_argument_php' => '',
+    ),
   ));
   $handler->override_option('title', 'My Galleries');
   $handler->override_option('style_plugin', 'grid');
@@ -1472,6 +1498,7 @@ function node_gallery_views_default_view
     'title' => '',
     'description' => '',
     'weight' => 0,
+    'name' => 'navigation',
   ));
   $handler = $view->new_display('page', 'My Galleries List', 'page_3');
   $handler->override_option('title', 'My Galleries');
@@ -1495,12 +1522,10 @@ function node_gallery_views_default_view
     'title' => '',
     'description' => '',
     'weight' => 0,
+    'name' => 'navigation',
   ));
   $views[$view->name] = $view;
 
-
-
-
   /**
    * Sort view.
    */
