You are here

function theme_subscriptions_ui_table in Subscriptions 2.0.x

Same name and namespace in other branches
  1. 5.2 subscriptions_ui.module \theme_subscriptions_ui_table()
  2. 6 subscriptions_ui.module \theme_subscriptions_ui_table()
  3. 7 subscriptions_ui.module \theme_subscriptions_ui_table()

Theme subscriptions node subform table.

Parameters

array $element:

Return value

string

1 theme call to theme_subscriptions_ui_table()
subscriptions_ui_node_form in subscriptions_ui/subscriptions_ui.module
Returns the form definition for the node subform.

File

subscriptions_ui/subscriptions_ui.module, line 341
Provides a user interface for Subscriptions.

Code

function theme_subscriptions_ui_table($element) {
  $rows = [];
  $headers = [];
  $header_strings = [
    [
      'class' => 'subscriptions-table',
      'width' => '30%',
    ],
    [
      'data' => t('On updates'),
      'width' => '1*',
      'style' => 'writing-mode: lr-tb',
    ],
    [
      'data' => t('On comments'),
    ],
  ];
  $element = $element['element'];
  foreach (element_children($element['subscriptions']) as $key) {
    $row = [];
    foreach ([
      'subscriptions',
      'updates',
      'comments',
    ] as $eli => $elv) {
      if (isset($element[$elv]) && $element[$elv]['#access']) {
        $row[] = drupal_render($element[$elv][$key]);
        $headers[$eli] = $header_strings[$eli];
      }
    }
    $rows[] = $row;
  }
  $col_indexes = array_keys($headers);
  unset($headers[end($col_indexes)]['width']);
  $output = theme('table', [
    'header' => $headers,
    'rows' => $rows,
  ]);
  $output .= drupal_render_children($element);
  drupal_add_js(drupal_get_path('module', 'subscriptions') . '/subscriptions_tableselect.js');
  return $output;
}