ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
class.ilPCSkillsGUI.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
44
49 public function __construct(&$a_pg_obj, &$a_content_obj, $a_hier_id, $a_pc_id = "")
50 {
51 global $DIC;
52
53 $this->tpl = $DIC["tpl"];
54 $this->ctrl = $DIC->ctrl();
55 $this->user = $DIC->user();
56 $this->lng = $DIC->language();
57 parent::__construct($a_pg_obj, $a_content_obj, $a_hier_id, $a_pc_id);
58 }
59
63 public function executeCommand()
64 {
65 // get next class that processes or forwards current command
66 $next_class = $this->ctrl->getNextClass($this);
67
68 // get current command
69 $cmd = $this->ctrl->getCmd();
70
71 switch ($next_class) {
72 default:
73 $ret = $this->$cmd();
74 break;
75 }
76
77 return $ret;
78 }
79
85 public function insert(ilPropertyFormGUI $a_form = null)
86 {
88
90
91 // template mode: get skills from global skill tree
92 if ($this->getPageConfig()->getEnablePCType("PlaceHolder")) {
93 include_once "Services/Skill/classes/class.ilPersonalSkillExplorerGUI.php";
94 $exp = new ilPersonalSkillExplorerGUI($this, "insert", $this, "create", "skill_id");
95 if (!$exp->handleCommand()) {
96 $tpl->setContent($exp->getHTML());
97 }
98 }
99 // editor mode: use personal skills
100 else {
101 if (!$a_form) {
102 $a_form = $this->initForm(true);
103 }
104 $tpl->setContent($a_form->getHTML());
105 }
106 }
107
113 public function edit(ilPropertyFormGUI $a_form = null)
114 {
116
117 $this->displayValidationError();
118
119 // template mode: get skills from global skill tree
120 if ($this->getPageConfig()->getEnablePCType("PlaceHolder")) {
121 include_once "Services/Skill/classes/class.ilPersonalSkillExplorerGUI.php";
122 $exp = new ilPersonalSkillExplorerGUI($this, "edit", $this, "update", "skill_id");
123 if (!$exp->handleCommand()) {
124 $tpl->setContent($exp->getHTML());
125 }
126 }
127 // editor mode: use personal skills
128 else {
129 if (!$a_form) {
130 $a_form = $this->initForm();
131 }
132 $tpl->setContent($a_form->getHTML());
133 }
134 }
135
142 protected function initForm($a_insert = false)
143 {
147
148 include_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
149 $form = new ilPropertyFormGUI();
150 $form->setFormAction($ilCtrl->getFormAction($this));
151 if ($a_insert) {
152 $form->setTitle($this->lng->txt("cont_insert_skills"));
153 } else {
154 $form->setTitle($this->lng->txt("cont_update_skills"));
155 }
156
157 $options = array();
158 include_once "Services/Skill/classes/class.ilPersonalSkill.php";
159
161 if ($skills) {
162 foreach ($skills as $skill) {
163 $options[$skill["skill_node_id"]] = $skill["title"];
164 }
165 asort($options);
166 } else {
167 ilUtil::sendFailure("cont_no_skills");
168 }
169 $obj = new ilSelectInputGUI($this->lng->txt("cont_pc_skills"), "skill_id");
170 $obj->setRequired(true);
171 $obj->setOptions($options);
172 $form->addItem($obj);
173
174 if ($a_insert) {
175 $form->addCommandButton("create_skill", $this->lng->txt("select"));
176 $form->addCommandButton("cancelCreate", $this->lng->txt("cancel"));
177 } else {
178 $obj->setValue($this->content_obj->getSkillId());
179 $form->addCommandButton("update", $this->lng->txt("select"));
180 $form->addCommandButton("cancelUpdate", $this->lng->txt("cancel"));
181 }
182
183 return $form;
184 }
185
189 public function create()
190 {
191 $valid = false;
192
193 // template mode: get skills from global skill tree
194 if ($this->getPageConfig()->getEnablePCType("PlaceHolder")) {
195 $data = (int) $_GET["skill_id"];
196 $valid = true;
197 }
198 // editor mode: use personal skills
199 else {
200 $form = $this->initForm(true);
201 if ($form->checkInput()) {
202 $data = $form->getInput("skill_id");
203 $valid = true;
204 }
205 }
206
207 if ($valid) {
208 $this->content_obj = new ilPCSkills($this->getPage());
209 $this->content_obj->create($this->pg_obj, $this->hier_id, $this->pc_id);
210 $this->content_obj->setData($data);
211 $this->updated = $this->pg_obj->update();
212 if ($this->updated === true) {
213 $this->ctrl->returnToParent($this, "jump" . $this->hier_id);
214 }
215 }
216
217 $form->setValuesByPost();
218 return $this->insert($form);
219 }
220
224 public function update()
225 {
226 // template mode: get skills from global skill tree
227 if ($this->getPageConfig()->getEnablePCType("PlaceHolder")) {
228 $data = (int) $_GET["skill_id"];
229 $valid = true;
230 }
231 // editor mode: use personal skills
232 else {
233 $form = $this->initForm();
234 if ($form->checkInput()) {
235 $data = $form->getInput("skill_id");
236 $valid = true;
237 }
238 }
239
240 if ($valid) {
241 $this->content_obj->setData($data);
242 $this->updated = $this->pg_obj->update();
243 if ($this->updated === true) {
244 $this->ctrl->returnToParent($this, "jump" . $this->hier_id);
245 }
246 }
247
248 $this->pg_obj->addHierIDs();
249 $form->setValuesByPost();
250 return $this->edit($form);
251 }
252}
user()
Definition: user.php:4
$_GET["client_id"]
An exception for terminatinating execution or to throw for unit testing.
Class ilPCSkillsGUI.
create()
Create new skill.
initForm($a_insert=false)
Init skills form.
__construct(&$a_pg_obj, &$a_content_obj, $a_hier_id, $a_pc_id="")
Constructor @access public.
executeCommand()
execute command
insert(ilPropertyFormGUI $a_form=null)
Insert skills form.
edit(ilPropertyFormGUI $a_form=null)
Edit skills form.
update()
Update blog.
Class ilPCSkills.
User Interface for Editing of Page Content Objects (Paragraphs, Tables, ...)
getPageConfig()
Get Page Config.
displayValidationError()
display validation errors
Explorer for selecting a personal skill.
static getSelectedUserSkills($a_user_id)
Get personal selected user skills.
This class represents a property form user interface.
This class represents a selection list property in a property form.
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
$valid
global $ilCtrl
Definition: ilias.php:18
$ret
Definition: parser.php:6
if(isset($_POST['submit'])) $form
global $DIC
Definition: saml.php:7
$ilUser
Definition: imgupload.php:18
$data
Definition: bench.php:6