Elgg  Version 3.0
button.php
Go to the documentation of this file.
1 <?php
2 
12 $vars['class'] = elgg_extract_class($vars, 'elgg-button');
13 
14 if (!isset($vars['text']) && isset($vars['value'])) {
15  // Keeping this to ease the transition to 3.0
16  $vars['text'] = elgg_extract('value', $vars);
17 }
18 
19 $type = elgg_extract('type', $vars, 'button', false);
20 $vars['type'] = $type;
21 
23 unset($vars['text']);
24 
25 $text = elgg_format_element('span', [
26  'class' => 'elgg-button-label',
27 ], $text);
28 
29 $icon = elgg_extract('icon', $vars, '');
30 unset($vars['icon']);
31 
32 if ($icon && !preg_match('/^</', $icon)) {
34  'class' => 'elgg-button-icon',
35  ]);
36 }
37 
38 switch ($type) {
39  case 'submit':
40  $vars['class'][] = 'elgg-button-submit';
41  break;
42 
43  case 'reset':
44  $vars['class'][] = 'elgg-button-cancel';
45  break;
46 }
47 
elgg_extract_class(array $array, $existing=[], $extract_key= 'class')
Extract class names from an array, optionally merging into a preexisting set.
Definition: elgglib.php:1153
elgg_format_element($tag_name, array $attributes=[], $text= '', array $options=[])
Format an HTML element.
Definition: output.php:168
elgg echo
Translates a string.
Definition: languages.js:43
elgg_extract($key, $array, $default=null, $strict=true)
Checks for $array[$key] and returns its value if it exists, else returns $default.
Definition: elgglib.php:1131
$icon
Definition: button.php:29
elgg_view_icon($name, $vars=[])
View an icon glyph.
Definition: views.php:1552
$vars['class']
Renders a <button>
Definition: button.php:12
$text
Definition: button.php:22
if(!isset($vars['text'])&&isset($vars['value'])) $type
Definition: button.php:19