Elgg  Version 3.0
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  'rel' => '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:48
$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:57
$main
Definition: user_hover.php:17
elgg_echo($message_key, array $args=[], $language="")
Given a message key, returns an appropriately translated full-text string.
Definition: languages.php:21
$card
Definition: user_hover.php:34
static factory($options)
Create an ElggMenuItem from an associative array.
$combined_actions
Definition: user_hover.php:37
Configuration exception.
elgg_format_element($tag_name, array $attributes=[], $text= '', array $options=[])
Format an HTML element.
Definition: output.php:168
elgg_view_entity(\ElggEntity $entity, array $vars=[])
Returns a string of a rendered entity.
Definition: views.php:842
elgg_pop_context()
Removes and returns the top context string from the stack.
Definition: pageowner.php:222
elgg echo
Translates a string.
Definition: languages.js:43
if(!$menu instanceof\Elgg\Menu\PreparedMenu) $actions
Definition: user_hover.php:16
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
$user_info
Definition: user_hover.php:27
elgg_push_context($context)
Push a context onto the top of the stack.
Definition: pageowner.php:212
$menu
User hover menu.
Definition: user_hover.php:11
$vars['type']
Definition: save.php:11
$user
Definition: user_hover.php:20
elgg_view($view, $vars=[], $viewtype= '')
Return a parsed view.
Definition: views.php:246