ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
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{
39
44 function ilPCSkillsGUI(&$a_pg_obj, &$a_content_obj, $a_hier_id, $a_pc_id = "")
45 {
46 parent::ilPageContentGUI($a_pg_obj, $a_content_obj, $a_hier_id, $a_pc_id);
47 }
48
52 function &executeCommand()
53 {
54 // get next class that processes or forwards current command
55 $next_class = $this->ctrl->getNextClass($this);
56
57 // get current command
58 $cmd = $this->ctrl->getCmd();
59
60 switch($next_class)
61 {
62 default:
63 $ret =& $this->$cmd();
64 break;
65 }
66
67 return $ret;
68 }
69
75 function insert(ilPropertyFormGUI $a_form = null)
76 {
77 global $tpl;
78
80
81 // template mode: get skills from global skill tree
82 if($this->getPageConfig()->getEnablePCType("PlaceHolder"))
83 {
84 include_once "Services/Skill/classes/class.ilPersonalSkillExplorerGUI.php";
85 $exp = new ilPersonalSkillExplorerGUI($this, "insert", $this, "create", "skill_id");
86 if (!$exp->handleCommand())
87 {
88 $tpl->setContent($exp->getHTML());
89 }
90 }
91 // editor mode: use personal skills
92 else
93 {
94 if(!$a_form)
95 {
96 $a_form = $this->initForm(true);
97 }
98 $tpl->setContent($a_form->getHTML());
99 }
100 }
101
107 function edit(ilPropertyFormGUI $a_form = null)
108 {
109 global $tpl;
110
111 $this->displayValidationError();
112
113 // template mode: get skills from global skill tree
114 if($this->getPageConfig()->getEnablePCType("PlaceHolder"))
115 {
116 include_once "Services/Skill/classes/class.ilPersonalSkillExplorerGUI.php";
117 $exp = new ilPersonalSkillExplorerGUI($this, "edit", $this, "update", "skill_id");
118 if (!$exp->handleCommand())
119 {
120 $tpl->setContent($exp->getHTML());
121 }
122 }
123 // editor mode: use personal skills
124 else
125 {
126 if(!$a_form)
127 {
128 $a_form = $this->initForm();
129 }
130 $tpl->setContent($a_form->getHTML());
131 }
132 }
133
140 protected function initForm($a_insert = false)
141 {
142 global $ilCtrl, $ilUser, $lng;
143
144 include_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
145 $form = new ilPropertyFormGUI();
146 $form->setFormAction($ilCtrl->getFormAction($this));
147 if ($a_insert)
148 {
149 $form->setTitle($this->lng->txt("cont_insert_skills"));
150 }
151 else
152 {
153 $form->setTitle($this->lng->txt("cont_update_skills"));
154 }
155
156 $options = array();
157 include_once "Services/Skill/classes/class.ilPersonalSkill.php";
158
160 if($skills)
161 {
162 foreach($skills as $skill)
163 {
164 $options[$skill["skill_node_id"]] = $skill["title"];
165 }
166 asort($options);
167 }
168 else
169 {
170 ilUtil::sendFailure("cont_no_skills");
171 }
172 $obj = new ilSelectInputGUI($this->lng->txt("cont_pc_skills"), "skill_id");
173 $obj->setRequired(true);
174 $obj->setOptions($options);
175 $form->addItem($obj);
176
177 if ($a_insert)
178 {
179 $form->addCommandButton("create_skill", $this->lng->txt("select"));
180 $form->addCommandButton("cancelCreate", $this->lng->txt("cancel"));
181 }
182 else
183 {
184 $obj->setValue($this->content_obj->getSkillId());
185 $form->addCommandButton("update", $this->lng->txt("select"));
186 $form->addCommandButton("cancelUpdate", $this->lng->txt("cancel"));
187 }
188
189 return $form;
190 }
191
195 function create()
196 {
197 $valid = false;
198
199 // template mode: get skills from global skill tree
200 if($this->getPageConfig()->getEnablePCType("PlaceHolder"))
201 {
202 $data = (int)$_GET["skill_id"];
203 $valid = true;
204 }
205 // editor mode: use personal skills
206 else
207 {
208 $form = $this->initForm(true);
209 if($form->checkInput())
210 {
211 $data = $form->getInput("skill_id");
212 $valid = true;
213 }
214 }
215
216 if($valid)
217 {
218 $this->content_obj = new ilPCSkills($this->getPage());
219 $this->content_obj->create($this->pg_obj, $this->hier_id, $this->pc_id);
220 $this->content_obj->setData($data);
221 $this->updated = $this->pg_obj->update();
222 if ($this->updated === true)
223 {
224 $this->ctrl->returnToParent($this, "jump".$this->hier_id);
225 }
226 }
227
228 $form->setValuesByPost();
229 return $this->insert($form);
230 }
231
235 function update()
236 {
237 // template mode: get skills from global skill tree
238 if($this->getPageConfig()->getEnablePCType("PlaceHolder"))
239 {
240 $data = (int)$_GET["skill_id"];
241 $valid = true;
242 }
243 // editor mode: use personal skills
244 else
245 {
246 $form = $this->initForm();
247 if($form->checkInput())
248 {
249 $data = $form->getInput("skill_id");
250 $valid = true;
251 }
252 }
253
254 if($valid)
255 {
256 $this->content_obj->setData($data);
257 $this->updated = $this->pg_obj->update();
258 if ($this->updated === true)
259 {
260 $this->ctrl->returnToParent($this, "jump".$this->hier_id);
261 }
262 }
263
264 $this->pg_obj->addHierIDs();
265 $form->setValuesByPost();
266 return $this->edit($form);
267 }
268}
269
270?>
$_GET["client_id"]
Class ilPCSkillsGUI.
ilPCSkillsGUI(&$a_pg_obj, &$a_content_obj, $a_hier_id, $a_pc_id="")
Constructor @access public.
create()
Create new skill.
initForm($a_insert=false)
Init skills form.
insert(ilPropertyFormGUI $a_form=null)
Insert skills form.
edit(ilPropertyFormGUI $a_form=null)
Edit skills form.
update()
Update blog.
& executeCommand()
execute command
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
$data
global $ilCtrl
Definition: ilias.php:18
$cmd
Definition: sahs_server.php:35
if(!is_array($argv)) $options
global $ilUser
Definition: imgupload.php:15