You are here

function __gotwo_list in Go - url redirects 5

shows the list of go entries

1 string reference to '__gotwo_list'
gotwo_menu in ./gotwo.module
Implementation of hook_menu

File

./gotwo.module, line 390
Module that provides easy to use redirection links. A redirection link would be like: http://examples.org/go/a_label http://examples.org/go/123546 http://examples.org/go/or/like/this

Code

function __gotwo_list() {
  drupal_set_title(t('Go list'));
  $header = array(
    array(
      'data' => t('ID'),
      'field' => 'gid',
    ),
    array(
      'data' => t('Label'),
      'field' => 'src',
    ),
    array(
      'data' => t('Destination'),
      'field' => 'dst',
    ),
    array(
      'data' => t('Counter'),
      'field' => 'cnt',
      'sort' => 'desc',
    ),
  );
  if (user_access('edit gotwo entries')) {
    $header[] = array(
      'data' => t('Tools'),
    );
  }
  $sql = "SELECT * FROM {gotwo}";
  $tablesort = tablesort_sql($header);
  $result = pager_query($sql . $tablesort, 50);
  while ($go = db_fetch_object($result)) {
    $i = count($rows);
    $rows[$i] = array(
      'data' => array(
        $go->gid,
        check_plain($go->src),
        check_plain($go->dst),
        $go->cnt,
      ),
    );
    if (user_access('edit gotwo entries')) {
      $rows[$i]['data'][] = l(t('reset'), 'admin/build/gotwo/reset/' . $go->gid, array(
        'title' => t('Reset the counter'),
      )) . ' ' . l(t('delete'), 'admin/build/gotwo/delete/' . $go->gid);
    }
  }
  if (!$rows) {
    $rows[] = array(
      array(
        'data' => t('No entries available.'),
        'colspan' => 4,
      ),
    );
  }
  $output .= theme('table', $header, $rows);
  $output .= theme('pager', NULL, 50, 0);
  return $output;
}