ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
class.ilADTEnumDefinition.php
Go to the documentation of this file.
1<?php
2
4{
5 protected $options; // [array]
6 protected $numeric; // [bool]
7
8 public function getType()
9 {
10 return "Enum";
11 }
12
13
14 // default
15
16 public function reset()
17 {
18 parent::reset();
19
20 $this->options = array();
21 $this->setNumeric(true);
22 }
23
24
25 // properties
26
27 public function isNumeric()
28 {
29 return $this->numeric;
30 }
31
32 public function setNumeric($a_value)
33 {
34 $this->numeric = $a_value;
35 }
36
37 public function getOptions()
38 {
39 return $this->options;
40 }
41
42 public function setOptions(array $a_values)
43 {
44 if($this->isNumeric())
45 {
46 foreach(array_keys($a_values) as $key)
47 {
48 if(!is_numeric($key))
49 {
50 throw new Exception("ilADTEnum was expecting numeric option keys");
51 }
52 }
53 }
54
55 $this->options = $a_values;
56 }
57
58
59 // comparison
60
61 public function isComparableTo(ilADT $a_adt)
62 {
63 // has to be enum-based
64 return ($a_adt instanceof ilADTEnum);
65 }
66
67
68 // ADT instance
69
70 public function getADTInstance()
71 {
72 if($this->isNumeric())
73 {
74 $class = "ilADTEnumNumeric";
75 }
76 else
77 {
78 $class = "ilADTEnumText";
79 }
80 include_once "Services/ADT/classes/Types/Enum/class.ilADTEnum.php";
81 include_once "Services/ADT/classes/Types/Enum/class.".$class.".php";
82 return new $class($this);
83 }
84}
85
86?>
ADT definition base class.
isComparableTo(ilADT $a_adt)
Check if given ADT is comparable to self.
reset()
Init property defaults.
getType()
Get type (from class/instance)
ADT base class.
Definition: class.ilADT.php:12