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