Elgg  Version master
theme.php
Go to the documentation of this file.
1 <?php
2 
3 $vars = (array) get_input('vars', [], false);
4 
5 $available_config = _elgg_services()->cssCompiler->getCssVars();
6 
8 if (isset($available_config['default'])) {
9  $default_scheme_vars = array_map(function() {
10  // empty function to clear the values
11  }, $available_config['default']);
12 }
13 
14 foreach ($vars as $color_scheme => $scheme_vars) {
15  $allowed_keys = $color_scheme === 'default' ? $scheme_vars : array_merge($default_scheme_vars, $scheme_vars);
16 
17  foreach ($scheme_vars as $name => $value) {
18  if (empty($value)) {
19  unset($vars[$color_scheme][$name]);
20  continue;
21  }
22 
23  if (!array_key_exists($name, $allowed_keys)) {
24  unset($vars[$color_scheme][$name]);
25  continue;
26  }
27 
28  if (strtolower($value) === strtolower((string) $available_config[$color_scheme][$name])) {
29  unset($vars[$color_scheme][$name]);
30  continue;
31  }
32  }
33 }
34 
35 if (empty($vars)) {
36  elgg_remove_config('custom_theme_vars');
37 } else {
38  elgg_save_config('custom_theme_vars', $vars);
39 }
40 
42 
43 return elgg_ok_response('', elgg_echo('save:success'));
$vars
Definition: theme.php:3
$default_scheme_vars
Definition: theme.php:7
$available_config
Definition: theme.php:5
if(! $user||! $user->canDelete()) $name
Definition: delete.php:22
elgg_invalidate_caches()
Invalidate all the registered caches.
Definition: cache.php:88
elgg_save_config(string $name, $value)
Save a configuration setting.
elgg_remove_config(string $name)
Removes a config setting.
_elgg_services()
Get the global service provider.
Definition: elgglib.php:347
get_input(string $variable, $default=null, bool $filter_result=true)
Parameter input functions.
Definition: input.php:20
$value
Definition: generic.php:51
elgg_echo(string $message_key, array $args=[], string $language='')
Elgg language module Functions to manage language and translations.
Definition: languages.php:17
elgg_ok_response($content='', string|array $message='', ?string $forward_url=null, int $status_code=ELGG_HTTP_OK)
Prepares a successful response to be returned by a page or an action handler.