You are here

function theme_hybridauth_admin_settings in HybridAuth Social Login 7

File

./hybridauth.admin.inc, line 310

Code

function theme_hybridauth_admin_settings($vars) {
  $form = $vars['form'];

  //Define your table headers
  $header = array(
    array(
      'data' => t('Name'),
      'colspan' => 2,
    ),
    t('Enabled'),
    t('Weight'),
    array(
      'data' => t('Operations'),
      'colspan' => 2,
    ),
  );
  $rows = array();
  foreach (element_children($form['providers']) as $provider_id) {
    if (isset($form['providers'][$provider_id]['name'])) {

      // Make this the weight class defined in the drupal_add_tabledrag function.
      $form['providers'][$provider_id]['hybridauth_provider_' . $provider_id . '_weight']['#attributes']['class'] = array(
        'hybridauth-provider-weight',
      );
      unset($form['providers'][$provider_id]['hybridauth_provider_' . $provider_id . '_enabled']['#title']);
      $row = array(
        drupal_render($form['providers'][$provider_id]['name']),
        drupal_render($form['providers'][$provider_id]['icon']),
        drupal_render($form['providers'][$provider_id]['hybridauth_provider_' . $provider_id . '_enabled']),
        drupal_render($form['providers'][$provider_id]['hybridauth_provider_' . $provider_id . '_weight']),
        drupal_render($form['providers'][$provider_id]['settings']),
      );
      $rows[] = array(
        'data' => $row,
        'class' => array(
          'draggable',
        ),
      );
    }
  }

  //Finally, output the sortable table. Make sure the id variable is the same as the table id in drupal_add_tabledrag
  $form['providers']['#children'] = theme('table', array(
    'header' => $header,
    'rows' => $rows,
    'sticky' => FALSE,
    'attributes' => array(
      'id' => 'hybridauth-providers',
    ),
  ));
  $output = drupal_render_children($form);

  //This function is the instantiator of the sorter. Make sure the 0th paramater is the id of your table, and the 3rd paramater is the class of your weight variable
  drupal_add_tabledrag('hybridauth-providers', 'order', 'sibling', 'hybridauth-provider-weight');
  return $output;
}