user_hover.php 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. <?php
  2. /**
  3. * User hover menu
  4. *
  5. * Register for the 'register', 'menu:user_hover' plugin hook to add to the user
  6. * hover menu. There are three sections: action, default, and admin.
  7. *
  8. * @uses $vars['menu'] Menu array provided by elgg_view_menu()
  9. */
  10. $user = $vars['entity'];
  11. $actions = elgg_extract('action', $vars['menu'], null);
  12. $main = elgg_extract('default', $vars['menu'], null);
  13. $admin = elgg_extract('admin', $vars['menu'], null);
  14. echo '<ul class="elgg-menu elgg-menu-hover">';
  15. // name and username
  16. $name_link = elgg_view('output/url', array(
  17. 'href' => $user->getURL(),
  18. 'text' => "<span class=\"elgg-heading-basic\">$user->name</span>&#64;$user->username",
  19. 'is_trusted' => true,
  20. ));
  21. echo "<li>$name_link</li>";
  22. // actions
  23. if (elgg_is_logged_in() && $actions) {
  24. echo '<li>';
  25. echo elgg_view('navigation/menu/elements/section', array(
  26. 'class' => "elgg-menu elgg-menu-hover-actions",
  27. 'items' => $actions,
  28. ));
  29. echo '</li>';
  30. }
  31. // main
  32. if ($main) {
  33. echo '<li>';
  34. echo elgg_view('navigation/menu/elements/section', array(
  35. 'class' => 'elgg-menu elgg-menu-hover-default',
  36. 'items' => $main,
  37. ));
  38. echo '</li>';
  39. }
  40. // admin
  41. if (elgg_is_admin_logged_in() && $admin) {
  42. echo '<li>';
  43. echo elgg_view('navigation/menu/elements/section', array(
  44. 'class' => 'elgg-menu elgg-menu-hover-admin',
  45. 'items' => $admin,
  46. ));
  47. echo '</li>';
  48. }
  49. echo '</ul>';