You are here

function theme_feedback_admin_view_form in Feedback 7.2

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

Output a sortable table containing all feedback entries.

File

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

Code

function theme_feedback_admin_view_form($variables) {
  $form = $variables['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']),
        drupal_render($entry['operations']),
      );

      // Render the checkbox.
      $rows[count($rows) - 1][0] = drupal_render($entry);
    }
    if (empty($rows)) {
      $rows[] = array(
        array(
          'data' => t('No feedback entries available.'),
          'colspan' => 6,
        ),
      );
    }
    $form['#feedback_header'][0] = $status == FEEDBACK_OPEN ? t('Process') : t('Re-open');

    // Inject the table.
    $item['messages'] = array(
      '#markup' => theme('table', array(
        'header' => $form['#feedback_header'],
        'rows' => $rows,
        'attributes' => array(
          'id' => 'feedback-status-' . $status,
        ),
      )),
      '#suffix' => theme('pager', array(
        'element' => $status,
      )),
      '#weight' => -1,
    );

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

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