ILIAS  eassessment Revision 61809
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilSCORM2004NodeGUI.php
Go to the documentation of this file.
1 <?php
2 /*
3  +-----------------------------------------------------------------------------+
4  | ILIAS open source |
5  +-----------------------------------------------------------------------------+
6  | Copyright (c) 1998-2008 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 
36 {
39 
45  function ilSCORM2004NodeGUI($a_slm_obj, $a_node_id = 0)
46  {
47  $this->slm_object = $a_slm_obj;
48  $this->node_object = null;
49 
50  if ($a_node_id > 0)
51  {
52  $this->getNodeObject($a_node_id);
53  }
54  }
55 
61  function setParentGUI($a_parentgui)
62  {
63  $this->parentgui = $a_parentgui;
64  }
65 
71  function getParentGUI()
72  {
73  return $this->parentgui;
74  }
75 
79  function getNodeObject($a_node_id)
80  {
81  include_once("./Modules/Scorm2004/classes/class.ilSCORM2004NodeFactory.php");
82  $this->node_object = ilSCORM2004NodeFactory::getInstance($this->slm_object,
83  $a_node_id, false);
84  }
85 
91  function putInTree($a_parent_id, $a_target)
92  {
93  $tree = new ilTree($this->slm_object->getId());
94  $tree->setTableNames('sahs_sc13_tree', 'sahs_sc13_tree_node');
95  $tree->setTreeTablePK("slm_id");
96 
97  /*$parent_id = (!empty($_GET["obj_id"]))
98  ? $_GET["obj_id"]
99  : $tree->getRootId();*/
100 
101 /* if (!empty($_GET["target"]))
102  {
103  $target = $_GET["target"];
104  }
105  else
106  {
107  // determine last child of current type
108  $childs =& $tree->getChildsByType($parent_id, $this->obj->getType());
109  if (count($childs) == 0)
110  {
111  $target = IL_FIRST_NODE;
112  }
113  else
114  {
115  $target = $childs[count($childs) - 1]["obj_id"];
116  }
117  }*/
118  if (!$tree->isInTree($this->node_obj->getId()))
119  {
120  $tree->insertNode($this->node_obj->getId(), $parent_id, $target);
121  }
122  }
123 
124 
130 /* function delete()
131  {
132  $this->setTabs();
133 
134  $cont_obj_gui =& new ilObjContentObjectGUI("",$this->content_object->getRefId(),
135  true, false);
136  $cont_obj_gui->delete($this->obj->getId());
137  }
138 */
139 
140 
146 /* function cancelDelete()
147  {
148  session_unregister("saved_post");
149  $this->ctrl->redirect($this, $_GET["backcmd"]);
150  }*/
151 
152 
158 /* function confirmedDelete()
159  {
160  $cont_obj_gui =& new ilObjContentObjectGUI("",$this->content_object->getRefId(),
161  true, false);
162  $cont_obj_gui->confirmedDelete($this->obj->getId());
163  $this->ctrl->redirect($this, $_GET["backcmd"]);
164  }
165 */
166 
167 
173 /* function checkTree()
174  {
175  $this->content_object->checkTree();
176  }
177 */
178 
182  function showOrganization()
183  {
184  global $lng, $ilCtrl, $tpl, $ilTabs;
185 
186  $this->setTabs();
187  $ilTabs->setTabActive("sahs_organization");
188  $this->setLocator();
189  $this->getParentGUI()->showOrganization($this->node_object->getId(),
190  $ilCtrl->getFormAction($this), $this->node_object->getTitle(),
191  ilUtil::getImagePath("icon_".$this->node_object->getType().".gif"),
192  $this, "showOrganization");
193  }
194 
198  function insertChapter()
199  {
200  global $ilCtrl;
201 
202  $res = $this->getParentGUI()->insertChapter(false);
203  $ilCtrl->setParameter($this, "highlight", $res["items"]);
204  $ilCtrl->redirect($this, "showOrganization", "node_".$res["node_id"]);
205  }
206 
210  function insertSco()
211  {
212  global $ilCtrl;
213 
214  $res = $this->getParentGUI()->insertSco(false);
215  $ilCtrl->setParameter($this, "highlight", $res["items"]);
216  $ilCtrl->redirect($this, "showOrganization", "node_".$res["node_id"]);
217  }
218 
222  function insertPage()
223  {
224  global $ilCtrl;
225 
226  $res = $this->getParentGUI()->insertPage(false);
227  $ilCtrl->setParameter($this, "highlight", $res["items"]);
228  $ilCtrl->redirect($this, "showOrganization", "node_".$res["node_id"]);
229  }
230 
231 
232 
236  function insertTemplateGUI()
237  {
238  global $ilCtrl;
239  $this->getParentGUI()->insertTemplateGUI(true);
240  }
241 
245  function collapseAll()
246  {
247  global $ilCtrl;
248 
249  $this->getParentGUI()->collapseAll(false);
250  $ilCtrl->redirect($this, "showOrganization");
251  }
252 
256  function ExpandAll()
257  {
258  global $ilCtrl;
259 
260  $this->getParentGUI()->expandAll(false);
261  $ilCtrl->redirect($this, "showOrganization");
262  }
263 
267  function saveAllTitles()
268  {
269  global $ilCtrl;
270 
271  $this->getParentGUI()->saveAllTitles(false);
272  $ilCtrl->redirect($this, "showOrganization");
273  }
274 
278  function deleteNodes()
279  {
280  global $ilCtrl;
281 
282  $ilCtrl->setParameter($this, "backcmd", $_GET["backcmd"]);
283  $this->getParentGUI()->deleteNodes($ilCtrl->getFormAction($this));
284  }
285 
289  function cancelDelete()
290  {
291  global $ilCtrl;
292  $ilCtrl->redirect($this, "showOrganization");
293  }
294 
298  function confirmedDelete()
299  {
300  global $ilCtrl;
301 
302  $this->getParentGUI()->confirmedDelete(false);
303  $ilCtrl->redirect($this, "showOrganization");
304  }
305 
309  function setLocator()
310  {
311  global $ilLocator, $tpl, $ilCtrl;
312 
313  $ilLocator->addRepositoryItems($_GET["ref_id"]);
314  $this->getParentGUI()->addLocatorItems();
315 
316  if ($_GET["obj_id"] > 0)
317  {
318  $tree = new ilTree($this->slm_object->getId());
319  $tree->setTableNames('sahs_sc13_tree', 'sahs_sc13_tree_node');
320  $tree->setTreeTablePK("slm_id");
321  $path = $tree->getPathFull($_GET["obj_id"]);
322  for( $i = 1; $i < count($path); $i++)
323  {
324 //var_dump($path[$i]);
325  switch($path[$i]["type"])
326  {
327  case "chap":
328  $ilCtrl->setParameterByClass("ilscorm2004chaptergui", "obj_id",
329  $path[$i]["child"]);
330  $ilLocator->addItem($path[$i]["title"],
331  $ilCtrl->getLinkTargetByClass("ilscorm2004chaptergui",
332  "showOrganization"), "", 0, $path[$i]["type"],
333  ilUtil::getImagePath("icon_chap_s.gif"));
334  break;
335 
336  case "seqc":
337  $ilCtrl->setParameterByClass("ilscorm2004seqchaptergui", "obj_id",
338  $path[$i]["child"]);
339  $ilLocator->addItem($path[$i]["title"],
340  $ilCtrl->getLinkTargetByClass("ilscorm2004seqchaptergui",
341  "showOrganization"), "", 0, $path[$i]["type"],
342  ilUtil::getImagePath("icon_chap_s.gif"));
343  break;
344 
345  case "sco":
346  $ilCtrl->setParameterByClass("ilscorm2004scogui", "obj_id",
347  $path[$i]["child"]);
348  $ilLocator->addItem($path[$i]["title"],
349  $ilCtrl->getLinkTargetByClass("ilscorm2004scogui",
350  "showOrganization"), "", 0, $path[$i]["type"],
351  ilUtil::getImagePath("icon_sco_s.gif"));
352  break;
353 
354  case "page":
355 
356  // content styles
357  include_once("./Services/Style/classes/class.ilObjStyleSheet.php");
358  $tpl->setCurrentBlock("ContentStyle");
359  $tpl->setVariable("LOCATION_CONTENT_STYLESHEET",
360  ilObjStyleSheet::getContentStylePath($this->slm_object->getStyleSheetId()));
361  $tpl->setVariable("LOCATION_ADDITIONAL_STYLESHEET",
363  $tpl->parseCurrentBlock();
364 
365  $tpl->setCurrentBlock("SyntaxStyle");
366  $tpl->setVariable("LOCATION_SYNTAX_STYLESHEET",
368  $tpl->parseCurrentBlock();
369 
370  $ilCtrl->setParameterByClass("ilscorm2004pagegui", "obj_id",
371  $path[$i]["child"]);
372  $ilLocator->addItem($path[$i]["title"],
373  $ilCtrl->getLinkTargetByClass("ilscorm2004pagegui",
374  "edit"), "", 0, $path[$i]["type"],
375  ilUtil::getImagePath("icon_pg_s.gif"));
376  break;
377  }
378  }
379  }
380  $ilCtrl->setParameter($this, "obj_id", $_GET["obj_id"]);
381 
382  $tpl->setLocator();
383  }
384 
388  function copyItems($a_return = "showOrganization")
389  {
390  global $ilCtrl, $lng;
391 
392  $items = ilUtil::stripSlashesArray($_POST["id"]);
393  $todel = array(); // delete IDs < 0 (needed for non-js editing)
394  foreach($items as $k => $item)
395  {
396  if ($item < 0)
397  {
398  $todel[] = $k;
399  }
400  }
401  foreach($todel as $k)
402  {
403  unset($items[$k]);
404  }
406  {
407  ilUtil::sendInfo($lng->txt("sahs_choose_pages_or_chapters_or_scos_only"), true);
408  $ilCtrl->redirect($this, $a_return);
409  }
410  ilSCORM2004Node::clipboardCopy($this->slm_object->getId(), $items);
411 
412  // @todo: move this to a service since it can be used here, too
413  include_once("./Modules/LearningModule/classes/class.ilEditClipboard.php");
415  ilUtil::sendInfo($lng->txt("cont_selected_items_have_been_copied"), true);
416 
417  $ilCtrl->redirect($this, $a_return);
418  }
419 
423  function cutItems($a_return = "showOrganization")
424  {
425  global $ilCtrl, $lng;
426 
427  $items = ilUtil::stripSlashesArray($_POST["id"]);
428  $todel = array(); // delete IDs < 0 (needed for non-js editing)
429  foreach($items as $k => $item)
430  {
431  if ($item < 0)
432  {
433  $todel[] = $k;
434  }
435  }
436  foreach($todel as $k)
437  {
438  unset($items[$k]);
439  }
440 
442  {
443  ilUtil::sendInfo($lng->txt("sahs_choose_pages_or_chapters_or_scos_only"), true);
444  $ilCtrl->redirect($this, $a_return);
445  }
446 
447  ilSCORM2004Node::clipboardCut($this->slm_object->getId(), $items);
448 
449  include_once("./Modules/LearningModule/classes/class.ilEditClipboard.php");
451 
452  ilUtil::sendInfo($lng->txt("cont_selected_items_have_been_cut"), true);
453 
454  $ilCtrl->redirect($this, $a_return);
455  }
456 
460  function insertPageClip()
461  {
462  global $ilCtrl, $ilUser;
463 
464  ilSCORM2004Node::insertPageClip($this->slm_object);
465 
466  $ilCtrl->redirect($this, "showOrganization",
468  }
469 
473  function insertScoClip()
474  {
475  global $ilCtrl, $ilUser;
476 
477  ilSCORM2004Node::insertScoClip($this->slm_object);
478 
479  $ilCtrl->redirect($this, "showOrganization",
481  }
482 
483 }
484 ?>