41 function __construct ($label, $description, $ldapName, $required, $min, $max, $defaultValue =
"", $acl =
"")
43 parent::__construct($label, $description, $ldapName, $required, $defaultValue, $acl);
44 $this->min = ($min === FALSE ? FALSE : $this->inputValue($min));
45 $this->max = ($max === FALSE ? FALSE : $this->inputValue($max));
48 public function getExample ()
50 if (($this->min !== FALSE) && ($this->max !== FALSE)) {
51 return sprintf(_(
'An integer between %d and %d'), $this->min, $this->max);
52 } elseif ($this->min !== FALSE) {
53 return sprintf(_(
'An integer larger than %d'), $this->min);
54 } elseif ($this->max !== FALSE) {
55 return sprintf(_(
'An integer smaller than %d'), $this->max);
59 function setStep ($step)
64 function inputValue ($value)
66 if (!$this->isRequired() && empty($value) && !is_numeric($value)) {
70 if ($this->isTemplate()) {
73 return intval($value);
79 $error = parent::check();
82 } elseif ($this->value !==
'') {
83 if (!is_numeric($this->value)) {
89 if (($this->min !== FALSE) && ($this->value < $this->min)) {
95 if (($this->max !== FALSE) && ($this->value > $this->max)) {
104 function renderFormInput ():
string 106 $id = $this->getHtmlId();
108 'value' => $this->getValue()
110 if ($this->min !== FALSE) {
111 $attributes[
'min'] = $this->min;
113 if ($this->max !== FALSE) {
114 $attributes[
'max'] = $this->max;
116 if ($this->step !== FALSE) {
117 $attributes[
'step'] = $this->step;
119 if (!empty($this->managedAttributes)) {
120 $js = $this->managedAttributesJS();
121 $attributes[
'onChange'] =
'javascript:'.$js;
123 if ($this->isSubAttribute) {
124 $attributes[
'class'] =
'subattribute';
125 } elseif ($this->isRequired()) {
126 $attributes[
'required'] =
'required';
128 $display = $this->renderInputField(
'number', $id, $attributes);
132 function renderTemplateInput ():
string 134 $id = $this->getHtmlId();
136 'value' => $this->getValue()
138 if ($this->isSubAttribute) {
139 $attributes[
'class'] =
'subattribute';
141 $display = $this->renderInputField(
'text', $id, $attributes);
166 function __construct ($label, $description, $ldapName, $required, $min, $max, $defaultValue = 0.0, $acl =
"")
168 parent::__construct($label, $description, $ldapName, $required, $min, $max, $defaultValue, $acl);
173 public function getExample ()
175 if (($this->min !== FALSE) && ($this->max !== FALSE)) {
176 return sprintf(_(
'A float between %f and %f'), $this->min, $this->max);
177 } elseif ($this->min !== FALSE) {
178 return sprintf(_(
'A float larger than %f'), $this->min);
179 } elseif ($this->max !== FALSE) {
180 return sprintf(_(
'A float smaller than %f'), $this->max);
184 function inputValue ($value)
186 if (!$this->isRequired() && empty($value) && !is_numeric($value)) {
190 if ($this->isTemplate()) {
193 return floatval($value);
This class allow to handle easily an Float LDAP attribute.
__construct($label, $description, $ldapName, $required, $min, $max, $defaultValue="", $acl="")
The constructor of IntAttribute.
__construct($label, $description, $ldapName, $required, $min, $max, $defaultValue=0.0, $acl="")
The constructor of FloatAttribute.
static invalidValue(string $error)
Format error message for invalid value.
Error returned by check method of SimplePlugin.
renderAcl(string $display)
Add ACL information around display.
This class allow to handle easily an Integer LDAP attribute.
This class allow to handle easily any kind of LDAP attribute.