You are here

function theme_nodehierarchy_children_form in Node Hierarchy 7.4

Same name and namespace in other branches
  1. 6.3 nodehierarchy.module \theme_nodehierarchy_children_form()
  2. 6.2 nodehierarchy.module \theme_nodehierarchy_children_form()
  3. 7.2 nodehierarchy.module \theme_nodehierarchy_children_form()

Display the children tab form.

File

./nodehierarchy.admin.inc, line 389
Admin functions for Node Hierarchy

Code

function theme_nodehierarchy_children_form($variables) {
  $form = $variables['form'];
  drupal_add_tabledrag('children-list', 'order', 'sibling', 'cweight');
  $colspan = module_exists('nodeaccess') ? '4' : '3';
  $header = array(
    t('Title'),
    t('Type'),
    t('Weight'),
    array(
      'data' => t('Operations'),
      'colspan' => $colspan,
    ),
  );
  $rows = array();
  foreach (element_children($form['children']) as $nhid) {
    $element =& $form['children'][$nhid];

    // Add special classes to be used for tabledrag.js.
    $element['cweight']['#attributes']['class'] = array(
      'cweight',
    );
    $node = $element['node']['#value'];
    $row = array();
    $row[] = drupal_render($element['title']);
    $row[] = drupal_render($element['type']);
    $row[] = drupal_render($element['cweight']);
    $row[] = node_access('update', $node) ? l(t('edit'), 'node/' . $node->nid . '/edit', array(
      'query' => drupal_get_destination(),
    )) : '';
    $row[] = node_access('delete', $node) ? l(t('delete'), 'node/' . $node->nid . '/delete', array(
      'query' => drupal_get_destination(),
    )) : '';
    $row[] = nodehierarchy_children_tab_access($node) ? l(t('children'), 'node/' . $node->nid . '/children') : '';
    if (module_exists('nodeaccess')) {
      $row[] = nodeaccess_access('grant', $node) ? l(t('grant'), 'node/' . $node->nid . '/grant') : '';
    }
    $row = array_merge(array(
      'data' => $row,
    ), $element['#attributes']);
    $row['class'][] = 'draggable';
    $rows[] = $row;
  }
  $output = '';
  if ($rows) {
    $output .= theme('table', array(
      'header' => $header,
      'rows' => $rows,
      'attributes' => array(
        'id' => 'children-list',
      ),
    ));
  }
  $output .= drupal_render_children($form);
  return $output;
}