ILIAS  Release_4_1_x_branch Revision 61804
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilPCResourcesGUI.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
4 require_once("./Services/COPage/classes/class.ilPCResources.php");
5 require_once("./Services/COPage/classes/class.ilPageContentGUI.php");
6 
18 {
19 
24  function ilPCResourcesGUI(&$a_pg_obj, &$a_content_obj, $a_hier_id, $a_pc_id = "")
25  {
26  parent::ilPageContentGUI($a_pg_obj, $a_content_obj, $a_hier_id, $a_pc_id);
27  }
28 
32  function &executeCommand()
33  {
34  // get next class that processes or forwards current command
35  $next_class = $this->ctrl->getNextClass($this);
36 
37  // get current command
38  $cmd = $this->ctrl->getCmd();
39 
40  switch($next_class)
41  {
42  default:
43  $ret =& $this->$cmd();
44  break;
45  }
46 
47  return $ret;
48  }
49 
53  function insert()
54  {
55  $this->edit(true);
56  }
57 
61  function edit($a_insert = false)
62  {
63  global $ilCtrl, $tpl, $lng, $objDefinition;
64 
65  $this->displayValidationError();
66 
67  // edit form
68  include_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
69  $form = new ilPropertyFormGUI();
70  $form->setFormAction($ilCtrl->getFormAction($this));
71  if ($a_insert)
72  {
73  $form->setTitle($this->lng->txt("cont_insert_resources"));
74  }
75  else
76  {
77  $form->setTitle($this->lng->txt("cont_update_resources"));
78  }
79 
80  // type selection
81  $type_prop = new ilRadioGroupInputGUI($this->lng->txt("cont_type"),
82  "type");
83  $obj_id = ilObject::_lookupObjId($_GET["ref_id"]);
84  $obj_type = ilObject::_lookupType($obj_id);
85  $sub_objs = $objDefinition->getGroupedRepositoryObjectTypes($obj_type);
86  $types = array();
87  foreach($sub_objs as $k => $so)
88  {
89  $types[$k] = $this->lng->txt("objs_".$k);
90  }
91  foreach($types as $k => $type)
92  {
93  $option = new ilRadioOption($type, $k, "");
94  $type_prop->addOption($option);
95  }
96  $selected = ($a_insert)
97  ? ""
98  : $this->content_obj->getResourceListType();
99  $type_prop->setValue($selected);
100  $form->addItem($type_prop);
101 
102  // save/cancel buttons
103  if ($a_insert)
104  {
105  $form->addCommandButton("create_resources", $lng->txt("save"));
106  $form->addCommandButton("cancelCreate", $lng->txt("cancel"));
107  }
108  else
109  {
110  $form->addCommandButton("update_resources", $lng->txt("save"));
111  $form->addCommandButton("cancelUpdate", $lng->txt("cancel"));
112  }
113  $html = $form->getHTML();
114  $tpl->setContent($html);
115  return $ret;
116 
117  }
118 
119 
123  function create()
124  {
125  $this->content_obj = new ilPCResources($this->dom);
126  $this->content_obj->create($this->pg_obj, $this->hier_id, $this->pc_id);
127  $this->content_obj->setResourceListType($_POST["type"]);
128  $this->updated = $this->pg_obj->update();
129  if ($this->updated === true)
130  {
131  $this->ctrl->returnToParent($this, "jump".$this->hier_id);
132  }
133  else
134  {
135  $this->insert();
136  }
137  }
138 
142  function update()
143  {
144  $this->content_obj->setResourceListType($_POST["type"]);
145  $this->updated = $this->pg_obj->update();
146  if ($this->updated === true)
147  {
148  $this->ctrl->returnToParent($this, "jump".$this->hier_id);
149  }
150  else
151  {
152  $this->pg_obj->addHierIDs();
153  $this->edit();
154  }
155  }
156 }
157 ?>