You are here

function messaging_template_format_table in Messaging 6.4

Format template tree as table rows

1 call to messaging_template_format_table()
messaging_template_admin_template in messaging_template/messaging_template.admin.inc

File

messaging_template/messaging_template.admin.inc, line 59
Messaging Framework - Admin UI

Code

function messaging_template_format_table($tree, $depth = 0) {
  $rows = array();
  foreach ($tree as $key => $template) {
    $options['attributes'] = !empty($template['description']) ? array(
      'title' => $template['description'],
    ) : array();
    $rows[] = array(
      theme('indentation', $depth) . l($template['name'], 'admin/messaging/template/edit/' . $key, $options),
      ($parts = module_invoke_all('messaging', 'message keys', $key)) ? implode(', ', $parts) : '',
    );
    if (!empty($template['children'])) {
      $rows = array_merge($rows, messaging_template_format_table($template['children'], $depth + 1));
    }
  }
  if ($depth) {
    return $rows;
  }
  else {
    $header = array(
      t('Message groups'),
      t('Parts'),
    );
    return theme('table', $header, $rows);
  }
}