Elgg  Version 3.0
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 $simple_cache_disabled_class = $is_simple_cache_on ? '' : 'elgg-state-disabled';
9 
11  'label' => elgg_echo('installation:simplecache:label'),
12  'name' => 'simplecache_enabled',
13  'checked' => $is_simple_cache_on,
14  'switch' => true,
15 ];
16 
17 $simple_cache_warning = elgg_echo('installation:simplecache:description');
18 if (_elgg_config()->hasInitialValue('simplecache_enabled')) {
19  $params['class'] = 'elgg-state-disabled';
20  $params['label_class'] = 'elgg-state-disabled';
21  $params['disabled'] = true;
22 
23  $simple_cache_warning .= "<span class=\"elgg-text-help\">" . elgg_echo('admin:settings:in_settings_file') . "</span>";
24 }
25 $simple_cache_input = elgg_view("input/checkbox", $params);
26 
28 $params = [
29  'label' => elgg_echo('installation:cache_symlink:label'),
30  'name' => 'cache_symlink_enabled',
31  'checked' => $cache_symlinked,
33  'label_class' => $simple_cache_disabled_class,
34  'switch' => true,
35 ];
36 $symlink_warning = '<p class="elgg-text-help">' . elgg_echo('installation:cache_symlink:description') . '</p>';
37 if ($cache_symlinked) {
38  $params['class'] = 'elgg-state-disabled';
39  $params['label_class'] = 'elgg-state-disabled';
40 
41  $symlink_warning .= elgg_format_element('span', ['class' => 'elgg-text-help'], elgg_echo('installation:cache_symlink:warning'));
42 }
43 
44 $symlink_input = elgg_view('input/checkbox', $params);
47 $symlink_paths_help = elgg_echo('installation:cache_symlink:paths', [$symlink_source, $symlink_target]);
48 $symlink_warning .= elgg_format_element('p', ['class' => 'elgg-text-help'], $symlink_paths_help);
49 
50 // minify
51 $minify_description = elgg_echo('installation:minify:description');
52 $minify_js_input = elgg_view("input/checkbox", [
53  'label' => elgg_echo('installation:minify_js:label'),
54  'name' => 'simplecache_minify_js',
55  'checked' => (bool) elgg_get_config('simplecache_minify_js'),
56  'label_class' => $simple_cache_disabled_class,
57  'switch' => true,
58 ]);
59 
60 $minify_css_input = elgg_view("input/checkbox", [
61  'label' => elgg_echo('installation:minify_css:label'),
62  'name' => 'simplecache_minify_css',
63  'checked' => (bool) elgg_get_config('simplecache_minify_css'),
64  'label_class' => $simple_cache_disabled_class,
65  'switch' => true,
66 ]);
67 
69  '#type' => 'checkbox',
70  'label' => elgg_echo('installation:systemcache:label'),
71  'help' => elgg_echo('installation:systemcache:description'),
72  'name' => 'system_cache_enabled',
73  'switch' => true,
74  'checked' => elgg_is_system_cache_enabled(),
75  '#class' => 'mtm',
76 ]);
77 
78 $body = <<<BODY
79  <div>
81  <p class="elgg-text-help">$simple_cache_warning</p>
82  </div>
83  <div>
86  </div>
87  <div>
88  <p>$minify_description</p>
89  $minify_js_input<br />
91  </div>
92 
94 BODY;
95 
96 echo elgg_view_module('info', elgg_echo('admin:legend:caching'), $body, ['id' => 'elgg-settings-advanced-caching']);
$params
Definition: caching.php:10
_elgg_is_cache_symlinked()
Checks if /cache directory has been symlinked to views simplecache directory.
Definition: cache.php:247
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:1395
if($cache_symlinked) $symlink_input
Definition: caching.php:44
$minify_css_input
Definition: caching.php:60
$symlink_warning
Definition: caching.php:36
$symlink_paths_help
Definition: caching.php:47
$is_simple_cache_on
Advanced site settings, caching section.
Definition: caching.php:7
$minify_js_input
Definition: caching.php:52
$symlink_source
Definition: caching.php:45
$system_cache_input
Definition: caching.php:68
elgg_echo($message_key, array $args=[], $language="")
Given a message key, returns an appropriately translated full-text string.
Definition: languages.php:21
$simple_cache_disabled_class
Definition: caching.php:8
$minify_description
Definition: caching.php:51
$symlink_target
Definition: caching.php:46
elgg_format_element($tag_name, array $attributes=[], $text= '', array $options=[])
Format an HTML element.
Definition: output.php:168
elgg_view_module($type, $title, $body, array $vars=[])
Wrapper function for the module display pattern.
Definition: views.php:1198
elgg_get_root_path()
Get the project path (where composer is installed), ending with slash.
elgg echo
Translates a string.
Definition: languages.js:43
_elgg_config()
Get the Elgg config service.
elgg_is_system_cache_enabled()
Is system cache enabled.
Definition: cache.php:68
$cache_symlinked
Definition: caching.php:27
if(_elgg_config() ->hasInitialValue('simplecache_enabled')) $simple_cache_input
Definition: caching.php:25
$simple_cache_warning
Definition: caching.php:17
$body
Definition: caching.php:78
elgg_view($view, $vars=[], $viewtype= '')
Return a parsed view.
Definition: views.php:246
elgg_get_config($name, $default=null)
Get an Elgg configuration value.