Elgg  Version 6.1
theme.php
Go to the documentation of this file.
1 <?php
2 
3 elgg_import_esm('forms/admin/site/theme');
4 
5 echo elgg_view('output/longtext', ['value' => elgg_echo('admin:theme:info')]);
6 
7 echo elgg_view_message('warning', elgg_echo('admin:theme:warning'));
8 
9 $css_vars = _elgg_services()->cssCompiler->getCssVars();
10 $original_vars = _elgg_services()->cssCompiler->getCssVars([], false);
11 
12 $config_values = (array) elgg_get_config('custom_theme_vars', []);
13 
14 $headings = elgg_format_element('th', [], elgg_echo('admin:theme:css_variable:name'));
15 $headings .= elgg_format_element('th', [], elgg_echo('admin:theme:css_variable:value'));
16 $headings .= elgg_format_element('th', [], '&nbsp;');
18 
19 $tbody = '';
20 foreach ($css_vars as $name => $value) {
21  $original_value = (string) elgg_extract($name, $original_vars);
22  $input_type = str_starts_with($original_value, '#') && strlen($original_value) === 7 ? 'color' : 'text';
23 
24  $reset = '&nbsp;';
25  if (array_key_exists($name, $config_values)) {
26  $reset = elgg_view_field([
27  '#type' => 'button',
28  '#class' => 'man',
29  'text' => elgg_echo('reset'),
30  'class' => 'elgg-button-action',
31  'data-original-theme-var' => $original_vars[$name],
32  ]);
33  }
34 
35  $row = elgg_format_element('th', [], $name);
36  $row .= elgg_format_element('td', [], elgg_view_field([
37  '#type' => $input_type,
38  '#class' => 'man',
39  'name' => "vars[{$name}]",
40  'value' => $value,
41  ]));
42  $row .= elgg_format_element('td', ['style' => 'width: 1%;'], $reset);
43 
44  $tbody .= elgg_format_element('tr', [], $row);
45 }
46 
48 $table .= elgg_format_element('tbody', [], $tbody);
49 
50 echo elgg_format_element('table', ['class' => 'elgg-table-alt'], $table);
51 
53  '#type' => 'submit',
54  'text' => elgg_echo('save'),
55 ]);
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.
if(!$user||!$user->canDelete()) $name
Definition: delete.php:22
elgg_echo(string $message_key, array $args=[], string $language= '')
Elgg language module Functions to manage language and translations.
Definition: languages.php:17
$footer
Definition: theme.php:52
$value
Definition: generic.php:51
elgg_extract($key, $array, $default=null, bool $strict=true)
Checks for $array[$key] and returns its value if it exists, else returns $default.
Definition: elgglib.php:256
elgg_view(string $view, array $vars=[], string $viewtype= '')
Return a parsed view.
Definition: views.php:156
elgg_set_form_footer(string $footer= '')
Sets form footer and defers its rendering until the form view and extensions have been rendered...
Definition: views.php:1046
$input_type
Helper view that can be used to filter vars for all input views.
Definition: input.php:6
$css_vars
Definition: theme.php:9
elgg_import_esm(string $name)
Helper functions for external files like css/js.
$original_vars
Definition: theme.php:10
$headings
Definition: theme.php:14
foreach($css_vars as $name=> $value) $table
Definition: theme.php:47
elgg_view_message(string $type, string $body, array $vars=[])
Wrapper function for the message display pattern.
Definition: views.php:940
$tbody
Definition: theme.php:19
_elgg_services()
Get the global service provider.
Definition: elgglib.php:353
elgg_format_element(string $tag_name, array $attributes=[], string $text= '', array $options=[])
Format an HTML element.
Definition: output.php:145
$thead
Definition: theme.php:17
$config_values
Definition: theme.php:12