Elgg  Version master
generic.php
Go to the documentation of this file.
1 <?php
7 echo elgg_view('output/longtext', [
8  'value' => elgg_echo('admin:performance:generic:description'),
9 ]);
10 
11 $icon_ok = elgg_view_icon('check', ['class' => ['elgg-state', 'elgg-state-success']]);
12 $icon_warning = elgg_view_icon('exclamation-triangle', ['class' => ['elgg-state', 'elgg-state-warning']]);
13 $icon_error = elgg_view_icon('times', ['class' => ['elgg-state', 'elgg-state-danger']]);
14 
15 $view_module = function($icon, $title, $value = '', $subtext = '') {
16  $body = elgg_format_element('strong', [], $title);
17  if (!elgg_is_empty($value)) {
18  $body .= elgg_format_element('span', ['class' => 'mlm'], $value);
19  }
20 
21  if (!elgg_is_empty($subtext)) {
22  $body .= elgg_format_element('div', ['class' => 'elgg-subtext'], $subtext);
23  }
24 
25  return elgg_view_image_block($icon, $body, ['class' => 'elgg-admin-information-row']);
26 };
27 
28 // apache version
29 // Check if the function exists before callling it else it may fail in case of Nginx or other Non Apache servers
30 if (function_exists('apache_get_version')) {
31  if (apache_get_version() !== false) {
33  $title = elgg_echo('admin:performance:apache:mod_cache');
34  $value = elgg_echo('status:unavailable');
35  $subtext = '';
36 
37  if (in_array('mod_cache', apache_get_modules())) {
38  $icon = $icon_ok;
39  $value = elgg_echo('status:enabled');
40  } else {
41  $subtext = elgg_echo('admin:performance:apache:mod_cache:warning');
42  }
43 
45  }
46 }
47 
48 // open_basedir
50 $title = elgg_echo('admin:performance:php:open_basedir');
51 $value = elgg_echo('admin:performance:php:open_basedir:not_configured');
52 $subtext = '';
53 
54 $open_basedirs = ini_get('open_basedir');
55 if (!empty($open_basedirs)) {
57  $value = elgg_format_element('span', ['class' => ['elgg-subtext']], $open_basedirs);
58 
59  $separator = ':';
60  if (stripos(PHP_OS, 'WIN') === 0) {
61  $separator = ';';
62  }
63 
64  $parsed_open_basedirs = explode($separator, $open_basedirs);
65 
66  if (count($parsed_open_basedirs) > 5) {
68  $subtext = elgg_echo('admin:performance:php:open_basedir:error');
69  } else {
70  $subtext = elgg_echo('admin:performance:php:open_basedir:warning');
71  }
72 
73  $subtext .= ' ' . elgg_echo('admin:performance:php:open_basedir:generic');
74 }
75 
77 
78 // opcache
80 $title = elgg_echo('admin:server:label:opcache');
81 $value = elgg_echo('status:unavailable');
82 $subtext = '';
83 
84 if (function_exists('opcache_get_status')) {
86  $opcache_status = opcache_get_status(false);
87 
88  if (!empty($opcache_status)) {
89  $icon = $icon_ok;
90  $value = elgg_echo('status:enabled');
91  } else {
92  $value = elgg_echo('status:disabled');
93  $subtext = elgg_echo('admin:server:opcache:inactive');
94  }
95 }
96 
98 
99 // simplecache
101 $title = elgg_view('output/url', [
102  'text' => elgg_echo('admin:performance:simplecache'),
103  'href' => elgg_generate_url('admin', [
104  'segments' => 'site_settings',
105  ]) . '#elgg-settings-advanced-caching',
106  'is_trusted' => true,
107 ]);
108 $value = elgg_echo('status:disabled');
109 $subtext = elgg_echo('installation:simplecache:description');
110 
111 if (_elgg_services()->simpleCache->isEnabled()) {
112  $icon = $icon_ok;
113  $value = elgg_echo('status:enabled');
114 
115  if (!elgg()->config->hasInitialValue('simplecache_enabled')) {
117  $subtext = elgg_echo('admin:performance:simplecache:settings:warning');
118  }
119 }
120 
122 
123 // systemcache
125 $title = elgg_view('output/url', [
126  'text' => elgg_echo('admin:performance:systemcache'),
127  'href' => elgg_generate_url('admin', [
128  'segments' => 'site_settings',
129  ]) . '#elgg-settings-advanced-caching',
130  'is_trusted' => true,
131 ]);
132 $value = elgg_echo('status:disabled');
133 $subtext = elgg_echo('installation:systemcache:description');
134 
135 if (_elgg_services()->systemCache->isEnabled()) {
136  $icon = $icon_ok;
137  $value = elgg_echo('status:enabled');
138  $subtext = '';
139 }
140 
foreach($categories as $key=> $category) $body
Definition: categories.php:38
elgg()
Bootstrapping and helper procedural code available for use in Elgg core and plugins.
Definition: elgglib.php:12
_elgg_services()
Get the global service provider.
Definition: elgglib.php:343
elgg_is_empty($value)
Check if a value isn't empty, but allow 0 and '0'.
Definition: input.php:176
$value
Definition: generic.php:51
$subtext
Definition: generic.php:52
$open_basedirs
Definition: generic.php:54
$icon_ok
Generic performance overview, more detailed information can be added to additional tabs in /admin/per...
Definition: generic.php:11
$icon_error
Definition: generic.php:13
$view_module
Definition: generic.php:15
if(function_exists('apache_get_version')) $icon
Definition: generic.php:49
$title
Definition: generic.php:50
$icon_warning
Definition: generic.php:12
elgg_echo(string $message_key, array $args=[], string $language='')
Elgg language module Functions to manage language and translations.
Definition: languages.php:17
elgg_view_icon(string $name, array $vars=[])
View an icon glyph.
Definition: views.php:1264
elgg_view_image_block(string $image, string $body, array $vars=[])
Wrapper function for the image block display pattern.
Definition: views.php:901
elgg_view(string $view, array $vars=[], string $viewtype='')
Return a parsed view.
Definition: views.php:156
$opcache_status
Definition: opcache.php:7
$separator
Definition: tags.php:56
elgg_format_element(string $tag_name, array $attributes=[], string $text='', array $options=[])
Format an HTML element.
Definition: output.php:145
elgg_generate_url(string $name, array $parameters=[])
Generate a URL for named route.