View source
<?php
function footermap_help($section = '') {
$output = '';
switch ($section) {
case "admin/modules#description":
$output = t("Displays a sitemap at the bottom of the page");
break;
}
return $output;
}
function footermap_perm() {
return array(
'access content',
);
}
function footermap_menu() {
$items = array();
$items[] = array(
'path' => 'admin/settings/footermap',
'title' => t('Footermap'),
'description' => t('Change recurse limit or specify top menu id'),
'callback' => 'drupal_get_form',
'callback arguments' => array(
'footermap_settings',
),
'access' => user_access('administer site configuration'),
'type' => MENU_NORMAL_ITEM,
);
return $items;
}
function footermap_settings() {
$form['recurse_limit'] = array(
'#type' => 'textfield',
'#title' => t('Recurse Limit'),
'#default_value' => variable_get('recurse_limit', 0),
'#size' => 3,
'#maxlength' => 3,
'#description' => t('Set the # of times to recurse through a particular menu. Default is 0, unlimited.'),
);
$form['top_menu'] = array(
'#type' => 'textfield',
'#title' => t('Top Menu'),
'#default_value' => variable_get('top_menu', variable_get('menu_primary_menu', 0)),
'#size' => 3,
'#maxlength' => 3,
'#description' => t('Set the menu id to use as the top level. Default is to start at 0 i.e. primary links.'),
);
$form['menu_headers'] = array(
'#type' => 'radios',
'#title' => t('Menu Headers'),
'#default_value' => variable_get('menu_headers', 0),
'#options' => array(
t('Yes'),
t('No'),
),
'#required' => '1',
'#description' => t('Display menu block headers in the footer site map.'),
);
return system_settings_form($form);
}
function footermap_footer($main = 0) {
$o = "";
$o .= "<div class=\"footermap\">\n";
$x = footermap_get_menu(variable_get('top_menu', variable_get('menu_primary_menu', 0)), 1, 0, $o, variable_get('recurse_limit', 0));
$o = preg_replace("/· (\\S+)\$/", "\$1", $o);
$o .= "</div>\n";
return $o;
}
function footermap_get_menu($mid, $level, $hastree, &$temp, $limit) {
if ($limit != 0 && $level > $limit) {
return 0;
}
$a = 0;
if ($paths) {
$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 * FROM menu WHERE pid = {$mid} ORDER BY pid,weight") or die(db_error());
}
while ($h = db_fetch_object($r)) {
if ($level == 2) {
$a = 1;
}
if ($h->alias) {
$h->path = $h->alias;
}
if ($h->path == "/") {
$h->path = $base_url;
}
else {
if (preg_match("/^http|www|gopher|https|mailto|ftp|file|news/", $h->path) == 0 && $h->path != "") {
$h->path = base_path() . $h->path;
}
else {
}
}
if ($level > 1 && $h->path != "" && dechex($h->type) % 10 != 0) {
$temp .= "\t<span class=\"footermap-item\"><a href=\"{$h->path}\">{$h->title}</a> · </span>";
}
else {
if ($h->path != "" && dechex($h->type) % 10 != 0) {
$temp .= "<span class=\"footermap-submenu\"><a href=\"{$h->path}\">{$h->title}</a> · </span>";
}
else {
if (variable_get('menu_headers', 0) == 0 && dechex($h->type) % 10 != 0) {
$temp .= "<span>{$h->title} ·</span>";
}
}
}
$i = footermap_get_menu($h->mid, $level + 1, $a, $temp, $limit);
if ($i > 0) {
$temp .= "<br>\n";
$temp = preg_replace("/· (\\S+)\$/", "\$1", $temp);
}
}
return $a;
}