Index: nodehierarchy_views/nodehierarchy_views.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/nodehierarchy/nodehierarchy_views/nodehierarchy_views.module,v
retrieving revision 1.1.2.2
diff -u -r1.1.2.2 nodehierarchy_views.module
--- nodehierarchy_views/nodehierarchy_views.module	18 Feb 2008 05:33:45 -0000	1.1.2.2
+++ nodehierarchy_views/nodehierarchy_views.module	13 May 2008 05:41:26 -0000
@@ -27,8 +27,8 @@
     case 'validate':
      break;
     case 'view':
-      if ( $page && user_access('access embedded child view')  ) {
-        nodehierarchy_views_embed_children( $node );
+      if ($page && user_access('access embedded child view')) {
+        nodehierarchy_views_embed_children($node);
       }
     break;
   }
@@ -37,17 +37,17 @@
 /**
  * Implementation of hook_nodehierarchyapi().
  */
-function nodehierarchy_views_nodehierarchyapi( $op, $node ) {
-  switch ( $op ) {
+function nodehierarchy_views_nodehierarchyapi($op, $node) {
+  switch ($op) {
     case "node_form":
       $form = array();
-      if ( user_access('edit embedded child view') && nodehierarchy_node_can_be_parent( $node ) ) { 
+      if (user_access('edit embedded child view') && nodehierarchy_node_can_be_parent($node)) {
         $form['nh_children_view'] = array(
           '#type'           => 'select',
           '#title'          => "Embed Children View",
-          '#multiple'       => false,
+          '#multiple'       => FALSE,
           '#options'        => _nodehierarchy_views_view_options(),
-          '#required'       => false,
+          '#required'       => FALSE,
           '#default_value' => $node->nh_children_view,
           '#description'    => t("Embed a view containing this node's children into the node's page view"),
         );
@@ -61,7 +61,7 @@
  * Implementation of hook_perm().
  */
  function nodehierarchy_views_perm() {
-  return array('access embedded child view', 'edit embedded child view' );
+  return array('access embedded child view', 'edit embedded child view');
 }
 
 /**
@@ -102,8 +102,8 @@
     // make sure the first argument is a node hierarchy parent argument
     $first_arg = $view->argument[0];
     if ( !$first_arg || $first_arg['type'] !== "parent" ) {
-      array_unshift( 
-          $view->argument, 
+      array_unshift(
+          $view->argument,
           array(
             'type' => 'parent',
             'argdefault' => '1',
@@ -114,21 +114,21 @@
           )
         );
     }
-    
-    // get the arguments to send to the view
+
+    // Get the arguments to send to the view.
     $arguments = explode('/', $_GET['q']);
-    // first arg will be 'node', remove it.
+    // First arg will be 'node', remove it.
     array_shift( $arguments );
-    // the next argument is the nid, this we will pass as the parent, 
-    // the rest may be added by the view (feed selectors, calendar params etc)
-        
-    // set the url of the view so that filters and arguments work
+    // The next argument is the nid, this we will pass as the parent,
+    // The rest may be added by the view (feed selectors, calendar params etc).
+
+    // Set the url of the view so that filters and arguments work.
     // NB: setting this to just 'node' works since the nid will be added by the
     // argument code in views (first arg is always the nid). This works but may
     // be taking advantage of a non-api side effect and should be treated with
     // caution.
     $view->url = "node";
-    
+
     $node->content['nodehierarchy_children'] = array(
       "#value"    => views_build_view( 'embed', $view, $arguments, $view->use_pager, $view->nodes_per_page ),
       "#weight"   => 10
@@ -141,27 +141,27 @@
  */
 function _nodehierarchy_views_view_options() {
   $options = array();
-  
+
   $options[0] = '-- '. t('NONE') .' --';
-  
+
   include_once(drupal_get_path('module', 'views') .'/views_cache.inc');
   $default_views = _views_get_default_views();
-  
+
   $res = db_query("SELECT name FROM {view_view} ORDER BY name");
   while ($view = db_fetch_object($res)) {
-    $options[$view->name] = $view->name; 
+    $options[$view->name] = $view->name;
   }
-  
+
   if (is_array($default_views)) {
     foreach ( $default_views as $key => $view ) {
       $options[$key] = $view->name;
     }
   }
-  
+
   return $options;
 }
 
-// Implementations of Views Hooks
+// Implementations of Views Hooks.
 
 /**
  * Implementation of hook_views_tables().
@@ -182,23 +182,23 @@
     'fields' => array(
       'order_by' => array(
         'name'      => t('Node Hierarchy: Sort Order'),
-        'sortable'  => true,
+        'sortable'  => TRUE,
         'help'      => t('This will display the sort order of a node in the hierarchy.'),
       ),
       'nid' => array(
         'name' => t('Node Hierarchy: Actions'),
-        'sortable'  => false,
+        'sortable'  => FALSE,
         'handler'   => 'views_handler_field_nodehierarchy_actions',
         'help'      => t('This will display hierarchy actions such as move up, move down, view and edit.'),
       ),
       'parent' => array(
         'name' => t('Node Hierarchy: Parent'),
-        'sortable'  => false,
+        'sortable'  => FALSE,
         'handler'   => 'views_handler_field_nodehierarchy_parent',
         'help'      => t('This will display the nodehierarchy parent for the node.'),
         'option'    => array(
                         '#type' => 'select',
-                        '#options' => 
+                        '#options' =>
                             array(
                                 'default' => 'Title (link)',
                                 'plain' => 'Title (no link)',
@@ -293,16 +293,16 @@
 function _nodehierarchy_views_get_descendant_parents( $nid ) {
   static $parent_types = NULL;
   if ( !$parent_types ) {
-    $types = _nodehierarchy_get_parent_types( "", true );
+    $types = _nodehierarchy_get_parent_types( "", TRUE );
     $parent_types = implode( ",", $types );
   }
-    
+
   $out = array( $nid );
   $result = db_query("SELECT n.nid FROM {node} n LEFT JOIN {nodehierarchy} h ON h.nid = n.nid WHERE h.parent = %d and n.type IN (". $parent_types .")", $nid);
   while ($child = db_fetch_object($result)) {
     $out = array_merge( $out, _nodehierarchy_views_get_descendant_parents( $child->nid ) );
   }
-  
+
   return $out;
 }
 
@@ -365,21 +365,21 @@
     ),
   );
   $view->exposed_filter = array();
-  $view->requires = array(nodehierarchy, node);
+  $view->requires = array('nodehierarchy', 'node');
   $views[$view->name] = $view;
-  
-  // duplicate the view
+
+  // Duplicate the view.
   $view = unserialize( serialize( $view ) );
   $view->page_type = 'list';
   $view->name = 'nodehierarchy_children_list';
   $view->description = t('Display a node\'s children as a list');
   $views[$view->name] = $view;
-  
+
   return $views;
 }
 
 /**
- * Display the actions
+ * Display the actions.
  */
 function views_handler_field_nodehierarchy_actions($fieldinfo, $fielddata, $value, $data) {
   $node = new stdClass();
@@ -388,11 +388,11 @@
 }
 
 /**
- * Display the parent
+ * Display the parent.
  */
 function views_handler_field_nodehierarchy_parent($fieldinfo, $fielddata, $value, $data) {
   static $titles = array();
-  
+
   if (!isset($titles[$value])) {
     $title = db_result(db_query("SELECT title FROM {node} WHERE nid=%d", $value));
     $titles[$value] = $title ? $title : '';
Index: nodehierarchyaccess/nodehierarchyaccess.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/nodehierarchy/nodehierarchyaccess/nodehierarchyaccess.module,v
retrieving revision 1.1
diff -u -r1.1 nodehierarchyaccess.module
--- nodehierarchyaccess/nodehierarchyaccess.module	4 Nov 2007 00:17:14 -0000	1.1
+++ nodehierarchyaccess/nodehierarchyaccess.module	13 May 2008 05:41:28 -0000
@@ -21,17 +21,17 @@
  * Implementation of hook_nodeapi().
  */
 function nodehierarchyaccess_nodeapi(&$node, $op, $a3 = NULL, $a4 = NULL) {
-  
+
   // don't do anything unless nodeaccess and nodehierarchy are installed and the node has an assigned parent
   if ( !module_exists( "nodeaccess" ) || !module_exists( "nodehierarchy" ) || !isset( $node->parent ) || !$node->parent ) {
     return;
   }
-  
+
   switch ( $op ) {
     case 'insert':
     case 'update':
       // if the parent is not the same, copy the new parent's grants
-      if ( $node->parent != $node->old_parent ) {      
+      if ( $node->parent != $node->old_parent ) {
         _nodehierarchyaccess_copy_parent_grants( $node );
       }
     break;
@@ -43,12 +43,12 @@
  * Implementation of hook_form_alter().
  */
 function nodehierarchyaccess_form_alter($form_id, &$form) {
-  
+
   // don't do anything unless nodeaccess and nodehierarchy are installed
   if ( !module_exists( "nodeaccess" ) || !module_exists( "nodehierarchy" ) ) {
     return;
-  } 
-  
+  }
+
   switch ( $form_id ) {
     case "nodeaccess_grants_form":
       $form['#submit']['nodehierarchyaccess_page_form_submit'] = array();
@@ -59,8 +59,8 @@
 
 /**
  * Callback for the nodeaccess form submit
- */ 
-function nodehierarchyaccess_page_form_submit($form_id, $form_values) {  
+ */
+function nodehierarchyaccess_page_form_submit($form_id, $form_values) {
   global $user;
   $grants = array();
   $nid = $form_values['nid'];
@@ -79,7 +79,7 @@
     // get the parent node grants and assign to the node.
     $grants = _nodehierarchyaccess_get_node_grants( $node->parent );
     // save the node itself
-    node_access_write_grants( $node, $grants );    
+    node_access_write_grants( $node, $grants );
     _nodeaccess_save_new($node->nid, $grants);
     // copy grants to the descendants of the node
     _nodehierarchyaccess_set_descendant_grants( $node->nid, $grants );
@@ -89,7 +89,7 @@
 /**
  *  Set the given grants for the given node and it's descentants
  */
-function _nodehierarchyaccess_set_descendant_grants( $nid, $grants ) { 
+function _nodehierarchyaccess_set_descendant_grants( $nid, $grants ) {
   // copy grants to the descendants of the node
   foreach ( nodehierarchy_get_descendant_list($nid) as $descendant_nid ) {
     $node = new stdClass();
Index: nodehierarchy_pathauto.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/nodehierarchy/nodehierarchy_pathauto.inc,v
retrieving revision 1.1.2.1
diff -u -r1.1.2.1 nodehierarchy_pathauto.inc
--- nodehierarchy_pathauto.inc	11 Nov 2007 04:38:21 -0000	1.1.2.1
+++ nodehierarchy_pathauto.inc	13 May 2008 05:41:25 -0000
@@ -39,30 +39,30 @@
  */
 function nodehierarchy_pathauto_get_placeholders($node) {
   $placeholders = array();
-  $placeholders[t('[hierarchypath]')]     = nodehierarchy_pathauto_get_hierarchypath( $node->nid );
-  $placeholders[t('[fullhierarchypath]')]   = nodehierarchy_pathauto_get_fullhierarchypath( $node->nid );
+  $placeholders[t('[hierarchypath]')]     = nodehierarchy_pathauto_get_hierarchypath($node->nid);
+  $placeholders[t('[fullhierarchypath]')]   = nodehierarchy_pathauto_get_fullhierarchypath($node->nid);
   return $placeholders;
 }
 
-function nodehierarchy_pathauto_get_fullhierarchypath( $node ) {
-  $node = node_load( $node );
+function nodehierarchy_pathauto_get_fullhierarchypath($node) {
+  $node = node_load($node);
   // return the hierarchy path with the converted title
-  return trim( nodehierarchy_pathauto_get_hierarchypath( $node->nid ) ."/". pathauto_cleanstring($node->title), "/" );
+  return trim(nodehierarchy_pathauto_get_hierarchypath($node->nid) ."/". pathauto_cleanstring($node->title), "/");
 }
 
-function nodehierarchy_pathauto_get_hierarchypath( $node ) {
-  if ( $node ) {
-    $node = node_load( $node );
-    // the hierarchy path is the parent node's full hierarchy path
-    if ( $node->parent ) {  
-      // if the parent already has an alias (generated or entered) use that
-      $parent_path = drupal_get_path_alias( "node/$node->parent" );
-      if ( $parent_path != "node/$node->parent" ) {
+function nodehierarchy_pathauto_get_hierarchypath($node) {
+  if ($node) {
+    $node = node_load($node);
+    // The hierarchy path is the parent node's full hierarchy path.
+    if ($node->parent) {
+      // If the parent already has an alias (generated or entered) use that.
+      $parent_path = drupal_get_path_alias("node/$node->parent");
+      if ($parent_path != "node/$node->parent") {
         return $parent_path;
-      } 
-      else if ( $node->parent ) {
-        // recurse
-        return nodehierarchy_pathauto_get_fullhierarchypath( $node->parent );
+      }
+      elseif ($node->parent) {
+        // Recurse.
+        return nodehierarchy_pathauto_get_fullhierarchypath($node->parent);
       }
     }
   }
Index: nodehierarchy_workflow_ng.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/nodehierarchy/nodehierarchy_workflow_ng.inc,v
retrieving revision 1.1.2.1
diff -u -r1.1.2.1 nodehierarchy_workflow_ng.inc
--- nodehierarchy_workflow_ng.inc	6 Mar 2008 19:54:09 -0000	1.1.2.1
+++ nodehierarchy_workflow_ng.inc	13 May 2008 05:41:25 -0000
@@ -3,11 +3,11 @@
 
 /**
  * @file
- * Some workflow-ng conditions/actions
+ * Some workflow-ng conditions/actions.
  */
 
-/*
- * Implementation of hook_condition_info()
+/**
+ * Implementation of hook_condition_info().
  */
 function nodehierarchy_condition_info() {
   return array(
@@ -27,7 +27,7 @@
 
 
 /**
- * Implementation of hook_action_info()
+ * Implementation of hook_action_info().
  */
 function nodehierarchy_action_info() {
   return array(
@@ -45,7 +45,7 @@
 }
 
 /**
- * Loads the node's parent
+ * Loads the node's parent.
  */
 function nodehierarchy_action_load($node, $settings) {
   if ($parent = node_load($node->parent)) {
Index: nodehierarchy_token.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/nodehierarchy/nodehierarchy_token.inc,v
retrieving revision 1.1.2.4
diff -u -r1.1.2.4 nodehierarchy_token.inc
--- nodehierarchy_token.inc	9 Apr 2008 02:42:20 -0000	1.1.2.4
+++ nodehierarchy_token.inc	13 May 2008 05:41:25 -0000
@@ -9,20 +9,21 @@
 
 function nodehierarchy_token_values($type, $object = NULL, $options = array()) {
   $tokens = array();
-  if ( $type == 'node' ) {
+  if ($type == 'node') {
     $node = $object;
     $tokens['hierarchyparentnid']          = (int)$node->parent;
-    $tokens['hierarchytitlepath']          = nodehierarchy_token_get_hierarchytitlepath( $node );
-    $tokens['fullhierarchytitlepath']      = nodehierarchy_token_get_fullhierarchytitlepath( $node );
-    $tokens['hierarchytitlepath-raw']      = nodehierarchy_token_get_hierarchytitlepath( $node, true );
-    $tokens['fullhierarchytitlepath-raw']  = nodehierarchy_token_get_fullhierarchytitlepath( $node, true );
-    $tokens['hierarchypath']               = nodehierarchy_token_get_hierarchypath( $node );
-    $tokens['fullhierarchypath']           = nodehierarchy_token_get_fullhierarchypath( $node );
+    $tokens['hierarchytitlepath']          = nodehierarchy_token_get_hierarchytitlepath($node);
+    $tokens['fullhierarchytitlepath']      = nodehierarchy_token_get_fullhierarchytitlepath($node);
+    $tokens['hierarchytitlepath-raw']      = nodehierarchy_token_get_hierarchytitlepath($node, TRUE);
+    $tokens['fullhierarchytitlepath-raw']  = nodehierarchy_token_get_fullhierarchytitlepath($node, TRUE);
+    $tokens['hierarchypath']               = nodehierarchy_token_get_hierarchypath($node);
+    $tokens['fullhierarchypath']           = nodehierarchy_token_get_fullhierarchypath($node);
 
-    if( $parent = node_load( $node->parent ) ) {
-      $tokens['hierarchyparenttitle']        = check_plain( @$parent->title );
+    if ($parent = node_load($node->parent)) {
+      $tokens['hierarchyparenttitle']        = check_plain(@$parent->title);
       $tokens['hierarchyparenttitle-raw']    = @$parent->title;
-    } else {
+    }
+    else {
       $tokens['hierarchyparenttitle']        = '';
       $tokens['hierarchyparenttitle-raw']    = '';
     }
@@ -49,38 +50,38 @@
 }
 
 
-function nodehierarchy_token_get_fullhierarchytitlepath( $node, $raw = true ) {
-  $title = $raw ? $node->title : check_plain( $node->title );
+function nodehierarchy_token_get_fullhierarchytitlepath($node, $raw = TRUE) {
+  $title = $raw ? $node->title : check_plain($node->title);
 
   // return the hierarchy path with the converted title
-  return trim( nodehierarchy_token_get_hierarchytitlepath( $node, $raw ) ."/". $title, "/" );
+  return trim(nodehierarchy_token_get_hierarchytitlepath($node, $raw) ."/". $title, "/");
 }
 
-function nodehierarchy_token_get_hierarchytitlepath( $node, $raw = true ) {
+function nodehierarchy_token_get_hierarchytitlepath($node, $raw = TRUE) {
   // the hierarchy path is the parent node's full hierarchy path
-  if ( $node->parent ) {  
-    return nodehierarchy_token_get_fullhierarchytitlepath( node_load( $node->parent ) );
+  if ($node->parent) {
+    return nodehierarchy_token_get_fullhierarchytitlepath(node_load($node->parent));
   }
   return "";
 }
 
-function nodehierarchy_token_get_fullhierarchypath( $node ) {
-  return trim( nodehierarchy_token_get_hierarchypath( $node ) ."/". $node->title, "/" );
+function nodehierarchy_token_get_fullhierarchypath($node) {
+  return trim(nodehierarchy_token_get_hierarchypath($node) ."/". $node->title, "/");
 }
 
-function nodehierarchy_token_get_hierarchypath( $node ) {
-  // the hierarchy path is the parent node's full hierarchy path
-  if ( $node->parent ) {  
-    // if the parent already has an alias (generated or entered) use that
-    $parent_path = drupal_get_path_alias( "node/$node->parent" );
-    if ( $parent_path != "node/$node->parent" ) {
-      // replace the separator with a space, so that pathauto replaces it with the separator again.
-      // a little hacky but prevents the separator from being stripped
-      return str_replace( variable_get('pathauto_separator', '-'), " ", $parent_path );
-    } 
+function nodehierarchy_token_get_hierarchypath($node) {
+  // The hierarchy path is the parent node's full hierarchy path.
+  if ($node->parent) {
+    // If the parent already has an alias (generated or entered) use that.
+    $parent_path = drupal_get_path_alias("node/$node->parent");
+    if ($parent_path != "node/$node->parent") {
+      // Replace the separator with a space, so that pathauto replaces it with the separator again.
+      // A little hacky but prevents the separator from being stripped.
+      return str_replace(variable_get('pathauto_separator', '-'), " ", $parent_path);
+    }
     else {
-      // recurse
-      return nodehierarchy_token_get_fullhierarchypath( node_load( $node->parent ) );
+      // Recurse.
+      return nodehierarchy_token_get_fullhierarchypath(node_load($node->parent));
     }
   }
   return "";
Index: nodehierarchy.install
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/nodehierarchy/nodehierarchy.install,v
retrieving revision 1.1
diff -u -r1.1 nodehierarchy.install
--- nodehierarchy.install	4 Nov 2007 00:17:13 -0000	1.1
+++ nodehierarchy.install	13 May 2008 05:41:24 -0000
@@ -12,7 +12,7 @@
       PRIMARY KEY (nid)
     ) TYPE=MyISAM /*!40100 DEFAULT CHARACTER SET utf8 */;");
   }
-  nodehierarchy_add_default_parents();  
+  nodehierarchy_add_default_parents();
 }
 
 function nodehierarchy_uninstall() {
@@ -28,16 +28,17 @@
   return nodehierarchy_add_default_parents();
 }
 
-// add nodehierarchy records for pre-existing nodes
+// Add nodehierarchy records for pre-existing nodes.
 function nodehierarchy_add_default_parents() {
   $out = array();
   $result = db_query("SELECT n.nid FROM {node} n LEFT JOIN {nodehierarchy} h ON n.nid = h.nid WHERE h.parent IS NULL ORDER BY n.nid");
   $order_by = 1;
   while ($node = db_fetch_object($result)) {
-    if( function_exists( "update_sql" ) ) {
-      $out[] = update_sql( "INSERT INTO {nodehierarchy} VALUES ($node->nid, 0, $order_by)" );
-    } else {
-      db_query( "INSERT INTO {nodehierarchy} VALUES ($node->nid, 0, $order_by)" );      
+    if (function_exists("update_sql")) {
+      $out[] = update_sql("INSERT INTO {nodehierarchy} VALUES ($node->nid, 0, $order_by)");
+    }
+    else {
+      db_query("INSERT INTO {nodehierarchy} VALUES ($node->nid, 0, $order_by)");
     }
     $order_by++;
   }
Index: nodehierarchy_theme.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/nodehierarchy/nodehierarchy_theme.inc,v
retrieving revision 1.1.2.2
diff -u -r1.1.2.2 nodehierarchy_theme.inc
--- nodehierarchy_theme.inc	6 Mar 2008 20:21:55 -0000	1.1.2.2
+++ nodehierarchy_theme.inc	13 May 2008 05:41:25 -0000
@@ -3,58 +3,58 @@
 
 /**
  * @file
- * Nodehierarchy theming functions
+ * Nodehierarchy theming functions.
  */
 
 /**
- * Display a list of nodes with nodehierarchy actions
+ * Display a list of nodes with nodehierarchy actions.
  */
-function theme_nodehierarchy_node_list( $nodes, $expandable = false ) {
+function theme_nodehierarchy_node_list($nodes, $expandable = FALSE) {
   $out = "";
-  
+
   $rows = array();
-  foreach ( $nodes as $node ) {
-    if ( node_access('view', $node) ) {
+  foreach ($nodes as $node) {
+    if (node_access('view', $node)) {
       $row = array(
         "class"   =>  "nodehierarchy_child",
         "id"      =>  'nh-'. $node->nid,
         'data'    =>  theme("nodehierarchy_actions", $node)
       );
-      
-      if ( $expandable ) {
+
+      if ($expandable) {
         $row['data'] .= _nodehierarchy_toggle_expand_link($node->title, $node->nid);
       }
       else {
         $row['data'] .= l($node->title, "node/". $node->nid);
       }
-      
-      if ( $expandable && _nodehierarhcy_is_expanded( $node->nid )  ) {
-        $row['data']  .= _nodehierarchy_display_children_list( $node, true );
+
+      if ($expandable && _nodehierarhcy_is_expanded($node->nid)) {
+        $row['data']  .= _nodehierarchy_display_children_list($node, TRUE);
         $row['class'] .= " expanded";
       }
-      else if ( $expandable && variable_get('nh_parent_'. $node->type, false )) {
+      elseif ($expandable && variable_get('nh_parent_'. $node->type, FALSE)) {
         $row['class'] .= " collapsed";
       }
       $rows[] = $row;
     }
   }
-  
-  if ( $rows ) {
-    $out .= theme( "node_hierarchy_item_list", $rows, array( "class" => "nodehierarchy_outline menu" ) );
+
+  if ($rows) {
+    $out .= theme("node_hierarchy_item_list", $rows, array("class" => "nodehierarchy_outline menu"));
   }
   return $out;
 }
 
 /**
- * Display links to create new children nodes of the given node
+ * Display links to create new children nodes of the given node.
  */
 function theme_nodehierarchy_new_child_links($node) {
   $out = "";
   $create_links = array();
-  
+
   if ( user_access( 'create child nodes' ) && node_access( 'update', $node ) ) {
     foreach ( node_get_types() as $key => $type ) {
-      if (node_access('create', $key) && variable_get('nh_child_'. $key, false )) {
+      if (node_access('create', $key) && variable_get('nh_child_'. $key, FALSE )) {
         $create_links[] = l($type->name, "node/add/$key", array('title' => t('Add a new %s.', array('%s' => $type->name))), drupal_get_destination() ."&edit[parent]=$node->nid");
       }
     }
@@ -66,12 +66,12 @@
 }
 
 /**
- * Display node hierarchy action links (view, edit, move up, move down, etc.)
+ * Display node hierarchy action links (view, edit, move up, move down, etc.).
  */
 function theme_nodehierarchy_actions( $node ) {
   global $user;
   drupal_add_css( drupal_get_path('module', 'nodehierarchy') .'/nodehierarchy.css');
-  
+
   $actions = array();
   $actions[] = theme('nodehierarchy_action', url( "node/$node->nid" ), 'view', node_access('view', $node) );
   $actions[] = theme('nodehierarchy_action', url( "node/$node->nid/edit", drupal_get_destination() ), 'edit', node_access('update', $node) );
@@ -80,16 +80,16 @@
     $actions[] = theme('nodehierarchy_action', url( "hierarchy/$node->nid/up", drupal_get_destination() ), 'up' );
     $actions[] = theme('nodehierarchy_action', url( "hierarchy/$node->nid/down", drupal_get_destination() ), 'down' );
   }
-  
+
   return "<div class='nodehierarchy_actions'>". implode( "", $actions ) .'</div>';
 }
 
 /**
- * Display a single node hierarchy action link
+ * Display a single node hierarchy action link.
  */
-function theme_nodehierarchy_action( $url, $name, $active = true ) {
+function theme_nodehierarchy_action( $url, $name, $active = TRUE ) {
   $img_path = base_path() . drupal_get_path('module', 'nodehierarchy') ."/images/$name.gif";
-  
+
   if ( $active ) {
     return '<a href="'. $url .'" class="nodehierarchy_action nodehierarchy_action_'. $name .'" title="'. t($name) .'"><span class="nodehierarchy_icon"><img src="'. $img_path .'" height="16" width="16"></span><span class="label">'. t($name) .'</span></a>';
   }
@@ -99,7 +99,7 @@
 }
 
 /**
- *  theme a link to the given sibling
+ * Theme a link to the given sibling.
  */
 function theme_nodehierarchy_sibling_link( $node ) {
   return l( $node->title, "node/". $node->nid );
@@ -134,67 +134,67 @@
     $output .= "</ul>";
   }
   return $output;
-} 
+}
 
 /**
  * Return a themed list of items.
  */
-function theme_nodehierarchy_children_list( $node, $children, $show_create_links = true ) {
+function theme_nodehierarchy_children_list($node, $children, $show_create_links = TRUE) {
   $output = "";
   if (!empty($children)) {
     $output .= '<ul class="nodehierarchy_outline menu">';
     $i = 1;
-    foreach ($children as $nid => $item) {     
+    foreach ($children as $nid => $item) {
       $children_list = "";
       $attributs = array();
-      
+
       $title = $item['node']->title;
-      if ( $item['url'] ) {
-        $title = '<a href="'. $item['url'] .'" class="'. 
-                    ($item['expandable'] ? "expand_widget" : "non_expandable") . 
+      if ($item['url']) {
+        $title = '<a href="'. $item['url'] .'" class="'.
+                    ($item['expandable'] ? "expand_widget" : "non_expandable") .
                     ($item['expanded'] ? " expanded" : " collapsed") .'" title="'. $item['tooltip'] .'">'. $title .'</a>';
       }
-      
+
       $attributes['id'] = "nodehierarchy_child-". $item['node']->nid;
       $attributes['class'] = "nodehierarchy_child";
-      if ( $item['expandable'] ) {
+      if ($item['expandable']) {
         $attributes['class'] .= " expandable";
         $attributes['class'] .= $item['expanded'] ? " expanded" : " collapsed";
       }
-      if ( !nodehierarchy_previous_sibling_nid( $item['node'] ) ) {
+      if (!nodehierarchy_previous_sibling_nid($item['node'])) {
         $attributes['class'] .= " first";
       }
-      if ( !nodehierarchy_next_sibling_nid( $item['node'] )  ) {
+      if (!nodehierarchy_next_sibling_nid($item['node'])) {
         $attributes['class'] .= " last";
       }
-      $actions = theme("nodehierarchy_actions", $item['node'] );
+      $actions = theme("nodehierarchy_actions", $item['node']);
       $grandchildren = "";
-      if ( $item['expanded'] ) {
-        $grandchildren = theme( "nodehierarchy_children_list", $item['node'], $item['children'] );
+      if ($item['expanded']) {
+        $grandchildren = theme("nodehierarchy_children_list", $item['node'], $item['children']);
       }
       $output .= '<li'. drupal_attributes($attributes) .'><div class="item">'. $actions . $title .'</div><div class="children">'. $grandchildren .'</div></li>';
       $i++;
     }
     $output .= "</ul>";
-  } 
+  }
   else {
-    $output .= t( "This node has no children" );
+    $output .= t("This node has no children");
   }
-  if ( $show_create_links ) {
-    $output .= theme( "nodehierarchy_new_child_links", $node );
+  if ($show_create_links) {
+    $output .= theme("nodehierarchy_new_child_links", $node);
   }
   return $output;
-} 
+}
 
 /**
  * Return a themed list of items.
  */
-function theme_nodehierarchy_children_list_more_link( $node, $num_displayed, $total ) {
+function theme_nodehierarchy_children_list_more_link($node, $num_displayed, $total) {
   $output = "";
-  if ( $num_displayed < $total ) {
+  if ($num_displayed < $total) {
     $output .= '<div class="nodehierarchy_children_more_link">';
-    $output .= t( "%num out of %total displayed. ", array( "%num" => $num_displayed, "%total" => $total ) );
-    $output .= l( t( "See more..."),  "node/". $node->nid ."/children", array(), 'page=1' );
+    $output .= t("%num out of %total displayed. ", array("%num" => $num_displayed, "%total" => $total));
+    $output .= l(t("See more..."),  "node/". $node->nid ."/children", array(), 'page=1');
     $output .= '</div>';
   }
   return $output;
Index: nodehierarchy.css
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/nodehierarchy/nodehierarchy.css,v
retrieving revision 1.1
diff -u -r1.1 nodehierarchy.css
--- nodehierarchy.css	4 Nov 2007 00:17:13 -0000	1.1
+++ nodehierarchy.css	13 May 2008 05:41:24 -0000
@@ -1,89 +1,94 @@
 /* nodehierarchy stylesheet */
 
 a.nodehierarchy_action, a.nodehierarchy_action:hover {
-	text-decoration: none;
+  text-decoration: none;
 }
 .nodehierarchy_action .nodehierarchy_icon img {
-	vertical-align: middle;
+  vertical-align: middle;
 }
 
 .nodehierarchy_action .label {
-	display: none;
+  display: none;
 }
 .nodehierarchy_action .disabled img,
 .first .nodehierarchy_action_up img,
 .last .nodehierarchy_action_down img
 {
-	opacity: 0.25;
-	filter:alpha(opacity=25);
+  opacity: 0.25;
+  filter:alpha(opacity=25);
 }
 
 ul.nodehierarchy_outline {
-	margin: 0;	padding: 0;
+  padding: 0;
 }
 ul.nodehierarchy_outline li {
-	background: none;
-	list-style-type: none;
-	list-style-image: none;	margin: 0;	padding: 0;
-	clear: right;}
+  background: none;
+  list-style-type: none;
+  list-style-image: none;
+  margin: 0;
+  padding: 0;
+  clear: right;
+}
 ul.nodehierarchy_outline li.nodehierarchy_child {
-	background: none;
-	padding: 0;
+  background: none;
+  padding: 0;
 }
-.nodehierarchy_outline .item, 
+.nodehierarchy_outline .item,
 .nodehierarchy_outline .newchild {
-	padding: .2em 0;	
+  padding: .2em 0;  
 }
-
+
 table.nodehierarchy_outline {
-	margin: 0;
+  margin: 0;
 }
 .nodehierarchy_outline td {
-	padding: 0;
-	vertical-align: top;
+  padding: 0;
+  vertical-align: top;
 }
 .nodehierarchy_actions {
-	float: right;
-	clear: right;
-	padding: 0;
+  float: right;
+  clear: right;
+  padding: 0;
 }
 .nodehierarchy_expand {
-	width: 16px;
+  width: 16px;
 }
 td.nodehierarchy_children {
-	padding-left: 16px;
+  padding-left: 16px;
 }
 
 ul.nodehierarchy_outline {
-	border-top: 2px solid #eee;	
+  border-top: 2px solid #eee;  
 }
 .nodehierarchy_outline li {
-	border-bottom: 2px solid #eee;
+  border-bottom: 2px solid #eee;
 }
 .nodehierarchy_outline .nodehierarchy_child a {
-	display: inline;
+  display: inline;
 }
 .nodehierarchy_outline .children {
-	clear: both;
-	padding-left: 15px;
+  clear: both;
+  padding-left: 15px;
 }
 
 a.expand_widget, a.non_expandable {
-	background-position: left center;	background-repeat:no-repeat;
-	padding-left: 20px;	
+  background-position: left center;
+  background-repeat:no-repeat;
+  padding-left: 20px;  
 }
 .nodehierarchy_outline .expanded a.expand_widget {
-	background-image: url(images/expanded.gif);		
+  background-image: url(images/expanded.gif);    
 }
 .nodehierarchy_outline .collapsed a.expand_widget {
-	background-image: url(images/collapsed.gif);		
+  background-image: url(images/collapsed.gif);    
 }
 
 .nodehierarchy_outline li.loading a.expand_widget {
-	background-image: url(images/loading.gif);}
+  background-image: url(images/loading.gif);
+}
 
 .nodehierarchy_outline .item:hover {
-	background-color: #eee;
+  background-color: #eee;
 }
 
 
Index: nodehierarchy.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/nodehierarchy/nodehierarchy.module,v
retrieving revision 1.1.2.7
diff -u -r1.1.2.7 nodehierarchy.module
--- nodehierarchy.module	10 Mar 2008 15:32:49 -0000	1.1.2.7
+++ nodehierarchy.module	13 May 2008 05:41:25 -0000
@@ -5,9 +5,9 @@
  * Implementation of hook_init().
  */
 function nodehierarchy_init() {
-  // ensure we are not serving a cached page
+  // Ensure we are not serving a cached page.
   if (function_exists('drupal_set_content')) {
-    // according to http://drupal.org/node/60526, this should not go in hook_menu
+    // According to http://drupal.org/node/60526, this should not go in hook_menu.
     if (module_exists('pathauto')) {
       include_once('./'. drupal_get_path('module', 'nodehierarchy') .'/nodehierarchy_pathauto.inc');
     }
@@ -23,7 +23,9 @@
   }
 }
 
-// Implementation of hook_help()
+/**
+ * Implementation of hook_help().
+ */
 function nodehierarchy_help($section) {
   switch ($section) {
     case 'admin/modules#description':
@@ -31,15 +33,19 @@
   }
 }
 
-// Implementation of hook_perm().
+/**
+ * Implementation of hook_perm().
+ */
 function nodehierarchy_perm() {
   return array('create child nodes', 'edit all node parents', 'edit own node parents', 'reorder children', 'view site outline', 'administer hierarchy');
 }
 
-// Implementation of hook_menu().
+/**
+ * Implementation of hook_menu().
+ */
 function nodehierarchy_menu($may_cache) {
   $items = array();
-  
+
   if ($may_cache) {
     $items[] = array(
       'path' => 'hierarchy',
@@ -54,7 +60,7 @@
       'access' => user_access('access content'),
       'type' => MENU_CALLBACK,
       'callback' => 'nodehierarchy_callback_ajax'
-    );  
+    );
     $items[] = array(
       'path' => 'admin/content/nodehierarchy',
       'title' => t('Site Outline'),
@@ -76,8 +82,8 @@
   else {
     if (arg(0) == 'node' && is_numeric(arg(1))) {
       $node = node_load(arg(1));
-      if ($node->nid && variable_get('nh_parent_'. $node->type, false )) {
-         $items[]= array(
+      if ($node->nid && variable_get('nh_parent_'. $node->type, FALSE)) {
+         $items[] = array(
           'path' => 'node/'. arg(1) .'/children',
           'title' => t('Children'),
           'callback' => 'nodehierarchy_view_children',
@@ -96,77 +102,80 @@
  * Helper function generates admin settings page.
  */
 function nodehierarchy_admin_settings() {
-  
+
   $form = array();
-  
+
   // individual type settings
   $form['nodehierarchy_types'] = array(
     '#type' => 'fieldset',
     '#title' => t('Node Type Settings'),
-    '#description' => t('Settings for individual node types. These can also be set in the !ct section.', array( "!ct" => l( t("Content Types"), "admin/content/types" ) ) )
+    '#description' => t('Settings for individual node types. These can also be set in the !ct section.', array("!ct" => l(t("Content Types"), "admin/content/types")))
   );
-  foreach ( node_get_types() as $key => $type ) {
-    // individual type settings
+  foreach (node_get_types() as $key => $type) {
+    // Individual type settings.
     $form['nodehierarchy_types'][$key] = array(
       '#type' => 'fieldset',
       '#title' => $type->name,
       '#collapsible' => TRUE,
       '#collapsed' => TRUE,
     );
-    $form['nodehierarchy_types'][$key] += _nodehierarchy_get_node_type_settings_form( $key, true );
+    $form['nodehierarchy_types'][$key] += _nodehierarchy_get_node_type_settings_form($key, TRUE);
   }
-  
-  // menu generation
-  if ( function_exists( 'menu_parent_options' ) ) {
+
+  // Menu generation.
+  if (function_exists('menu_parent_options')) {
     $form['nodehierarchy_menu'] = array(
       '#type' => 'fieldset',
       '#title' => t('Node Hierarchy Menu Generation'),
     );
-    
+
     $form['nodehierarchy_menu']['nodehierarchy_menus'] = array(
       '#type' => 'checkbox',
       '#title' => t('Allow users to generate menus automatically.'),
-      '#default_value' => variable_get('nodehierarchy_menus', true ),
+      '#default_value' => variable_get('nodehierarchy_menus', TRUE),
     );
-    
+
     $form['nodehierarchy_menu']['nodehierarchy_menus_default'] = array(
       '#type' => 'select',
       '#title' => t('Default parent menu.'),
       '#options' => menu_parent_options(0) ,
-      '#default_value' => variable_get('nodehierarchy_menus_default', 1 ),
+      '#default_value' => variable_get('nodehierarchy_menus_default', 1),
       '#description' => t('Other nodes can be created as child nodes of this node type.')
     );
   }
-  
+
   return system_settings_form($form);
 }
 
-// Implementation of hooks_forms_alter so we don't see preview or delete buttons for hierarchy
+/**
+ * Implementation of hooks_form_alter().
+ * So we don't see preview or delete buttons for hierarchy.
+ */
 function nodehierarchy_form_alter($form_id, &$form) {
   global $user;
-  
+
   switch ($form_id) {
     case 'node_type_form':
       $type = $form['old_type']['#value'];
-      
+
       $form['nodehierarchy'] = array(
         '#type' => 'fieldset',
         '#title' => t('Node Hierarchy'),
         '#weight' => 0
       );
-      
-      $form['nodehierarchy'] += _nodehierarchy_get_node_type_settings_form( $type );
+
+      $form['nodehierarchy'] += _nodehierarchy_get_node_type_settings_form($type);
     break;
-    // node edit form
+    // Node edit form.
     case $form['type']['#value'] .'_node_form':
       $node = isset($form['#node']) ? $form['#node'] : NULL;
-      $hierarchy_form = nodehierarchy_invoke_api( "node_form", $node );
-      if ( $hierarchy_form ) {
+      $hierarchy_form = nodehierarchy_invoke_api("node_form", $node);
+      if ($hierarchy_form) {
         $form['hierarchy'] = $hierarchy_form;
-        
-        // if there are any visible elements, wrap them in a fieldset.
-        foreach ( $hierarchy_form as $item ) {
-          if ( $item['#type'] !== "value" && $item['#type'] !== "hidden" ) {
+
+        // If there are any visible elements, wrap them in a fieldset.
+        foreach ($hierarchy_form as $item) {
+          if ($item['#type'] !== "value" && $item['#type'] !== "hidden") {
             $form['hierarchy'] = array_merge(
               array(
                 '#type'         => 'fieldset',
@@ -180,9 +189,9 @@
           }
         }
       }
-      
+
       break;
-   }
+  }
 }
 
 /**
@@ -194,10 +203,10 @@
     return;
     case 'insert':
     case 'update':
-      nodehierarchy_invoke_api( "update_parent", $node );
+      nodehierarchy_invoke_api("update_parent", $node);
       break;
     case 'load':
-       return nodehierarchy_load_node($node);
+      return nodehierarchy_load_node($node);
     break;
     case 'delete':
       nodehierarchy_delete_node($node);
@@ -205,72 +214,72 @@
     case 'submit':
       break;
     case 'validate':
-     break;
+      break;
     case 'view':
-      if ( $page && !$teaser ) {
-        nodehierarchy_set_breadcrumbs( $node );
+      if ($page && !$teaser) {
+        nodehierarchy_set_breadcrumbs($node);
       }
     break;
   }
 }
 
 /**
- * Implementation of hook_nodehierarchyapi(). Responds to own api calls
+ * Implementation of hook_nodehierarchyapi(). Responds to own api calls.
  */
-function nodehierarchy_nodehierarchyapi( $op, &$node ) {
+function nodehierarchy_nodehierarchyapi($op, &$node) {
   global $user;
-  
-  switch ( $op ) {
+
+  switch ($op) {
     case "node_form":
       $form = array();
-      // if this node type can be a child
-      if ( nodehierarchy_node_can_be_child( $node ) ) {
-        
-        // save the old value of the node's parent
+      // If this node type can be a child.
+      if (nodehierarchy_node_can_be_child($node)) {
+
+        // Save the old value of the node's parent.
         $old_parent = @$node->parent;
-        // set the default parent if the node does not already have a parent
-        $parent = $node->parent !== NULL ? $node->parent : variable_get('nh_defaultparent_'. $node->type, 0 );
-        
-        // get the parent from the get string. user must have update perms for parent
-        if ( $node->parent === NULL && isset($_GET['edit']['parent']) && (int)$_GET['edit']['parent'] ) {
-          $parent_node = node_load( (int)$_GET['edit']['parent'] );
-          $parent = node_access( "update", $parent_node ) ? $_GET['edit']['parent'] : $parent;
+        // Set the default parent if the node does not already have a parent.
+        $parent = $node->parent !== NULL ? $node->parent : variable_get('nh_defaultparent_'. $node->type, 0);
+
+        // Get the parent from the get string. user must have update perms for parent.
+        if ($node->parent === NULL && isset($_GET['edit']['parent']) && (int)$_GET['edit']['parent']) {
+          $parent_node = node_load((int)$_GET['edit']['parent']);
+          $parent = node_access("update", $parent_node) ? $_GET['edit']['parent'] : $parent;
+        }
+
+        $form['old_parent'] = array('#type' => 'value', '#value' => $old_parent);
+
+        // if the current user can edit the current node's hierarchy settings (or create new children)
+        $can_set_parent =
+            user_access('edit all node parents') ||
+            ($node->nid == NULL && user_access('create child nodes')) ||
+            ($node->uid == $user->uid && user_access('edit own node parents'));
+
+        if ($can_set_parent) {
+          $form['parent'] = _nodehierarchy_get_parent_pulldown($node->type, $parent, t('Parent'), $node->nid);
         }
-        
-        $form['old_parent'] =  array( '#type' => 'value', '#value' => $old_parent );
-        
-        // if the current user can edit the current node's hierarchy settings (or create new children)        
-        $can_set_parent = 
-            user_access( 'edit all node parents' ) || 
-            ($node->nid == NULL && user_access( 'create child nodes' )) || 
-            ($node->uid == $user->uid && user_access( 'edit own node parents' ));
-        
-        if ( $can_set_parent ) {
-          $form['parent'] = _nodehierarchy_get_parent_pulldown( $node->type, $parent, t( 'Parent' ), $node->nid );
-        } 
         else {
-          // non-editable parent setting.
+          // Non-editable parent setting.
           $form['parent'] = array(
             '#type'   => 'value',
             '#value'  => $parent,
           );
         }
-        
-        if ( module_exists( 'menu' ) && user_access('administer menu') && variable_get('nodehierarchy_menus', true ) ) {
-          $mid = _nodehierarchy_get_menu( $node->nid );
-          // (re)create a menu
+
+        if (module_exists('menu') && user_access('administer menu') && variable_get('nodehierarchy_menus', TRUE)) {
+          $mid = _nodehierarchy_get_menu($node->nid);
+          // (Re)create a menu.
           $form['nodehierarchy_create_menu'] = array(
             '#type'           => 'checkbox',
             '#title'          => ($mid ? t('Recreate Menu') : t('Create Menu')),
-            '#default_value'  => false,
+            '#default_value'  => FALSE,
           );
         }
       }
       return $form;
     break;
     case "update_parent":
-      nodehierarchy_insert_node( $node );
-      _nodehierarchy_create_menu( $node );
+      nodehierarchy_insert_node($node);
+      _nodehierarchy_create_menu($node);
     break;
   }
 }
@@ -279,61 +288,64 @@
 /**
  * Insert or update a node. Set it's parent
  */
-function nodehierarchy_insert_node( &$node ) {
+function nodehierarchy_insert_node(&$node) {
   global $user;
-  
-  // if the node is valid and the parent has changed or the node does not already have a parent
-  if ( $node->nid && ($node->old_parent !== $node->parent) || $node->old_parent === NULL ) {
-    
+
+  // If the node is valid and the parent has changed or the node does not already have a parent.
+  if ($node->nid && ($node->old_parent !== $node->parent) || $node->old_parent === NULL) {
+
     $node_descendants = nodehierarchy_get_descendant_list($node->nid);
-    
-    // set a the parent to the type default or the previous parent if
+
+    // Set a the parent to the type default or the previous parent if:
     //  a) parent is not specified (should never happen)
     //  b) node is new, and user does not have 'create child nodes' permissions OR
     //  c) node doesn't belong to user and user doesn't have 'edit all node parents' permissions OR
     //  d) node belongs to user and user doesn't have 'edit own node parents' permissions
     //  e) the parent is somehow set to a descendent of the node
-    if ( 
-      $node->parent === NULL ||                                                // (a)
-      ($node->old_parent === NULL && !user_access( 'create child nodes' ))  || // (b)
-      ($node->uid != $user->uid && !user_access( 'edit all node parents' )) || // (c)
-      ($node->uid == $user->uid && !user_access( 'edit own node parents' )) || // (d)
-      in_array( $node->parent, $node_descendants )                             // (e)
+    if (
+      $node->parent === NULL ||                                              // (a)
+      ($node->old_parent === NULL && !user_access('create child nodes'))  || // (b)
+      ($node->uid != $user->uid && !user_access('edit all node parents')) || // (c)
+      ($node->uid == $user->uid && !user_access('edit own node parents')) || // (d)
+      in_array($node->parent, $node_descendants)                             // (e)
     ) {
-      // set the parent back to the old parent if there was one, otherwise to the type default
-      $node->parent = $node->old_parent !== NULL ? $node->old_parent : variable_get('nh_defaultparent_'. $node->type, 0 );
+      // Set the parent back to the old parent if there was one, otherwise to the type default.
+      $node->parent = $node->old_parent !== NULL ? $node->old_parent : variable_get('nh_defaultparent_'. $node->type, 0);
     }
-    
-    // check descendants again, in case the default item is in the item's descendant list
-    if ( in_array( $node->parent, $node_descendants ) ) {
+
+    // Check descendants again, in case the default item is in the item's descendant list.
+    if (in_array($node->parent, $node_descendants)) {
       $node->parent = 0;
     }
-    
-    // if after all that the node has a new parent
-    if ( $node->parent !== $node->old_parent ) {
-      // place at the end of the new child list
-      // massive number will be normalized during the insert
+
+    // If after all that the node has a new parent.
+    if ($node->parent !== $node->old_parent) {
+      // Place at the end of the new child list.
+      // Massive number will be normalized during the insert.
       $node->order_by = 100000;
-      
-      db_query('DELETE FROM {nodehierarchy} WHERE nid = %d', $node->nid );
-      db_query("INSERT INTO {nodehierarchy} (nid, parent, order_by) VALUES (%d, %d, %f)", $node->nid, $node->parent, $node->order_by );
+
+      db_query('DELETE FROM {nodehierarchy} WHERE nid = %d', $node->nid);
+      db_query("INSERT INTO {nodehierarchy} (nid, parent, order_by) VALUES (%d, %d, %f)", $node->nid, $node->parent, $node->order_by);
       _nodehierarchy_normalize_child_order($node->parent);
       _nodehierarchy_normalize_child_order($node->old_parent);
-      
-      // reload order (it may have shifted during the sort)
+
+      // Reload order (it may have shifted during the sort).
       $additions = nodehierarchy_load_node($node);
       $node->order_by = $additions['order_by'];
     }
   }
 }
 
-// Implementation of hook_delete().
+/**
+ * Implementation of hook_delete().
+ */
 function nodehierarchy_delete_node($node) {
   db_query('DELETE FROM {nodehierarchy} WHERE nid = %d OR parent = %d', $node->nid, $node->nid);
 }
 
-
-// Implementation of hook_load().
+/**
+ * Implementation of hook_load().
+ */
 function nodehierarchy_load_node($node) {
   $additions = db_fetch_array(db_query('SELECT parent, order_by FROM {nodehierarchy} WHERE nid = %d', $node->nid));
   return $additions;
@@ -349,15 +361,15 @@
  * @return
  *   The returned value of the invoked hooks.
  */
-function nodehierarchy_invoke_api( $op, &$node ) {
+function nodehierarchy_invoke_api($op, &$node) {
   $return = array();
   foreach (module_implements('nodehierarchyapi') as $name) {
     $function = $name .'_nodehierarchyapi';
-    $result = $function( $op, $node );
+    $result = $function($op, $node);
     if (isset($result) && is_array($result)) {
       $return = array_merge($return, $result);
     }
-    else if (isset($result)) {
+    elseif (isset($result)) {
       $return[] = $result;
     }
   }
@@ -368,54 +380,53 @@
  * Determine if a given node can be a child of another given node
  *
  * @param $parent
- *    the potentential parent node (can be null for any node)
+ *  The potentential parent node (can be null for any node).
  * @param $child
- *    the potential child node (can be null for any node)
+ *  The potential child node (can be null for any node).
  * @return
- *   Boolean. Whether second node can be a child of the first.
- *       If parent is null, returns whether the child can be a child of any node
- *       If child is null returns whether the parent can be parent of any node
- *       If both are null, results undefined. (returns true but that could to change)
- */
-function nodehierarchy_node_can_be_child_of( $parent=NULL, $child=NULL ) {
-  $out = true;
-  
-  if ( $parent ) {
-    $out = ($out && variable_get('nh_parent_'. $parent->type, false ));
+ *  Boolean. Whether second node can be a child of the first.
+ *  If parent is null, returns whether the child can be a child of any node.
+ *  If child is null returns whether the parent can be parent of any node.
+ *  If both are null, results undefined. (returns TRUE but that could to change).
+ */
+function nodehierarchy_node_can_be_child_of($parent = NULL, $child = NULL) {
+  $out = TRUE;
+
+  if ($parent) {
+    $out = ($out && variable_get('nh_parent_'. $parent->type, FALSE));
   }
-  if ( $child ) {
-    $out = ($out && variable_get('nh_child_'. $child->type, false ));
+  if ($child) {
+    $out = ($out && variable_get('nh_child_'. $child->type, FALSE));
   }
-  // TODO: implement settings system where certain node types can only be children
-  //    of certain other node types
+  // TODO: implement settings system where certain node types can only be
+  // children of certain other node types.
   return $out;
 }
 
 /**
- * Wrapper for nodehierarchy_node_can_be_child_of
- *
+ * Wrapper for nodehierarchy_node_can_be_child_of.
  */
-function nodehierarchy_node_can_be_child( $node ) {
-  return nodehierarchy_node_can_be_child_of( NULL, $node );
+function nodehierarchy_node_can_be_child($node) {
+  return nodehierarchy_node_can_be_child_of(NULL, $node);
 }
 
 /**
  * Wrapper for nodehierarchy_node_can_be_child_of
  *
  */
-function nodehierarchy_node_can_be_parent( $node ) {
-  return nodehierarchy_node_can_be_child_of( $node, NULL );
+function nodehierarchy_node_can_be_parent($node) {
+  return nodehierarchy_node_can_be_child_of($node, NULL);
 }
 
 
 /**
  * Display the children tab
  */
-function nodehierarchy_view_children( $nid ) {
-  $node = node_load( $nid );
-  drupal_set_title(t('Children of %t', array( '%t' => $node->title )));
-  //nodehierarchy_set_breadcrumbs( $node, true );
-  return _nodehierarchy_display_children_list( $node );
+function nodehierarchy_view_children($nid) {
+  $node = node_load($nid);
+  drupal_set_title(t('Children of %t', array('%t' => $node->title)));
+  //nodehierarchy_set_breadcrumbs($node, TRUE);
+  return _nodehierarchy_display_children_list($node);
 }
 
 /**
@@ -425,24 +436,24 @@
   $nid   = arg(2);
   $action = arg(3);
   $child = node_load(array('nid' => $nid));
-  
+
   header("Cache-Control: no-cache, must-revalidate");
   header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
-  
+
   // Look to see if we need to change node order in this list
   if ($nid && $action) {
-    switch ( $action ) {
+    switch ($action) {
       case "getchildren":
-        $node = node_load( $nid );
-        $children = nodehierarchy_get_node_children_list( $node->nid, true, 20 );
-        print theme( "nodehierarchy_children_list", $node, $children, false );
-        print theme( "nodehierarchy_children_list_more_link", $node, 20, _nodehierarchy_get_children_count( $node->nid ) );
-        //print theme( "nodehierarchy_new_child_links", $node );
+        $node = node_load($nid);
+        $children = nodehierarchy_get_node_children_list($node->nid, TRUE, 20);
+        print theme("nodehierarchy_children_list", $node, $children, FALSE);
+        print theme("nodehierarchy_children_list_more_link", $node, 20, _nodehierarchy_get_children_count($node->nid));
+        //print theme("nodehierarchy_new_child_links", $node);
       break;
       case "up":
       case "down":
-        $node = node_load( $nid );
-        nodehierarchy_movechild( $node, $action ); 
+        $node = node_load($nid);
+        nodehierarchy_movechild($node, $action);
       break;
     }
   }
@@ -456,16 +467,16 @@
   $nid   = arg(1);
   $action = arg(2);
   $child = node_load(array('nid' => $nid));
-  
+
   // Look to see if we need to change node order in this list
     if ($nid && $action) {
-      
+
       if ($action == 'up') {
-        nodehierarchy_movechild( $child, 'up' ); 
+        nodehierarchy_movechild($child, 'up');
         drupal_set_message(t('<b>%s</b> has been moved <b>up</b>.', array('%s' => $child->title)));
       }
       elseif ($action == 'down') {
-        nodehierarchy_movechild( $child, 'down' ); 
+        nodehierarchy_movechild($child, 'down');
         drupal_set_message(t('<b>%s</b> has been moved <b>down</b>.', array('%s' => $child->title)));
       }
     }
@@ -473,68 +484,68 @@
 }
 
 /**
- * Move a child up or down by the given ammount
+ * Move a child up or down by the given ammount.
  */
-function nodehierarchy_movechild( $node, $direction ) {
-  if ( $direction == "up" ) {
+function nodehierarchy_movechild($node, $direction) {
+  if ($direction == "up") {
     $node->order_by -= 1.5;
-  } 
+  }
   else {
     $node->order_by += 1.5;
   }
-  
-  db_query("UPDATE {nodehierarchy} SET order_by = %f WHERE nid = %d", $node->order_by, $node->nid );
+
+  db_query("UPDATE {nodehierarchy} SET order_by = %f WHERE nid = %d", $node->order_by, $node->nid);
   _nodehierarchy_normalize_child_order($node->parent);
 }
 
 
 
 /**
- * Display a page with the outline of the entire site
+ * Display a page with the outline of the entire site.
  */
 function nodehierarchy_site_outline() {
   $node = new stdClass();
   $node->nid = 0;
-  $out = _nodehierarchy_display_children_list( $node, true );
+  $out = _nodehierarchy_display_children_list($node, TRUE);
   return $out;
 }
 
 /**
- * Get the children list of the given node
+ * Get the children list of the given node.
  */
-function _nodehierarchy_display_children_list( $node, $expandable = false ) {
+function _nodehierarchy_display_children_list($node, $expandable = FALSE) {
   $out = "";
-  drupal_add_js( drupal_get_path( "module", "nodehierarchy" ) .'/nodehierarchy.js' );
-  drupal_add_js( 'Drupal.nodehierarchy.callbackURL = "'. url( "nodehierarchy/ajax" ) .'"; Drupal.nodehierarchy.destination = "'. drupal_get_destination() .'"', 'inline' );
+  drupal_add_js(drupal_get_path("module", "nodehierarchy") .'/nodehierarchy.js');
+  drupal_add_js('Drupal.nodehierarchy.callbackURL = "'. url("nodehierarchy/ajax") .'"; Drupal.nodehierarchy.destination = "'. drupal_get_destination() .'"', 'inline');
   $children = nodehierarchy_get_node_children_list($node->nid, $expandable, 20);
-  $out .= theme( "nodehierarchy_children_list", $node, $children );
+  $out .= theme("nodehierarchy_children_list", $node, $children);
   $out .= theme('pager', NULL, 20, 0);
   return $out;
 }
 
 /**
- * Display a list of nodes with nodehierarchy actions
+ * Display a list of nodes with nodehierarchy actions.
  */
-function nodehierarchy_get_node_children_list( $nid, $expandable = false, $pager = false ) {
+function nodehierarchy_get_node_children_list($nid, $expandable = FALSE, $pager = FALSE) {
   $rows = array();
   $children = nodehierarchy_get_children($nid, $pager);
-  foreach ( $children as $child ) {
-    $node = node_load( $child );
-    
-    if ( node_access('view', $node) ) {
-      
-      $item_expandable = $expandable && variable_get('nh_parent_'. $node->type, false );
-      $expanded   = $item_expandable && _nodehierarhcy_is_expanded( $node->nid );
+  foreach ($children as $child) {
+    $node = node_load($child);
+
+    if (node_access('view', $node)) {
+
+      $item_expandable = $expandable && variable_get('nh_parent_'. $node->type, FALSE);
+      $expanded   = $item_expandable && _nodehierarhcy_is_expanded($node->nid);
       $url        = $item_expandable ?
-                      _nodehierarchy_toggle_expand_url( $node->nid ) :
+                      _nodehierarchy_toggle_expand_url($node->nid) :
                       url("node/". $node->nid);
       $children   = $expanded ?
-                      nodehierarchy_get_node_children_list( $node->nid, $expandable ) :
+                      nodehierarchy_get_node_children_list($node->nid, $expandable) :
                       array();
-      
-      $tooltip    =  $node->title .' '. t( '(Type: !type)', array( "!type" => node_get_types( 'name', $node ) ) );
-      $tooltip    .= $item_expandable ? ' '. t( 'Click to toggle children.' ) : ' '. t( 'Click to view.' );
-      
+
+      $tooltip    =  $node->title .' '. t('(Type: !type)', array("!type" => node_get_types('name', $node)));
+      $tooltip    .= $item_expandable ? ' '. t('Click to toggle children.') : ' '. t('Click to view.');
+
       $rows[] = array(
         "node"        => $node,
         "url"         => $url,
@@ -550,64 +561,64 @@
 
 
 /**
- * Is the given node expanded (in the current site outline)
+ * Is the given node expanded (in the current site outline).
  *
  * @param $nid
- *   The node id of the node we want to check
+ *   The node id of the node we want to check.
  * @return
- *   Boolean. True if the node is expanded, false if collapsed
+ *   Boolean. TRUE if the node is expanded, FALSE if collapsed.
  */
-function _nodehierarhcy_is_expanded( $nid ) {
+function _nodehierarhcy_is_expanded($nid) {
   $expanded_nodes = _nodehierarhcy_get_expanded();
-  return isset( $expanded_nodes[$nid] );
+  return isset($expanded_nodes[$nid]);
 }
 
 /**
- * Get the list of expanded nodes
+ * Get the list of expanded nodes.
  *
  * @return
- *   An array whose keys are the expanded nodes (values are irrelevant)
+ *   An array whose keys are the expanded nodes (values are irrelevant).
  */
 function _nodehierarhcy_get_expanded() {
   static $expanded_nodes = NULL;
-  if ( $expanded_nodes === NULL ) {
-    if ( preg_match( "/(\d+,?)*/", @$_GET['nodehierarchy_expanded'] ) ) {
-      $expanded_nodes = array_flip(explode( ",", $_GET['nodehierarchy_expanded'] ));
+  if ($expanded_nodes === NULL) {
+    if (preg_match("/(\d+,?)*/", @$_GET['nodehierarchy_expanded'])) {
+      $expanded_nodes = array_flip(explode(",", $_GET['nodehierarchy_expanded']));
     }
   }
   return $expanded_nodes;
 }
 
 /**
- * Get a link which expands or contracts the given node in the site outline
+ * Get a link which expands or contracts the given node in the site outline.
  */
-function _nodehierarchy_toggle_expand_link( $title, $nid ) {
-  return url( "content/nodehierarchy", _nodehierarchy_toggle_expand_url_params( $nid ) );
+function _nodehierarchy_toggle_expand_link($title, $nid) {
+  return url("content/nodehierarchy", _nodehierarchy_toggle_expand_url_params($nid));
 }
 
 
 /**
- * Get a url which expands or contracts the given node in the site outline
+ * Get a url which expands or contracts the given node in the site outline.
  */
-function _nodehierarchy_toggle_expand_url( $nid ) {
+function _nodehierarchy_toggle_expand_url($nid) {
   $path = isset($_GET['q']) ? $_GET['q'] : '';
-  return url( $path, _nodehierarchy_toggle_expand_url_params( $nid ) );
+  return url($path, _nodehierarchy_toggle_expand_url_params($nid));
 }
 
 /**
- * Get the url params needed to toggle the expansion of the given node id
+ * Get the url params needed to toggle the expansion of the given node id.
  */
-function _nodehierarchy_toggle_expand_url_params( $nid ) {
+function _nodehierarchy_toggle_expand_url_params($nid) {
   $expanded_nodes = _nodehierarhcy_get_expanded();
-  
-  if ( isset( $expanded_nodes[$nid] ) ) {
-    unset( $expanded_nodes[$nid] );
+
+  if (isset($expanded_nodes[$nid])) {
+    unset($expanded_nodes[$nid]);
   }
   else {
-    $expanded_nodes[$nid] = true;
+    $expanded_nodes[$nid] = TRUE;
   }
-  
-  $expanded_param = trim( implode( ",", array_keys($expanded_nodes) ), "," );
+
+  $expanded_param = trim(implode(",", array_keys($expanded_nodes)), ",");
   return $expanded_param ? "nodehierarchy_expanded=$expanded_param" : "";
 }
 
@@ -621,32 +632,32 @@
  * @param $add_node
  *   Whether we want the current node in the breadcrumb (eg: for the children tab)
  */
-function nodehierarchy_set_breadcrumbs($node, $add_node = false) {
-    // place the given node
-  $menu[] = array( "path" => "node/". $node->nid, 'title' => $node->title, 'type' => MENU_NORMAL_ITEM );
-  
+function nodehierarchy_set_breadcrumbs($node, $add_node = FALSE) {
+    // Place the given node.
+  $menu[] = array("path" => "node/". $node->nid, 'title' => $node->title, 'type' => MENU_NORMAL_ITEM);
+
   $homepage = drupal_get_normal_path(variable_get('site_frontpage', 'node'));
-  
+
   $parent = $node;
-  // push the antecedants onto the breadcrumb/active menu stack (but not the homepage)
-  while ( $parent->parent ) {
-    $parent = node_load( $parent->parent );
-    if ( "node/". $parent->nid != $homepage ) {
-      $menu[] = array( "path" => "node/". $parent->nid, 'title' => $parent->title, 'type' => MENU_NORMAL_ITEM );
+  // Push the antecedants onto the breadcrumb/active menu stack (but not the homepage).
+  while ($parent->parent) {
+    $parent = node_load($parent->parent);
+    if ("node/". $parent->nid != $homepage) {
+      $menu[] = array("path" => "node/". $parent->nid, 'title' => $parent->title, 'type' => MENU_NORMAL_ITEM);
     }
   }
-  
-  // set the menu location and breadcrumb
-  menu_set_location( array_reverse( $menu ) );
+
+  // Set the menu location and breadcrumb.
+  menu_set_location(array_reverse($menu));
 }
 
-// descendant functions
+// Descendant functions.
 
 /**
-*  count the children of the given node
-*/
-function _nodehierarchy_get_children_count( $nid ) {
-  $query = "SELECT count(nid) as children_count FROM {nodehierarchy} h WHERE h.parent = %d";        
+ * Count the children of the given node.
+ */
+function _nodehierarchy_get_children_count($nid) {
+  $query = "SELECT count(nid) as children_count FROM {nodehierarchy} h WHERE h.parent = %d";
   $result = db_query($query, $nid);
   if ($out = db_fetch_object($result)) {
     return $out->children_count;
@@ -655,63 +666,63 @@
 }
 
 /**
-*  get the children of the given node
-*/
-function nodehierarchy_get_children($nid, $pager = false ) {
+ * Get the children of the given node.
+ */
+function nodehierarchy_get_children($nid, $pager = FALSE) {
     $children = array();
-    
-    if ( $nid ) {
-      $query = "SELECT h.nid FROM {nodehierarchy} h WHERE  h.parent = %d ORDER BY h.order_by ASC";        
+
+    if ($nid) {
+      $query = "SELECT h.nid FROM {nodehierarchy} h WHERE  h.parent = %d ORDER BY h.order_by ASC";
     }
     else {
-      $query = "SELECT n.nid FROM {node} n LEFT JOIN {nodehierarchy} h ON h.nid = n.nid WHERE h.parent = 0 OR h.parent IS NULL ORDER BY h.order_by ASC";        
+      $query = "SELECT n.nid FROM {node} n LEFT JOIN {nodehierarchy} h ON h.nid = n.nid WHERE h.parent = 0 OR h.parent IS NULL ORDER BY h.order_by ASC";
     }
 
-    if ( $pager ) {
+    if ($pager) {
       $result = pager_query($query, $pager, 0, NULL, $nid);
-    } 
+    }
     else {
       $result = db_query($query, $nid);
     }
-    
+
     while ($node = db_fetch_object($result)) {
       $children[] = $node->nid;
     }
-    
+
     return $children;
 }
 
 /**
-*  get the descendant tree for the given node
-*/
+ * Get the descendant tree for the given node.
+ */
 function nodehierarchy_get_descendant_list($nid) {
   $out = array();
   $children = nodehierarchy_get_children($nid);
   $out = $children;
-  
-  foreach ( $children as $child ) {
-    $out = array_merge( $out, nodehierarchy_get_descendant_list($child) );
+
+  foreach ($children as $child) {
+    $out = array_merge($out, nodehierarchy_get_descendant_list($child));
   }
-  
+
   return $out;
 }
 
-// sibling functions
+// Sibling functions.
 /**
-*  get the next sibling of the given node
-*/
-function nodehierarchy_next_sibling( $node ) {
-  if ( $nid = nodehierarchy_next_sibling_nid( $node ) ) {
-    return node_load( $nid );
+ * Get the next sibling of the given node.
+ */
+function nodehierarchy_next_sibling($node) {
+  if ($nid = nodehierarchy_next_sibling_nid($node)) {
+    return node_load($nid);
   }
   return NULL;
 }
 
 /**
-*  get the next sibling id of the given node
-*/
-function nodehierarchy_next_sibling_nid( $node ) {
-  if ( $node->parent !== NULL && $node->order_by ) {
+ * Get the next sibling id of the given node.
+ */
+function nodehierarchy_next_sibling_nid($node) {
+  if ($node->parent !== NULL && $node->order_by) {
     $sibling = db_fetch_object(db_query("SELECT h.nid FROM {nodehierarchy} h WHERE h.parent = %d AND h.order_by > %d ORDER BY h.order_by ASC LIMIT 1", $node->parent, $node->order_by));
     return @$sibling->nid;
   }
@@ -719,30 +730,30 @@
 }
 
 /**
-*  get the next sibling of the given node
-*/
-function nodehierarchy_next_sibling_link( $node ) {
-  if ( $sibling = nodehierarchy_next_sibling( $node ) ) {
-    return theme( "nodehierarchy_sibling_link", $sibling );
+ * Get the next sibling of the given node.
+ */
+function nodehierarchy_next_sibling_link($node) {
+  if ($sibling = nodehierarchy_next_sibling($node)) {
+    return theme("nodehierarchy_sibling_link", $sibling);
   }
   return "";
 }
 
 /**
-*  get the previous sibling of the given node
-*/
-function nodehierarchy_previous_sibling( $node ) {
-  if ( $nid = nodehierarchy_previous_sibling_nid( $node ) ) {
-    return node_load( $nid );
+ * Get the previous sibling of the given node.
+ */
+function nodehierarchy_previous_sibling($node) {
+  if ($nid = nodehierarchy_previous_sibling_nid($node)) {
+    return node_load($nid);
   }
   return NULL;
 }
 
 /**
-*  get the previous sibling of the given node
-*/
-function nodehierarchy_previous_sibling_nid( $node ) {
-  if ( $node->parent !== NULL && $node->order_by ) {
+ * Get the previous sibling of the given node.
+ */
+function nodehierarchy_previous_sibling_nid($node) {
+  if ($node->parent !== NULL && $node->order_by) {
     $sibling = db_fetch_object(db_query("SELECT h.nid FROM {nodehierarchy} h WHERE h.parent = %d AND h.order_by < %d ORDER BY h.order_by DESC LIMIT 1", $node->parent, $node->order_by));
     return @$sibling->nid;
   }
@@ -750,131 +761,132 @@
 }
 
 /**
-*  get the next sibling of the given node
-*/
-function nodehierarchy_previous_sibling_link( $node ) {
-  if ( $sibling = nodehierarchy_previous_sibling( $node ) ) {
-    return theme( "nodehierarchy_sibling_link", $sibling );
+ * Get the next sibling of the given node.
+ */
+function nodehierarchy_previous_sibling_link($node) {
+  if ($sibling = nodehierarchy_previous_sibling($node)) {
+    return theme("nodehierarchy_sibling_link", $sibling);
   }
   return "";
 }
 
 /**
- *  Get the nodehierarchy setting form for a particular node type
+ * Get the nodehierarchy setting form for a particular node type.
  */
 
-function _nodehierarchy_get_node_type_settings_form( $key, $append_key = false ) {
+function _nodehierarchy_get_node_type_settings_form($key, $append_key = FALSE) {
   $form = array();
   $form[($append_key ? ('nh_parent_'. $key) : 'nh_parent')] = array(
     '#type' => 'checkbox',
     '#title' => t('Can be parent'),
-    '#default_value' => variable_get('nh_parent_'. $key, false ),
+    '#default_value' => variable_get('nh_parent_'. $key, FALSE),
     '#description' => t('Other nodes can be created as child nodes of this node type.')
   );
   $form[($append_key ? ('nh_child_'. $key) : 'nh_child')] = array(
     '#type' => 'checkbox',
     '#title' => t('Can be child'),
-    '#default_value' => variable_get('nh_child_'. $key, false ),
+    '#default_value' => variable_get('nh_child_'. $key, FALSE),
     '#description' => t('This node type can be created as a child of other nodes.')
   );
-  $form[($append_key ? ('nh_defaultparent_'. $key) : 'nh_defaultparent')] = _nodehierarchy_get_parent_pulldown( $key, variable_get('nh_defaultparent_'. $key, 0 ), t('Default Parent') );
+  $form[($append_key ? ('nh_defaultparent_'. $key) : 'nh_defaultparent')] = _nodehierarchy_get_parent_pulldown($key, variable_get('nh_defaultparent_'. $key, 0), t('Default Parent'));
 
   return $form;
 }
 
-function _nodehierarchy_order_by( $node ) {
-  $menu_changed = false;
-  // done either on insert or update of a hierarchy. we want to make order by values into integers to get in the updated one and remain consistent
+function _nodehierarchy_order_by($node) {
+  $menu_changed = FALSE;
+  // Done either on insert or update of a hierarchy. we want to make order by
+  // values into integers to get in the updated one and remain consistent.
   $result = db_query("SELECT * FROM {nodehierarchy} h WHERE h.parent = %d ORDER BY h.order_by ASC", $node->parent);
 
   $i = 1;
   while ($hierarchy = db_fetch_object($result)) {
       $hierarchy->order_by = $i;
       $i++;
-       db_query("UPDATE {nodehierarchy} SET order_by = %d WHERE nid = %d", $hierarchy->order_by, $hierarchy->nid);
-      $menu_changed = (_nodehierarchy_set_menu_order( $node->parent, $hierarchy->nid, $hierarchy->order_by ) || $menu_changed);
+      db_query("UPDATE {nodehierarchy} SET order_by = %d WHERE nid = %d", $hierarchy->order_by, $hierarchy->nid);
+      $menu_changed = (_nodehierarchy_set_menu_order($node->parent, $hierarchy->nid, $hierarchy->order_by) || $menu_changed);
   }
-  
-  if ( $menu_changed ) {
+
+  if ($menu_changed) {
     menu_rebuild();
   }
 }
 
 /**
- * normalize the order of the children of the given node
+ * Normalize the order of the children of the given node.
  */
-function _nodehierarchy_normalize_child_order( $parent_nid ) {
-  if ( $parent_nid !== NULL ) {  
-    $menu_changed = false;
-    // done either on insert or update of a hierarchy. we want to make order by values into integers to get in the updated one and remain consistent
+function _nodehierarchy_normalize_child_order($parent_nid) {
+  if ($parent_nid !== NULL) {
+    $menu_changed = FALSE;
+    // Done either on insert or update of a hierarchy. we want to make order by values into integers to get in the updated one and remain consistent.
     $result = db_query("SELECT * FROM {nodehierarchy} h WHERE h.parent = %d ORDER BY h.order_by ASC", $parent_nid);
-  
+
     $i = 1;
     while ($hierarchy = db_fetch_object($result)) {
         $hierarchy->order_by = $i;
         $i++;
-         db_query("UPDATE {nodehierarchy} SET order_by = %d WHERE nid = %d", $hierarchy->order_by, $hierarchy->nid);
-        $menu_changed = (_nodehierarchy_set_menu_order( $parent_nid, $hierarchy->nid, $hierarchy->order_by ) || $menu_changed);
+        db_query("UPDATE {nodehierarchy} SET order_by = %d WHERE nid = %d", $hierarchy->order_by, $hierarchy->nid);
+        $menu_changed = (_nodehierarchy_set_menu_order($parent_nid, $hierarchy->nid, $hierarchy->order_by) || $menu_changed);
     }
-    
-    if ( $menu_changed ) {
+
+    if ($menu_changed) {
       menu_rebuild();
     }
   }
 }
 
 
-// menu functions
+// Menu functions.
 
 /**
- * create a menu item if the user selects one.
+ * Create a menu item if the user selects one.
  */
 function _nodehierarchy_create_menu(&$node) {
-  // if the menu is to be (re)created set the values to that derived by the hierarchy
-  if ( function_exists( 'menu_edit_item_save' ) && variable_get('nodehierarchy_menus', true ) && user_access('administer menu') && $node->nodehierarchy_create_menu ) {
+  // If the menu is to be (re)created set the values to that derived by the hierarchy.
+  if (function_exists('menu_edit_item_save') && variable_get('nodehierarchy_menus', TRUE) && user_access('administer menu') && $node->nodehierarchy_create_menu) {
 
-    if ( $parent_menu = _nodehierarchy_get_menu( $node->parent ) ) {
+    if ($parent_menu = _nodehierarchy_get_menu($node->parent)) {
       $node->menu['pid']      = $parent_menu;
     }
     else {
-      $node->menu['pid']      = variable_get('nodehierarchy_menus_default', 1 );
-    } 
-    
+      $node->menu['pid']      = variable_get('nodehierarchy_menus_default', 1);
+    }
+
     $node->menu['path']     = 'node/'. $node->nid;
     $node->menu['title']    = $node->title;
     $node->menu['weight']   = $node->order_by - 11; // editable menu weight range is -10 to 10
     $node->menu['type']     = MENU_CUSTOM_ITEM | MENU_MODIFIED_BY_ADMIN | MENU_VISIBLE_IN_TREE;
-    
+
     menu_edit_item_save($node->menu);
     menu_rebuild();
-    
-    // prevent the menu.module saving the menu itself in case
-    // the module is called after this one
+
+    // Prevent the menu.module saving the menu itself in case
+    // the module is called after this one.
     $node->menu = array();
-    
-    // prevent the this module from attempting to create a menu twice
-    $node->nodehierarchy_create_menu = false;
-   }
+
+    // Prevent the this module from attempting to create a menu twice.
+    $node->nodehierarchy_create_menu = FALSE;
+  }
 }
 
 /**
-* reorder the child menus of the given parent
-*/
-function _nodehierarchy_set_menu_order( $parent, $nid, $order_by ) {
-  if ( $parent_mid = _nodehierarchy_get_menu( $parent ) ) {
-    if ( $child_mid = _nodehierarchy_get_menu( $nid, $parent_mid ) ) {
-      db_query("UPDATE {menu} SET weight = %d WHERE mid = %d", ($order_by-11), $child_mid );
-      return true;
+ * Reorder the child menus of the given parent.
+ */
+function _nodehierarchy_set_menu_order($parent, $nid, $order_by) {
+  if ($parent_mid = _nodehierarchy_get_menu($parent)) {
+    if ($child_mid = _nodehierarchy_get_menu($nid, $parent_mid)) {
+      db_query("UPDATE {menu} SET weight = %d WHERE mid = %d", ($order_by-11), $child_mid);
+      return TRUE;
     }
   }
-  return false;
+  return FALSE;
 }
 
 /**
-* find the menu id for the given node, optionally with the given parent menu id
-*/
-function _nodehierarchy_get_menu( $nid, $pid = NULL ) {
-  if ( $pid ) {
+ * Find the menu ID for the given node, optionally with the given parent menu ID.
+ */
+function _nodehierarchy_get_menu($nid, $pid = NULL) {
+  if ($pid) {
     $item = db_fetch_array(db_query("SELECT mid FROM {menu} WHERE path = 'node/%d' AND pid = '%d'", $nid, $pid));
   }
   else {
@@ -884,55 +896,55 @@
 }
 
 /**
- * get the parent selector pulldown
+ * Get the parent selector pulldown.
  */
-function _nodehierarchy_get_parent_pulldown( $child_type, $default, $title, $nid = NULL ) {
+function _nodehierarchy_get_parent_pulldown($child_type, $default, $title, $nid = NULL) {
   // $child_type is currently unused
-  
+
   $types = array();
   foreach (node_get_types() as $key => $type) {
-    if ( variable_get('nh_parent_'. $key, false ) ) {
+    if (variable_get('nh_parent_'. $key, FALSE)) {
       $types[] = "'$key'";
     }
   }
-  
+
   $descendant_clause = "";
-  if ( $nid ) {
+  if ($nid) {
     $descendants = nodehierarchy_get_descendant_list($nid);
     $descendants[] = $nid;
-    $descendant_clause = " AND n.nid NOT IN (". implode( ",", $descendants ) .")";
+    $descendant_clause = " AND n.nid NOT IN (". implode(",", $descendants) .")";
   }
-  
+
   $hierarchylists[0] = '-- '. t('NONE') .' --';
-  
-  if ( $types ) {
-    $result = db_query("SELECT * FROM {node} n WHERE n.type IN (". implode( ",", $types ) .") $descendant_clause ORDER BY n.title ASC");  
+
+  if ($types) {
+    $result = db_query("SELECT * FROM {node} n WHERE n.type IN (". implode(",", $types) .") $descendant_clause ORDER BY n.title ASC");
     while ($hierarchylist = db_fetch_object($result)) {
-      if ( node_access( 'update', $hierarchylist ) || $hierarchylist->nid == $default ) {
+      if (node_access('update', $hierarchylist) || $hierarchylist->nid == $default) {
         $hierarchylists[$hierarchylist->nid] = $hierarchylist->title;
       }
     }
   }
-  
+
   $out = array(
     '#type' => 'select',
     '#title' => $title,
     '#default_value' => $default,
     '#options' => $hierarchylists,
   );
-  
+
   return $out;
 }
 
 /**
- * get a list of types which can be parents
+ * Get a list of types which can be parents.
  */
-function _nodehierarchy_get_parent_types( $child_type="", $quoted=false ) {
+function _nodehierarchy_get_parent_types($child_type = "", $quoted = FALSE) {
   // $child_type is currently unused
-  
+
   $types = array();
   foreach (node_get_types() as $key => $type) {
-    if ( variable_get('nh_parent_'. $key, false ) ) {
+    if (variable_get('nh_parent_'. $key, FALSE)) {
       $types[] = $quoted ? "'$key'" : $key;
     }
   }
Index: README.txt
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/nodehierarchy/README.txt,v
retrieving revision 1.1.2.1
diff -u -r1.1.2.1 README.txt
--- README.txt	11 Nov 2007 04:38:20 -0000	1.1.2.1
+++ README.txt	13 May 2008 05:41:24 -0000
@@ -4,15 +4,15 @@
 -------------------------------------------------------------------------------
 
 Node Hierarchy is a module which allows nodes to be children of other nodes
-creating a tree-like hierarchy of content. 
+creating a tree-like hierarchy of content.
 
 The module offers:
-  * Automatic hierarchical urls using pathauto 
+  * Automatic hierarchical urls using pathauto
     (eg: http://example.com/aboutus/history/beginning).
   * Automatic creation of hierarchical menus if desired.
   * Optional Views integration.
   * Optional Node Access integration
-  
+
 -------------------------------------------------------------------------------
 Installation
 ------------
@@ -34,7 +34,7 @@
 
 You will also need to assign the following permissions to the appropriate users:
 
-1) create child nodes 
+1) create child nodes
    For users who are allowed to create children under existing nodes.
 2) edit all node parents
    For users who are allowed to change the parent of any node, regardless of
@@ -48,14 +48,14 @@
    For users who are allowed to view the site outline
 6) administer hierarchy
    For users who are allowed to edit the node hierarchy defaults.
-      
+
 
 -------------------------------------------------------------------------------
 Using Node Hierarchy
 --------------------
 To assign a parent to a node, either:
 1) Create a new node of a type that whose "Can be child" setting is true or edit
-   an existing node. Expand the Node Hierarchy fieldset and chose a parent from 
+   an existing node. Expand the Node Hierarchy fieldset and chose a parent from
    the pulldown.
 -- OR --
 2) Navigate to the node you wish to make a parent. Click on the children tab,
@@ -96,8 +96,8 @@
 Token and Pathauto 2.x
 ----------------------
 Node Hierarchy integrates with token (and therefore Pathauto 2.x and others).
-For a description of available tokens see the Pathauto setting screen (or any 
-other token list). 
+For a description of available tokens see the Pathauto setting screen (or any
+other token list).
 
 For Pathauto, the recommended token to use is [fullhierarchypath] as it will
 reflect any changes you have made to the url of a nodes ancestors. For example,
@@ -113,7 +113,7 @@
   Parent Node Id - Takes a node id and returns only nodes which are children of
   that node. Used to provide lists of children for a give node.
 
-Fields: 
+Fields:
   Sort Order - The numerical sort order of a child node.
   Actions - A set of actions to manipulate child nodes. Should only be used in
   views accessible by Administrators.
@@ -132,7 +132,7 @@
   http://drupal.org/project/nodeaccess
 
 To enable this integration simply enable the Node Hierarchy Access Module.
-Once this module is enabled, grants added to a node will be autimatically added 
+Once this module is enabled, grants added to a node will be autimatically added
 all descendant nodes. This allows access control on an entire branch of the site
 tree.
 
@@ -147,8 +147,8 @@
 -------------------------------------------------------------------------------
 TODO
 ----
-* Improve "Can be child" setting to allow admins to specify which node types 
-  can be children of which node types. (e.g. 'chapter' nodes can only be 
+* Improve "Can be child" setting to allow admins to specify which node types
+  can be children of which node types. (e.g. 'chapter' nodes can only be
   children of 'book' nodes)
 * Drag and drop reordering and parent changing.
 * OPML imoport and export.
