Elgg  Version 2.3
num_display.php
Go to the documentation of this file.
1 <?php
10 $widget = elgg_extract('entity', $vars);
11 if (!($widget instanceof \ElggWidget)) {
12  return;
13 }
14 unset($vars['widget']);
15 
16 $name = elgg_extract('name', $vars, 'num_display');
17 $vars['name'] = "params[{$name}]";
18 
19 if (!isset($vars['label'])) {
20  $vars['label'] = elgg_echo('widget:numbertodisplay');
21 }
22 $vars['#label'] = $vars['label'];
23 unset($vars['label']);
24 
25 if (!isset($vars['options'])) {
26  $vars['options'] = [5, 8, 10, 12, 15, 20];
27 }
28 
29 $value = sanitize_int($widget->$name, false);
30 if (!$value) {
31  $value = elgg_extract('default', $vars, $vars['options'][0]);
32 }
33 $vars['value'] = $value;
34 $vars['#type'] = 'select';
35 
elgg_view_field(array $params=[])
Renders a form field, usually with a wrapper element, a label, help text, etc.
Definition: views.php:1424
elgg_echo($message_key, $args=array(), $language="")
Given a message key, returns an appropriately translated full-text string.
Definition: languages.php:21
$name
Definition: num_display.php:16
$vars['name']
Definition: num_display.php:17
$widget
Widget edit num_display.
Definition: num_display.php:10
elgg echo
Translates a string.
Definition: languages.js:48
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:1375
if(!isset($vars['options'])) $value
Definition: num_display.php:29
sanitize_int($int, $signed=true)
Sanitizes an integer for database use.
Definition: database.php:180