You are here

function theme_heartbeat_plugins_attachments_form in Heartbeat 7

Theme function for the draggable attachments form.

File

modules/heartbeat_plugins/heartbeat_plugins.module, line 710

Code

function theme_heartbeat_plugins_attachments_form($variables) {
  $form = $variables['form'];

  // Special ID and classes for draggable tables.
  $weight_class = 'heartbeat-attachment-order-weight';
  $table_id = 'heartbeat-attachments-table';

  // Build up a table of applicable fields.
  $headers = array();
  $headers[] = drupal_render($form['title']);
  $headers[] = t('Enabled');
  $headers[] = t('Settings');
  $headers[] = t('Weight');
  foreach ($form['name'] as $key => $element) {

    // Do not take form control structures.
    if (is_array($element) && element_child($key)) {
      $title = drupal_render($form['name'][$key]);
      $form['enabled'][$key]['#title'] = t('Enable !title', array(
        '!title' => $title,
      ));
      $form['enabled'][$key]['#title_display'] = 'invisible';
      $rows[] = array(
        'data' => array(
          '<strong>' . $title . '</strong>',
          array(
            'data' => drupal_render($form['enabled'][$key]),
            'align' => 'center',
          ),
          drupal_render($form['settings_button'][$key]) . drupal_render($form['settings'][$key]),
          drupal_render($form['weight'][$key]),
        ),
        'class' => array(
          'draggable',
        ),
      );
    }
  }
  $output = theme('table', array(
    'header' => $headers,
    'rows' => $rows,
    'attributes' => array(
      'id' => $table_id,
    ),
  ));
  $output .= drupal_render_children($form);
  drupal_add_tabledrag($table_id, 'order', 'sibling', $weight_class);
  return $output;
}