function theme_taxonomy_delete_link_taxonomy_overview_terms in Taxonomy Delete Link 7
Returns HTML for a terms overview form as a sortable list of terms.
File
- ./
taxonomy_delete_link.module, line 70 - Provides the taxonomy term delete link.
Code
function theme_taxonomy_delete_link_taxonomy_overview_terms($variables) {
$form = $variables['form'];
$page_entries = $form['#page_entries'];
$back_step = $form['#back_step'];
$forward_step = $form['#forward_step'];
// Add drag and drop if parent fields are present in the form.
if ($form['#parent_fields']) {
drupal_add_tabledrag('taxonomy', 'match', 'parent', 'term-parent', 'term-parent', 'term-id', FALSE);
drupal_add_tabledrag('taxonomy', 'depth', 'group', 'term-depth', NULL, NULL, FALSE);
drupal_add_js(drupal_get_path('module', 'taxonomy') . '/taxonomy.js');
drupal_add_js(array(
'taxonomy' => array(
'backStep' => $back_step,
'forwardStep' => $forward_step,
),
), 'setting');
drupal_add_css(drupal_get_path('module', 'taxonomy') . '/taxonomy.css');
}
drupal_add_tabledrag('taxonomy', 'order', 'sibling', 'term-weight');
$errors = form_get_errors() != FALSE ? form_get_errors() : array();
$rows = array();
foreach (element_children($form) as $key) {
if (isset($form[$key]['#term'])) {
$term =& $form[$key];
$row = array();
$row[] = (isset($term['#term']['depth']) && $term['#term']['depth'] > 0 ? theme('indentation', array(
'size' => $term['#term']['depth'],
)) : '') . drupal_render($term['view']);
if ($form['#parent_fields']) {
$term['tid']['#attributes']['class'] = array(
'term-id',
);
$term['parent']['#attributes']['class'] = array(
'term-parent',
);
$term['depth']['#attributes']['class'] = array(
'term-depth',
);
$row[0] .= drupal_render($term['parent']) . drupal_render($term['tid']) . drupal_render($term['depth']);
}
$term['weight']['#attributes']['class'] = array(
'term-weight',
);
$row[] = drupal_render($term['weight']);
$term['edit'] = NULL;
$operations_term_access = new stdClass();
$operations_term_access->vid = $term['#term']['vid'];
$operations_term_access->tid = $term['#term']['tid'];
$operations_links = array();
if (taxonomy_term_edit_access($operations_term_access)) {
$operations_links['edit'] = array(
'title' => t('edit'),
'href' => 'taxonomy/term/' . $term['#term']['tid'] . '/edit',
'query' => drupal_get_destination(),
);
}
if (module_exists('nodeorder') && (!empty($form['#vocabulary']->module) && $form['#vocabulary']->module == 'nodeorder') && nodeorder_taxonomy_order_access($operations_term_access->vid)) {
$operations_links['order'] = array(
'title' => t('order'),
'href' => 'taxonomy/term/' . $term['#term']['tid'] . '/order',
'query' => drupal_get_destination(),
);
}
if (taxonomy_delete_link_term_delete_access($operations_term_access)) {
$operations_links['delete'] = array(
'title' => t('delete'),
'href' => 'taxonomy/term/' . $term['#term']['tid'] . '/delete',
'query' => drupal_get_destination(),
);
}
if (!empty($operations_links)) {
$row[] = theme('links', array(
'links' => $operations_links,
'attributes' => array(
'class' => array(
'links',
'inline',
),
),
));
}
$row = array(
'data' => $row,
);
$rows[$key] = $row;
}
}
// Add necessary classes to rows.
$row_position = 0;
foreach ($rows as $key => $row) {
$rows[$key]['class'] = array();
if (isset($form['#parent_fields'])) {
$rows[$key]['class'][] = 'draggable';
}
// Add classes that mark which terms belong to previous and next pages.
if ($row_position < $back_step || $row_position >= $page_entries - $forward_step) {
$rows[$key]['class'][] = 'taxonomy-term-preview';
}
if ($row_position !== 0 && $row_position !== count($rows) - 1) {
if ($row_position == $back_step - 1 || $row_position == $page_entries - $forward_step - 1) {
$rows[$key]['class'][] = 'taxonomy-term-divider-top';
}
elseif ($row_position == $back_step || $row_position == $page_entries - $forward_step) {
$rows[$key]['class'][] = 'taxonomy-term-divider-bottom';
}
}
// Add an error class if this row contains a form error.
foreach ($errors as $error_key => $error) {
if (strpos($error_key, $key) === 0) {
$rows[$key]['class'][] = 'error';
}
}
$row_position++;
}
if (empty($rows)) {
$rows[] = array(
array(
'data' => $form['#empty_text'],
'colspan' => '3',
),
);
}
if (empty($operations_links)) {
$header = array(
t('Name'),
t('Weight'),
);
}
else {
$header = array(
t('Name'),
t('Weight'),
t('Operations'),
);
}
$output = theme('table', array(
'header' => $header,
'rows' => $rows,
'attributes' => array(
'id' => 'taxonomy',
),
));
$output .= drupal_render_children($form);
$output .= theme('pager');
return $output;
}