ILIAS  release_7 Revision v7.30-3-g800a261c036
All Data Structures Namespaces Files Functions Variables Modules Pages
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 
24 require_once("./Services/COPage/classes/class.ilPCSkills.php");
25 require_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  {
87  $tpl = $this->tpl;
88 
89  $this->displayValidationError();
90 
91  // template mode: get skills from global skill tree
92  if ($this->getPageConfig()->getEnablePCType("PlaceHolder")) {
93  $exp = new ilPersonalSkillExplorerGUI($this, "insert", $this, "create", "skill_id");
94  if (!$exp->handleCommand()) {
95  $tpl->setContent($exp->getHTML());
96  }
97  }
98  // editor mode: use personal skills
99  else {
100  if (!$a_form) {
101  $a_form = $this->initForm(true);
102  }
103  $tpl->setContent($a_form->getHTML());
104  }
105  }
106 
112  public function edit(ilPropertyFormGUI $a_form = null)
113  {
114  $tpl = $this->tpl;
115 
116  $this->displayValidationError();
117 
118  // template mode: get skills from global skill tree
119  if ($this->getPageConfig()->getEnablePCType("PlaceHolder")) {
120  $exp = new ilPersonalSkillExplorerGUI($this, "edit", $this, "update", "skill_id");
121  if (!$exp->handleCommand()) {
122  $tpl->setContent($exp->getHTML());
123  }
124  }
125  // editor mode: use personal skills
126  else {
127  if (!$a_form) {
128  $a_form = $this->initForm();
129  }
130  $tpl->setContent($a_form->getHTML());
131  }
132  }
133 
140  protected function initForm($a_insert = false)
141  {
142  $ilCtrl = $this->ctrl;
144  $lng = $this->lng;
145 
146  include_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
147  $form = new ilPropertyFormGUI();
148  $form->setFormAction($ilCtrl->getFormAction($this));
149  if ($a_insert) {
150  $form->setTitle($this->lng->txt("cont_insert_skills"));
151  } else {
152  $form->setTitle($this->lng->txt("cont_update_skills"));
153  }
154 
155  $options = array();
156 
158  if ($skills) {
159  foreach ($skills as $skill) {
160  $options[$skill["skill_node_id"]] = $skill["title"];
161  }
162  asort($options);
163  } else {
164  ilUtil::sendFailure("cont_no_skills");
165  }
166  $obj = new ilSelectInputGUI($this->lng->txt("cont_pc_skills"), "skill_id");
167  $obj->setRequired(true);
168  $obj->setOptions($options);
169  $form->addItem($obj);
170 
171  if ($a_insert) {
172  $form->addCommandButton("create_skill", $this->lng->txt("select"));
173  $form->addCommandButton("cancelCreate", $this->lng->txt("cancel"));
174  } else {
175  $obj->setValue($this->content_obj->getSkillId());
176  $form->addCommandButton("update", $this->lng->txt("select"));
177  $form->addCommandButton("cancelUpdate", $this->lng->txt("cancel"));
178  }
179 
180  return $form;
181  }
182 
186  public function create()
187  {
188  $valid = false;
189 
190  // template mode: get skills from global skill tree
191  if ($this->getPageConfig()->getEnablePCType("PlaceHolder")) {
192  $data = (int) $_GET["skill_id"];
193  $valid = true;
194  }
195  // editor mode: use personal skills
196  else {
197  $form = $this->initForm(true);
198  if ($form->checkInput()) {
199  $data = $form->getInput("skill_id");
200  $valid = true;
201  }
202  }
203 
204  if ($valid) {
205  $this->content_obj = new ilPCSkills($this->getPage());
206  $this->content_obj->create($this->pg_obj, $this->hier_id, $this->pc_id);
207  $this->content_obj->setData($data);
208  $this->updated = $this->pg_obj->update();
209  if ($this->updated === true) {
210  $this->ctrl->returnToParent($this, "jump" . $this->hier_id);
211  }
212  }
213 
214  $form->setValuesByPost();
215  return $this->insert($form);
216  }
217 
221  public function update()
222  {
223  // template mode: get skills from global skill tree
224  if ($this->getPageConfig()->getEnablePCType("PlaceHolder")) {
225  $data = (int) $_GET["skill_id"];
226  $valid = true;
227  }
228  // editor mode: use personal skills
229  else {
230  $form = $this->initForm();
231  if ($form->checkInput()) {
232  $data = $form->getInput("skill_id");
233  $valid = true;
234  }
235  }
236 
237  if ($valid) {
238  $this->content_obj->setData($data);
239  $this->updated = $this->pg_obj->update();
240  if ($this->updated === true) {
241  $this->ctrl->returnToParent($this, "jump" . $this->hier_id);
242  }
243  }
244 
245  $this->pg_obj->addHierIDs();
246  $form->setValuesByPost();
247  return $this->edit($form);
248  }
249 }
edit(ilPropertyFormGUI $a_form=null)
Edit skills form.
$data
Definition: storeScorm.php:23
This class represents a property form user interface.
$_GET["client_id"]
__construct(&$a_pg_obj, &$a_content_obj, $a_hier_id, $a_pc_id="")
Constructor public.
$valid
executeCommand()
execute command
Explorer for selecting a personal skill.
update()
Update blog.
static getSelectedUserSkills($a_user_id)
Get personal selected user skills.
Class ilPCSkillsGUI.
getPageConfig()
Get Page Config.
user()
Definition: user.php:4
User Interface for Editing of Page Content Objects (Paragraphs, Tables, ...)
Class ilPCSkills.
global $DIC
Definition: goto.php:24
create()
Create new skill.
displayValidationError()
display validation errors
insert(ilPropertyFormGUI $a_form=null)
Insert skills form.
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
__construct(Container $dic, ilPlugin $plugin)
initForm($a_insert=false)
Init skills form.
$ret
Definition: parser.php:6
$ilUser
Definition: imgupload.php:18