You are here

function rate_admin_page in Rate 7

Same name and namespace in other branches
  1. 6.2 rate.admin.inc \rate_admin_page()

Menu callback.

Generates the admin page which contains the widget listing.

1 string reference to 'rate_admin_page'
rate_menu in ./rate.module
Implements hook_menu().

File

./rate.admin.inc, line 13
Rating admin

Code

function rate_admin_page() {
  $widgets = variable_get(RATE_VAR_WIDGETS, array());
  uasort($widgets, '_rate_sort');
  $header = array(
    t('Title'),
    t('Name'),
    t('Operations'),
  );
  $rows = array();
  foreach ($widgets as $id => $widget) {
    $edit = l(t('Edit'), str_replace('%', $id, RATE_PATH_ADMIN_PAGE_EDIT));
    $delete = l(t('Delete'), str_replace('%', $id, RATE_PATH_ADMIN_PAGE_DELETE));
    $rows[] = array(
      $widget->title,
      $widget->name,
      "{$edit} {$delete}",
    );
  }
  $output = '';
  $output .= '<h3>' . t('Add widget') . '</h3>';
  $add_form = drupal_get_form('rate_choose_template_form');
  $output .= drupal_render($add_form);
  if ($rows) {
    $output .= theme('table', array(
      'header' => $header,
      'rows' => $rows,
    ));
  }
  else {
    $text = t('You do not have any rate widgets defined yet.');
    $output .= '<p>' . check_plain($text) . '</p>';
  }
  return $output;
}