ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
class.ilPCTabsGUI.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.ilPCTabs.php");
5require_once("./Services/COPage/classes/class.ilPageContentGUI.php");
6
18{
23 function ilPCTabsGUI(&$a_pg_obj, &$a_content_obj, $a_hier_id, $a_pc_id = "")
24 {
25 parent::ilPageContentGUI($a_pg_obj, $a_content_obj, $a_hier_id, $a_pc_id);
26 }
27
31 function &executeCommand()
32 {
33 // get next class that processes or forwards current command
34 $next_class = $this->ctrl->getNextClass($this);
35
36 // get current command
37 $cmd = $this->ctrl->getCmd();
38
39 switch($next_class)
40 {
41 default:
42 $ret =& $this->$cmd();
43 break;
44 }
45
46 return $ret;
47 }
48
52 function insert($a_omit_form_init = false)
53 {
54 global $tpl;
55
57
58 if (!$a_omit_form_init)
59 {
60 $this->initForm("create");
61 }
62 $html = $this->form->getHTML();
63 $tpl->setContent($html);
64 }
65
69 function editProperties()
70 {
71 global $ilCtrl, $lng, $tpl;
72
74 $this->setTabs();
75
76 $this->initForm();
77 $this->getFormValues();
78 $html = $this->form->getHTML();
79 $tpl->setContent($html);
80 }
81
85 function initForm($a_mode = "edit")
86 {
87 global $ilCtrl, $tpl, $lng;
88
89 include_once("./Services/Accordion/classes/class.ilAccordionGUI.php");
91
92 // edit form
93 include_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
94 $this->form = new ilPropertyFormGUI();
95 $this->form->setFormAction($ilCtrl->getFormAction($this));
96 if ($a_mode != "edit")
97 {
98 $this->form->setTitle($lng->txt("cont_ed_insert_tabs"));
99 }
100 else
101 {
102 $this->form->setTitle($lng->txt("cont_edit_tabs"));
103 }
104
105
106 // type selection
107 $radg = new ilRadioGroupInputGUI($lng->txt("cont_type"), "type");
108 $radg->setValue(ilPCTabs::ACCORDION_VER);
109
110 // type: vertical accordion
111 $op1 = new ilRadioOption($lng->txt("cont_tabs_acc_ver"), ilPCTabs::ACCORDION_VER);
112
113 $templ = $this->getTemplateOptions("vaccordion");
114 require_once("./Services/Form/classes/class.ilAdvSelectInputGUI.php");
115 if (count($templ) > 0)
116 {
117 $vchar_prop = new ilAdvSelectInputGUI($this->lng->txt("cont_characteristic"),
118 "vaccord_templ");
119 foreach($templ as $k => $te)
120 {
121 $t = explode(":", $k);
122 $html = $this->style->lookupTemplatePreview($t[1]).'<div style="clear:both" class="small">'.$te."</div>";
123 $vchar_prop->addOption($k, $te, $html);
124 if ($t[2] == "VerticalAccordion")
125 {
126 $vchar_prop->setValue($k);
127 }
128 }
129 $op1->addSubItem($vchar_prop);
130 }
131 else
132 {
133 $vchar_prop = new ilHiddenInputGUI("vaccord_templ");
134 $this->form->addItem($vchar_prop);
135 }
136 $radg->addOption($op1);
137
138
139
140 // type: horizontal accordion
141 $op2 = new ilRadioOption($lng->txt("cont_tabs_acc_hor"), ilPCTabs::ACCORDION_HOR);
142
143 $templ = $this->getTemplateOptions("haccordion");
144 if (count($templ) > 0)
145 {
146 $hchar_prop = new ilAdvSelectInputGUI($this->lng->txt("cont_characteristic"),
147 "haccord_templ");
148 foreach($templ as $k => $te)
149 {
150 $t = explode(":", $k);
151 $html = $this->style->lookupTemplatePreview($t[1]).'<div style="clear:both" class="small">'.$te."</div>";
152 $hchar_prop->addOption($k, $te, $html);
153 if ($t[2] == "HorizontalAccordion")
154 {
155 $hchar_prop->setValue($k);
156 }
157 }
158 $op2->addSubItem($hchar_prop);
159 }
160 else
161 {
162 $hchar_prop = new ilHiddenInputGUI("haccord_templ");
163 $this->form->addItem($hchar_prop);
164 }
165
166 $radg->addOption($op2);
167
168 // type: carousel
169 $op3 = new ilRadioOption($lng->txt("cont_tabs_carousel"), ilPCTabs::CAROUSEL);
170 $templ = $this->getTemplateOptions("carousel");
171 require_once("./Services/Form/classes/class.ilAdvSelectInputGUI.php");
172 if (count($templ) > 0)
173 {
174 $cchar_prop = new ilAdvSelectInputGUI($this->lng->txt("cont_characteristic"),
175 "carousel_templ");
176 foreach($templ as $k => $te)
177 {
178 $t = explode(":", $k);
179 $html = $this->style->lookupTemplatePreview($t[1]).'<div style="clear:both" class="small">'.$te."</div>";
180 $cchar_prop->addOption($k, $te, $html);
181 if ($t[2] == "Carousel")
182 {
183 $cchar_prop->setValue($k);
184 }
185 }
186 $op3->addSubItem($cchar_prop);
187 }
188 else
189 {
190 $cchar_prop = new ilHiddenInputGUI("carousel_templ");
191 $this->form->addItem($cchar_prop);
192 }
193
194 $radg->addOption($op3);
195 $this->form->addItem($radg);
196
197
198 // number of initial tabs
199 if ($a_mode == "create")
200 {
201 $nr_prop = new ilSelectInputGUI($lng->txt("cont_number_of_tabs"),
202 "nr");
203 $nrs = array(1 => 1, 2 => 2, 3 => 3, 4 => 4, 5 => 5, 6 => 6,
204 7 => 7, 8 => 8, 9 => 9, 10 => 10);
205 $nr_prop->setOptions($nrs);
206 $this->form->addItem($nr_prop);
207 }
208
209 $ni = new ilNumberInputGUI($this->lng->txt("cont_tab_cont_width"), "content_width");
210 $ni->setMaxLength(4);
211 $ni->setSize(4);
212 $this->form->addItem($ni);
213
214 $ni = new ilNumberInputGUI($this->lng->txt("cont_tab_cont_height"), "content_height");
215 $ni->setMaxLength(4);
216 $ni->setSize(4);
217 $this->form->addItem($ni);
218
219 // behaviour
220 $options = array(
221 "AllClosed" => $lng->txt("cont_all_closed"),
222 "FirstOpen" => $lng->txt("cont_first_open"),
223 "ForceAllOpen" => $lng->txt("cont_force_all_open"),
224 );
225 $si = new ilSelectInputGUI($this->lng->txt("cont_behavior"), "vbehavior");
226 $si->setOptions($options);
227 $op1->addSubItem($si);
228 $si = new ilSelectInputGUI($this->lng->txt("cont_behavior"), "hbehavior");
229 $si->setOptions($options);
230 $op2->addSubItem($si);
231
232
233 // alignment
234 $align_opts = array("Left" => $lng->txt("cont_left"),
235 "Right" => $lng->txt("cont_right"), "Center" => $lng->txt("cont_center"),
236 "LeftFloat" => $lng->txt("cont_left_float"),
237 "RightFloat" => $lng->txt("cont_right_float"));
238 $align = new ilSelectInputGUI($this->lng->txt("cont_align"), "valign");
239 $align->setOptions($align_opts);
240 $align->setValue("Center");
241 //$align->setInfo($lng->txt("cont_tabs_hor_align_info"));
242 $op1->addSubItem($align);
243 $align = new ilSelectInputGUI($this->lng->txt("cont_align"), "calign");
244 $align->setOptions($align_opts);
245 $align->setValue("Center");
246 $op3->addSubItem($align);
247
248 // carousel: time
249 $ti = new ilNumberInputGUI($this->lng->txt("cont_auto_time"), "auto_time");
250 $ti->setMaxLength(6);
251 $ti->setSize(6);
252 $ti->setSuffix("ms");
253 $ti->setMinValue(100);
254 $op3->addSubItem($ti);
255
256 // carousel: random start
257 $cb = new ilCheckboxInputGUI($this->lng->txt("cont_rand_start"), "rand_start");
258 //$cb->setOptionTitle($this->lng->txt(""));
259 //$cb->setInfo($this->lng->txt(""));
260 $op3->addSubItem($cb);
261
262
263 // save/cancel buttons
264 if ($a_mode == "create")
265 {
266 $this->form->addCommandButton("create_section", $lng->txt("save"));
267 $this->form->addCommandButton("cancelCreate", $lng->txt("cancel"));
268 }
269 else
270 {
271 $this->form->addCommandButton("update", $lng->txt("save"));
272 $this->form->addCommandButton("cancelUpdate", $lng->txt("cancel"));
273 }
274 }
275
279 function getFormValues()
280 {
281 $values["type"] = $this->content_obj->getTabType();
282 $values["content_width"] = $this->content_obj->getContentWidth();
283 $values["content_height"] = $this->content_obj->getContentHeight();
284 $values["valign"] = $this->content_obj->getHorizontalAlign();
285 $values["calign"] = $this->content_obj->getHorizontalAlign();
286 $values["vbehavior"] = $this->content_obj->getBehavior();
287 $values["hbehavior"] = $this->content_obj->getBehavior();
288
289 $values["auto_time"] = $this->content_obj->getAutoTime();
290 $values["rand_start"] = $this->content_obj->getRandomStart();
291
292 $this->form->setValuesByArray($values);
293
294 if ($values["type"] == ilPCTabs::ACCORDION_VER)
295 {
296 $va = $this->form->getItemByPostVar("vaccord_templ");
297 $v = "t:".
298 ilObjStyleSheet::_lookupTemplateIdByName($this->getStyleId(), $this->content_obj->getTemplate()).":".
299 $this->content_obj->getTemplate();
300 $va->setValue($v);
301 }
302 if ($values["type"] == ilPCTabs::ACCORDION_HOR)
303 {
304 $ha = $this->form->getItemByPostVar("haccord_templ");
305 $v = "t:".
306 ilObjStyleSheet::_lookupTemplateIdByName($this->getStyleId(), $this->content_obj->getTemplate()).":".
307 $this->content_obj->getTemplate();
308 $ha->setValue($v);
309 }
310 if ($values["type"] == ilPCTabs::CAROUSEL)
311 {
312 $ca = $this->form->getItemByPostVar("carousel_templ");
313 $v = "t:".
314 ilObjStyleSheet::_lookupTemplateIdByName($this->getStyleId(), $this->content_obj->getTemplate()).":".
315 $this->content_obj->getTemplate();
316 $ca->setValue($v);
317 }
318 }
319
323 function create()
324 {
325 global $ilDB, $lng;
326
327 $this->initForm("create");
328 if ($this->form->checkInput())
329 {
330 $this->content_obj = new ilPCTabs($this->getPage());
331 $this->content_obj->create($this->pg_obj, $this->hier_id, $this->pc_id);
332
333 $this->setPropertiesByForm();
334
335 for ($i = 0; $i < (int) $_POST["nr"]; $i++)
336 {
337 $this->content_obj->addTab($lng->txt("cont_new_tab"));
338 }
339
340 $this->updated = $this->pg_obj->update();
341
342 if ($this->updated === true)
343 {
344 $this->afterCreation();
345 //$this->ctrl->returnToParent($this, "jump".$this->hier_id);
346 }
347 else
348 {
349 $this->insert();
350 }
351 }
352 else
353 {
354 $this->form->setValuesByPost();
355 $this->insert(true);
356// return $this->form->getHtml();
357 }
358 }
359
363 function afterCreation()
364 {
365 global $ilCtrl;
366
367 $this->pg_obj->stripHierIDs();
368 $this->pg_obj->addHierIDs();
369 $ilCtrl->setParameter($this, "hier_id", $this->content_obj->readHierId());
370 $ilCtrl->setParameter($this, "pc_id", $this->content_obj->readPCId());
371 $this->content_obj->setHierId($this->content_obj->readHierId());
372 $this->setHierId($this->content_obj->readHierId());
373 $this->content_obj->setPCId($this->content_obj->readPCId());
374 $this->edit();
375 }
376
384 {
386 $f = $this->form;
387
388 $c->setTabType($f->getInput("type"));
389
390 $c->setContentWidth($f->getInput("content_width"));
391 $c->setContentHeight($f->getInput("content_height"));
392 $c->setTemplate("");
393 switch ($_POST["type"])
394 {
396 $t = explode(":", $f->getInput("vaccord_templ"));
397 $c->setTemplate($t[2]);
398 $c->setBehavior($f->getInput("vbehavior"));
399 $c->setHorizontalAlign($f->getInput("valign"));
400 break;
401
403 $t = explode(":", $f->getInput("haccord_templ"));
404 $c->setTemplate($t[2]);
405 $c->setBehavior($f->getInput("hbehavior"));
406 break;
407
409 $t = explode(":", $f->getInput("carousel_templ"));
410 $c->setTemplate($t[2]);
411 $c->setHorizontalAlign($f->getInput("calign"));
412 $c->setAutoTime($f->getInput("auto_time"));
413 $c->setRandomStart($f->getInput("rand_start"));
414 break;
415 }
416 }
417
418
422 function update()
423 {
424 $this->initForm();
425 $this->updated = false;
426 if ($this->form->checkInput())
427 {
428 $this->setPropertiesByForm();
429 $this->updated = $this->pg_obj->update();
430 }
431 if ($this->updated === true)
432 {
433 ilUtil::sendSuccess($this->lng->txt("msg_obj_modified"), true);
434 $this->ctrl->redirect($this, "editProperties");
435 //$this->ctrl->returnToParent($this, "jump".$this->hier_id);
436 }
437 else
438 {
439 $this->pg_obj->addHierIDs();
440 $this->editProperties();
441 }
442 }
443
444 //
445 // Edit Tabs
446 //
447
448
452 function edit()
453 {
454 global $tpl, $ilTabs, $ilCtrl, $ilToolbar, $lng;
455
456 $ilToolbar->addButton($lng->txt("cont_add_tab"),
457 $ilCtrl->getLinkTarget($this, "addTab"));
458
459 $this->setTabs();
460 $ilTabs->activateTab("cont_tabs");
461 include_once("./Services/COPage/classes/class.ilPCTabsTableGUI.php");
462 $table_gui = new ilPCTabsTableGUI($this, "edit", $this->content_obj);
463 $tpl->setContent($table_gui->getHTML());
464 }
465
469 function saveTabs()
470 {
471 global $ilCtrl, $lng;
472
473 if (is_array($_POST["caption"]))
474 {
475 $captions = ilUtil::stripSlashesArray($_POST["caption"]);
476 $this->content_obj->saveCaptions($captions);
477 }
478 if (is_array($_POST["position"]))
479 {
480 $positions = ilUtil::stripSlashesArray($_POST["position"]);
481 $this->content_obj->savePositions($positions);
482 }
483 $this->updated = $this->pg_obj->update();
484 ilUtil::sendSuccess($lng->txt("msg_obj_modified"), true);
485 $ilCtrl->redirect($this, "edit");
486 }
487
491 function addTab()
492 {
493 global $lng, $ilCtrl;
494
495 $this->content_obj->addTab($lng->txt("cont_new_tab"));
496 $this->updated = $this->pg_obj->update();
497
498 ilUtil::sendSuccess($lng->txt("cont_added_tab"), true);
499 $ilCtrl->redirect($this, "edit");
500 }
501
506 {
507 global $ilCtrl, $tpl, $lng;
508
509 $this->setTabs();
510
511 if (!is_array($_POST["tid"]) || count($_POST["tid"]) == 0)
512 {
513 ilUtil::sendInfo($lng->txt("no_checkbox"), true);
514 $ilCtrl->redirect($this, "edit");
515 }
516 else
517 {
518 include_once("./Services/Utilities/classes/class.ilConfirmationGUI.php");
519 $cgui = new ilConfirmationGUI();
520 $cgui->setFormAction($ilCtrl->getFormAction($this));
521 $cgui->setHeaderText($lng->txt("cont_tabs_confirm_deletion"));
522 $cgui->setCancel($lng->txt("cancel"), "cancelTabDeletion");
523 $cgui->setConfirm($lng->txt("delete"), "deleteTabs");
524
525 foreach ($_POST["tid"] as $k => $i)
526 {
527 $id = explode(":", $k);
528 $cgui->addItem("tid[]", $k,
529 $this->content_obj->getCaption($id[0], $id[1]));
530 }
531
532 $tpl->setContent($cgui->getHTML());
533 }
534 }
535
540 {
541 global $ilCtrl;
542 $ilCtrl->redirect($this, "edit");
543 }
544
548 function deleteTabs()
549 {
550 global $ilCtrl;
551
552 if (is_array($_POST["tid"]))
553 {
554 foreach($_POST["tid"] as $tid)
555 {
556 $ids = explode(":", $tid);
557 $this->content_obj->deleteTab($ids[0], $ids[1]);
558 }
559 }
560 $this->updated = $this->pg_obj->update();
561
562 $ilCtrl->redirect($this, "edit");
563 }
564
565
569 function setTabs()
570 {
571 global $ilTabs, $ilCtrl, $lng;
572
573 $ilTabs->setBackTarget($lng->txt("pg"),
574 $this->ctrl->getParentReturn($this));
575
576 $ilTabs->addTarget("cont_tabs",
577 $ilCtrl->getLinkTarget($this, "edit"), "edit",
578 get_class($this));
579
580 $ilTabs->addTarget("cont_edit_tabs",
581 $ilCtrl->getLinkTarget($this, "editProperties"), "editProperties",
582 get_class($this));
583
584 }
585}
586?>
static addCss()
Add required css.
This class represents an advanced selection list property in a property form.
This class represents a checkbox property in a property form.
Confirmation screen class.
This class represents a hidden form property in a property form.
This class represents a number property in a property form.
static _lookupTemplateIdByName($a_style_id, $a_name)
Lookup table template preview.
Class ilPCTabsGUI.
cancelTabDeletion()
Cancel tab deletion.
update()
Save tabs properties in db and return to page edit screen.
ilPCTabsGUI(&$a_pg_obj, &$a_content_obj, $a_hier_id, $a_pc_id="")
Constructor @access public.
confirmTabsDeletion()
Confirm tabs deletion.
afterCreation()
After creation processing.
insert($a_omit_form_init=false)
Insert new tabs.
& executeCommand()
execute command
deleteTabs()
Delete Tabs.
initForm($a_mode="edit")
Insert tabs form.
editProperties()
Edit tabs.
edit()
List all tabs.
getFormValues()
Get form values.
setTabs()
Set tabs.
setPropertiesByForm()
Set properties by post.
create()
Create new tabs in dom and update page in db.
addTab()
Save tabs properties in db and return to page edit screen.
saveTabs()
Save tabs properties in db and return to page edit screen.
TableGUI class for tabs.
Class ilPCTabs.
const CAROUSEL
const ACCORDION_HOR
const ACCORDION_VER
User Interface for Editing of Page Content Objects (Paragraphs, Tables, ...)
getTemplateOptions($a_type)
Get table templates.
displayValidationError()
display validation errors
setHierId($a_hier_id)
get hierarchical id in dom object
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.
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
static stripSlashesArray($a_arr, $a_strip_html=true, $a_allow="")
Strip slashes from array.
$_POST['username']
Definition: cron.php:12
$html
Definition: example_001.php:87
global $ilCtrl
Definition: ilias.php:18
$cmd
Definition: sahs_server.php:35
global $ilDB
if(!is_array($argv)) $options