Elgg  Version 3.0
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 unset($vars['widget']);
19 
20 $name = elgg_extract('name', $vars, 'num_display');
21 $vars['name'] = "params[{$name}]";
22 
23 if (!isset($vars['label'])) {
24  $vars['label'] = elgg_echo('widget:numbertodisplay');
25 }
26 $vars['#label'] = elgg_extract('label', $vars);
27 unset($vars['label']);
28 
29 $value = (int) $widget->$name;
30 if ($value < 1) {
31  $value = (int) elgg_extract('default', $vars, 4);
32 }
33 $vars['value'] = $value;
34 
35 $vars['step'] = (int) elgg_extract('step', $vars, 1);
36 
37 $min = (int) elgg_extract('min', $vars, 1);
38 $vars['min'] = max($min, 1);
39 
40 $max = (int) elgg_extract('max', $vars, false);
41 if (!$max) {
42  $max = (int) elgg_get_config('default_limit');
43 }
44 if (!$max) {
45  $max = max($min, 20);
46 }
47 $vars['max'] = max($max, $vars['min']);
48 
49 $vars['#type'] = 'number';
50 
elgg_view_field(array $params=[])
Renders a form field, usually with a wrapper element, a label, help text, etc.
Definition: views.php:1395
$min
Definition: num_display.php:37
if(!$enabled) if(PHP_SAPI!== 'cli')
Interates through each element of an array and calls callback a function.
$name
Definition: num_display.php:20
$vars['name']
Definition: num_display.php:21
$widget
Widget edit num_display.
Definition: num_display.php:14
$value
Definition: num_display.php:29
elgg_echo($message_key, array $args=[], $language="")
Given a message key, returns an appropriately translated full-text string.
Definition: languages.php:21
elgg echo
Translates a string.
Definition: languages.js:43
$max
Definition: num_display.php:40
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
elgg_get_config($name, $default=null)
Get an Elgg configuration value.