Elgg  Version 4.3
AdminHeader.php
Go to the documentation of this file.
1 <?php
2 
3 namespace Elgg\Menus;
4 
6 
13 class AdminHeader {
14 
22  public static function register(\Elgg\Hook $hook) {
23  if (!elgg_is_admin_logged_in()) {
24  return;
25  }
26 
27  /* @var $return MenuItems */
28  $return = $hook->getValue();
29 
31 
32  // link back to the site
33  $return[] = \ElggMenuItem::factory([
34  'name' => 'view_site',
35  'text' => elgg_echo('admin:view_site'),
36  'href' => elgg_get_site_url(),
37  'priority' => 800,
38  ]);
39 
40  // logout action
41  $return[] = \ElggMenuItem::factory([
42  'name' => 'admin_logout',
43  'text' => elgg_echo('logout'),
44  'href' => elgg_generate_action_url('logout'),
45  'priority' => 900,
46  ]);
47 
48  // link to admin profile
49  $return[] = \ElggMenuItem::factory([
50  'name' => 'account',
51  'text' => $admin->getDisplayName(),
52  'href' => $admin->getURL(),
53  'icon' => elgg_view('output/img', [
54  'src' => $admin->getIconURL('small'),
55  'alt' => $admin->getDisplayName(),
56  ]),
57  'link_class' => 'elgg-avatar-small',
58  'priority' => 1000,
59  ]);
60 
61  return $return;
62  }
63 
71  public static function registerMaintenance(\Elgg\Hook $hook) {
72  if (!elgg_is_admin_logged_in()) {
73  return;
74  }
75 
76  if (!elgg_get_config('elgg_maintenance_mode')) {
77  return;
78  }
79 
80  /* @var $return MenuItems */
81  $return = $hook->getValue();
82 
83  $return[] = \ElggMenuItem::factory([
84  'name' => 'maintenance',
85  'text' => elgg_echo('admin:configure_utilities:maintenance'),
86  'href' => 'admin/configure_utilities/maintenance',
87  'link_class' => 'elgg-maintenance-mode-warning',
88  'priority' => 700,
89  ]);
90 
91  return $return;
92  }
93 }
elgg_is_admin_logged_in()
Returns whether or not the viewer is currently logged in and an admin user.
Definition: sessions.php:52
elgg_generate_action_url($action, array $query=[], $add_csrf_tokens=true)
Generate an action URL.
$admin
Definition: useradd.php:21
elgg_echo($message_key, array $args=[], $language="")
Elgg language module Functions to manage language and translations.
Definition: languages.php:18
static factory($options)
Create an ElggMenuItem from an associative array.
Models an event passed to hook handlers.
Definition: Hook.php:11
static registerMaintenance(\Elgg\Hook $hook)
Add the maintenance link.
Definition: AdminHeader.php:71
elgg_get_site_url()
Get the URL for the current (or specified) site, ending with "/".
Register menu items for the admin_header menu.
Definition: AdminHeader.php:13
elgg_get_logged_in_user_entity()
Return the current logged in user, or null if no user is logged in.
Definition: sessions.php:24
elgg_view($view, $vars=[], $viewtype= '')
Return a parsed view.
Definition: views.php:179
elgg_get_config($name, $default=null)
Get an Elgg configuration value.