ILIAS  release_7 Revision v7.30-3-g800a261c036
class.ilPCListGUI.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */
3
4require_once("./Services/COPage/classes/class.ilPCList.php");
5require_once("./Services/COPage/classes/class.ilPageContentGUI.php");
6
18{
19
24 public function __construct(&$a_pg_obj, &$a_content_obj, $a_hier_id, $a_pc_id = "")
25 {
26 global $DIC;
27
28 $this->tpl = $DIC["tpl"];
29 $this->lng = $DIC->language();
30 $this->ctrl = $DIC->ctrl();
31 parent::__construct($a_pg_obj, $a_content_obj, $a_hier_id, $a_pc_id);
32 }
33
37 public function executeCommand()
38 {
39 // get next class that processes or forwards current command
40 $next_class = $this->ctrl->getNextClass($this);
41
42 // get current command
43 $cmd = $this->ctrl->getCmd();
44
45 switch ($next_class) {
46 default:
47 $ret = $this->$cmd();
48 break;
49 }
50
51 return $ret;
52 }
53
54
58 public function insert()
59 {
61
62 $this->initListForm("create");
63 $this->tpl->setContent($this->form->getHTML());
64 }
65
66
70 public function create()
71 {
74 $ilCtrl = $this->ctrl;
75
76 $this->initListForm("create");
77 if ($this->form->checkInput()) {
78 $this->content_obj = new ilPCList($this->getPage());
79 $this->content_obj->create($this->pg_obj, $this->hier_id, $this->pc_id);
80 $this->content_obj->addItems($_POST["nr_items"]);
81 $this->content_obj->setStartValue($_POST["start_value"]);
82 $this->content_obj->setListType($_POST["list_type"]);
83 if ($_POST["list_type"] == "Unordered") {
84 $this->content_obj->setNumberingType("");
85 $this->content_obj->setStyleClass($_POST["bullet_style"]);
86 } else {
87 $this->content_obj->setNumberingType($_POST["numbering_type"]);
88 $this->content_obj->setStyleClass($_POST["number_style"]);
89 }
90 $this->updated = $this->pg_obj->update();
91 if ($this->updated === true) {
92 $this->ctrl->returnToParent($this, "jump" . $this->hier_id);
93 }
94 }
95 $this->form->setValuesByPost();
96 $tpl->setContent($this->form->getHtml());
97 }
98
102 public function edit()
103 {
104 $this->displayValidationError();
105
106 $this->initListForm("edit");
107 $this->getValues();
108 $this->tpl->setContent($this->form->getHTML());
109 }
110
114 public function saveProperties()
115 {
117 $ilCtrl = $this->ctrl;
119
120 $this->initListForm("edit");
121 if ($this->form->checkInput()) {
122 $this->content_obj->setStartValue($_POST["start_value"]);
123 $this->content_obj->setListType($_POST["list_type"]);
124 if ($_POST["list_type"] == "Unordered") {
125 $this->content_obj->setNumberingType("");
126 $this->content_obj->setStyleClass($_POST["bullet_style"]);
127 } else {
128 $this->content_obj->setNumberingType($_POST["numbering_type"]);
129 $this->content_obj->setStyleClass($_POST["number_style"]);
130 }
131
132 $this->updated = $this->pg_obj->update();
133 if ($this->updated === true) {
134 $this->ctrl->returnToParent($this, "jump" . $this->hier_id);
135 }
136 }
137 $this->form->setValuesByPost();
138 $tpl->setContent($this->form->getHtml());
139 }
140
146 public function initListForm($a_mode = "edit")
147 {
149 include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
150 $this->form = new ilPropertyFormGUI();
151
152 // type
153 $radg = new ilRadioGroupInputGUI($lng->txt("type"), "list_type");
154 $op1 = new ilRadioOption($lng->txt("cont_bullet_list"), "Unordered");
155
156 // style of bullet list
157 require_once("./Services/Form/classes/class.ilAdvSelectInputGUI.php");
158 $style = new ilAdvSelectInputGUI(
159 $this->lng->txt("cont_style"),
160 "bullet_style"
161 );
162 $this->getCharacteristicsOfCurrentStyle("list_u");
163 $options = $this->getCharacteristics();
164 if ($a_mode == "edit" && $this->content_obj->getListType() == "Unordered"
165 && $this->content_obj->getStyleClass() != ""
166 && !in_array($this->content_obj->getStyleClass(), $options)) {
167 $options[$this->content_obj->getStyleClass()] =
168 $this->content_obj->getStyleClass();
169 }
170 if (count($options) > 1) {
171 foreach ($options as $k => $option) {
172 $html = '<ul class="ilc_list_u_' . $k . '"><li class="ilc_list_item_StandardListItem">' .
173 $option . '</li></ul>';
174 if ($k == "BulletedList") {
175 $k = "";
176 }
177 $style->addOption($k, $option, $html);
178 }
179 $style->setValue("");
180 $op1->addSubItem($style);
181 }
182
183 $radg->addOption($op1);
184
185
186 $op2 = new ilRadioOption($lng->txt("cont_numbered_list"), "Ordered");
187
188 // style of numbered list
189 require_once("./Services/Form/classes/class.ilAdvSelectInputGUI.php");
190 $style = new ilAdvSelectInputGUI(
191 $this->lng->txt("cont_style"),
192 "number_style"
193 );
194 $this->getCharacteristicsOfCurrentStyle("list_o");
195 $options = $this->getCharacteristics();
196 if ($a_mode == "edit" && $this->content_obj->getListType() == "Ordered"
197 && $this->content_obj->getStyleClass() != ""
198 && !in_array($this->content_obj->getStyleClass(), $options)) {
199 $options[$this->content_obj->getStyleClass()] =
200 $this->content_obj->getStyleClass();
201 }
202 if (count($options) > 1) {
203 foreach ($options as $k => $option) {
204 $html = '<ol class="ilc_list_o_' . $k . '"><li class="ilc_list_item_StandardListItem">' .
205 $option . '</li></ol>';
206 if ($k == "NumberedList") {
207 $k = "";
208 }
209 $style->addOption($k, $option, $html);
210 }
211 $style->setValue("");
212 $op2->addSubItem($style);
213 }
214
215 // numeric type
216 $options = array(
217 "Number" => $this->lng->txt("cont_number_std"),
218 "Decimal" => $this->lng->txt("cont_decimal"),
219 "Roman" => $this->lng->txt("cont_roman"),
220 "roman" => $this->lng->txt("cont_roman_s"),
221 "Alphabetic" => $this->lng->txt("cont_alphabetic"),
222 "alphabetic" => $this->lng->txt("cont_alphabetic_s")
223 );
224 $si = new ilSelectInputGUI($this->lng->txt("cont_number_type"), "numbering_type");
225 $si->setOptions($options);
226 $op2->addSubItem($si);
227
228 // starting value
229 $ni = new ilNumberInputGUI($this->lng->txt("cont_start_value"), "start_value");
230 $ni->setMaxLength(3);
231 $ni->setSize(3);
232 $ni->setInfo($lng->txt("cont_start_value_info"));
233 $op2->addSubItem($ni);
234
235 $radg->addOption($op2);
236 $radg->setValue("Unordered");
237 $this->form->addItem($radg);
238
239 // nr of items
240 $options = array();
241 if ($a_mode == "create") {
242 for ($i = 1; $i <= 10; $i++) {
243 $options[$i] = $i;
244 }
245 $si = new ilSelectInputGUI($this->lng->txt("cont_nr_items"), "nr_items");
246 $si->setOptions($options);
247 $si->setValue(2);
248 $this->form->addItem($si);
249 }
250
251 // save and cancel commands
252 if ($a_mode == "create") {
253 $this->form->addCommandButton("create_list", $lng->txt("save"));
254 $this->form->addCommandButton("cancelCreate", $lng->txt("cancel"));
255 $this->form->setTitle($lng->txt("cont_insert_list"));
256 } else {
257 $this->form->addCommandButton("saveProperties", $lng->txt("save"));
258 $this->form->addCommandButton("cancelUpdate", $lng->txt("cancel"));
259 $this->form->setTitle($lng->txt("cont_list_properties"));
260 }
261
262 $this->form->setFormAction($this->ctrl->getFormAction($this));
263 }
264
269 public function getValues()
270 {
272
273 $values = array();
274
275 $values["start_value"] = $this->content_obj->getStartValue();
276 $values["list_type"] = $this->content_obj->getListType();
277 $values["numbering_type"] = $this->content_obj->getNumberingType();
278 if ($values["list_type"] == "Ordered") {
279 $values["number_style"] = $this->content_obj->getStyleClass();
280 $values["bullet_style"] = "";
281 } else {
282 $values["bullet_style"] = $this->content_obj->getStyleClass();
283 $values["number_style"] = "";
284 }
285 $this->form->setValuesByArray($values);
286 }
287}
$_POST["username"]
An exception for terminatinating execution or to throw for unit testing.
This class represents an advanced selection list property in a property form.
This class represents a number property in a property form.
Class ilPCListGUI.
edit()
edit properties form
executeCommand()
execute command
create()
Save list.
saveProperties()
Save properties.
insert()
insert new list form
initListForm($a_mode="edit")
Init list form.
__construct(&$a_pg_obj, &$a_content_obj, $a_hier_id, $a_pc_id="")
Constructor @access public.
getValues()
Get current values for list from.
Class ilPCList.
User Interface for Editing of Page Content Objects (Paragraphs, Tables, ...)
getCharacteristicsOfCurrentStyle($a_type)
Get characteristics of current style.
displayValidationError()
display validation errors
getCharacteristics()
Get characteristics.
This class represents a property form user interface.
This class represents a property in a property form.
This class represents an option in a radio group.
This class represents a selection list property in a property form.
global $DIC
Definition: goto.php:24
$i
Definition: metadata.php:24
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
$ret
Definition: parser.php:6