ILIAS  eassessment Revision 61809
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilObjectPluginGUI.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 include_once("./Services/Object/classes/class.ilObject2GUI.php");
5 include_once("./Services/Component/classes/class.ilPlugin.php");
6 
7 /*
8 * Object GUI class for plugins
9 *
10 * @author Alex Killing <alex.killing@gmx.de>
11 * @version $Id$
12 * @ingroup ServicesRepository
13 */
14 abstract class ilObjectPluginGUI extends ilObject2GUI
15 {
19  function __construct($a_ref_id = 0)
20  {
21  parent::__construct($a_ref_id, true);
22  $this->plugin =
23  ilPlugin::getPluginObject(IL_COMP_SERVICE, "Repository", "robj",
24  ilPlugin::lookupNameForId(IL_COMP_SERVICE, "Repository", "robj", $this->getType()));
25  if (!is_object($this->plugin))
26  {
27  die("ilObjectPluginGUI: Could not instantiate plugin object for type ".$this->getType().".");
28  }
29  }
30 
34  function &executeCommand()
35  {
36  global $ilCtrl, $tpl, $ilAccess, $lng, $ilNavigationHistory, $ilTabs;
37 
38  // get standard template (includes main menu and general layout)
39  $tpl->getStandardTemplate();
40 
41  // set title
42  if (!$this->getCreationMode())
43  {
44  $tpl->setTitle($this->object->getTitle());
45  $tpl->setTitleIcon($this->plugin->getImagePath("icon_".$this->object->getType()."_b.gif"),
46  $lng->txt("icon")." ".$this->txt("obj_".$this->object->getType()));
47 
48  // set tabs
49  if (strtolower($_GET["baseClass"]) != "iladministrationgui")
50  {
51  $this->setTabs();
52  $this->setLocator();
53  }
54  else
55  {
56  $this->addAdminLocatorItems();
57  $tpl->setLocator();
58  $this->setAdminTabs();
59  }
60 
61  // add entry to navigation history
62  if ($ilAccess->checkAccess("read", "", $_GET["ref_id"]))
63  {
64  $ilNavigationHistory->addItem($_GET["ref_id"],
65  $ilCtrl->getLinkTarget($this, $this->getStandardCmd()), $this->getType());
66  }
67 
68  }
69  else
70  {
71  // show info of parent
72  $tpl->setTitle(ilObject::_lookupTitle(ilObject::_lookupObjId($_GET["ref_id"])));
73  $tpl->setTitleIcon(
75  $lng->txt("obj_".ilObject::_lookupType($_GET["ref_id"], true)));
76  $this->setLocator();
77 
78  }
79 
80  $next_class = $this->ctrl->getNextClass($this);
81  $cmd = $this->ctrl->getCmd();
82 
83  switch($next_class)
84  {
85  case "ilinfoscreengui":
86  $this->checkPermission("visible");
87  $this->infoScreen(); // forwards command
88  break;
89 
90  case 'ilpermissiongui':
91  include_once("Services/AccessControl/classes/class.ilPermissionGUI.php");
92  $perm_gui = new ilPermissionGUI($this);
93  $ilTabs->setTabActive("perm_settings");
94  $ret = $ilCtrl->forwardCommand($perm_gui);
95  break;
96 
97  default:
98  if (strtolower($_GET["baseClass"]) == "iladministrationgui")
99  {
100  $this->viewObject();
101  return;
102  }
103  if(!$cmd)
104  {
105  $cmd = $this->getStandardCmd();
106  }
107  if ($cmd == "infoScreen")
108  {
109  $ilCtrl->setCmd("showSummary");
110  $ilCtrl->setCmdClass("ilinfoscreengui");
111  $this->infoScreen();
112  }
113  else
114  {
115  if ($this->getCreationMode())
116  {
117  $this->$cmd();
118  }
119  else
120  {
121  $this->performCommand($cmd);
122  }
123  }
124  break;
125  }
126 
127  if (!$this->getCreationMode())
128  {
129  $tpl->show();
130  }
131  }
132 
136  function addLocatorItems()
137  {
138  global $ilLocator;
139 
140  if (!$this->getCreationMode())
141  {
142  $ilLocator->addItem($this->object->getTitle(),
143  $this->ctrl->getLinkTarget($this, $this->getStandardCmd()), "", $_GET["ref_id"]);
144  }
145  }
146 
147 
148  final public function cloneAll() { return parent::cloneAllObject(); }
149 
155  final private function getPlugin()
156  {
157  return $this->plugin;
158  }
159 
163  final protected function txt($a_var)
164  {
165  return $this->getPlugin()->txt($a_var);
166  }
167 
173  public function initEditForm($a_mode = "edit", $a_new_type = "")
174  {
175  global $lng, $ilCtrl;
176 
177  include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
178  $this->form = new ilPropertyFormGUI();
179  $this->form->setTarget("_top");
180 
181  // title
182  $ti = new ilTextInputGUI($lng->txt("title"), "title");
183  $ti->setMaxLength(128);
184  $ti->setSize(40);
185  $ti->setRequired(true);
186  $this->form->addItem($ti);
187 
188  // description
189  $ta = new ilTextAreaInputGUI($lng->txt("description"), "desc");
190  $ta->setCols(40);
191  $ta->setRows(2);
192  $this->form->addItem($ta);
193 
194  // save and cancel commands
195  if ($a_mode == "create")
196  {
197  $this->form->addCommandButton("save", $this->txt($a_new_type."_add"));
198  $this->form->addCommandButton("cancelCreation", $lng->txt("cancel"));
199  $this->form->setTitle($this->txt($a_new_type."_new"));
200  }
201  else
202  {
203  $this->form->addCommandButton("update", $lng->txt("save"));
204  $this->form->addCommandButton("cancelUpdate", $lng->txt("cancel"));
205  $this->form->setTitle($lng->txt("edit"));
206  }
207 
208  $this->form->setFormAction($ilCtrl->getFormAction($this));
209 
210  }
211 
217  public function initImportForm($a_new_type = "")
218  {
219  global $lng, $ilCtrl;
220 
221  include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
222  $this->form = new ilPropertyFormGUI();
223  $this->form->setTarget("_top");
224 
225  // Import file
226  include_once("./Services/Form/classes/class.ilFileInputGUI.php");
227  $fi = new ilFileInputGUI($lng->txt("import_file"), "importfile");
228  $fi->setSuffixes(array("zip"));
229  $this->form->addItem($fi);
230 
231  $this->form->addCommandButton("importFile", $lng->txt("import"));
232  $this->form->addCommandButton("cancelCreation", $lng->txt("cancel"));
233  $this->form->setTitle($lng->txt("import"));
234 
235  $this->form->setFormAction($ilCtrl->getFormAction($this));
236  }
237 
242  function afterSave($newObj)
243  {
244  global $ilCtrl;
245  // always send a message
246  ilUtil::sendSuccess($this->lng->txt("object_added"),true);
247 
248  $ilCtrl->initBaseClass("ilObjPluginDispatchGUI");
249  $ilCtrl->setTargetScript("ilias.php");
250  $ilCtrl->getCallStructure(strtolower("ilObjPluginDispatchGUI"));
251 
252 //var_dump($ilCtrl->call_node);
253 //var_dump($ilCtrl->forward);
254 //var_dump($ilCtrl->parent);
255 //var_dump($ilCtrl->root_class);
256 
257  $ilCtrl->setParameterByClass(get_class($this), "ref_id", $newObj->getRefId());
258  $ilCtrl->redirectByClass(array("ilobjplugindispatchgui", get_class($this)), $this->getAfterCreationCmd());
259  }
260 
264  abstract function getAfterCreationCmd();
265 
266  abstract function getStandardCmd();
267 
268 // abstract function performCommand();
269 
273  function addInfoTab()
274  {
275  global $ilAccess, $ilTabs;
276 
277  // info screen
278  if ($ilAccess->checkAccess('visible', "", $this->object->getRefId()))
279  {
280  $ilTabs->addTarget("info_short",
281  $this->ctrl->getLinkTargetByClass(
282  "ilinfoscreengui", "showSummary"),
283  "showSummary");
284  }
285  }
286 
290  function addPermissionTab()
291  {
292  global $ilAccess, $ilTabs, $ilCtrl;
293 
294  // edit permissions
295  if($ilAccess->checkAccess('edit_permission', "", $this->object->getRefId()))
296  {
297  $ilTabs->addTarget("perm_settings",
298  $ilCtrl->getLinkTargetByClass("ilpermissiongui", "perm"),
299  array("perm","info","owner"), 'ilpermissiongui');
300  }
301  }
302 
303 
307  function infoScreen()
308  {
309  global $ilAccess, $ilUser, $lng, $ilCtrl, $tpl, $ilTabs;
310 
311  $ilTabs->setTabActive("info_short");
312 
313  $this->checkPermission("visible");
314 
315  include_once("./Services/InfoScreen/classes/class.ilInfoScreenGUI.php");
316  $info = new ilInfoScreenGUI($this);
317  $info->enablePrivateNotes();
318 
319  // general information
320  $lng->loadLanguageModule("meta");
321 
322  $this->addInfoItems($info);
323 
324  // forward the command
325  $ret = $ilCtrl->forwardCommand($info);
326  //$tpl->setContent($ret);
327  }
328 
332  function addInfoItems($info)
333  {
334  }
335 
339  function _goto($a_target)
340  {
341  global $ilCtrl, $ilAccess, $lng;
342 
343  $t = explode("_", $a_target[0]);
344  $ref_id = (int) $t[0];
345  $class_name = $a_target[1];
346 
347  if ($ilAccess->checkAccess("read", "", $ref_id))
348  {
349  $ilCtrl->initBaseClass("ilObjPluginDispatchGUI");
350  $ilCtrl->setTargetScript("ilias.php");
351  $ilCtrl->getCallStructure(strtolower("ilObjPluginDispatchGUI"));
352  $ilCtrl->setParameterByClass($class_name, "ref_id", $ref_id);
353  $ilCtrl->redirectByClass(array("ilobjplugindispatchgui", $class_name), "");
354  }
355  else if($ilAccess->checkAccess("visible", "", $ref_id))
356  {
357  $ilCtrl->initBaseClass("ilObjPluginDispatchGUI");
358  $ilCtrl->setTargetScript("ilias.php");
359  $ilCtrl->getCallStructure(strtolower("ilObjPluginDispatchGUI"));
360  $ilCtrl->setParameterByClass($class_name, "ref_id", $ref_id);
361  $ilCtrl->redirectByClass(array("ilobjplugindispatchgui", $class_name), "infoScreen");
362  }
363  else if ($ilAccess->checkAccess("read", "", ROOT_FOLDER_ID))
364  {
365  $_GET["cmd"] = "frameset";
366  $_GET["target"] = "";
367  $_GET["ref_id"] = ROOT_FOLDER_ID;
368  ilUtil::sendFailure(sprintf($lng->txt("msg_no_perm_read_item"),
370  include("repository.php");
371  exit;
372  }
373  }
374 
375 }