Elgg  Version master
caching.php
Go to the documentation of this file.
1 <?php
6 // simple cache
7 $is_simple_cache_on = (bool) elgg_get_config('simplecache_enabled');
8 
9 $params = [
10  '#type' => 'switch',
11  '#label' => elgg_echo('installation:simplecache:label'),
12  '#help' => elgg_echo('installation:simplecache:description'),
13  'name' => 'simplecache_enabled',
14 ];
15 
16 if (elgg()->config->hasInitialValue('simplecache_enabled')) {
17  $params['disabled'] = true;
18 
19  // set checked state based on value in settings.php
20  $is_simple_cache_on = (bool) elgg()->config->getInitialValue('simplecache_enabled');
21 
22  $params['#help'] .= ' ' . elgg_echo('admin:settings:in_settings_file');
23 }
24 
26 $simple_cache_disabled_class = $is_simple_cache_on ? '' : 'elgg-state-disabled';
27 
29 
30 $cache_symlinked = _elgg_services()->simpleCache->isSymbolicLinked();
31 
32 $help = elgg_echo('installation:cache_symlink:description');
33 $help .= elgg_echo('installation:cache_symlink:paths', [elgg_get_root_path() . 'cache/', elgg_get_asset_path()]);
34 if ($cache_symlinked) {
35  $help .= elgg_format_element('p', [], elgg_echo('installation:cache_symlink:warning'));
36 }
37 
39  '#type' => 'fieldset',
40  '#class' => ['elgg-divide-left', 'plm'],
41  'fields' => [
42  [
43  '#type' => 'switch',
44  '#label' => elgg_echo('installation:cache_symlink:label'),
45  '#help' => $help,
46  'name' => 'cache_symlink_enabled',
47  'value' => $cache_symlinked,
48  'disabled' => !$is_simple_cache_on,
49  ],
50  [
51  '#type' => 'switch',
52  '#label' => elgg_echo('installation:minify_js:label'),
53  '#help' => elgg_echo('installation:minify:description'),
54  'name' => 'simplecache_minify_js',
55  'value' => elgg_get_config('simplecache_minify_js'),
56  'disabled' => !$is_simple_cache_on,
57  'label_class' => $simple_cache_disabled_class,
58  ],
59  [
60  '#type' => 'switch',
61  '#label' => elgg_echo('installation:minify_css:label'),
62  '#help' => elgg_echo('installation:minify:description'),
63  'name' => 'simplecache_minify_css',
64  'value' => elgg_get_config('simplecache_minify_css'),
65  'disabled' => !$is_simple_cache_on,
66  'label_class' => $simple_cache_disabled_class,
67  ],
68  ],
69 ]);
70 
72  '#type' => 'switch',
73  '#label' => elgg_echo('installation:systemcache:label'),
74  '#help' => elgg_echo('installation:systemcache:description'),
75  'name' => 'system_cache_enabled',
76  'value' => _elgg_services()->systemCache->isEnabled(),
77 ]);
78 
79 echo elgg_view_module('info', elgg_echo('admin:legend:caching'), $body, ['id' => 'elgg-settings-advanced-caching']);
$cache_symlinked
Definition: caching.php:30
$body
Definition: caching.php:28
$simple_cache_disabled_class
Definition: caching.php:26
$is_simple_cache_on
Advanced site settings, caching section.
Definition: caching.php:7
$help
Definition: caching.php:32
$params
Definition: caching.php:9
elgg_get_asset_path()
Get the asset cache directory path for this installation, ending with slash.
elgg_get_root_path()
Get the project path (where composer is installed), ending with slash.
elgg_get_config(string $name, $default=null)
Get an Elgg configuration value.
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:347
elgg_echo(string $message_key, array $args=[], string $language='')
Elgg language module Functions to manage language and translations.
Definition: languages.php:17
elgg_view_module(string $type, string $title, string $body, array $vars=[])
Wrapper function for the module display pattern.
Definition: views.php:930
elgg_view_field(array $params=[])
Renders a form field, usually with a wrapper element, a label, help text, etc.
Definition: views.php:1116
elgg_format_element(string $tag_name, array $attributes=[], string $text='', array $options=[])
Format an HTML element.
Definition: output.php:145