You are here

function theme_feedback_admin_view_form in Feedback 6.2

Same name and namespace in other branches
  1. 5.2 feedback.module \theme_feedback_admin_view_form()
  2. 7.2 feedback.admin.inc \theme_feedback_admin_view_form()

Output a sortable table containing all feedback entries.

File

./feedback.admin.inc, line 65
Administrative functionality for Feedback module.

Code

function theme_feedback_admin_view_form($form) {
  $output = '';
  foreach (element_children($form['feedback-messages']) as $status) {
    $item =& $form['feedback-messages'][$status];
    if (!isset($item['#type']) || $item['#type'] != 'fieldset') {
      continue;
    }

    // Build the table.
    $rows = array();
    foreach (element_children($item) as $element_entry) {
      $entry =& $item[$element_entry];

      // Render the data first.
      $rows[] = array(
        0,
        drupal_render($entry['location']),
        drupal_render($entry['date']),
        drupal_render($entry['user']),
        drupal_render($entry['message']),
      );

      // Render the checkbox.
      $rows[count($rows) - 1][0] = drupal_render($entry);
    }
    if (empty($rows)) {
      $rows[] = array(
        array(
          'data' => t('No feedback entries available.'),
          'colspan' => 5,
        ),
      );
    }

    // Inject the table.
    $item['messages'] = array(
      '#value' => theme('table', $form['#feedback_header'], $rows) . theme('pager', array(), 50, $status),
      '#weight' => -1,
    );

    // Render the fieldset.
    $output .= drupal_render($item);
  }

  // Render internal FAPI and potential extra form elements.
  $output .= drupal_render($form);
  return $output;
}