ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
class.ilPCMyCoursesGUI.php
Go to the documentation of this file.
1<?php
2
3/* Copyright (c) 1998-2019 ILIAS open source, Extended GPL, see docs/LICENSE */
4
13{
18 public function __construct($a_pg_obj, $a_content_obj, $a_hier_id, $a_pc_id = "")
19 {
20 global $DIC;
21
22 $this->tpl = $DIC["tpl"];
23 $this->ctrl = $DIC->ctrl();
24 parent::__construct($a_pg_obj, $a_content_obj, $a_hier_id, $a_pc_id);
25 }
26
30 public function executeCommand()
31 {
32 // get next class that processes or forwards current command
33 $next_class = $this->ctrl->getNextClass($this);
34
35 // get current command
36 $cmd = $this->ctrl->getCmd();
37
38 switch ($next_class) {
39 default:
40 $ret = &$this->$cmd();
41 break;
42 }
43
44 return $ret;
45 }
46
52 public function insert(ilPropertyFormGUI $a_form = null)
53 {
55
56 /* #12816 - no form needed yet
57 $this->create();
58 */
59
61
62 if (!$a_form) {
63 $a_form = $this->initForm(true);
64 }
65 $tpl->setContent($a_form->getHTML());
66 }
67
73 public function edit(ilPropertyFormGUI $a_form = null)
74 {
76
78
79 if (!$a_form) {
80 $a_form = $this->initForm();
81 }
82 $tpl->setContent($a_form->getHTML());
83 }
84
91 protected function initForm($a_insert = false)
92 {
94
95 $form = new ilPropertyFormGUI();
96 $form->setFormAction($ilCtrl->getFormAction($this));
97 if ($a_insert) {
98 $form->setTitle($this->lng->txt("cont_insert_my_courses"));
99 } else {
100 $form->setTitle($this->lng->txt("cont_update_my_courses"));
101 }
102
103 $sort = new ilRadioGroupInputGUI($this->lng->txt("cont_mycourses_sortorder"), "sort");
104 $sort->setInfo($this->lng->txt("cont_mycourses_sortorder_info")); //#15511
105 $sort->setRequired(true);
106 $form->addItem($sort);
107
108 $sort->addOption(new ilRadioOption($this->lng->txt("cont_mycourses_sortorder_alphabetical"), "alpha"));
109 $sort->addOption(new ilRadioOption($this->lng->txt("cont_mycourses_sortorder_location"), "loc"));
110
111 if ($a_insert) {
112 $sort->setValue("alpha");
113
114 $form->addCommandButton("create_my_courses", $this->lng->txt("save"));
115 $form->addCommandButton("cancelCreate", $this->lng->txt("cancel"));
116 } else {
117 $sort->setValue($this->content_obj->getSorting());
118
119 $form->addCommandButton("update", $this->lng->txt("save"));
120 $form->addCommandButton("cancelUpdate", $this->lng->txt("cancel"));
121 }
122
123 return $form;
124 }
125
129 public function create()
130 {
131 $form = $this->initForm(true);
132 if ($form->checkInput()) {
133 $sort = $form->getInput("sort");
134
135 $this->content_obj = new ilPCMyCourses($this->getPage());
136 $this->content_obj->create($this->pg_obj, $this->hier_id, $this->pc_id);
137 $this->content_obj->setData($sort);
138 $this->updated = $this->pg_obj->update();
139 if ($this->updated === true) {
140 $this->ctrl->returnToParent($this, "jump" . $this->hier_id);
141 }
142 }
143
144 $form->setValuesByPost();
145 return $this->insert($form);
146 }
147
151 public function update()
152 {
153 $form = $this->initForm();
154 if ($form->checkInput()) {
155 $sort = $form->getInput("sort");
156
157 $this->content_obj->setData($sort);
158 $this->updated = $this->pg_obj->update();
159 if ($this->updated === true) {
160 $this->ctrl->returnToParent($this, "jump" . $this->hier_id);
161 }
162 }
163
164 $this->pg_obj->addHierIDs();
165 $form->setValuesByPost();
166 return $this->edit($form);
167 }
168}
An exception for terminatinating execution or to throw for unit testing.
Class ilPCMyCoursesGUI.
__construct($a_pg_obj, $a_content_obj, $a_hier_id, $a_pc_id="")
Constructor @access public.
initForm($a_insert=false)
Init courses form.
create()
Create new courses.
edit(ilPropertyFormGUI $a_form=null)
Edit courses form.
insert(ilPropertyFormGUI $a_form=null)
Insert courses form.
executeCommand()
execute command
Class ilPCMyCourses.
User Interface for Editing of Page Content Objects (Paragraphs, Tables, ...)
displayValidationError()
display validation errors
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.
global $ilCtrl
Definition: ilias.php:18
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
$ret
Definition: parser.php:6
$DIC
Definition: xapitoken.php:46