function token_custom_list_page in Custom Tokens 7.2
Same name and namespace in other branches
- 7 token_custom.admin.inc \token_custom_list_page()
Callback for the token_custom token list page.
Return value
string The token list page HTML.
1 string reference to 'token_custom_list_page'
- token_custom_menu in ./
token_custom.module - Implements of hook_menu().
File
- ./
token_custom.admin.inc, line 53 - Page callbacks and admin forms of the token_custom module.
Code
function token_custom_list_page() {
// Load all out tokens.
$tokens = token_custom_load_multiple();
$token_admin = user_access('administer custom tokens');
$token_info = token_info();
$variables = array();
// Build the table rows.
foreach ($tokens as $token) {
// Get demo value if token doesn't need external data.
if (empty($token_info['types'][$token->type]['needs-data'])) {
$value = token_replace('[' . $token->type . ':' . $token->machine_name . ']');
}
else {
$value = t('Demo value not available');
}
$row = array(
$token->name,
$token->machine_name,
$token->type,
$token->description,
$value,
);
// Add the edit/delete links if the user has the right permissions.
if ($token_admin) {
$row[] = l(t('Edit'), 'admin/structure/token-custom/' . $token->machine_name . '/edit') . ' / ' . l(t('Delete'), 'admin/structure/token-custom/' . $token->machine_name . '/delete');
}
$variables['rows'][] = $row;
}
if (empty($variables['rows'])) {
$variables['rows'][] = array(
array(
'data' => t('No custom tokens available.'),
'colspan' => array(
$token_admin ? 6 : 5,
),
),
);
}
$variables['header'] = array(
t('Name'),
t('Machine name'),
t('Type'),
t('Description'),
t('Demo (if available)'),
);
// Add extra header cell if edit/delete links were printed.
if ($token_admin) {
$variables['header'][] = "";
}
return theme('table', $variables);
}