ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
class.ilPCList.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/COPage/classes/class.ilPageContent.php");
5 
16 class ilPCList extends ilPageContent
17 {
18  public $list_node;
19 
23  public function init()
24  {
25  $this->setType("list");
26  }
27 
31  public function setNode($a_node)
32  {
33  parent::setNode($a_node); // this is the PageContent node
34  $this->list_node = $a_node->first_child(); // this is the Table node
35  }
36 
40  public function create(&$a_pg_obj, $a_hier_id, $a_pc_id = "")
41  {
42  $this->node = $this->createPageContentNode();
43  $a_pg_obj->insertContent($this, $a_hier_id, IL_INSERT_AFTER, $a_pc_id);
44  $this->list_node = $this->dom->create_element("List");
45  $this->list_node = $this->node->append_child($this->list_node);
46  }
47 
51  public function addItems($a_nr)
52  {
53  for ($i=1; $i<=$a_nr; $i++) {
54  $new_item = $this->dom->create_element("ListItem");
55  $new_item = $this->list_node->append_child($new_item);
56  }
57  }
58 
62  /* function setOrderType($a_type = "Unordered")
63  {
64  switch ($a_type)
65  {
66  case "Unordered":
67  $this->list_node->set_attribute("Type", "Unordered");
68  if ($this->list_node->has_attribute("NumberingType"))
69  {
70  $this->list_node->remove_attribute("NumberingType");
71  }
72  break;
73 
74  case "Number":
75  case "Roman":
76  case "roman":
77  case "Alphabetic":
78  case "alphabetic":
79  case "Decimal":
80  $this->list_node->set_attribute("Type", "Ordered");
81  $this->list_node->set_attribute("NumberingType", $a_type);
82  break;
83  }
84  }*/
85 
89  public function getOrderType()
90  {
91  if ($this->list_node->get_attribute("Type") == "Unordered") {
92  return "Unordered";
93  }
94 
95  $nt = $this->list_node->get_attribute("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  break;
105 
106  default:
107  return "Number";
108  }
109  }
110 
114  public function getListType()
115  {
116  if ($this->list_node->get_attribute("Type") == "Unordered") {
117  return "Unordered";
118  }
119  return "Ordered";
120  }
121 
127  public function setListType($a_val)
128  {
129  $this->list_node->set_attribute("Type", $a_val);
130  }
131 
135  public function getNumberingType()
136  {
137  $nt = $this->list_node->get_attribute("NumberingType");
138  switch ($nt) {
139  case "Number":
140  case "Roman":
141  case "roman":
142  case "Alphabetic":
143  case "alphabetic":
144  case "Decimal":
145  return $nt;
146  break;
147 
148  default:
149  return "Number";
150  }
151  }
152 
158  public function setNumberingType($a_val)
159  {
160  if ($a_val != "") {
161  $this->list_node->set_attribute("NumberingType", $a_val);
162  } else {
163  if ($this->list_node->has_attribute("NumberingType")) {
164  $this->list_node->remove_attribute("NumberingType");
165  }
166  }
167  }
168 
174  public function setStartValue($a_val)
175  {
176  if ($a_val != "") {
177  $this->list_node->set_attribute("StartValue", $a_val);
178  } else {
179  if ($this->list_node->has_attribute("StartValue")) {
180  $this->list_node->remove_attribute("StartValue");
181  }
182  }
183  }
184 
190  public function getStartValue()
191  {
192  return $this->list_node->get_attribute("StartValue");
193  }
194 
200  public function setStyleClass($a_val)
201  {
202  if (!in_array($a_val, array("", "BulletedList", "NumberedList"))) {
203  $this->list_node->set_attribute("Class", $a_val);
204  } else {
205  if ($this->list_node->has_attribute("Class")) {
206  $this->list_node->remove_attribute("Class");
207  }
208  }
209  }
210 
216  public function getStyleClass()
217  {
218  return $this->list_node->get_attribute("Class");
219  }
220 }
setStartValue($a_val)
Set start value.
setListType($a_val)
Set list type.
getOrderType()
Set order type.
setType($a_type)
Set Type.
addItems($a_nr)
Add a number of items to list.
Class ilPageContent.
getListType()
Get list type.
setStyleClass($a_val)
Set style class.
getNumberingType()
Get numbering type.
const IL_INSERT_AFTER
Create styles array
The data for the language used.
Class ilPCList.
createPageContentNode($a_set_this_node=true)
Create page content node (always use this method first when adding a new element) ...
create(&$a_pg_obj, $a_hier_id, $a_pc_id="")
Create new list.
setNumberingType($a_val)
Set numbering type.
getStartValue()
Get start value.
$i
Definition: disco.tpl.php:19
init()
Init page content component.
setNode($a_node)
Set pc node.
getStyleClass()
Get style class.