ILIAS  release_7 Revision v7.30-3-g800a261c036
class.ilPCLearningHistoryGUI.php
Go to the documentation of this file.
1<?php
2/*
3 +-----------------------------------------------------------------------------+
4 | ILIAS open source |
5 +-----------------------------------------------------------------------------+
6 | Copyright (c) 1998-2001 ILIAS open source, University of Cologne |
7 | |
8 | This program is free software; you can redistribute it and/or |
9 | modify it under the terms of the GNU General Public License |
10 | as published by the Free Software Foundation; either version 2 |
11 | of the License, or (at your option) any later version. |
12 | |
13 | This program is distributed in the hope that it will be useful, |
14 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16 | GNU General Public License for more details. |
17 | |
18 | You should have received a copy of the GNU General Public License |
19 | along with this program; if not, write to the Free Software |
20 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
21 +-----------------------------------------------------------------------------+
22*/
23
24require_once("./Services/COPage/classes/class.ilPCSkills.php");
25require_once("./Services/COPage/classes/class.ilPageContentGUI.php");
26
38{
42 protected $user;
43
47 protected $ui;
48
52 protected $service;
53
57 public function __construct(ilPageObject $a_pg_obj, ilPCLearningHistory $a_content_obj = null, $a_hier_id = "", $a_pc_id = "")
58 {
59 global $DIC;
60
61 $this->tpl = $DIC["tpl"];
62 $this->ctrl = $DIC->ctrl();
63 $this->user = $DIC->user();
64 $this->lng = $DIC->language();
65 $this->lng->loadLanguageModule("lhist");
66 parent::__construct($a_pg_obj, $a_content_obj, $a_hier_id, $a_pc_id);
67 $this->service = $DIC->learningHistory();
68 $this->ui = $DIC->ui();
69 }
70
74 public function executeCommand()
75 {
76 // get next class that processes or forwards current command
77 $next_class = $this->ctrl->getNextClass($this);
78
79 // get current command
80 $cmd = $this->ctrl->getCmd();
81
82 switch ($next_class) {
83 default:
84 $ret = $this->$cmd();
85 break;
86 }
87
88 return $ret;
89 }
90
96 public function insert(ilPropertyFormGUI $a_form = null)
97 {
99
100 $this->displayValidationError();
101
102 if (!$a_form) {
103 $a_form = $this->initForm(true);
104 }
105 $tpl->setContent($a_form->getHTML());
106 }
107
113 public function edit(ilPropertyFormGUI $a_form = null)
114 {
116
117 $this->displayValidationError();
118
119 if (!$a_form) {
120 $a_form = $this->initForm();
121 }
122 $tpl->setContent($a_form->getHTML());
123 }
124
131 protected function initForm($a_insert = false)
132 {
133 $ilCtrl = $this->ctrl;
136
137 include_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
138 $form = new ilPropertyFormGUI();
139 $form->setFormAction($ilCtrl->getFormAction($this));
140 if ($a_insert) {
141 $form->setTitle($this->lng->txt("cont_create_lhist"));
142 } else {
143 $form->setTitle($this->lng->txt("cont_update_lhist"));
144 }
145
146 // duration
147 $du = new ilDateDurationInputGUI($lng->txt("lhist_period"), "period");
148 if (!$a_insert) {
149 if ($this->content_obj->getFrom() != "") {
150 $du->setStart(new ilDate($this->content_obj->getFrom(), IL_CAL_DATE));
151 }
152 if ($this->content_obj->getTo() != "") {
153 $du->setEnd(new ilDate($this->content_obj->getTo(), IL_CAL_DATE));
154 }
155 }
156 $du->setAllowOpenIntervals(true);
157 $form->addItem($du);
158
159 //
160 $radg = new ilRadioGroupInputGUI($lng->txt("lhist_type_of_achievement"), "mode");
161 //$radg->setValue();
162 $op1 = new ilRadioOption($lng->txt("lhist_all"), 0);
163 $radg->addOption($op1);
164 $op2 = new ilRadioOption($lng->txt("lhist_selected"), 1);
165 $radg->addOption($op2);
166 $form->addItem($radg);
167
168
169 // select type
170 $options = [];
171 foreach ($this->service->provider()->getAllProviders(true) as $p) {
172 $options[get_class($p)] = $p->getName();
173 }
174 $si = new ilMultiSelectInputGUI($lng->txt(""), "class");
175 $si->setHeight(130);
176 if (!$a_insert) {
177 $si->setValue($this->content_obj->getClasses());
178 if (count($this->content_obj->getClasses()) > 0) {
179 $radg->setValue(1);
180 }
181 }
182 $si->setOptions($options);
183 $op2->addSubItem($si);
184
185
186
187 if ($a_insert) {
188 $form->addCommandButton("create_lhist", $this->lng->txt("insert"));
189 $form->addCommandButton("cancelCreate", $this->lng->txt("cancel"));
190 } else {
191 $form->addCommandButton("update", $this->lng->txt("save"));
192 $form->addCommandButton("cancelUpdate", $this->lng->txt("cancel"));
193 }
194
195 return $form;
196 }
197
198
202 public function create()
203 {
204 $valid = false;
205
206 $form = $this->initForm(true);
207 if ($form->checkInput()) {
208 //$data = $form->getInput("skill_id");
209 $valid = true;
210 }
211
212 if ($valid) {
213 $this->content_obj = new ilPCLearningHistory($this->getPage());
214 $this->content_obj->create($this->pg_obj, $this->hier_id, $this->pc_id);
215 $this->setAttributesFromInput($form);
216 $this->updated = $this->pg_obj->update();
217 if ($this->updated === true) {
218 $this->ctrl->returnToParent($this, "jump" . $this->hier_id);
219 }
220 }
221
222 $form->setValuesByPost();
223 return $this->insert($form);
224 }
225
229 public function update()
230 {
231 $form = $this->initForm();
232 if ($form->checkInput()) {
233 $this->setAttributesFromInput($form);
234 $this->updated = $this->pg_obj->update();
235 if ($this->updated === true) {
236 ilUtil::sendInfo($this->lng->txt("msg_obj_modified"), true);
237 $this->ctrl->returnToParent($this, "jump" . $this->hier_id);
238 }
239 }
240
241 $this->pg_obj->addHierIDs();
242 $form->setValuesByPost();
243 return $this->edit($form);
244 }
245
252 protected function setAttributesFromInput($form)
253 {
255 $item = $form->getItemByPostVar("period");
256 $from = (is_null($item->getStart()))
257 ? ""
258 : $item->getStart()->get(IL_CAL_DATE);
259 $to = (is_null($item->getEnd()))
260 ? ""
261 : $item->getEnd()->get(IL_CAL_DATE);
262
263 $this->content_obj->setFrom($from);
264 $this->content_obj->setTo($to);
265 $classes = ($form->getInput("mode") == "1" && is_array($form->getInput("class")))
266 ? $form->getInput("class")
267 : array();
268 $this->content_obj->setClasses($classes);
269 }
270
277 public static function getPlaceholderPresentation()
278 {
279 global $DIC;
280
281 $lng = $DIC->language();
282 $lng->loadLanguageModule("lhist");
283
284 // @todo we need a ks element for this
285 $content = '<div style="margin:5px" class="ilBox"><h3>' . $lng->txt("lhist_lhist") . '</h3><div class="il_Description_no_margin">' .
286 $lng->txt("lhist_cont_placeholder_text") . '</div></div>';
287
288 return $content;
289 }
290}
user()
Definition: user.php:4
An exception for terminatinating execution or to throw for unit testing.
const IL_CAL_DATE
input GUI for a time span (start and end date)
Class for single dates.
This class represents a multi selection list property in a property form.
GUI class for learning history page content.
static getPlaceholderPresentation()
Get placeholder presentation.
initForm($a_insert=false)
Init learning history edit form.
create()
Create new learning history component.
update()
Update learning history component.
edit(ilPropertyFormGUI $a_form=null)
Edit skills form.
insert(ilPropertyFormGUI $a_form=null)
Insert learning history form.
__construct(ilPageObject $a_pg_obj, ilPCLearningHistory $a_content_obj=null, $a_hier_id="", $a_pc_id="")
Constructor.
Learning history page content.
User Interface for Editing of Page Content Objects (Paragraphs, Tables, ...)
displayValidationError()
display validation errors
Class ilPageObject Handles PageObjects of ILIAS Learning Modules (see ILIAS DTD)
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.
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
$valid
global $DIC
Definition: goto.php:24
$ilUser
Definition: imgupload.php:18
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
$ret
Definition: parser.php:6
ui()
Definition: ui.php:5