function theme_user_badge in User Badges 7.3
Same name and namespace in other branches
- 5 user_badges.module \theme_user_badge()
- 6.2 user_badges.module \theme_user_badge()
- 6 user_badges.module \theme_user_badge()
- 7 user_badges.module \theme_user_badge()
- 7.2 user_badges.module \theme_user_badge()
Return html representation of a badge image (note: theme_image does the check_plaining)
12 theme calls to theme_user_badge()
- user_badges_add_badge_action_form in ./
user_badges.actions.inc - @todo Please document this function.
- user_badges_badgelist_form in ./
user_badges.admin.inc - Form builder; list of badges
- user_badges_badge_autocomplete in ./
user_badges.module - Menu callback; Retrieve a JSON object containing autocomplete suggestions for badges
- user_badges_block_view in ./
user_badges.module - Implements hook_block_view().
- user_badges_change_form in ./
user_badges.module - Form to change badges of a user
File
- ./
user_badges.module, line 1297 - @brief User Badges module file
Code
function theme_user_badge($variables) {
$badge = $variables['badge'];
$image = _user_badges_build_image($badge);
// We don't link the badge if there is no link and no default,
// or if the default is overridden.
if (!isset($badge->href) || $badge->href == '' && !variable_get('user_badges_defaulthref', '') || drupal_strtolower($badge->href) == '<none>') {
return $image;
}
else {
$href = $badge->href ? $badge->href : variable_get('user_badges_defaulthref', '');
// Implement token replacement.
if (module_exists('token')) {
$vars = array(
'userbadge' => $badge,
);
if (isset($variables['account'])) {
$vars['user'] = $variables['account'];
}
$href = token_replace($href, $vars);
}
$pieces = parse_url($href);
$pieces['html'] = TRUE;
$pieces['path'] = isset($pieces['path']) ? $pieces['path'] : '';
if (isset($pieces['scheme'])) {
$pieces['path'] = $pieces['scheme'] . '://' . $pieces['host'] . $pieces['path'];
}
// We need to convert the query to an associative array before we pass it
// to the l() function.
if (isset($pieces['query'])) {
$pieces['query'] = drupal_get_query_array($pieces['query']);
}
return l($image, $pieces['path'], $pieces);
}
}