ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilPCList.php
Go to the documentation of this file.
1<?php
2
27{
28 public function init(): void
29 {
30 $this->setType("list");
31 }
32
33 public function create(
34 ilPageObject $a_pg_obj,
35 string $a_hier_id,
36 string $a_pc_id = ""
37 ): void {
38 $this->createInitialChildNode($a_hier_id, $a_pc_id, "List");
39 }
40
44 public function addItems(int $a_nr): void
45 {
46 for ($i = 1; $i <= $a_nr; $i++) {
47 $new_item = $this->dom_doc->createElement("ListItem");
48 $new_item = $this->getChildNode()->appendChild($new_item);
49 }
50 }
51
52
56 public function getOrderType(): string
57 {
58 if ($this->getChildNode()->getAttribute("Type") == "Unordered") {
59 return "Unordered";
60 }
61
62 $nt = $this->getChildNode()->getAttribute("NumberingType");
63 switch ($nt) {
64 case "Number":
65 case "Roman":
66 case "roman":
67 case "Alphabetic":
68 case "alphabetic":
69 case "Decimal":
70 return $nt;
71
72 default:
73 return "Number";
74 }
75 }
76
77 public function getListType(): string
78 {
79 if ($this->getChildNode()->getAttribute("Type") == "Unordered") {
80 return "Unordered";
81 }
82 return "Ordered";
83 }
84
85 public function setListType(string $a_val): void
86 {
87 $this->getChildNode()->setAttribute("Type", $a_val);
88 }
89
93 public function getNumberingType(): string
94 {
95 $nt = $this->getChildNode()->getAttribute("NumberingType");
96 switch ($nt) {
97 case "Number":
98 case "Roman":
99 case "roman":
100 case "Alphabetic":
101 case "alphabetic":
102 case "Decimal":
103 return $nt;
104
105 default:
106 return "Number";
107 }
108 }
109
110 public function setNumberingType(string $a_val): void
111 {
112 if ($a_val != "") {
113 $this->getChildNode()->setAttribute("NumberingType", $a_val);
114 } else {
115 if ($this->getChildNode()->hasAttribute("NumberingType")) {
116 $this->getChildNode()->removeAttribute("NumberingType");
117 }
118 }
119 }
120
121 public function setStartValue(int $a_val): void
122 {
123 if ($a_val != "") {
124 $this->getChildNode()->setAttribute("StartValue", $a_val);
125 } else {
126 if ($this->getChildNode()->hasAttribute("StartValue")) {
127 $this->getChildNode()->removeAttribute("StartValue");
128 }
129 }
130 }
131
132 public function getStartValue(): int
133 {
134 return (int) $this->getChildNode()->getAttribute("StartValue");
135 }
136
137 public function setStyleClass(string $a_val): void
138 {
139 if (!in_array($a_val, array("", "BulletedList", "NumberedList"))) {
140 $this->getChildNode()->setAttribute("Class", $a_val);
141 } else {
142 if ($this->getChildNode()->hasAttribute("Class")) {
143 $this->getChildNode()->removeAttribute("Class");
144 }
145 }
146 }
147
148 public function setItemStyleClass(string $a_val): void
149 {
150 if (!in_array($a_val, array("", "StandardListItem"))) {
151 $this->getChildNode()->setAttribute("ItemClass", $a_val);
152 } else {
153 if ($this->getChildNode()->hasAttribute("ItemClass")) {
154 $this->getChildNode()->removeAttribute("ItemClass");
155 }
156 }
157 }
158
159 public function getStyleClass(): string
160 {
161 return $this->getChildNode()->getAttribute("Class");
162 }
163
164 public function getItemStyleClass(): string
165 {
166 return $this->getChildNode()->getAttribute("ItemClass");
167 }
168}
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
create(ilPageObject $a_pg_obj, string $a_hier_id, string $a_pc_id="")
addItems(int $a_nr)
Add a number of items to list.
setItemStyleClass(string $a_val)
getOrderType()
Get order type.
setStartValue(int $a_val)
init()
Init object.
getNumberingType()
Get numbering type.
setNumberingType(string $a_val)
setListType(string $a_val)
setStyleClass(string $a_val)
Content object of ilPageObject (see ILIAS DTD).
createInitialChildNode(string $hier_id, string $pc_id, string $child, array $child_attributes=[])
setType(string $a_type)
Set Type.
Class ilPageObject Handles PageObjects of ILIAS Learning Modules (see ILIAS DTD)