');
while ($row = db_fetch_object($result)) {
$options[$row->vid] = $row->name;
}
$output .= form_select(t('Categories to include in the site map'), 'site_map_show_vocabularies', $value, $options, NULL, 0, TRUE);
return $output;
}
/**
* hook_menu() implementation
*/
function site_map_menu() {
$items[] = array(
'path' => 'sitemap',
'title' => t('site map'),
'callback' => '_site_map_page',
'access' => (user_access('access site map') || user_access('administer site map'))
);
return $items;
}
/**
* The site map
*/
function _site_map_page() {
//
// Vocabulary and menu trees are compiled and passed to theme functions
// individually.
//
if (variable_get('site_map_show_nav_menus', 1)) {
//
// Compile the menu trees.
// All the defined items in the 'Navigation' tree will be rendered. The items
// must be visible, of course.
//
$output .= theme('site_map_menu_tree', 1);
}
//
// Compile the vocabulary trees.
//
$vids = variable_get('site_map_show_vocabularies', array('0'));
$result = db_query('SELECT vid,name,description FROM {vocabulary} WHERE vid IN (%s) ORDER BY weight ASC, name', implode(',', $vids));
while ($t = db_fetch_object($result)) {
$tree = taxonomy_get_tree($t->vid);
$output .= theme('site_map_taxonomy_tree', $tree, variable_get('site_map_show_count', 1), $t->name, $t->description);
}
print theme('page', $output);
}
/**
* Themeable site map trees, called by _site_map_page(), to render a menu tree.
*
* @param $menu The item from menu_get_menu() that should be rendered.
* @return A string representing a rendered tree.
*/
function theme_site_map_menu_tree($item = 1) {
$menu = menu_get_menu();
foreach ($menu['visible'][$item]['children'] as $child) {
$output .= theme('site_map_menu_item', $child);
}
if ($output) {
$output = '
\n";
if ($menu['visible'][$item]['title']) {
$output = ''.$menu['visible'][$item]['title']."
\n".$output;
}
$output = ''.$output."
\n";
}
return $output;
}
/**
* Themeable site map trees, called by _site_map_page(), to render menu items.
*
* @param $menu The item from menu_get_menu() that should be rendered.
* @return A string representing a rendered tree.
*/
function theme_site_map_menu_item($item) {
$menu = menu_get_menu();
$output = '';
$output .= l($menu['visible'][$item]['title'], $menu['visible'][$item]['path']);
if ($menu['visible'][$item]['children']) {
$output .= '';
foreach ($menu['visible'][$item]['children'] as $child) {
$output .= theme('site_map_menu_item', $child);
}
$output .= "
\n";
}
$output .= "\n";
return $output;
}
/**
* Themeable site map trees, called by _site_map_page(), to render taxonomy trees.
*
* @param $tree The results of taxonomy_get_tree() with optional 'count' fields.
* @param $show_count Enabled node count if set.
* @param $name An optional name for the tree. (Default: NULL)
* @param $description An optional description of the tree. (Default: NULL)
* @return A string representing a rendered tree.
*/
function theme_site_map_taxonomy_tree(&$tree, $show_count, $name = NULL, $description = NULL) {
$name && $output = ''.$name.'
';
$description && $output .= ''.$description.'
';
$show_rss_links = variable_get('site_map_show_rss_links', 1);
if ($show_rss_links) {
$rss_depth = variable_get('site_map_rss_depth', 'all');
if (!is_numeric($rss_depth) || $rss_depth < 0) {
$rss_depth = 'all';
}
}
$last_depth = -1;
$output .= '';
foreach ($tree as $term) {
//
// Adjust the depth of the
based on the change
// in $term->depth since the $last_depth.
/*
if ($term->depth > $last_depth) {
for ($i = 0; $i < ($term->depth - $last_depth); $i++) {
$output .= '';
}
}
else if ($term->depth < $last_depth) {
for ($i = 0; $i < ($last_depth - $term->depth); $i++) {
$output .= '
';
}
}
//
// Display the $term. If $term->count exists, show the count too.
*/
$count = taxonomy_term_count_nodes($term->tid);
$output .= ' ' . l(drupal_specialchars($term->name). ' ·', 'taxonomy/term/'. $term->tid, array('class' => 'tag', 'title' => $term->description , 'style' => 'font-size:' . (13 + 0.18*$count) . 'px;'));
if ($show_rss_links) {
$output = $output . ' (' . l(t('RSS'), "taxonomy/term/{$term->tid}/{$rss_depth}/feed") . ')';
}
if ($show_count) {
$count = taxonomy_term_count_nodes($term->tid);
$output .= " ($count)\n";
}
//
// Reset $last_depth in preparation for the next $term.
//
$last_depth = $term->depth;
}
//
// Bring the depth back to where it began, -1.
//
if ($last_depth > -1) {
for ($i = 0; $i < ($last_depth + 1); $i++) {
$output .= '
';
}
}
$output .= "
\n";
return ''.$output.'
';
}
?>