
//    $vocabularies = taxonomy_get_vocabularies();
//    foreach ($vocabularies AS $vid => $vocabulary) {
//      $items[] = array(
//        'path' => 'directory/vocabulary/'. $vid,
//        'title' => t('Directory for !vocabulary-name', array('!vocabulary-name' => $vocabulary->name)),
//        'callback' => 'directory_vocabulary_page',
//        'callback arguments' => $vid,
//        'access' => user_access('access content'),
//        'type' => MENU_SUGGESTED_ITEM,
//      );
//    }
    
    $access = user_access('access content');

    foreach (taxonomy_get_vocabularies() as $vid => $vocabulary) {
      $path = 'directory/vocabulary/'. $vid;
      $items[] = array(
        'path' => $path,
        'title' => t($vocabulary->name),
        'callback' => 'directory_vocabulary_page',
        'callback arguments' => $vid,
        'access' => $access,
        'type' => MENU_SUGGESTED_ITEM,
        'weight' => $vocabulary->weight);

      $tree = taxonomy_get_tree($vocabulary->vid);
      $old_depth = -1;
      $old_path = $path;

      foreach ($tree as $term) {
        if ($term->depth <= $old_depth) {
          $slashes_to_remove = $old_depth - $term->depth + 1;
          for ($i = 0; $i < $slashes_to_remove; $i++) {
            $old_path = substr($old_path, 0, strrpos($old_path, '/'));
          }
        }
        $path = $old_path .'/'. $term->tid;
        $old_depth = $term->depth;
        $old_path = $path;
        $items[] = array(
          'path' => $path,
          'title' => t($term->name),
          'weight' => $term->weight);
      }
    }
