Elgg  Version 6.1
user_hover.php
Go to the documentation of this file.
1 <?php
12 if (!$menu instanceof \Elgg\Menu\PreparedMenu) {
13  return;
14 }
15 
16 $actions = $menu->getItems('action');
17 $main = $menu->getItems('default');
18 $admin = $menu->getItems('admin');
19 
20 $user = elgg_extract('entity', $vars);
21 if (!($user instanceof ElggUser)) {
22  return;
23 }
24 
25 elgg_push_context('user_hover');
26 
28  'full_view' => false,
29  'use_hover' => false,
30  'size' => 'medium',
31  'metadata' => false,
32 ]);
33 
34 $card = elgg_format_element('div', ['class' => 'elgg-menu-hover-card'], $user_info);
35 
36 // actions
38 if (elgg_is_logged_in() && !empty($actions)) {
40 }
41 
42 // main
43 if (!empty($main)) {
45 }
46 
47 if (elgg_is_admin_logged_in() && !empty($admin)) {
49  'name' => 'toggle_admin',
50  'text' => elgg_echo('admin:options'),
51  'icon' => 'ellipsis-v',
52  'href' => false,
53  'data-toggle-selector' => ".hover_toggle_admin_{$user->guid}",
54  'class' => 'elgg-toggle',
55  ]);
56 }
57 
58 if (!empty($combined_actions)) {
59  $card .= elgg_view('navigation/menu/elements/section', [
60  'class' => 'elgg-menu elgg-menu-hover-actions',
61  'items' => $combined_actions,
62  ]);
63 }
64 
65 echo elgg_format_element('div', ['class' => 'elgg-menu-hover-card-container'], $card);
66 
67 // admin
68 if (elgg_is_admin_logged_in() && !empty($admin)) {
69  echo elgg_view('navigation/menu/elements/section', [
70  'class' => [
71  'elgg-menu',
72  'elgg-menu-hover-admin',
73  'hidden',
74  "hover_toggle_admin_{$user->guid}",
75  ],
76  'items' => $admin,
77  ]);
78 }
79 
elgg_is_logged_in()
Returns whether or not the user is currently logged in.
Definition: sessions.php:43
$admin
Definition: user_hover.php:18
elgg_is_admin_logged_in()
Returns whether or not the viewer is currently logged in and an admin user.
Definition: sessions.php:52
$main
Definition: user_hover.php:17
elgg_echo(string $message_key, array $args=[], string $language= '')
Elgg language module Functions to manage language and translations.
Definition: languages.php:17
static factory(array $options)
Create an ElggMenuItem from an associative array.
elgg_extract($key, $array, $default=null, bool $strict=true)
Checks for $array[$key] and returns its value if it exists, else returns $default.
Definition: elgglib.php:256
elgg_pop_context()
Removes and returns the top context string from the stack.
Definition: context.php:62
$card
Definition: user_hover.php:34
elgg_view(string $view, array $vars=[], string $viewtype= '')
Return a parsed view.
Definition: views.php:156
$combined_actions
Definition: user_hover.php:37
elgg_view_entity(\ElggEntity $entity, array $vars=[])
Returns a string of a rendered entity.
Definition: views.php:493
if(!$menu instanceof\Elgg\Menu\PreparedMenu) $actions
Definition: user_hover.php:16
$user_info
Definition: user_hover.php:27
elgg_push_context(string $context)
Push a context onto the top of the stack.
Definition: context.php:52
$vars
Definition: theme.php:5
$menu
User hover menu.
Definition: user_hover.php:11
elgg_format_element(string $tag_name, array $attributes=[], string $text= '', array $options=[])
Format an HTML element.
Definition: output.php:145
$user
Definition: user_hover.php:20