You are here

function theme_flag_admin_listing in Flag 6.2

Same name and namespace in other branches
  1. 7.3 includes/flag.admin.inc \theme_flag_admin_listing()
  2. 7.2 includes/flag.admin.inc \theme_flag_admin_listing()

Theme the output of the normal, database flags into a table.

File

includes/flag.admin.inc, line 64
Contains administrative pages for creating, editing, and deleting flags.

Code

function theme_flag_admin_listing($form) {
  $flags = $form['#flags'];
  $output = '';
  foreach ($flags as $flag) {
    $ops = array(
      'flags_edit' => array(
        'title' => t('edit'),
        'href' => $flag
          ->admin_path('edit'),
      ),
      'flags_delete' => array(
        'title' => t('delete'),
        'href' => $flag
          ->admin_path('delete'),
      ),
      'flags_export' => array(
        'title' => t('export'),
        'href' => $flag
          ->admin_path('export'),
      ),
    );
    $roles = array_flip(array_intersect(array_flip(user_roles()), $flag->roles['flag']));
    $row = array();
    $row[] = $flag->name;
    if (count($flags) > 1) {
      $row[] = drupal_render($form['flags'][$flag->name]['weight']);
    }
    $row[] = $flag->content_type;
    $row[] = empty($flag->roles['flag']) ? '<em>' . t('No roles') . '</em>' : implode(', ', $roles);
    $row[] = $flag->types ? implode(', ', $flag->types) : '-';
    $row[] = $flag->global ? t('Yes') : t('No');
    $row[] = theme('links', $ops);
    $rows[] = array(
      'data' => $row,
      'class' => 'draggable',
    );
  }
  if (!$flags) {
    $rows[] = array(
      array(
        'data' => t('No flags are currently defined.'),
        'colspan' => 7,
      ),
    );
  }
  else {
    if (count($flags) > 1) {
      drupal_add_tabledrag('flag-admin-listing-table', 'order', 'sibling', 'flag-weight');
    }
  }
  $header = array(
    t('Flag'),
  );
  if (count($flags) > 1) {
    $header[] = t('Weight');
  }
  $header = array_merge($header, array(
    t('Flag type'),
    t('Roles'),
    t('Entity bundles'),
    t('Global?'),
    t('Operations'),
  ));
  $output .= theme('table', $header, $rows, array(
    'id' => 'flag-admin-listing-table',
  ));
  $output .= drupal_render($form);
  return $output;
}