You are here

function theme_taxonomy_tools_overview in Taxonomy Tools 8

Same name and namespace in other branches
  1. 7 taxonomy_tools.admin.inc \theme_taxonomy_tools_overview()

Returns HTML for a taxonomy overview form as a table.

Parameters

array $variables: An associative array containing:

  • form: A render element representing the form.

See also

taxonomy_tools_overview()

File

./taxonomy_tools.admin.inc, line 337
Administrative page callbacks for the Taxonomy Tools module.

Code

function theme_taxonomy_tools_overview($variables) {
  $form = $variables['form'];
  if (user_access('administer taxonomy') || user_access('edit terms in ' . $form['#vocabulary']->vid)) {
    drupal_add_tabledrag('taxonomy-tools-overview-table', 'order', 'sibling', 'term-weight');
  }
  $rows = array();
  foreach (element_children($form) as $key) {
    if (is_numeric($key)) {
      $row = array();
      $data =& $form[$key];
      $row[] = drupal_render($data['name']) . drupal_render($data['child_count']);
      if (isset($data['info_icons'])) {
        $row[0] .= drupal_render($data['info_icons']);
      }
      $data['weight_' . $key]['#attributes']['class'] = array(
        'term-weight',
      );
      if (user_access('administer taxonomy') || user_access('edit terms in ' . $form['#vocabulary']->vid)) {
        $row[] = drupal_render($data['weight_' . $key]);
      }
      $row[] = drupal_render($data['operations']);
      if (user_access('administer taxonomy') || user_access('delete terms in ' . $form['#vocabulary']->vid)) {
        $row[] = drupal_render($data['delete_' . $key]);
      }
      if (module_exists('taxonomy_tools_publisher')) {
        $row[] = drupal_render($data['status']);
      }
      if (module_exists('taxonomy_tools_role_access') && isset($data['access']) && user_access('administer taxonomy role access')) {
        foreach (element_children($data['access']) as $role) {
          $row[] = drupal_render($data['access'][$role]);
        }
      }
      $row = array(
        'data' => $row,
        'class' => array(
          'row_' . $key,
          'draggable',
        ),
      );
      $rows[$key] = $row;
    }
  }
  $header = array();
  $header[] = array(
    'data' => t('Name'),
    'class' => array(
      'table-header',
    ),
  );
  if (user_access('administer taxonomy') || user_access('edit terms in ' . $form['#vocabulary']->vid)) {
    $header[] = array(
      'data' => t('Order'),
      'class' => array(
        'table-header',
      ),
    );
  }
  $header[] = array(
    'data' => t('Operations'),
    'class' => array(
      'table-header',
    ),
  );
  if (user_access('administer taxonomy') || user_access('delete terms in ' . $form['#vocabulary']->vid)) {
    $header[] = array(
      'data' => t('Delete'),
      'class' => array(
        'table-header',
        'term-delete',
      ),
    );
  }
  if (module_exists('taxonomy_tools_publisher')) {
    $header[] = array(
      'data' => t('Status'),
      'class' => array(
        'table-header',
      ),
    );
  }
  if (module_exists('taxonomy_tools_role_access') && isset($data['access']) && user_access('administer taxonomy role access')) {
    foreach (element_children($data['access']) as $role) {
      $header[] = array(
        'data' => t('Access for :role', array(
          ':role' => $role,
        )),
        'class' => array(
          'table-header',
        ),
      );
    }
  }
  if (empty($rows)) {
    $empty_data = t('Empty branch.');
    if (taxonomy_tools_overview_access($form['#vocabulary'], TRUE)) {
      $url = $form['add_term'];
      $empty_data .= ' ' . render($url);
    }
    if (isset($form['level_up'])) {
      $rows[] = array(
        'data' => array(
          array(
            'data' => drupal_render($form['level_up']),
            'colspan' => count($header),
          ),
        ),
        'class' => array(
          'level-up',
        ),
      );
    }
    $rows[] = array(
      array(
        'data' => $empty_data,
        'colspan' => count($header),
      ),
    );
  }
  elseif (isset($form['level_up'])) {
    $level_up = array(
      'data' => array(
        array(
          'data' => drupal_render($form['level_up']),
          'colspan' => count($header),
        ),
      ),
      'class' => array(
        'level-up',
      ),
    );
    array_unshift($rows, $level_up);
  }
  $output = '';
  $output .= drupal_render($form['add_term']);
  $output .= theme('table', array(
    'header' => $header,
    'rows' => $rows,
    'attributes' => array(
      'id' => 'taxonomy-tools-overview-table',
    ),
    'sticky' => FALSE,
  ));
  $output .= drupal_render_children($form);
  return $output;
}