function taxonomy_list_show in Taxonomy List 7
Same name and namespace in other branches
- 5.2 taxonomy_list.module \taxonomy_list_show()
- 5 taxonomy_list.module \taxonomy_list_show()
- 6.2 taxonomy_list.module \taxonomy_list_show()
- 6 taxonomy_list.module \taxonomy_list_show()
Show the category list
1 string reference to 'taxonomy_list_show'
- taxonomy_list_menu in ./
taxonomy_list.module - Implementation of hook_menu().
File
- ./
taxonomy_list.module, line 323 - List all terms in a vocabulary.
Code
function taxonomy_list_show($str_vids, $max_depth = 'all', $op = NULL, $columns = NULL, $type = NULL) {
drupal_add_css(drupal_get_path('module', 'taxonomy_list') . '/taxonomy_list.css');
if (empty($str_vids)) {
$str_vids = 'all';
}
$params = array(
'max_depth' => 'all',
'op' => NULL,
'type' => NULL,
'columns' => variable_get('taxonomy_list_cell_per_row', 2),
'format' => variable_get('taxonomy_list_format', 'table'),
'list_mode' => variable_get('taxonomy_list_list_mode', 0),
);
$params = array_merge($params, $_GET);
unset($params['q']);
if (isset($params['cols'])) {
$params['columns'] = $params['cols'];
unset($params['cols']);
}
if (isset($params['depth'])) {
$params['max_depth'] = $params['depth'];
unset($params['depth']);
}
if (isset($params['mode'])) {
$params['list_mode'] = $params['mode'];
unset($params['mode']);
}
array_walk($params, 'check_plain');
if ($params['max_depth'] == 'all') {
$params['max_depth'] = 9999999;
}
$vids = array();
if ($str_vids == 'all') {
$vocs = taxonomy_get_vocabularies();
foreach ($vocs as $vid => $vocab) {
$vids[] = $vid;
}
}
else {
$vocs = explode(' ', $str_vids);
foreach ($vocs as $name) {
$vocab = taxonomy_vocabulary_machine_name_load($name);
if ($vocab) {
$vids[] = $vocab->vid;
}
else {
drupal_set_message(t('I do not recognize "@name". ', array(
'@name' => $name,
)));
}
}
/*
if (preg_match('/^([0-9]+[+ ])+[0-9]+$/', $str_vids)) {
// The '+' character in a query string may be parsed as ' '.
$vids = preg_split('/[+ ]/', $str_vids);
}
else {
if (preg_match('/^[0-9]+$/', $str_vids) ) {
$vids = array($str_vids);
}
}
/* */
}
if (count($vids) <= 0) {
drupal_set_message(t('There were no vaild vocabularies requested. '));
return;
}
// Do we want to list the nodes?
if ($params['op'] == 'list') {
// return 'taxonomy_list_nodes_render';
return taxonomy_list_nodes_render($vids, $params['max_depth'], $params['type']);
}
$vocab_titles = array();
$total_terms = 0;
$output = '<div id="taxonomy-list">';
foreach ($vids as $vid) {
$vocab = taxonomy_vocabulary_load($vid);
if ($vocab == FALSE) {
continue;
}
$vocab_titles[] = $vocab->name;
$terms = taxonomy_list_get_tree($vid, 0, $params['max_depth']);
$c = count($terms);
if ($c <= 0) {
// This vocab has no term, skip.
continue;
}
$total_terms += $c;
$output .= '<div id="taxonomy-list-' . drupal_html_class($vocab->machine_name) . '">';
$output .= theme('taxonomy_list_vocabulary', array(
'vocabulary' => $vocab,
'title' => count($vids) > 1,
));
// $output .= theme(array('taxonomy_list_'. $params['format'], 'taxonomy_list_table'),
$output .= theme('taxonomy_list_' . $params['format'], array(
'terms' => $terms,
'cells' => $params['columns'],
'title' => $params['list_mode'],
));
$output .= '</div>';
}
$output .= '</div>';
// class="taxonomy-list"
if ($total_terms == 0) {
return t('Could not handle @what. ', array(
'@what' => $str_vids,
));
drupal_not_found();
return;
}
// drupal_set_title(filter_xss_admin(implode(variable_get('taxonomy_list_title_separator', ' & '), $vocab_titles)));
drupal_set_title(implode(variable_get('taxonomy_list_title_separator', ' & '), $vocab_titles));
$output = theme('taxonomy_list_admin_links', array(
'vids' => $vids,
)) . $output;
return $output;
}