ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
class.ilADTMultiEnum.php
Go to the documentation of this file.
1<?php
2
3abstract class ilADTMultiEnum extends ilADT
4{
5 protected $values; // [array]
6
7 public function getType()
8 {
9 return "MultiEnum";
10 }
11
12
13 // definition
14
15 protected function isValidDefinition(ilADTDefinition $a_def)
16 {
17 return ($a_def instanceof ilADTMultiEnumDefinition);
18 }
19
20 public function reset()
21 {
22 parent::reset();
23
24 $this->values = null;
25 }
26
27
28 // properties
29
30 abstract protected function handleSelectionValue($a_value);
31
32 public function setSelections(array $a_values = null)
33 {
34 if($a_values !== null)
35 {
36 foreach($a_values as $idx => $value)
37 {
38 $value = $this->handleSelectionValue($value);
39 if(!$this->isValidOption($value))
40 {
41 unset($a_values[$idx]);
42 }
43 }
44 if(!sizeof($a_values))
45 {
46 $a_values = null;
47 }
48 }
49 $this->values = $a_values;
50 }
51
52 public function getSelections()
53 {
54 return $this->values;
55 }
56
57 public function isValidOption($a_value)
58 {
59 $a_value = $this->handleSelectionValue($a_value);
60 return array_key_exists($a_value, $this->getDefinition()->getOptions());
61 }
62
63
64 // comparison
65
66 public function equals(ilADT $a_adt)
67 {
68 if($this->getDefinition()->isComparableTo($a_adt))
69 {
70 return ($this->getCheckSum() === $a_adt->getCheckSum());
71 }
72 }
73
74 public function isLarger(ilADT $a_adt)
75 {
76 // return null?
77 }
78
79 public function isSmaller(ilADT $a_adt)
80 {
81 // return null?
82 }
83
84
85 // null
86
87 public function isNull()
88 {
89 return ($this->getSelections() === null);
90 }
91
92
93 // check
94
95 public function getCheckSum()
96 {
97 if(!$this->isNull())
98 {
99 $current = $this->getSelections();
100 sort($current);
101 return md5(implode(",", $current));
102 }
103 }
104}
105
106?>
ADT definition base class.
isSmaller(ilADT $a_adt)
Check if given ADT is smaller than self.
isValidDefinition(ilADTDefinition $a_def)
Check if definition is valid for ADT.
getType()
Get type (from class/instance)
reset()
Init property defaults.
setSelections(array $a_values=null)
handleSelectionValue($a_value)
equals(ilADT $a_adt)
Check if given ADT equals self.
getCheckSum()
Get unique checksum.
isNull()
Is currently null.
isLarger(ilADT $a_adt)
Check if given ADT is larger than self.
ADT base class.
Definition: class.ilADT.php:12
getCheckSum()
Get unique checksum.
getDefinition()
Get definition.
Definition: class.ilADT.php:99