You are here

function footermap_get_menu in footermap: a footer site map 5.2

Same name and namespace in other branches
  1. 5 footermap.module \footermap_get_menu()
  2. 6 footermap.module \footermap_get_menu()
  3. 7 footermap.module \footermap_get_menu()

Retrieve menu recursively

Parameters

mid menu_id:

level what level we are in the tree:

limit recurse limit:

mapref array pointer:

arrcnt block counter:

avail_menus visible menus:

1 call to footermap_get_menu()
_footermap_render in ./footermap.module
Render function for footermap

File

./footermap.module, line 223
This module queries the menu for pages and makes a dynamic sitemap at the bottom of the page.

Code

function footermap_get_menu($mid, $level, $limit, &$mapref, $arrcnt, $avail_menus) {
  $x = 0;
  $a = 0;
  if ($limit != 0 && $level > $limit) {
    return 0;
  }
  if (module_exists('path')) {
    $r = db_query("SELECT menu.*, (SELECT dst FROM {url_alias} WHERE src = menu.path) AS alias FROM {menu} WHERE pid = {$mid} ORDER BY pid,weight") or die(db_error());
  }
  else {
    $r = db_query("SELECT menu.* FROM {menu} WHERE pid = {$mid} ORDER BY pid,weight") or die(db_error());
  }
  while ($h = db_fetch_object($r)) {
    if (preg_match("/node\\/(\\d+)/", $h->path, $matches) == 1) {
      $node = node_load($matches[1]);
    }
    $g = 0;
    if ($level == 1) {

      // in drupal 5 menu block headers are the first level!
      foreach ($avail_menus as $key => $mn) {
        print "<!-- " . $mn . " = " . $h->title . " -->\n";
        if ($mn == $h->title) {
          $g = 1;
          end;
        }
      }
    }
    else {
      $g = 1;
    }
    unset($cur);

    // let's make sure we unset things first
    $cur = 'menu' . $h->mid;
    if (dechex($h->type) % 10 != 0 && $g == 1 && ($node->status == 1 || !isset($node))) {
      if ($h->path != '') {
        $a = 1;
      }
      else {
        if (variable_get('menu_headers', 0) == 1 && $h->path == '') {
          $a = 1;
        }
        else {
          $a = 2;
        }
      }
      if ($a == 1) {

        // menu_headers enabled
        if ($h->alias) {
          $mapref[$arrcnt][$cur][href] = $h->alias;
        }
        else {
          $mapref[$arrcnt][$cur][href] = $h->path;
        }
        if ($h->path == "/") {
          $mapref[$arrcnt][$cur][href] = $base_url;
        }
        $mapref[$arrcnt][$cur][title] = $h->title;
      }
      footermap_get_menu($h->mid, $level + 1, $limit, $mapref, $arrcnt, array());
      if ($level == 1) {
        $arrcnt++;
      }
    }
  }
}