View source
<?php
define('TAXONOMY_MENU_BASE_PATH', 'admin/build/taxonomy_menu/');
function taxonomy_menu_group_list() {
$groups = taxonomy_menu_get_menu_groups();
foreach ($groups as $group) {
$rows[] = array(
'<strong>Menu Group:</strong> ' . check_plain($group->name),
l(t('Edit'), TAXONOMY_MENU_BASE_PATH . 'group/' . $group->mgid . '/edit'),
l(t('Rebuild'), TAXONOMY_MENU_BASE_PATH . 'group/' . $group->mgid . '/rebuild'),
l(t('Delete'), TAXONOMY_MENU_BASE_PATH . 'group/' . $group->mgid . '/delete'),
);
$term_sets = taxonomy_menu_get_term_sets_by_group($group->mgid);
taxonomy_menu_term_set_table($term_sets, $rows);
$rows[] = array();
}
if (empty($rows)) {
return t('No Menu Groups');
}
else {
return theme('table', array(), $rows);
}
}
function taxonomy_menu_term_set_table($term_sets, &$rows) {
if ($term_sets) {
foreach ($term_sets as $term_set) {
$term_set_path = $term_set->mgid . '/' . $term_set->tsid;
$rows[] = array(
'-Term Set: ' . check_plain($term_set->name),
l(t('Edit'), TAXONOMY_MENU_BASE_PATH . 'termset/' . $term_set->tsid . '/edit'),
l(t('Delete'), TAXONOMY_MENU_BASE_PATH . 'termset/' . $term_set->tsid . '/delete'),
);
}
}
else {
$rows[] = array(
l(t('No Term Sets. Edit the menu group associate a Term Set'), TAXONOMY_MENU_BASE_PATH . 'gropu/' . $term_set->mgid . '/edit'),
);
}
}
function taxonomy_menu_term_sets() {
$term_sets = taxonomy_menu_get_term_sets();
if ($term_sets) {
$rows = array();
foreach ($term_sets as $term_set) {
$rows[] = array(
'<strong>Term Set:</strong> ' . check_plain($term_set->name),
l(t('Edit'), TAXONOMY_MENU_BASE_PATH . 'termset/' . $term_set->tsid . '/edit'),
l(t('Delete'), TAXONOMY_MENU_BASE_PATH . 'termset/' . $term_set->tsid . '/delete'),
);
$menu_groups = taxonomy_menu_get_menu_group_by_ts($term_set->tsid);
taxonomy_menu_group_table($menu_groups, $rows);
$rows[] = array();
}
}
else {
return t('No Term Sets');
}
return theme('table', array(), $rows);
}
function taxonomy_menu_group_table($menu_groups, &$rows) {
if ($menu_groups) {
foreach ($menu_groups as $menu_group) {
$rows[] = array(
'-Menu Group: ' . check_plain($menu_group->name),
l(t('Edit'), TAXONOMY_MENU_BASE_PATH . 'group/' . $menu_group->mgid . '/edit'),
);
}
}
else {
$rows[] = array(
t('No Menu Groups for Term Set'),
);
}
}
function taxonomy_menu_group_form($form_state, $mgid = 0) {
$breadcrumb = drupal_get_breadcrumb();
$breadcrumb[] = l(t('Menu Groups'), 'admin/build/taxonomy_menu');
drupal_set_breadcrumb($breadcrumb);
$menu_items = menu_parent_options(menu_get_menus(), NULL);
if ($mgid) {
$menu_group = taxonomy_menu_get_group($mgid);
$form_state['storage']['menu_group_name'] = $menu_group->name;
$form_state['storage']['parent_menu_item'] = $menu_group->parent_menu;
$form_state['storage']['path'] = $menu_group->path;
$form_state['storage']['mgid'] = $mgid;
$form_state['storage']['items'] = $menu_group->items;
}
$form['menu_group_name'] = array(
'#type' => 'textfield',
'#title' => t('Menu Group Name'),
'#default_value' => $form_state['storage']['menu_group_name'],
'#required' => TRUE,
);
$form['parent_menu_item'] = array(
'#type' => 'select',
'#title' => t('Parent Menu Item'),
'#default_value' => $form_state['storage']['parent_menu_item'],
'#options' => $menu_items,
'#required' => TRUE,
'#description' => t('The Parent Menu Item that the Menu Link will be built under.'),
);
$form['path'] = array(
'#type' => 'select',
'#title' => t('Path Type'),
'#default_value' => $form_state['storage']['path'],
'#options' => taxonomy_menu_get_paths(),
'#required' => TRUE,
'#ahah' => array(
'event' => 'change',
'method' => 'replace',
'path' => 'taxonomy_menu/ahah/path',
'wrapper' => 'taxonomy-menu-path-options',
'effect' => 'fade',
),
);
$form['vid_select_submit'] = array(
'#type' => 'submit',
'#value' => t('Update the Path Type'),
'#submit' => array(
'taxonomy_menu_select_submit',
),
'#attributes' => array(
'class' => 'no-js',
),
);
$form['path_options'] = taxonomy_menu_get_options('PATH', $form_state['storage']['path']);
$form['path_options']['#title'] = t('Path Options');
$form['path_options']['#prefix'] = '<div id = "taxonomy-menu-path-options">';
$form['path_options']['#suffix'] = '</div>';
$form['path_options']['#collapsed'] = TRUE;
$form['term_sets'] = array(
'#prefix' => '<div id="taxonomy-menu-term-sets">',
'#suffix' => '</div>',
'#theme' => 'taxonomy_menu_term_set_table',
);
$term_sets = taxonomy_menu_get_term_sets_by_group($form_state['storage']['mgid']);
foreach ($term_sets as $term_set) {
$form['term_sets']['list'][$term_set->tsid]['name'] = array(
'#value' => t($term_set->name),
);
$form['term_sets']['list'][$term_set->tsid]['vocab'] = array(
'#value' => t($term_set->vocab_name),
);
$form['term_sets']['list'][$term_set->tsid]['parent'] = array(
'#value' => t($term_set->parent->name),
);
$form['term_sets']['list'][$term_set->tsid]['remove'] = array(
'#type' => 'submit',
'#value' => t('Remove'),
'#submit' => 'taxonomy_menu_group_remove_term_set_submit',
'#ahah' => array(
'path' => 'taxonomy_menu/ahah/term_sets_remove/' . $form_state['storage']['mgid'] . '/' . $term_set->tsid,
'wrapper' => 'taxonomy-menu-term-sets',
'method' => 'replace',
'effect' => 'fade',
),
);
}
$form['term_sets']['mgid'] = array(
'#type' => 'value',
'#value' => $form_state['storage']['mgid'],
);
if ($form_state['storage']['mgid']) {
$form['term_sets']['term_set_add'] = array(
'#type' => 'fieldset',
'#title' => t('Assoicate Term Set to Menu Group'),
'#tree' => FALSE,
'#theme' => 'taxonomy_menu_group_term_set_add',
);
$form['term_sets']['term_set_add']['term_set'] = array(
'#type' => 'select',
'#title' => t('Term Set'),
'#options' => _taxonomy_menu_get_term_sets_options($form_state['storage']['mgid']),
);
$form['term_sets']['term_set_add']['term_set_parent'] = array(
'#type' => 'select',
'#title' => t('Parent Term Set Item'),
'#options' => _taxonomy_menu_get_term_set_parent_item_options($form_state['storage']['items']),
);
$form['term_sets']['term_set_add']['term_set_more'] = array(
'#type' => 'submit',
'#value' => t('Associate'),
'#submit' => array(
'taxonomy_menu_group_term_submit',
),
'#ahah' => array(
'path' => 'taxonomy_menu/ahah/term_sets',
'wrapper' => 'taxonomy-menu-term-sets',
'method' => 'replace',
'effect' => 'fade',
),
);
}
$form['group_options'] = taxonomy_menu_get_options('GROUP', $form_state['storage']['mgid']);
$form['group_options']['#title'] = t('Group Options');
$form['submit'] = array(
'#type' => 'submit',
'#value' => t('Save'),
);
return $form;
}
function taxonomy_menu_group_form_submit($form, &$form_state) {
$menu_group = array(
'path' => $form_state['values']['path'],
'name' => $form_state['values']['menu_group_name'],
'parent_menu' => $form_state['values']['parent_menu_item'],
'mgid' => $form_state['values']['mgid'],
);
taxonomy_menu_save_menu_group($menu_group);
if ($form_state['values']['path_options']) {
_taxonomy_menu_save_options('PATH', $form_state['values']['path_options'], $menu_group['mgid']);
}
if ($form_state['values']['group_options']) {
_taxonomy_menu_save_options('GROUP', $form_state['values']['group_options'], $menu_group['mgid']);
}
$form_state['redirect'] = 'admin/build/taxonomy_menu/group/' . $menu_group['mgid'] . '/edit';
}
function taxonomy_menu_group_term_submit($form, &$form_state) {
$menu_set = array(
'mgid' => $form_state['values']['mgid'],
'tsid' => $form_state['values']['term_set'],
'parent_item' => $form_state['values']['term_set_parent'],
);
taxonomy_menu_save_menu_set_rtln($menu_set);
$form_values = $form_state['values'];
unset($form_state['submit_handlers']);
form_execute_handlers('submit', $form, $form_state);
$form_state['storage'] = $form_values;
$form_state['rebuild'] = TRUE;
}
function taxonomy_menu_group_remove_term_set_submit($form, &$form_state) {
taxonomy_menu_group_remove_term_set($form_state['values']['mgid'], $form_state['values']['term_set']);
$form_values = $form_state['values'];
unset($form_state['submit_handlers']);
form_execute_handlers('submit', $form, $form_state);
$form_state['storage'] = $form_values;
$form_state['rebuild'] = TRUE;
}
function _taxonomy_menu_group_display($group) {
if ($group->enabled) {
return l(t('Disable'), TAXONOMY_MENU_BASE_PATH . $group->mgid . '/disable');
}
else {
return l(t('Enable'), TAXONOMY_MENU_BASE_PATH . $group->mgid . '/enable');
}
}
function _taxonomy_menu_save_options($type, $options, $type_key) {
$option = new stdClass();
foreach ($options as $name => $value) {
$option->name = $name;
$option->type = $type;
$option->type_key = $type_key;
$option->value = $value;
taxonomy_menu_save_option($option);
}
}
function taxonomy_menu_term_set_add($tsid = 0) {
$vocabs = taxonomy_get_vocabularies();
if ($vocabs) {
return drupal_get_form('taxonomy_menu_term_set_form', $vocabs, $tsid);
}
return l(t('Please create a vocabulary before creating the Taxonomy Menu'), 'admin/content/taxonomy/add/vocabulary');
}
function taxonomy_menu_term_set_form($form_state, $vocabs, $tsid = 0) {
$breadcrumb = drupal_get_breadcrumb();
$breadcrumb[] = l(t('Term Sets'), 'admin/build/taxonomy_menu/termset');
drupal_set_breadcrumb($breadcrumb);
if ($tsid) {
$term_set = taxonomy_menu_get_term_set($tsid);
$form['tsid'] = array(
'#type' => 'value',
'#value' => $tsid,
);
$form_state['storage']['title'] = $term_set->name;
$form_state['storage']['vid'] = $term_set->vid;
$form_state['storage']['items'] = $term_set->items;
foreach ($term_set->items as $term) {
$form_state['storage']['terms'][] = $term->tid;
}
}
if (isset($form_state['values'])) {
$form_state['storage'] = $form_state['values'];
}
$form['#cache'] = TRUE;
$form['title'] = array(
'#type' => 'textfield',
'#title' => t('Title'),
'#default_value' => $form_state['storage']['title'],
'#required' => TRUE,
);
foreach ($vocabs as $vocab) {
$vocab_items[$vocab->vid] = $vocab->name;
}
array_unshift($vocab_items, '-Select vocabulary-');
$form['vid'] = array(
'#type' => 'select',
'#title' => t('Vocabulary'),
'#required' => TRUE,
'#options' => $vocab_items,
'#default_value' => $form_state['storage']['vid'],
'#ahah' => array(
'event' => 'change',
'method' => 'replace',
'path' => 'taxonomy_menu/ahah/tids',
'wrapper' => 'taxonomy-menu-tids',
'effect' => 'fade',
),
);
$form['vid_select_submit'] = array(
'#type' => 'submit',
'#value' => t('Update the Term Tree'),
'#submit' => array(
'taxonomy_menu_select_submit',
),
'#attributes' => array(
'class' => 'no-js',
),
);
$form['terms_wrapper'] = array(
'#prefix' => '<div id="taxonomy-menu-tids">',
'#suffix' => '</div>',
);
$form['terms_wrapper']['terms'] = array(
'#type' => 'taxonomy_manager_tree',
'#vid' => $form_state['storage']['vid'],
'#title' => t('Select terms'),
'#parent' => 0,
'#multiple' => TRUE,
'#add_term_info' => TRUE,
'#default_value' => $form_state['storage']['terms'],
);
$form['sync_method'] = array(
'#type' => 'select',
'#title' => t('Sync Method'),
'#required' => TRUE,
'#options' => array(
'-Select-',
),
'#description' => t('TODO'),
);
$form['term_set_options'] = taxonomy_menu_get_options('TERM_SET', $tsid);
$form['term_set_options']['#title'] = t('Term Set Options');
$form['submit'] = array(
'#type' => 'submit',
'#value' => t('Save'),
);
$form['#redirect'] = 'admin/build/taxonomy_menu/termset';
return $form;
}
function taxonomy_menu_term_set_form_submit($form, &$form_state) {
if ($form_state['clicked_button']['#value'] === t('Save')) {
$term_set['tsid'] = $form_state['values']['tsid'];
$term_set['name'] = $form_state['values']['title'];
$term_set['vid'] = $form_state['values']['vid'];
if (!$form_state['values']['tsid']) {
taxonomy_menu_save_term_set($term_set);
}
$term_set['items'] = taxonomy_menu_build_tree($form_state['values']['vid'], $form_state['values']['terms']['selected_terms'], $term_set['tsid']);
taxonomy_menu_save_term_set($term_set);
_taxonomy_menu_save_options('TERM_SET', $form_state['values']['term_set_options'], $term_set['tsid']);
$form_state['#redirect'] = 'admin/build/taxonomy_menu/termset';
}
}
function taxonomy_menu_select_submit($form, &$form_state) {
$form_values = $form_state['values'];
unset($form_state['submit_handlers']);
form_execute_handlers('submit', $form, $form_state);
$form_state['storage'] = $form_values;
$form_state['rebuild'] = TRUE;
}
function taxonomy_menu_ahah_helper() {
$form_state = array(
'storage' => NULL,
'submitted' => TRUE,
);
$form_build_id = $_POST['form_build_id'];
$form = form_get_cache($form_build_id, $form_state);
$args = $form['#parameters'];
$form_id = array_shift($args);
$form['#post'] = $_POST;
$form['#redirect'] = FALSE;
$form['#programmed'] = FALSE;
$form_state['post'] = $_POST;
$form['#validate'] = NULL;
$form['#submit'] = NULL;
$form_state['submit_handlers'] = NULL;
$form_state['validate_handlers'] = NULL;
_taxonomy_menu_ahah_disable_validation($form);
drupal_process_form($form_id, $form, $form_state);
$form = drupal_rebuild_form($form_id, $form_state, $args, $form_build_id);
return $form;
}
function taxonomy_menu_ahah_element_helper($changed_elements) {
unset($changed_elements['#prefix'], $changed_elements['#suffix']);
$javascript = drupal_add_js(NULL, NULL, 'header');
drupal_json(array(
'status' => TRUE,
'data' => theme('status_messages') . drupal_render($changed_elements),
'settings' => call_user_func_array('array_merge_recursive', $javascript['setting']),
));
}
function taxonomy_menu_ahah_tids() {
$form = taxonomy_menu_ahah_helper();
taxonomy_menu_ahah_element_helper($form['terms_wrapper']);
}
function taxonomy_menu_ahah_path() {
$form = taxonomy_menu_ahah_helper();
taxonomy_menu_ahah_element_helper($form['path_options']);
}
function taxonomy_menu_ahah_term_sets() {
$form = taxonomy_menu_ahah_helper();
taxonomy_menu_ahah_element_helper($form['term_sets']);
}
function taxonomy_menu_ahah_term_set_remove($mgid, $tsid) {
taxonomy_menu_group_remove_term_set($mgid, $tsid);
taxonomy_menu_ahah_term_sets();
}
function _taxonomy_menu_ahah_disable_validation(&$form) {
foreach (element_children($form) as $child) {
$form[$child]['#validated'] = TRUE;
_taxonomy_menu_ahah_disable_validation($form[$child]);
}
}
function taxonomy_menu_build_tree($vid, $tids, $tsid) {
$tree = taxonomy_get_tree($vid);
foreach ($tree as $key => $term) {
if (!in_array($term->tid, $tids)) {
unset($tree[$key]);
}
else {
$tree[$key]->parent = $tsid . ':' . $term->parents[0];
unset($tree[$key]->parents);
$tree[$key]->tsid = $tsid;
}
}
return $tree;
}
function taxonomy_menu_group_delete_confirm(&$form_state, $mgid) {
$form['mgid'] = array(
'#type' => 'value',
'#value' => $mgid,
);
$menu_group = taxonomy_menu_get_group($mgid);
return confirm_form($form, t('Are you sure you want to delete %title? This will also delete all of the related Menu Items', array(
'%title' => $menu_group->name,
)), 'admin/build/taxonomy_menu', t('This action cannot be undone'), t('Delete'), t('Cancel'));
}
function taxonomy_menu_group_delete_confirm_submit($form, &$form_state) {
if ($form_state['values']['confirm']) {
taxonomy_menu_group_delete($form_state['values']['mgid']);
}
$form_state['redirect'] = 'admin/build/taxonomy_menu';
}
function taxonomy_menu_term_set_delete_confirm(&$form_state, $tsid) {
$term_set = taxonomy_menu_get_term_set($tsid);
$form['term_set'] = array(
'#type' => 'value',
'#value' => $term_set,
);
$form['#redirect'] = 'admin/build/taxonomy_menu/termset';
return confirm_form($form, t('Are you sure you want to delete %title?', array(
'%title' => check_plain($term_set->name),
)), drupal_get_destination(), t('This action cannot be undone'), t('Delete'), t('Cancel'));
}
function taxonomy_menu_term_set_delete_confirm_submit($form, &$form_state) {
if ($form_state['values']['confirm']) {
taxonomy_menu_term_set_delete($form_state['values']['term_set']->tsid);
drupal_set_message(t('%title has been deleted.', array(
'%title' => check_plain($form_state['values']['term_set']->name),
)), 'status');
}
}
function taxonomy_menu_save_menu_group(&$menu_group) {
if (is_object($menu_group)) {
$menu_group = (array) $menu_group;
}
if ($menu_group['mgid']) {
drupal_write_record('taxonomy_menu_group', $menu_group, 'mgid');
}
else {
drupal_write_record('taxonomy_menu_group', $menu_group);
}
drupal_set_message(t('Menu Group %menu_group has been saved', array(
'%menu_group' => $menu_group['name'],
)));
}
function taxonomy_menu_save_term_set(&$term_set) {
if ($term_set['tsid']) {
drupal_write_record('taxonomy_menu_term_set', $term_set, 'tsid');
}
else {
drupal_write_record('taxonomy_menu_term_set', $term_set);
}
}
function taxonomy_menu_get_group($mgid) {
$menu_group = db_fetch_object(db_query('SELECT * FROM {taxonomy_menu_group} WHERE mgid = %d', $mgid));
$menu_group->items = unserialize($menu_group->items);
$menu_group->options = _taxonomy_menu_get_options_by_key('GROUP', $mgid);
return $menu_group;
}
function taxonomy_menu_get_menu_groups() {
$output = array();
$result = db_query('SELECT * FROM {taxonomy_menu_group');
while ($data = db_fetch_object($result)) {
$data->items = unserialize($data->items);
$output[$data->mgid] = $data;
$output[$data->mgid]->options = _taxonomy_menu_get_options_by_key('GROUP', $data->mgid);
}
return $output;
}
function taxonomy_menu_get_term_sets_by_group($mgid) {
$output = array();
$result = db_query('SELECT * FROM {taxonomy_menu_group_term_set} WHERE mgid = %d', $mgid);
while ($data = db_fetch_object($result)) {
list($ptsid, $ptid) = explode(':', $data->parent_item);
$output[$data->tsid] = taxonomy_menu_get_term_set($data->tsid);
$output[$data->tsid]->parent = taxonomy_menu_get_term_set($ptsid);
}
return $output;
}
function taxonomy_menu_get_term_set($tsid) {
$term_set = db_fetch_object(db_query('SELECT * FROM {taxonomy_menu_term_set} WHERE tsid = %d', $tsid));
$term_set->items = unserialize($term_set->items);
$term_set->vocab_name = _taxonomy_menu_get_vocab_name($term_set->vid);
$term_set->options = _taxonomy_menu_get_options_by_key('TERM_SET', $tsid);
return $term_set;
}
function taxonomy_menu_get_term_sets() {
$output = array();
$result = db_query('SELECT tsid FROM {taxonomy_menu_term_set}');
while ($data = db_fetch_object($result)) {
$output[$data->tsid] = taxonomy_menu_get_term_set($data->tsid);
}
return $output;
}
function _taxonomy_menu_get_term_sets_options($mgid) {
$term_sets = array();
$result = db_query('SELECT * FROM {taxonomy_menu_group_term_set} WHERE mgid = %d', $mgid);
while ($data = db_fetch_object($result)) {
$term_sets[] = $data->tsid;
}
$output = array();
$result = db_query('SELECT * FROM {taxonomy_menu_term_set}');
while ($data = db_fetch_object($result)) {
if (!in_array($data->tsid, $term_sets)) {
$output[$data->tsid] = $data->name;
}
}
return $output;
}
function taxonomy_menu_get_menu_group_by_ts($tsid) {
$output = array();
$result = db_query('SELECT * FROM {taxonomy_menu_group_term_set} WHERE tsid = %d', $tsid);
while ($data = db_fetch_object($result)) {
$output[$data->mgid] = taxonomy_menu_get_group($data->mgid);
}
return $output;
}
function taxonomy_menu_save_menu_set_rtln($menu_set) {
drupal_write_record('taxonomy_menu_group_term_set', $menu_set);
$menu_group = taxonomy_menu_get_group($menu_set['mgid']);
$term_set = taxonomy_menu_get_term_set($menu_set['tsid']);
if ($menu_set['parent_item']) {
$depth = $menu_group->items[$menu_set['parent_item']]->depth + 1;
}
else {
$depth = 0;
}
foreach ($term_set->items as $key => $item) {
$item->depth = $item->depth + $depth;
unset($item->parents);
$item->parent = $menu_set['parent_item'];
$menu_group->items[$item->tsid . ':' . $item->tid] = $item;
}
$menu_group->items = taxonomy_menu_build_menu_tree($menu_group->items);
taxonomy_menu_save_menu_group($menu_group);
}
function taxonomy_menu_group_delete($mgid, $name = NULL) {
if (!$name) {
$menu_group = taxonomy_menu_get_group($mgid);
$name = $menu_group->name;
}
db_query('DELETE FROM {taxonomy_menu_group_term_set} WHERE mgid = %d', $mgid);
_taxonomy_menu_options_delete_by_parent($mgid, 'GROUP');
db_query('DELETE FROM {taxonomy_menu_group} WHERE mgid = %d', $mgid);
drupal_set_message(t('Menu Group %menu_group has been deleted', array(
'%menu_group' => $name,
)));
}
function taxonomy_menu_term_set_delete($tsid) {
$menu_groups = taxonomy_menu_get_menu_group_by_ts($tsid);
foreach ($menu_groups as $mgid => $menu_group) {
taxonomy_menu_group_remove_term_set($mgid, $tsid);
}
_taxonomy_menu_options_delete_by_parent($tsid, 'ITEM');
db_query('DELETE FROM {taxonomy_menu_term_set WHERE tsid = %d', $tsid);
}
function _taxonomy_menu_options_delete_by_parent($parent, $type) {
db_query("DELETE FROM {taxonomy_menu_options} WHERE type_key = '%s' AND type = '%s'", strval($parent), $type);
}
function _taxonomy_menu_get_term_set_parent_item_options($items) {
$output = array();
if ($items) {
foreach ($items as $item) {
$output[$item->tsid . ':' . $item->tid] = str_repeat('-', $item->depth) . $item->name;
}
}
array_unshift($output, t('None'));
return $output;
}
function taxonomy_menu_group_remove_term_set($mgid, $tsid) {
$menu_group = taxonomy_menu_get_group($mgid);
foreach ($menu_group->items as $key => $item) {
if ($item->tsid == $tsid) {
unset($menu_group->items[$key]);
}
}
taxonomy_menu_save_menu_group($menu_group);
db_query('DELETE FROM {taxonomy_menu_group_term_set} WHERE mgid = %d AND tsid = %d', $mgid, $tsid);
drupal_set_message(t('Term Set Removed'), 'status');
}
function taxonomy_menu_build_menu_tree($items) {
if (!$items) {
return $items;
}
$tree = array();
foreach ($items as $key => $item) {
$tree[$key] = $item;
$tree = array_merge($tree, _taxonomy_menu_build_menu_tree($items, $key));
}
return $tree;
}
function _taxonomy_menu_build_menu_tree(&$items, $key) {
$output = array();
foreach ($items as $item_key => $item) {
if ($item->parent == $key) {
$output[$item_key] = $item;
unset($items[$item_key]);
}
}
if (!$output) {
return array();
}
usort($output, '_taxonomy_menu_sort_tree');
foreach ($ouput as $index => $value) {
unset($output[$index]);
$output[$value->tsid . ':' . $value->tid];
}
return $output;
}
function _taxonomy_menu_sort_tree($a, $b) {
if ($a->weight == $b->weight) {
return 0;
}
return $a->weight < $b->weight ? -1 : 1;
}