function theme_user_badge in User Badges 6.2
Same name and namespace in other branches
- 5 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()
- 7.3 user_badges.module \theme_user_badge()
Return html representation of a badge image (note: theme_image does the check_plaining)
15 theme calls to theme_user_badge()
- user_badges_add_badge_action_form in ./
user_badges.module - 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_change_form in ./
user_badges.module - Form to change badges of a user
- user_badges_delete_form in ./
user_badges.module
File
- ./
user_badges.module, line 1088 - @brief User Badges module file
Code
function theme_user_badge($badge, $account = NULL) {
//If we haven't been supplied with a user, use whoever is logged in
global $user;
if (is_null($account)) {
$account = $user;
}
if (!isset($badge->class)) {
$badge->class = 'badge ' . _user_badges_class($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 ($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')) {
$href = token_replace($href, $type = 'userbadge', $object = $badge);
$href = token_replace($href, $type = 'user', $object = $account);
}
$pieces = parse_url($href);
$pieces['html'] = TRUE;
if (isset($pieces['scheme'])) {
$pieces['path'] = $pieces['scheme'] . '://' . $pieces['host'] . $pieces['path'];
}
return l($image, $pieces['path'], $pieces);
}
}