placeholder.php 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. <?php
  2. $menus_present = (array) elgg_get_config("lazy_hover:menus");
  3. $user = elgg_extract("entity", $vars);
  4. if (!elgg_instanceof($user, "user")) {
  5. return;
  6. }
  7. $guid = (int) $user->getGUID();
  8. $page_owner_guid = (int) elgg_get_page_owner_guid();
  9. $contexts = elgg_get_context_stack();
  10. $input = (array) elgg_get_config("input");
  11. // generate MAC so we don't have to trust the client's choice of contexts
  12. $data = serialize([$guid, $page_owner_guid, $contexts, $input]);
  13. $mac = elgg_build_hmac($data)->getToken();
  14. $attrs = [
  15. "rel" => $mac,
  16. "class" => "elgg-menu elgg-menu-hover elgg-ajax-loader",
  17. ];
  18. if (empty($menus_present[$mac])) {
  19. $attrs["data-elgg-menu-data"] = json_encode([
  20. "g" => $guid,
  21. "pog" => $page_owner_guid,
  22. "c" => $contexts,
  23. "m" => $mac,
  24. "i" => $input,
  25. ]);
  26. $menus_present[$mac] = true;
  27. elgg_set_config("lazy_hover:menus", $menus_present);
  28. }
  29. echo elgg_format_element('ul', $attrs);