You are here

function theme_mostpopular_admin_services_table in Drupal Most Popular 7

Defines a theme function for rendering the services form.

Parameters

array $variables :

  • form: The form to render.
1 theme call to theme_mostpopular_admin_services_table()
mostpopular_services_admin_form in ./mostpopular.services.inc
Renders a form for configuring the blocks and services.

File

./mostpopular.services.inc, line 208
Provides an admin GUI for configuring services.

Code

function theme_mostpopular_admin_services_table(&$variables) {
  $elements = $variables['element'];
  $header = array(
    array(
      'data' => '',
      'width' => 2,
    ),
    t('ID'),
    t('Service Name'),
    t('Enabled'),
    t('Status'),
    t('Title'),
    t('Block'),
    t('Weight'),
    t('Options'),
  );
  $rows = array();
  $output = '';
  foreach (element_children($elements) as $bid) {
    $block = $elements[$bid];
    $block['bid']['#attributes']['class'][] = 'mostpopular-block-bid';
    $title = $block['#title'];
    $rows[] = array(
      'data' => array(
        array(
          'data' => '<strong>' . $title . '</strong>' . drupal_render($block['bid']),
          'colspan' => 9,
        ),
      ),
    );
    foreach (element_children($block['services']) as $sid) {
      $item = $block['services'][$sid];

      // Add class to group weight fields for drag and drop
      $item['bid']['#attributes']['class'][] = "mostpopular-bid";
      $item['bid']['#attributes']['class'][] = "mostpopular-bid-{$bid}";
      $item['weight']['#attributes']['class'][] = "mostpopular-weight";
      $item['weight']['#attributes']['class'][] = "mostpopular-weight-{$bid}";
      $row = array();
      $row[] = '';
      $row[] = drupal_render($item['id']);
      $row[] = drupal_render($item['name']);
      $row[] = drupal_render($item['enabled']);
      $row[] = drupal_render($item['status']);
      $row[] = drupal_render($item['title']);
      $row[] = drupal_render($item['bid']);
      $row[] = drupal_render($item['weight']);
      $row[] = drupal_render($item);
      $rows[] = array(
        'data' => $row,
        'class' => array(
          'draggable',
        ),
      );
    }

    // Add tabledrag behavior to this region
    drupal_add_tabledrag('mostpopular-admin-services', 'match', 'parent', 'mostpopular-bid', "mostpopular-bid-{$bid}", 'mostpopular-block-bid', FALSE);
    drupal_add_tabledrag('mostpopular-admin-services', 'order', 'sibling', 'mostpopular-weight', "mostpopular-weight-{$bid}");
  }
  $output .= theme('table', array(
    'header' => $header,
    'rows' => $rows,
    'attributes' => array(
      'id' => 'mostpopular-admin-services',
    ),
  ));
  drupal_add_css(drupal_get_path('module', 'mostpopular') . '/css/mostpopular-admin.css');
  return $output;
}