You are here

function theme_flag_lists_admin_page in Flag Lists 7

Same name and namespace in other branches
  1. 6 flag_lists.admin.inc \theme_flag_lists_admin_page()
  2. 7.3 flag_lists.admin.inc \theme_flag_lists_admin_page()

Theme the output for the main flag administration page.

1 theme call to theme_flag_lists_admin_page()
flag_lists_admin_page in ./flag_lists.admin.inc
Flag administration page. Display a list of existing flags.

File

./flag_lists.admin.inc, line 18
Contains administrative pages for creating, editing, and deleting flag lists.

Code

function theme_flag_lists_admin_page($variables) {
  $flag = $variables['flag'];
  drupal_set_title(t('Flag lists'));
  $output = '<p>' . t('This page shows all the <em>lists</em> that are currently defined on this system.') . '</p>';

  // Can we use our default view?
  if (module_exists('views')) {
    $view = views_get_view('flag_lists', FALSE);
    if (!empty($view)) {
      $view
        ->set_display('default');
      $output .= $view
        ->render();
    }
  }
  else {
    $header = array(
      array(
        'data' => t('List'),
        'field' => 'name',
      ),
      array(
        'data' => t('List title'),
        'field' => 'title',
      ),
      array(
        'data' => t('List type'),
      ),
      array(
        'data' => t('Owner'),
        'field' => 'uid',
      ),
      array(
        'data' => t('Node types'),
      ),
      array(
        'data' => t('Operations'),
      ),
    );
    $flags = flag_lists_get_flags(25, $header);
    foreach ($flags as $flag) {
      $ops = theme('flag_lists_ops', $flag);
      $name = db_select('users', 'u')
        ->fields('u', array(
        'name',
      ))
        ->condition('uid', $flag->uid)
        ->execute()
        ->fetchField();
      $owner = l($name, 'user/' . $flag->uid, array(
        'attributes' => array(
          'title' => t('View user profile.'),
        ),
      ));
      $rows[] = array(
        $flag->name,
        $flag->title,
        $flag->content_type,
        $owner,
        $flag->types ? implode(', ', $flag->types) : '-',
        $ops,
      );
    }
    if (!$flags) {
      $rows[] = array(
        array(
          'data' => t('No flags are currently defined.'),
          'colspan' => 6,
        ),
      );
    }
    $output .= theme('table', array(
      'header' => $header,
      'rows' => $rows,
    ));
    $output .= theme('pager', NULL, 25, 0);
  }
  return $output;
}