Elgg  Version 3.0
placeholder.php
Go to the documentation of this file.
1 <?php
2 
3 $menus_present = (array) elgg_get_config("elgg_lazy_hover_menus");
4 
5 $user = elgg_extract("entity", $vars);
6 if (!$user instanceof ElggUser) {
7  return;
8 }
9 
10 $guid = (int) $user->getGUID();
13 $input = (array) elgg_get_config("input");
14 
15 // generate MAC so we don't have to trust the client's choice of contexts
17 $mac = elgg_build_hmac($data)->getToken();
18 
19 $attrs = [
20  "rel" => $mac,
21  "class" => "elgg-menu elgg-menu-hover",
22  'data-menu-placeholder' => '1', // flag for the JS to know this menu isn't fully loaded yet
23 ];
24 
25 if (empty($menus_present[$mac])) {
26  $attrs["data-elgg-menu-data"] = json_encode([
27  "g" => $guid,
28  "pog" => $page_owner_guid,
29  "c" => $contexts,
30  "m" => $mac,
31  "i" => $input,
32  ]);
33 
34  $menus_present[$mac] = true;
35  elgg_set_config("elgg_lazy_hover_menus", $menus_present);
36 }
37 
$page_owner_guid
Definition: placeholder.php:11
$menus_present
Definition: placeholder.php:3
$data
Definition: placeholder.php:16
$attrs
Definition: placeholder.php:19
$contexts
Definition: placeholder.php:12
$input
Definition: placeholder.php:13
$user
Definition: placeholder.php:5
elgg_set_config($name, $value)
Set an Elgg configuration value.
elgg_format_element($tag_name, array $attributes=[], $text= '', array $options=[])
Format an HTML element.
Definition: output.php:168
if(!$user instanceof ElggUser) $guid
Definition: placeholder.php:10
elgg echo
Translates a string.
Definition: languages.js:43
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
$vars['type']
Definition: save.php:11
elgg_get_context_stack()
Get the entire context stack (e.g.
Definition: pageowner.php:248
elgg_build_hmac($data)
Get an HMAC token builder/validator object.
Definition: actions.php:62
$mac
Definition: placeholder.php:17
elgg_get_page_owner_guid($guid=0)
Gets the guid of the entity that owns the current page.
Definition: pageowner.php:22
elgg_get_config($name, $default=null)
Get an Elgg configuration value.