Elgg  Version master
num_display.php
Go to the documentation of this file.
1 <?php
14 $widget = elgg_extract('entity', $vars);
15 if (!$widget instanceof \ElggWidget) {
16  return;
17 }
18 
19 unset($vars['widget']);
20 
21 $name = elgg_extract('name', $vars, 'num_display');
22 $vars['name'] = "params[{$name}]";
23 
24 if (!isset($vars['label'])) {
25  $vars['label'] = elgg_echo('widget:numbertodisplay');
26 }
27 
28 $vars['#label'] = elgg_extract('label', $vars);
29 unset($vars['label']);
30 
31 $value = (int) $widget->$name;
32 if ($value < 1) {
33  $value = (int) elgg_extract('default', $vars, 4);
34 }
35 
36 $vars['value'] = $value;
37 
38 $vars['step'] = (int) elgg_extract('step', $vars, 1);
39 
40 $min = (int) elgg_extract('min', $vars, 1);
41 $vars['min'] = max($min, 1);
42 
43 $max = (int) elgg_extract('max', $vars, false);
44 if (!$max) {
45  $max = (int) elgg_get_config('default_limit');
46 }
47 
48 if (!$max) {
49  $max = max($min, 20);
50 }
51 
52 $vars['max'] = max($max, $vars['min']);
53 
54 $vars['#type'] = 'number';
55 
if(parse_url(elgg_get_site_url(), PHP_URL_PATH)!== '/') if(file_exists(elgg_get_root_path(). 'robots.txt'))
Set robots.txt.
Definition: robots.php:10
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.
$min
Definition: num_display.php:40
$name
Definition: num_display.php:21
elgg_echo(string $message_key, array $args=[], string $language= '')
Elgg language module Functions to manage language and translations.
Definition: languages.php:17
$vars['name']
Definition: num_display.php:22
$widget
Widget edit num_display.
Definition: num_display.php:14
$value
Definition: num_display.php:31
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:254
$max
Definition: num_display.php:43