Elgg  Version 3.0
default.php
Go to the documentation of this file.
1 <?php
19 $size = elgg_extract('size', $vars, 'medium');
20 
21 if (!($user instanceof ElggUser)) {
22  return;
23 }
24 
26 if (!array_key_exists($size, $icon_sizes)) {
27  $size = 'medium';
28 }
29 
30 $name = htmlspecialchars($user->getDisplayName(), ENT_QUOTES, 'UTF-8', false);
31 $username = $user->username;
32 
34  'elgg-avatar',
35  "elgg-avatar-$size",
36 ];
38 
39 if ($user->isBanned()) {
40  $wrapper_class[] = 'elgg-state-banned';
41  $name .= ' (' . elgg_echo('banned') . ')';
42 }
43 
44 $icon = elgg_view('output/img', [
45  'src' => $user->getIconURL($size),
46  'alt' => $name,
47  'title' => $name,
48  'class' => elgg_extract_class($vars, [], 'img_class'),
49 ]);
50 
51 if (empty($icon)) {
52  return;
53 }
54 
55 $show_menu = elgg_extract('use_hover', $vars, true) && (elgg_is_admin_logged_in() || !$user->isBanned());
56 
57 $content = '';
58 
59 if ($show_menu) {
60  $params = [
61  'entity' => $user,
62  'username' => $username,
63  'name' => $name,
64  ];
65  $content .= elgg_view('navigation/menu/user_hover/placeholder', ['entity' => $user]);
66 
67  $wrapper_class[] = 'elgg-avatar-menu';
68 }
69 
70 if (elgg_extract('use_link', $vars, true)) {
71  $content .= elgg_view('output/url', [
72  'href' => elgg_extract('href', $vars, $user->getURL()),
73  'text' => $icon,
74  'is_trusted' => true,
75  'class' => elgg_extract_class($vars, [], 'link_class'),
76  ]);
77 } else {
78  $content .= elgg_format_element('a', [], $icon);
79 }
80 
81 echo elgg_format_element('div', ['class' => $wrapper_class], $content);
elgg_is_admin_logged_in()
Returns whether or not the viewer is currently logged in and an admin user.
Definition: sessions.php:57
$wrapper_class
Definition: default.php:33
elgg_get_icon_sizes($entity_type=null, $entity_subtype=null, $type= 'icon')
Returns a configuration array of icon sizes.
$content
Definition: default.php:57
elgg_echo($message_key, array $args=[], $language="")
Given a message key, returns an appropriately translated full-text string.
Definition: languages.php:21
elgg_extract_class(array $array, $existing=[], $extract_key= 'class')
Extract class names from an array, optionally merging into a preexisting set.
Definition: elgglib.php:1153
if(!$owner) $icon
Definition: default.php:16
if(empty($icon)) $show_menu
Definition: default.php:55
elgg_format_element($tag_name, array $attributes=[], $text= '', array $options=[])
Format an HTML element.
Definition: output.php:168
elgg echo
Translates a string.
Definition: languages.js:43
if(!array_key_exists($size, $icon_sizes)) $vars['size']
Definition: default.php:27
elgg_extract($key, $array, $default=null, $strict=true)
Checks for $array[$key] and returns its value if it exists, else returns $default.
Definition: elgglib.php:1131
if(!$entity instanceof ElggEntity) $icon_sizes
Definition: default.php:21
$size
Definition: default.php:23
$params
Definition: default.php:50
elgg_get_logged_in_user_entity()
Return the current logged in user, or null if no user is logged in.
Definition: sessions.php:29
$username
Definition: default.php:31
if(!array_key_exists($size, $icon_sizes)) $name
Definition: default.php:30
$user
Elgg user icon.
Definition: default.php:18
elgg_view($view, $vars=[], $viewtype= '')
Return a parsed view.
Definition: views.php:246