ILIAS  release_8 Revision v8.24
class.ilPCList.php
Go to the documentation of this file.
1<?php
2
27{
29
30 public function init(): void
31 {
32 $this->setType("list");
33 }
34
35 public function setNode(php4DOMElement $a_node): void
36 {
37 parent::setNode($a_node); // this is the PageContent node
38 $this->list_node = $a_node->first_child(); // this is the Table node
39 }
40
41 public function create(
42 ilPageObject $a_pg_obj,
43 string $a_hier_id,
44 string $a_pc_id = ""
45 ): void {
46 $this->node = $this->createPageContentNode();
47 $a_pg_obj->insertContent($this, $a_hier_id, IL_INSERT_AFTER, $a_pc_id);
48 $this->list_node = $this->dom->create_element("List");
49 $this->list_node = $this->node->append_child($this->list_node);
50 }
51
55 public function addItems(int $a_nr): void
56 {
57 for ($i = 1; $i <= $a_nr; $i++) {
58 $new_item = $this->dom->create_element("ListItem");
59 $new_item = $this->list_node->append_child($new_item);
60 }
61 }
62
63
67 public function getOrderType(): string
68 {
69 if ($this->list_node->get_attribute("Type") == "Unordered") {
70 return "Unordered";
71 }
72
73 $nt = $this->list_node->get_attribute("NumberingType");
74 switch ($nt) {
75 case "Number":
76 case "Roman":
77 case "roman":
78 case "Alphabetic":
79 case "alphabetic":
80 case "Decimal":
81 return $nt;
82
83 default:
84 return "Number";
85 }
86 }
87
88 public function getListType(): string
89 {
90 if ($this->list_node->get_attribute("Type") == "Unordered") {
91 return "Unordered";
92 }
93 return "Ordered";
94 }
95
96 public function setListType(string $a_val): void
97 {
98 $this->list_node->set_attribute("Type", $a_val);
99 }
100
104 public function getNumberingType(): string
105 {
106 $nt = $this->list_node->get_attribute("NumberingType");
107 switch ($nt) {
108 case "Number":
109 case "Roman":
110 case "roman":
111 case "Alphabetic":
112 case "alphabetic":
113 case "Decimal":
114 return $nt;
115
116 default:
117 return "Number";
118 }
119 }
120
121 public function setNumberingType(string $a_val): void
122 {
123 if ($a_val != "") {
124 $this->list_node->set_attribute("NumberingType", $a_val);
125 } else {
126 if ($this->list_node->has_attribute("NumberingType")) {
127 $this->list_node->remove_attribute("NumberingType");
128 }
129 }
130 }
131
132 public function setStartValue(int $a_val): void
133 {
134 if ($a_val != "") {
135 $this->list_node->set_attribute("StartValue", $a_val);
136 } else {
137 if ($this->list_node->has_attribute("StartValue")) {
138 $this->list_node->remove_attribute("StartValue");
139 }
140 }
141 }
142
143 public function getStartValue(): int
144 {
145 return (int) $this->list_node->get_attribute("StartValue");
146 }
147
148 public function setStyleClass(string $a_val): void
149 {
150 if (!in_array($a_val, array("", "BulletedList", "NumberedList"))) {
151 $this->list_node->set_attribute("Class", $a_val);
152 } else {
153 if ($this->list_node->has_attribute("Class")) {
154 $this->list_node->remove_attribute("Class");
155 }
156 }
157 }
158
159 public function getStyleClass(): string
160 {
161 return $this->list_node->get_attribute("Class");
162 }
163}
const IL_INSERT_AFTER
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
setNode(php4DOMElement $a_node)
Set xml node of page content.
create(ilPageObject $a_pg_obj, string $a_hier_id, string $a_pc_id="")
addItems(int $a_nr)
Add a number of items to list.
php4DOMElement $list_node
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)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
createPageContentNode(bool $a_set_this_node=true)
Create page content node (always use this method first when adding a new element)
setType(string $a_type)
Set Type.
Class ilPageObject Handles PageObjects of ILIAS Learning Modules (see ILIAS DTD)
insertContent(ilPageContent $a_cont_obj, string $a_pos, int $a_mode=IL_INSERT_AFTER, string $a_pcid="", bool $remove_placeholder=true)
insert a content node before/after a sibling or as first child of a parent
$i
Definition: metadata.php:41