ILIAS
Release_5_0_x_branch Revision 61816
◀ ilDoc Overview
Main Page
Related Pages
Modules
Namespaces
Data Structures
Files
Examples
File List
Globals
All
Data Structures
Namespaces
Files
Functions
Variables
Groups
Pages
class.ilAdvancedMDFieldDefinitionFloat.php
Go to the documentation of this file.
1
<?php
2
/* Copyright (c) 1998-2013 ILIAS open source, Extended GPL, see docs/LICENSE */
3
4
require_once
"Services/AdvancedMetaData/classes/Types/class.ilAdvancedMDFieldDefinitionInteger.php"
;
5
14
class
ilAdvancedMDFieldDefinitionFloat
extends
ilAdvancedMDFieldDefinitionInteger
15
{
16
protected
$decimals
;
// [integer]
17
18
//
19
// generic types
20
//
21
22
public
function
getType
()
23
{
24
return
self::TYPE_FLOAT
;
25
}
26
27
protected
function
init
()
28
{
29
parent::init
();
30
$this->
setDecimals
(2);
31
}
32
33
34
//
35
// ADT
36
//
37
38
protected
function
initADTDefinition
()
39
{
40
$def =
ilADTFactory::getInstance
()->getDefinitionInstanceByType(
"Float"
);
41
42
$def->setMin($this->
getMin
());
43
$def->setMax($this->
getMax
());
44
$def->setDecimals($this->
getDecimals
());
45
$def->setSuffix($this->
getSuffix
());
46
47
return
$def;
48
}
49
50
51
//
52
// properties
53
//
54
60
public
function
setDecimals
($a_value)
61
{
62
$this->decimals = max(1, abs((
int
)$a_value));
63
}
64
70
public
function
getDecimals
()
71
{
72
return
$this->decimals
;
73
}
74
75
76
//
77
// definition (NOT ADT-based)
78
//
79
80
protected
function
importFieldDefinition
(array $a_def)
81
{
82
parent::importFieldDefinition
($a_def);
83
$this->
setDecimals
($a_def[
"decimals"
]);
84
}
85
86
protected
function
getFieldDefinition
()
87
{
88
$def =
parent::getFieldDefinition
();
89
$def[
"decimals"
] = $this->
getDecimals
();
90
return
$def;
91
}
92
93
public
function
getFieldDefinitionForTableGUI
()
94
{
95
global
$lng
;
96
97
$res
=
parent::getFieldDefinitionForTableGUI
();
98
$res
[$lng->txt(
"md_adv_number_decimals"
)] = $this->
getDecimals
();
99
return
$res
;
100
}
101
108
public
function
addCustomFieldToDefinitionForm
(
ilPropertyFormGUI
$a_form, $a_disabled =
false
)
109
{
110
global
$lng
;
111
112
// #32
113
parent::addCustomFieldToDefinitionForm
($a_form, $a_disabled);
114
115
$decimals
=
new
ilNumberInputGUI
($lng->txt(
"md_adv_number_decimals"
),
"dec"
);
116
$decimals
->setRequired(
true
);
117
$decimals
->setValue($this->
getDecimals
());
118
$decimals
->setSize(5);
119
$a_form->
addItem
(
$decimals
);
120
121
if
($a_disabled)
122
{
123
$decimals
->setDisabled(
true
);
124
}
125
}
126
132
public
function
importCustomDefinitionFormPostValues
(
ilPropertyFormGUI
$a_form)
133
{
134
parent::importCustomDefinitionFormPostValues
($a_form);
135
136
$this->
setDecimals
($a_form->
getInput
(
"dec"
));
137
}
138
139
140
//
141
// export/import
142
//
143
144
protected
function
addPropertiesToXML
(
ilXmlWriter
$a_writer)
145
{
146
parent::addPropertiesToXML
($a_writer);
147
148
$a_writer->
xmlElement
(
'FieldValue'
,array(
"id"
=>
"decimals"
),$this->
getDecimals
());
149
}
150
151
public
function
importXMLProperty
($a_key, $a_value)
152
{
153
if
($a_key ==
"decimals"
)
154
{
155
$this->
setDecimals
($a_value !=
""
? $a_value : null);
156
}
157
158
parent::importXMLProperty
($a_key, $a_value);
159
}
160
}
161
162
?>
Services
AdvancedMetaData
classes
Types
class.ilAdvancedMDFieldDefinitionFloat.php
Generated on Wed Apr 27 2016 21:01:28 for ILIAS by
1.8.1.2 (using
Doxyfile
)