You are here

function theme_eu_cookie_compliance_admin_categories_form in EU Cookie Compliance (GDPR Compliance) 7

Same name and namespace in other branches
  1. 7.2 eu_cookie_compliance.admin.categories.inc \theme_eu_cookie_compliance_admin_categories_form()

Implements hook_theme().

File

./eu_cookie_compliance.admin.categories.inc, line 95
This file provides administration forms for the cookie categories.

Code

function theme_eu_cookie_compliance_admin_categories_form($variables) {
  $form = $variables['form'];
  $rows = array();
  foreach (element_children($form['categories']) as $machine_name) {
    $form['categories'][$machine_name]['weight']['#attributes']['class'] = array(
      'categories-order-weight',
    );
    $rows[] = array(
      'data' => array(
        array(
          'class' => array(
            'slide-cross',
          ),
        ),
        drupal_render($form['categories'][$machine_name]['label']),
        drupal_render($form['categories'][$machine_name]['machine_name']),
        drupal_render($form['categories'][$machine_name]['description']),
        drupal_render($form['categories'][$machine_name]['checkbox_default_state']),
        drupal_render($form['categories'][$machine_name]['weight']),
        drupal_render($form['categories'][$machine_name]['op']),
      ),
      'class' => array(
        'draggable',
      ),
    );
  }
  $header = array(
    '',
    t('Label'),
    t('Machine name'),
    t('Description'),
    t('Checkbox default state'),
    t('Weight'),
    t('Operations'),
  );
  $options = array();

  // Adapt links to follow realm language if present.
  $query_parameters = drupal_get_query_parameters();
  if (isset($query_parameters['variable_realm_key_language'])) {
    $language_list = language_list();
    $language = $language_list[$query_parameters['variable_realm_key_language']] ?: FALSE;
    if ($language) {
      $options['language'] = $language;
    }
  }
  $output = drupal_render_children($form, array(
    'add_new',
  ));
  $output .= theme('table', array(
    'header' => $header,
    'rows' => $rows,
    'empty' => t('No categories exist yet. <a href="@path">Add new category.</a>', array(
      '@path' => url('admin/config/system/eu-cookie-compliance/categories/add', $options),
    )),
    'attributes' => array(
      'id' => 'categories-order',
    ),
  ));
  $output .= drupal_render_children($form);
  drupal_add_tabledrag('categories-order', 'order', 'sibling', 'categories-order-weight');
  return $output;
}