Elgg  Version 3.0
navigation.php
Go to the documentation of this file.
1 <?php
52 
100 function elgg_register_menu_item($menu_name, $menu_item) {
101  if (is_array($menu_item)) {
102  $options = $menu_item;
103  $menu_item = ElggMenuItem::factory($options);
104  if (!$menu_item instanceof ElggMenuItem) {
105  $menu_item_name = elgg_extract('name', $options, 'MISSING NAME');
106  elgg_log("Unable to add menu item '{$menu_item_name}' to '$menu_name' menu", 'WARNING');
107  return false;
108  }
109  }
110 
111  if (!$menu_item instanceof ElggMenuItem) {
112  elgg_log('Second argument of elgg_register_menu_item() must be an instance of '
113  . 'ElggMenuItem or an array of menu item factory options', 'ERROR');
114  return false;
115  }
116 
117  $menus = _elgg_config()->menus;
118  if (empty($menus)) {
119  $menus = [];
120  }
121 
122  $menus[$menu_name][] = $menu_item;
123  _elgg_config()->menus = $menus;
124 
125  return true;
126 }
127 
137 function elgg_unregister_menu_item($menu_name, $item_name) {
138  $menus = _elgg_config()->menus;
139  if (empty($menus)) {
140  return null;
141  }
142 
143  if (!isset($menus[$menu_name])) {
144  return null;
145  }
146 
147  foreach ($menus[$menu_name] as $index => $menu_object) {
148  /* @var \ElggMenuItem $menu_object */
149  if ($menu_object instanceof ElggMenuItem && $menu_object->getName() == $item_name) {
150  $item = $menus[$menu_name][$index];
151  unset($menus[$menu_name][$index]);
152  elgg_set_config('menus', $menus);
153  return $item;
154  }
155  }
156 
157  return null;
158 }
159 
170  $menus = _elgg_config()->menus;
171  if (empty($menus)) {
172  return false;
173  }
174 
175  if (!isset($menus[$menu_name])) {
176  return false;
177  }
178 
179  foreach ($menus[$menu_name] as $menu_object) {
180  /* @var \ElggMenuItem $menu_object */
181  if ($menu_object->getName() == $item_name) {
182  return true;
183  }
184  }
185 
186  return false;
187 }
188 
198 function elgg_get_menu_item($menu_name, $item_name) {
199  $menus = _elgg_config()->menus;
200  if (empty($menus)) {
201  return null;
202  }
203 
204  if (!isset($menus[$menu_name])) {
205  return null;
206  }
207 
208  foreach ($menus[$menu_name] as $index => $menu_object) {
209  /* @var \ElggMenuItem $menu_object */
210  if ($menu_object->getName() == $item_name) {
211  return $menus[$menu_name][$index];
212  }
213  }
214 
215  return null;
216 }
217 
234 function elgg_register_title_button($handler = null, $name = 'add', $entity_type = 'all', $entity_subtype = 'all') {
235 
237  if (!$owner) {
238  // noone owns the page so this is probably an all site list page
240  }
241 
242  if (($name === 'add') && ($owner instanceof ElggUser)) {
243  // make sure the add link goes to the current logged in user, not the page owner
244  $logged_in_user = elgg_get_logged_in_user_entity();
245  if (!empty($logged_in_user) && ($logged_in_user->guid !== $owner->guid)) {
246  // change the 'owner' for the link to the current logged in user
247  $owner = $logged_in_user;
248  }
249  }
250 
251  // do we have an owner and is the current user allowed to create content here
252  if (!$owner || !$owner->canWriteToContainer(0, $entity_type, $entity_subtype)) {
253  return;
254  }
255 
256  $href = elgg_generate_url("$name:$entity_type:$entity_subtype", [
257  'guid' => $owner->guid,
258  ]);
259 
260  if (!$href) {
261  if (!$handler) {
263  }
264  $href = "$handler/$name/$owner->guid";
265  }
266 
267  if (elgg_language_key_exists("$name:$entity_type:$entity_subtype")) {
268  $text = elgg_echo("$name:$entity_type:$entity_subtype");
269  } elseif (elgg_language_key_exists("$handler:$name")) {
270  $text = elgg_echo("$handler:$name");
271  } else {
272  $text = elgg_echo($name);
273  }
274 
275  // register the title menu item
276  elgg_register_menu_item('title', [
277  'name' => $name,
278  'icon' => $name === 'add' ? 'plus' : '',
279  'href' => $href,
280  'text' => $text,
281  'link_class' => 'elgg-button elgg-button-action',
282  ]);
283 }
284 
298 function elgg_push_breadcrumb($text, $href = false) {
299  $breadcrumbs = (array) _elgg_config()->breadcrumbs;
300 
301  $breadcrumbs[] = [
302  'text' => $text,
303  'href' => $href,
304  ];
305 
306  elgg_set_config('breadcrumbs', $breadcrumbs);
307 }
308 
316  $breadcrumbs = (array) _elgg_config()->breadcrumbs;
317 
318  if (empty($breadcrumbs)) {
319  return [];
320  }
321 
322  $popped = array_pop($breadcrumbs);
323  elgg_set_config('breadcrumbs', $breadcrumbs);
324 
325  return $popped;
326 }
327 
348 function elgg_get_breadcrumbs(array $breadcrumbs = null) {
349  if (!isset($breadcrumbs)) {
350  // if no crumbs set, still allow hook to populate it
351  $breadcrumbs = (array) _elgg_config()->breadcrumbs;
352  }
353 
354  $params = [
355  'breadcrumbs' => $breadcrumbs,
356  ];
357 
358  $params['identifier'] = _elgg_services()->request->getFirstUrlSegment();
359  $params['segments'] = _elgg_services()->request->getUrlSegments();
360  array_shift($params['segments']);
361 
362  $breadcrumbs = elgg_trigger_plugin_hook('prepare', 'breadcrumbs', $params, $breadcrumbs);
363  if (!is_array($breadcrumbs)) {
364  _elgg_services()->logger->error('"prepare, breadcrumbs" hook must return an array of breadcrumbs');
365  return [];
366  }
367 
368  foreach ($breadcrumbs as $key => $breadcrumb) {
369  $text = elgg_extract('text', $breadcrumb, elgg_extract('title', $breadcrumb));
370  if (isset($breadcrumb['link'])) {
371  elgg_deprecated_notice("Breadcrumb [{$text}] requires 'href' instead of 'link' set in the configuration", '3.0');
372 
373  $breadcrumbs[$key]['href'] = $breadcrumb['link'];
374  unset($breadcrumbs[$key]['link']);
375  }
376  if (isset($breadcrumb['title'])) {
377  elgg_deprecated_notice("Breadcrumb [{$text}] requires 'text' instead of 'title' set in the configuration", '3.0');
378 
379  $breadcrumbs[$key]['text'] = $breadcrumb['title'];
380  unset($breadcrumbs[$key]['title']);
381  }
382 
383  // adds name for usage in menu items
384  if (!isset($breadcrumb['name'])) {
385  $breadcrumbs[$key]['name'] = $key;
386  }
387  }
388 
389  return $breadcrumbs;
390 }
391 
405  // remove last crumb if not a link
406  $last_crumb = end($breadcrumbs);
407  if (empty($last_crumb['href'])) {
408  array_pop($breadcrumbs);
409  }
410 
411  // apply excerpt to text
412  foreach (array_keys($breadcrumbs) as $i) {
413  $breadcrumbs[$i]['text'] = elgg_get_excerpt($breadcrumbs[$i]['text'], 100);
414  }
415  return $breadcrumbs;
416 }
417 
426 function elgg_push_entity_breadcrumbs(ElggEntity $entity, $link_self = true) {
427 
428  $container = $entity->getContainerEntity() ? : null;
429  elgg_push_collection_breadcrumbs($entity->type, $entity->subtype, $container);
430 
431  $entity_url = $link_self ? $entity->getURL() : false;
432  elgg_push_breadcrumb($entity->getDisplayName(), $entity_url);
433 }
434 
445 function elgg_push_collection_breadcrumbs($entity_type, $entity_subtype, ElggEntity $container = null, $friends = false) {
446 
447  if ($container) {
448  if (!$container instanceof \ElggSite) {
449  elgg_push_breadcrumb($container->getDisplayName(), $container->getURL());
450  }
451 
452  if ($friends) {
453  $collection_route = "collection:$entity_type:$entity_subtype:friends";
454  } else if ($container instanceof ElggUser) {
455  $collection_route = "collection:$entity_type:$entity_subtype:owner";
456  } else if ($container instanceof ElggGroup) {
457  $collection_route = "collection:$entity_type:$entity_subtype:group";
458  } else if ($container instanceof ElggSite) {
459  $collection_route = "collection:$entity_type:$entity_subtype:all";
460  } else {
461  $collection_route = "collection:$entity_type:$entity_subtype:container";
462  }
463 
464  $parameters = _elgg_services()->routes->resolveRouteParameters($collection_route, $container);
465  if ($parameters !== false) {
466  $label = elgg_echo("collection:$entity_type:$entity_subtype");
467  if ($friends) {
468  if (elgg_language_key_exists("collection:$entity_type:$entity_subtype:friends")) {
469  $label = elgg_echo("collection:$entity_type:$entity_subtype:friends");
470  } else {
471  $label = elgg_echo('collection:friends', [$label]);
472  }
473  }
474  $collection_url = elgg_generate_url($collection_route, $parameters);
475  elgg_push_breadcrumb($label, $collection_url);
476  }
477  } else {
478  $label = elgg_echo("collection:$entity_type:$entity_subtype");
479  $collection_url = elgg_generate_url("collection:$entity_type:$entity_subtype:all");
480  elgg_push_breadcrumb($label, $collection_url);
481  }
482 }
483 
494 function elgg_get_filter_tabs($context = null, $selected = null, ElggUser $user = null, array $vars = []) {
495 
496  if (!isset($selected)) {
497  $selected = 'all';
498  }
499 
500  if (!$user) {
502  }
503 
504  $items = [];
506  'name' => 'all',
507  'text' => elgg_echo('all'),
508  'href' => (isset($vars['all_link'])) ? $vars['all_link'] : "$context/all",
509  'selected' => ($selected == 'all'),
510  'priority' => 200,
511  ]);
512 
513  if ($user) {
515  'name' => 'mine',
516  'text' => elgg_echo('mine'),
517  'href' => (isset($vars['mine_link'])) ? $vars['mine_link'] : "$context/owner/{$user->username}",
518  'selected' => ($selected == 'mine'),
519  'priority' => 300,
520  ]);
521  }
522 
523  $params = [
524  'selected' => $selected,
525  'user' => $user,
526  'vars' => $vars,
527  ];
528  $items = _elgg_services()->hooks->trigger('filter_tabs', $context, $params, $items);
529 
530  return $items;
531 }
532 
547 function _elgg_site_menu_init($hook, $type, $return, $params) {
548  $custom_menu_items = elgg_get_config('site_custom_menu_items');
549 
550  if ($custom_menu_items) {
551  // add custom menu items
552  $n = 1;
553  foreach ($custom_menu_items as $title => $url) {
554  $item = new ElggMenuItem("custom$n", $title, $url);
555  $return[] = $item;
556  $n++;
557  }
558  }
559 
560  return $return;
561 }
562 
578 
579  $featured_menu_names = array_values((array) elgg_get_config('site_featured_menu_names'));
580 
581  $registered = $menu->getItems('default');
582  if (empty($registered)) {
583  return;
584  }
585 
586  $has_selected = false;
587  $priority = 500;
588 
589  foreach ($registered as $item) {
590  if (in_array($item->getName(), $featured_menu_names)) {
591  $featured_index = array_search($item->getName(), $featured_menu_names);
592  $item->setPriority($featured_index);
593  } else {
594  $item->setPriority($priority);
595  $priority++;
596  }
597  if ($item->getSelected()) {
598  $has_selected = true;
599  }
600  }
601 
602  if (!$has_selected) {
603  $is_selected = function (ElggMenuItem $item) {
604  $current_url = current_page_url();
605  if (strpos($item->getHref(), elgg_get_site_url()) === 0) {
606  if ($item->getName() == elgg_get_context()) {
607  return true;
608  }
609  if ($item->getHref() == $current_url) {
610  return true;
611  }
612  }
613 
614  return false;
615  };
616 
617  foreach ($registered as $item) {
618  if ($is_selected($item)) {
619  $item->setSelected(true);
620  break;
621  }
622  }
623  }
624 
625  usort($registered, [\ElggMenuBuilder::class, 'compareByPriority']);
626 
627  $max_display_items = 5;
628 
629  $num_menu_items = count($registered);
630 
631  $more = [];
632  if ($max_display_items && $num_menu_items > ($max_display_items + 1)) {
633  $more = array_splice($registered, $max_display_items);
634  }
635 
636  if (!empty($more)) {
637  $dropdown = ElggMenuItem::factory([
638  'name' => 'more',
639  'href' => false,
640  'text' => elgg_echo('more'),
641  'icon_alt' => 'angle-down',
642  'priority' => 999,
643  ]);
644 
645  foreach ($more as &$item) {
646  $item->setParentName('more');
647  }
648 
649  $dropdown->setChildren($more);
650 
651  $registered[] = $dropdown;
652  }
653 
654  $menu->getSection('default')->fill($registered);
655 
656 }
657 
673 function _elgg_setup_vertical_menu(\Elgg\Hook $hook) {
674  $menu = $hook->getValue();
675  /* @var $menu PreparedMenu */
676 
677  $prepare = function(ElggMenuItem $menu_item) use (&$prepare) {
678  $child_menu_vars = $menu_item->getChildMenuOptions();
679  if (empty($child_menu_vars['display'])) {
680  $child_menu_vars['display'] = 'toggle';
681  }
682  $menu_item->setChildMenuOptions($child_menu_vars);
683 
684  foreach ($menu_item->getChildren() as $child_menu_item) {
685  $prepare($child_menu_item);
686  }
687  };
688 
689  foreach ($menu as $section => $menu_items) {
690  foreach ($menu_items as $menu_item) {
691  if ($menu_item instanceof ElggMenuItem) {
692  $prepare($menu_item);
693  }
694  }
695  }
696 
697  $selected_item = $hook->getParam('selected_item');
698  if ($selected_item instanceof \ElggMenuItem) {
699  $parent = $selected_item->getParent();
700  while ($parent instanceof \ElggMenuItem) {
701  $parent->setSelected();
702  $parent->addItemClass('elgg-has-selected-child');
703  $parent = $parent->getParent();
704  }
705  }
706 
707  return $menu;
708 }
709 
722 function _elgg_entity_menu_setup($hook, $type, $return, $params) {
723  $entity = elgg_extract('entity', $params);
724  if (!($entity instanceof \ElggEntity) || $entity instanceof \ElggUser) {
725  // users mostly use the hover menu for their actions
726  return;
727  }
728 
729  $handler = elgg_extract('handler', $params, false);
730  if ($handler) {
731  elgg_deprecated_notice("Using 'handler' in entity menu parameters is deprecated. Use named routes instead.", '3.0');
732 
733  $edit_url = "$handler/edit/{$entity->guid}";
734 
735  if (elgg_action_exists("$handler/delete")) {
736  $action = "$handler/delete";
737  } else {
738  $action = "entity/delete";
739  }
740  $delete_url = elgg_generate_action_url($action, [
741  'guid' => $entity->guid,
742  ]);
743  } else {
744  $edit_url = elgg_generate_entity_url($entity, 'edit');
745  $delete_url = elgg_generate_action_url('entity/delete', [
746  'guid' => $entity->guid,
747  ]);
748  }
749 
750  if ($entity->canEdit() && $edit_url) {
751  $return[] = \ElggMenuItem::factory([
752  'name' => 'edit',
753  'icon' => 'edit',
754  'text' => elgg_echo('edit'),
755  'title' => elgg_echo('edit:this'),
756  'href' => $edit_url,
757  'priority' => 900,
758  ]);
759  }
760 
761  if ($entity->canDelete() && $delete_url) {
762  $return[] = \ElggMenuItem::factory([
763  'name' => 'delete',
764  'icon' => 'delete',
765  'text' => elgg_echo('delete'),
766  'title' => elgg_echo('delete:this'),
767  'href' => $delete_url,
768  'confirm' => elgg_echo('deleteconfirm'),
769  'priority' => 950,
770  ]);
771  }
772 
773  return $return;
774 }
775 
790 function _elgg_menu_transform_to_dropdown(\Elgg\Hook $hook) {
791  $menu = $hook->getValue();
792  /* @var $menu PreparedMenu */
793 
794  $is_dropdown = $hook->getParam('dropdown', true);
795  if ($is_dropdown === false) {
796  return;
797  }
798 
799  $items = $menu->getItems('default');
800  if (empty($items)) {
801  return;
802  }
803 
804  $menu->getSection('default')->fill([
806  'name' => 'entity-menu-toggle',
807  'icon' => 'ellipsis-v',
808  'href' => false,
809  'text' => '',
810  'child_menu' => [
811  'display' => 'dropdown',
812  'data-position' => json_encode([
813  'at' => 'right bottom',
814  'my' => 'right top',
815  'collision' => 'fit fit',
816  ]),
817  'class' => "elgg-{$hook->getParam('name')}-dropdown-menu",
818  ],
819  'children' => $items,
820  ]),
821  ]);
822 }
823 
836  $entity = $hook->getEntityParam();
837  if (!$entity) {
838  return;
839  }
840 
841  $return = $hook->getValue();
842  /* @var $return MenuItems */
843 
844  $options = [
845  'type' => $entity->getType(),
846  'subtype' => $entity->getSubtype(),
847  'container_guid' => $entity->container_guid,
848  'limit' => 1,
849  ];
850 
851  $previous_options = $options;
852  $previous_options['wheres'] = [
853  function (\Elgg\Database\QueryBuilder $qb, $main_alias) use ($entity) {
854  return $qb->merge([
855  $qb->compare("{$main_alias}.time_created", '<', $entity->time_created, ELGG_VALUE_INTEGER),
856  $qb->merge([
857  $qb->compare("{$main_alias}.time_created", '=', $entity->time_created, ELGG_VALUE_INTEGER),
858  $qb->compare("{$main_alias}.guid", '<', $entity->guid, ELGG_VALUE_GUID),
859  ], 'AND'),
860  ], 'OR');
861  },
862  ];
863  $previous_options['order_by'] = [
864  new \Elgg\Database\Clauses\OrderByClause('time_created', 'DESC'),
865  new \Elgg\Database\Clauses\OrderByClause('guid', 'DESC'),
866  ];
867 
868  $previous = elgg_get_entities($previous_options);
869  if ($previous) {
870  $previous = $previous[0];
871  $return[] = \ElggMenuItem::factory([
872  'name' => 'previous',
873  'text' => elgg_echo('previous'),
874  'entity' => $previous,
875  'href' => $previous->getUrl(),
876  'title' => $previous->getDisplayName(),
877  'icon' => 'angle-double-left',
878  'link_class' => 'elgg-button elgg-button-outline',
879  'priority' => 100,
880  ]);
881  }
882 
883  $next_options = $options;
884  $next_options['wheres'] = [
885  function (\Elgg\Database\QueryBuilder $qb, $main_alias) use ($entity) {
886  return $qb->merge([
887  $qb->compare("{$main_alias}.time_created", '>', $entity->time_created, ELGG_VALUE_INTEGER),
888  $qb->merge([
889  $qb->compare("{$main_alias}.time_created", '=', $entity->time_created, ELGG_VALUE_INTEGER),
890  $qb->compare("{$main_alias}.guid", '>', $entity->guid, ELGG_VALUE_GUID),
891  ], 'AND'),
892  ], 'OR');
893  },
894  ];
895  $next_options['order_by'] = [
896  new \Elgg\Database\Clauses\OrderByClause('time_created', 'ASC'),
897  new \Elgg\Database\Clauses\OrderByClause('guid', 'ASC'),
898  ];
899 
900  $next = elgg_get_entities($next_options);
901  if ($next) {
902  $next = $next[0];
903  $return[] = \ElggMenuItem::factory([
904  'name' => 'next',
905  'text' => elgg_echo('next'),
906  'entity' => $next,
907  'href' => $next->getUrl(),
908  'title' => $next->getDisplayName(),
909  'icon_alt' => 'angle-double-right',
910  'link_class' => 'elgg-button elgg-button-outline',
911  'priority' => 800,
912  ]);
913  }
914 
915  return $return;
916 }
917 
930 function _elgg_widget_menu_setup($hook, $type, $return, $params) {
931 
932  $widget = elgg_extract('entity', $params);
933  if (!($widget instanceof \ElggWidget)) {
934  return;
935  }
936 
937  if ($widget->canDelete()) {
938  $return[] = \ElggMenuItem::factory([
939  'name' => 'delete',
940  'text' => elgg_view_icon('delete-alt'),
941  'title' => elgg_echo('widget:delete', [$widget->getDisplayName()]),
942  'href' => "action/widgets/delete?widget_guid=$widget->guid",
943  'is_action' => true,
944  'link_class' => 'elgg-widget-delete-button',
945  'id' => "elgg-widget-delete-button-$widget->guid",
946  'data-elgg-widget-type' => $widget->handler,
947  'priority' => 900,
948  ]);
949  }
950 
951  $show_edit = elgg_extract('show_edit', $params, $widget->canEdit());
952  if ($show_edit) {
953  $return[] = \ElggMenuItem::factory([
954  'name' => 'settings',
955  'text' => elgg_view_icon('settings-alt'),
956  'title' => elgg_echo('widget:edit'),
957  'href' => "#widget-edit-$widget->guid",
958  'link_class' => "elgg-widget-edit-button",
959  'rel' => 'toggle',
960  'priority' => 800,
961  ]);
962  }
963 
964  return $return;
965 }
966 
979 function _elgg_login_menu_setup($hook, $type, $return, $params) {
980 
982  $return[] = \ElggMenuItem::factory([
983  'name' => 'register',
984  'href' => elgg_get_registration_url(),
985  'text' => elgg_echo('register'),
986  'link_class' => 'registration_link',
987  ]);
988  }
989 
990  $return[] = \ElggMenuItem::factory([
991  'name' => 'forgotpassword',
992  'href' => elgg_generate_url('account:password:reset'),
993  'text' => elgg_echo('user:password:lost'),
994  'link_class' => 'forgot_link',
995  ]);
996 
997  return $return;
998 }
999 
1012 function _elgg_rss_menu_setup($hook, $type, $return, $params) {
1013 
1014  if (!elgg_is_logged_in()) {
1015  return;
1016  }
1017 
1018  if (!_elgg_has_rss_link()) {
1019  return;
1020  }
1021 
1022  $return[] = ElggMenuItem::factory([
1023  'name' => 'rss',
1024  'text' => elgg_echo('feed:rss'),
1025  'icon' => 'rss',
1027  'view' => 'rss',
1028  ]),
1029  'title' => elgg_echo('feed:rss:title'),
1030  ]);
1031 
1032  return $return;
1033 }
1034 
1042 function _elgg_nav_init() {
1043  elgg_register_plugin_hook_handler('prepare', 'breadcrumbs', 'elgg_prepare_breadcrumbs');
1044 
1045  elgg_register_plugin_hook_handler('prepare', 'menu:site', '_elgg_site_menu_setup', 999);
1046  elgg_register_plugin_hook_handler('register', 'menu:site', '_elgg_site_menu_init');
1047 
1048  elgg_register_plugin_hook_handler('prepare', 'menu:page', '_elgg_setup_vertical_menu', 999);
1049  elgg_register_plugin_hook_handler('prepare', 'menu:owner_block', '_elgg_setup_vertical_menu', 999);
1050 
1051  elgg_register_plugin_hook_handler('prepare', 'menu:entity', '_elgg_menu_transform_to_dropdown');
1052  elgg_register_plugin_hook_handler('prepare', 'menu:river', '_elgg_menu_transform_to_dropdown');
1053  elgg_register_plugin_hook_handler('register', 'menu:entity', '_elgg_entity_menu_setup');
1054  elgg_register_plugin_hook_handler('register', 'menu:widget', '_elgg_widget_menu_setup');
1055  elgg_register_plugin_hook_handler('register', 'menu:login', '_elgg_login_menu_setup');
1056  elgg_register_plugin_hook_handler('register', 'menu:footer', '_elgg_rss_menu_setup');
1057  elgg_register_plugin_hook_handler('register', 'menu:entity_navigation', '_elgg_entity_navigation_menu_setup');
1058 
1059  elgg_register_plugin_hook_handler('public_pages', 'walled_garden', '_elgg_nav_public_pages');
1060 
1061  if (!_elgg_config()->remove_branding) {
1063  'name' => 'powered',
1064  'text' => elgg_echo("elgg:powered"),
1065  'href' => 'http://elgg.org',
1066  'title' => 'Elgg ' . elgg_get_version(true),
1067  'section' => 'meta',
1068  'priority' => 600,
1069  ]));
1070  }
1071 
1072  elgg_register_ajax_view('navigation/menu/user_hover/contents');
1073 
1074  // Using a view extension to ensure that themes that have replaced the item view
1075  // still load the required AMD modules
1076  elgg_extend_view('navigation/menu/elements/item', 'navigation/menu/elements/item_deps');
1077 }
1078 
1091 function _elgg_nav_public_pages($hook_name, $entity_type, $return_value, $params) {
1092  if (is_array($return_value)) {
1093  $return_value[] = 'navigation/menu/user_hover/contents';
1094  }
1095 
1096  return $return_value;
1097 }
1098 
1102 return function(\Elgg\EventsService $events, \Elgg\HooksRegistrationService $hooks) {
1103  $events->registerHandler('init', 'system', '_elgg_nav_init');
1104 };
elgg_language_key_exists($key, $language= 'en')
Check if a given language key exists.
Definition: languages.php:96
elgg_http_add_url_query_elements($url, array $elements)
Sets elements in a URL&#39;s query string.
Definition: elgglib.php:942
$custom_menu_items
Definition: save.php:18
elgg_is_logged_in()
Returns whether or not the user is currently logged in.
Definition: sessions.php:48
elgg_unregister_menu_item($menu_name, $item_name)
Remove an item from a menu.
Definition: navigation.php:137
$action
Definition: full.php:111
$context
Definition: add.php:8
if($view &&elgg_view_exists($view)) $label
Definition: field.php:26
if(!$user||!$user->canDelete()) $name
Definition: delete.php:22
_elgg_login_menu_setup($hook, $type, $return, $params)
Add the register and forgot password links to login menu.
Definition: navigation.php:979
if(!$items) $item
Definition: delete.php:13
elgg_generate_action_url($action, array $query=[], $add_csrf_tokens=true)
Generate an action URL.
if(!($entity instanceof\ElggEntity)) $params
Definition: navigation.php:13
const ELGG_VALUE_INTEGER
Value types.
Definition: constants.php:138
$CONFIG allow_registration
Is registration enabled?
Definition: config.php:149
const ELGG_VALUE_GUID
Definition: constants.php:140
Events service.
elgg_get_menu_item($menu_name, $item_name)
Get a menu item registered for a menu.
Definition: navigation.php:198
current_page_url()
Returns the current page&#39;s complete URL.
Definition: input.php:94
$items
Definition: delete.php:8
$type
Definition: delete.php:21
_elgg_setup_vertical_menu(\Elgg\Hook $hook)
Prepare vertically stacked menu.
Definition: navigation.php:673
elgg_register_plugin_hook_handler($hook, $type, $callback, $priority=500)
Definition: elgglib.php:634
_elgg_widget_menu_setup($hook, $type, $return, $params)
Widget menu is a set of widget controls.
Definition: navigation.php:930
_elgg_site_menu_setup($hook, $type, $menu, $params)
Set up the site menu.
Definition: navigation.php:577
elgg_echo($message_key, array $args=[], $language="")
Given a message key, returns an appropriately translated full-text string.
Definition: languages.php:21
elgg_push_breadcrumb($text, $href=false)
Adds a breadcrumb to the breadcrumbs stack.
Definition: navigation.php:298
$options
Elgg admin footer.
Definition: footer.php:6
$text
Definition: default.php:28
$featured_menu_names
Definition: save.php:15
_elgg_has_rss_link()
Should the RSS view of this URL be linked to?
Definition: views.php:1594
static factory($options)
Create an ElggMenuItem from an associative array.
elgg_prepare_breadcrumbs($hook, $type, $breadcrumbs, $params)
Prepare breadcrumbs before display.
Definition: navigation.php:404
Configuration exception.
elgg_register_title_button($handler=null, $name= 'add', $entity_type= 'all', $entity_subtype= 'all')
Convenience function for registering a button to the title menu.
Definition: navigation.php:234
Base class for events and hooks.
$title
Definition: user.php:20
$menu_items
Definition: save.php:11
$owner
Definition: crop.php:7
$container
Definition: delete.php:23
elgg_get_entities(array $options=[])
Fetches/counts entities or performs a calculation on their properties.
Definition: entities.php:545
elgg_set_config($name, $value)
Set an Elgg configuration value.
elgg_log($message, $level=\Psr\Log\LogLevel::NOTICE)
Log a message.
Definition: elgglib.php:786
$num_menu_items
Definition: save.php:17
$menu
Definition: navigation.php:16
elgg_generate_url($name, array $parameters=[])
Generate a URL for named route.
Definition: pagehandler.php:58
$user
Definition: ban.php:7
elgg_get_breadcrumbs(array $breadcrumbs=null)
Returns all breadcrumbs as an array [ [ &#39;text&#39; => &#39;Breadcrumb title&#39;, &#39;href&#39; => &#39;/path/to/page&#39;, ] ]
Definition: navigation.php:348
$url
Definition: default.php:33
elgg_trigger_plugin_hook($hook, $type, $params=null, $returnvalue=null)
Definition: elgglib.php:720
elgg_get_context()
Get the current context.
Definition: pageowner.php:201
elgg_deprecated_notice($msg, $dep_version, $backtrace_level=1)
Log a notice about deprecated use of a function, view, etc.
Definition: elgglib.php:841
elgg_get_page_owner_entity()
Gets the owner entity for the current page.
Definition: pageowner.php:65
elgg_register_ajax_view($view)
Register a view to be available for ajax calls.
Definition: views.php:133
elgg_get_site_url()
Get the URL for the current (or specified) site, ending with "/".
elgg_register_menu_item($menu_name, $menu_item)
Register an item for an Elgg menu.
Definition: navigation.php:100
elgg_extend_view($view, $view_extension, $priority=501)
Extends a view with another view.
Definition: views.php:293
if($item instanceof\ElggEntity) elseif($item instanceof\ElggRiverItem) elseif(is_callable([$item, 'getType']))
Definition: item.php:39
_elgg_entity_menu_setup($hook, $type, $return, $params)
Entity menu is list of links and info on any entity.
Definition: navigation.php:722
if($guid===false) $widget
Definition: add.php:30
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
elgg_get_registration_url(array $query=[], $fragment= '')
Returns site&#39;s registration URL Triggers a &#39;registration_url&#39;, &#39;site&#39; plugin hook that can be used by...
Definition: users.php:262
if($container instanceof ElggGroup &&$container->guid!=elgg_get_page_owner_guid()) $key
Definition: summary.php:55
elgg_get_filter_tabs($context=null, $selected=null, ElggUser $user=null, array $vars=[])
Returns default filter tabs (All, Mine, Friends) for the user.
Definition: navigation.php:494
elgg_push_entity_breadcrumbs(ElggEntity $entity, $link_self=true)
Resolves and pushes entity breadcrumbs based on named routes.
Definition: navigation.php:426
_elgg_config()
Get the Elgg config service.
elgg_get_version($human_readable=false)
Get the current Elgg version information.
Definition: elgglib.php:814
_elgg_nav_init()
Navigation initialization.
_elgg_menu_transform_to_dropdown(\Elgg\Hook $hook)
Moves default menu items into a dropdown.
Definition: navigation.php:790
elgg_view_icon($name, $vars=[])
View an icon glyph.
Definition: views.php:1552
$vars['type']
Definition: save.php:11
_elgg_site_menu_init($hook, $type, $return, $params)
Init site menu.
Definition: navigation.php:547
_elgg_entity_navigation_menu_setup(\Elgg\Hook $hook)
Entity navigation menu is previous/next link for an entity.
Definition: navigation.php:835
elgg_get_excerpt($text, $num_chars=250)
Returns an excerpt.
Definition: output.php:74
class
Definition: placeholder.php:21
_elgg_services()
Get the global service provider.
Definition: elgglib.php:1292
elgg_get_logged_in_user_entity()
Return the current logged in user, or null if no user is logged in.
Definition: sessions.php:29
$index
Definition: gallery.php:47
$handler
Definition: add.php:7
getContainerEntity()
Get the container entity for this object.
_elgg_nav_public_pages($hook_name, $entity_type, $return_value, $params)
Extend public pages.
elgg_action_exists($action)
Check if an action is registered and its script exists.
Definition: actions.php:117
elgg_generate_entity_url(ElggEntity $entity, $resource= 'view', $subresource=null, array $parameters=[])
Generate entity URL from a named route.
Definition: pagehandler.php:84
getURL()
Gets the URL for this entity.
elgg_push_collection_breadcrumbs($entity_type, $entity_subtype, ElggEntity $container=null, $friends=false)
Resolves and pushes collection breadcrumbs for a container.
Definition: navigation.php:445
elgg_pop_breadcrumb()
Removes last breadcrumb entry.
Definition: navigation.php:315
_elgg_rss_menu_setup($hook, $type, $return, $params)
Add the RSS link to the menu.
$entity
Outputs entity previous/next navigation elements.
Definition: navigation.php:8
$priority
if(empty($value)&&$value!==0 &&$value!== '0') $href
Definition: tag.php:16
getDisplayName()
Get the entity&#39;s display name.
Definition: ElggEntity.php:307
elgg_get_config($name, $default=null)
Get an Elgg configuration value.
elgg_is_menu_item_registered($menu_name, $item_name)
Check if a menu item has been registered.
Definition: navigation.php:169