function _gotwo_list in Go - url redirects 7
Same name and namespace in other branches
- 6 gotwo.admin.inc \_gotwo_list()
Shows the list of go redirects.
1 string reference to '_gotwo_list'
- gotwo_menu in ./
gotwo.module - Implements hook_menu().
File
- ./
gotwo.admin.inc, line 90 - Administrative page callbacks for the gotwo module.
Code
function _gotwo_list() {
$access = user_access('edit gotwo redirects');
$header = array(
'gid' => array(
'data' => t('ID'),
'field' => 'gid',
),
'src' => array(
'data' => t('Label'),
'field' => 'src',
),
'dst' => array(
'data' => t('Destination'),
'field' => 'dst',
),
'cnt' => array(
'data' => t('Counter'),
'field' => 'cnt',
'sort' => 'desc',
),
);
if ($access) {
$header[] = array(
'data' => t('Operations'),
'colspan' => 2,
);
}
$query = db_select('gotwo', 'g')
->extend('PagerDefault')
->extend('TableSort');
$result = $query
->fields('g')
->limit(50)
->orderByHeader($header)
->execute();
$rows = array();
foreach ($result as $go) {
$rows[] = array(
'data' => array(
$go->gid,
check_plain($go->src),
l($go->dst, $go->dst),
$go->cnt,
$access ? l(t('Reset counter'), 'admin/structure/gotwo/reset/' . $go->gid) : ' ',
$access ? l(t('Delete'), 'admin/structure/gotwo/delete/' . $go->gid) : ' ',
),
);
}
$build['gotwo_table'] = array(
'#theme' => 'table',
'#header' => $header,
'#rows' => $rows,
'#empty' => t('No redirects have been found.'),
);
$build['gotwo_pager'] = array(
'#theme' => 'pager',
);
return $build;
}