ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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
4include_once("./Services/Object/classes/class.ilObject2GUI.php");
5include_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*/
14abstract class ilObjectPluginGUI extends ilObject2GUI
15{
16
17 protected $plugin;
21 function __construct($a_ref_id = 0, $a_id_type = self::REPOSITORY_NODE_ID, $a_parent_node_id = 0)
22 {
23 parent::__construct($a_ref_id, $a_id_type, $a_parent_node_id);
24 $this->plugin = $this->getPlugin();
25 }
26
30 function executeCommand()
31 {
32 global $ilCtrl, $tpl, $ilAccess, $lng, $ilNavigationHistory, $ilTabs;
33
34 // get standard template (includes main menu and general layout)
35 $tpl->getStandardTemplate();
36
37 // set title
38 if (!$this->getCreationMode())
39 {
40 $tpl->setTitle($this->object->getTitle());
41 $tpl->setTitleIcon(ilObject::_getIcon($this->object->getId()));
42
43 // set tabs
44 if (strtolower($_GET["baseClass"]) != "iladministrationgui")
45 {
46 $this->setTabs();
47 $this->setLocator();
48 }
49 else
50 {
51 $this->addAdminLocatorItems();
52 $tpl->setLocator();
53 $this->setAdminTabs();
54 }
55
56 // add entry to navigation history
57 if ($ilAccess->checkAccess("read", "", $_GET["ref_id"]))
58 {
59 $ilNavigationHistory->addItem($_GET["ref_id"],
60 $ilCtrl->getLinkTarget($this, $this->getStandardCmd()), $this->getType());
61 }
62
63 }
64 else
65 {
66 // show info of parent
67 $tpl->setTitle($this->lookupParentTitleInCreationMode());
68 $tpl->setTitleIcon(
70 $lng->txt("obj_".ilObject::_lookupType($_GET["ref_id"], true)));
71 $this->setLocator();
72
73 }
74
75 $next_class = $this->ctrl->getNextClass($this);
76 $cmd = $this->ctrl->getCmd();
77
78 switch($next_class)
79 {
80 case "ilinfoscreengui":
81 $this->checkPermission("visible");
82 $this->infoScreen(); // forwards command
83 break;
84
85 case 'ilpermissiongui':
86 include_once("Services/AccessControl/classes/class.ilPermissionGUI.php");
87 $perm_gui = new ilPermissionGUI($this);
88 $ilTabs->setTabActive("perm_settings");
89 $ilCtrl->forwardCommand($perm_gui);
90 break;
91
92 case 'ilobjectcopygui':
93 include_once './Services/Object/classes/class.ilObjectCopyGUI.php';
94 $cp = new ilObjectCopyGUI($this);
95 $cp->setType($this->getType());
96 $this->ctrl->forwardCommand($cp);
97 break;
98
99 case 'ilexportgui':
100 // only if plugin supports it?
101 include_once './Services/Export/classes/class.ilExportGUI.php';
102 $exp = new ilExportGUI($this);
103 $exp->addFormat('xml');
104 $this->ctrl->forwardCommand($exp);
105 break;
106
107 case 'illearningprogressgui':
108 $ilTabs->setTabActive("learning_progress");
109 include_once './Services/Tracking/classes/class.ilLearningProgressGUI.php';
111 $this->object->getRefId(),
112 $_GET['user_id'] ? $_GET['user_id'] : $GLOBALS['ilUser']->getId());
113 $this->ctrl->forwardCommand($new_gui);
114 break;
115 case 'ilcommonactiondispatchergui':
116 include_once("Services/Object/classes/class.ilCommonActionDispatcherGUI.php");
118 $this->ctrl->forwardCommand($gui);
119 break;
120 default:
121 if ($this->getCreationMode() || $cmd == "save")
122 {
123 $this->$cmd();
124 return;
125 }
126// if (strtolower($_GET["baseClass"]) == "iladministrationgui")
127// {
128// $this->viewObject();
129// return;
130// }
131 if(!$cmd)
132 {
133 $cmd = $this->getStandardCmd();
134 }
135 if ($cmd == "infoScreen")
136 {
137 $ilCtrl->setCmd("showSummary");
138 $ilCtrl->setCmdClass("ilinfoscreengui");
139 $this->infoScreen();
140 }
141 else
142 {
143 $this->performCommand($cmd);
144 }
145 break;
146 }
147
148 if (!$this->getCreationMode())
149 {
150 $tpl->show();
151 }
152 }
153
158 {
159 global $ilLocator;
160
161 if (!$this->getCreationMode())
162 {
163 $ilLocator->addItem($this->object->getTitle(),
164 $this->ctrl->getLinkTarget($this, $this->getStandardCmd()), "", $_GET["ref_id"]);
165 }
166 }
167
173 protected function getPlugin()
174 {
175 if(!$this->plugin) {
176 $this->plugin =
177 ilPlugin::getPluginObject(IL_COMP_SERVICE, "Repository", "robj",
178 ilPlugin::lookupNameForId(IL_COMP_SERVICE, "Repository", "robj", $this->getType()));
179 if (!is_object($this->plugin)) {
180 throw new ilPluginException("ilObjectPluginGUI: Could not instantiate plugin object for type " . $this->getType() . ".");
181 }
182 }
183 return $this->plugin;
184 }
185
189 final protected function txt($a_var)
190 {
191 return $this->getPlugin()->txt($a_var);
192 }
193
200 protected function getCreationFormTitle($a_form_type)
201 {
202 switch($a_form_type)
203 {
204 case self::CFORM_NEW:
205 return $this->txt($this->getType()."_new");
206
208 return $this->lng->txt("import");
209
211 return $this->txt("objs_".$this->getType()."_duplicate");
212 }
213 }
214
223 protected function initCreationForms($a_new_type)
224 {
225 global $ilPluginAdmin;
226
227 $forms = array();
228 $forms[self::CFORM_NEW] = $this->initCreateForm($a_new_type);
229
230 if($this->supportsExport())
231 {
232 $forms[self::CFORM_IMPORT] = $this->initImportForm($a_new_type);
233 }
234 if($this->supportsCloning()) {
235 $forms[self::CFORM_CLONE] = $this->fillCloneTemplate(null, $a_new_type);
236 }
237
238 return $forms;
239 }
240
244 protected function supportsCloning() {
245 return true;
246 }
247
254 public function initCreateForm($a_new_type)
255 {
256 include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
257 $form = new ilPropertyFormGUI();
258 $form->setTarget("_top");
259 $form->setFormAction($this->ctrl->getFormAction($this, "save"));
260 $form->setTitle($this->txt($a_new_type."_new"));
261
262 // title
263 $ti = new ilTextInputGUI($this->lng->txt("title"), "title");
264 $ti->setSize(min(40, ilObject::TITLE_LENGTH));
265 $ti->setMaxLength(ilObject::TITLE_LENGTH);
266 $ti->setRequired(true);
267 $form->addItem($ti);
268
269 // description
270 $ta = new ilTextAreaInputGUI($this->lng->txt("description"), "desc");
271 $ta->setCols(40);
272 $ta->setRows(2);
273 $form->addItem($ta);
274
275 $form->addCommandButton("save", $this->txt($a_new_type."_add"));
276 $form->addCommandButton("cancel", $this->lng->txt("cancel"));
277
278 return $form;
279 }
280
286 public function initEditForm()
287 {
288 global $lng, $ilCtrl;
289
290 include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
291 $form = new ilPropertyFormGUI();
292 $form->setTarget("_top");
293 $form->setFormAction($ilCtrl->getFormAction($this, "update"));
294 $form->setTitle($lng->txt("edit"));
295
296 // title
297 $ti = new ilTextInputGUI($lng->txt("title"), "title");
298 $ti->setSize(min(40, ilObject::TITLE_LENGTH));
299 $ti->setMaxLength(ilObject::TITLE_LENGTH);
300 $ti->setRequired(true);
301 $form->addItem($ti);
302
303 // description
304 $ta = new ilTextAreaInputGUI($lng->txt("description"), "desc");
305 $ta->setCols(40);
306 $ta->setRows(2);
307 $form->addItem($ta);
308
309 $form->addCommandButton("update", $lng->txt("save"));
310 // $this->form->addCommandButton("cancelUpdate", $lng->txt("cancel"));
311
312 return $form;
313 }
314
321 protected function initImportForm($a_new_type)
322 {
323 include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
324 $form = new ilPropertyFormGUI();
325 $form->setTarget("_top");
326 $form->setFormAction($this->ctrl->getFormAction($this, "importFile"));
327 $form->setTitle($this->lng->txt("import"));
328
329 include_once("./Services/Form/classes/class.ilFileInputGUI.php");
330 $fi = new ilFileInputGUI($this->lng->txt("import_file"), "importfile");
331 $fi->setSuffixes(array("zip"));
332 $fi->setRequired(true);
333 $form->addItem($fi);
334
335 $form->addCommandButton("importFile", $this->lng->txt("import"));
336 $form->addCommandButton("cancel", $this->lng->txt("cancel"));
337
338 return $form;
339 }
340
345 function afterSave(ilObject $newObj)
346 {
347 global $ilCtrl;
348 // always send a message
349 ilUtil::sendSuccess($this->lng->txt("object_added"),true);
350
351 $ilCtrl->initBaseClass("ilObjPluginDispatchGUI");
352 $ilCtrl->setTargetScript("ilias.php");
353 $ilCtrl->getCallStructure(strtolower("ilObjPluginDispatchGUI"));
354
355//var_dump($ilCtrl->call_node);
356//var_dump($ilCtrl->forward);
357//var_dump($ilCtrl->parent);
358//var_dump($ilCtrl->root_class);
359
360 $ilCtrl->setParameterByClass(get_class($this), "ref_id", $newObj->getRefId());
361 $ilCtrl->redirectByClass(array("ilobjplugindispatchgui", get_class($this)), $this->getAfterCreationCmd());
362 }
363
367 abstract function getAfterCreationCmd();
368
369 abstract function getStandardCmd();
370
371// abstract function performCommand();
372
376 function addInfoTab()
377 {
378 global $ilAccess, $ilTabs;
379
380 // info screen
381 if ($ilAccess->checkAccess('visible', "", $this->object->getRefId()))
382 {
383 $ilTabs->addTarget("info_short",
384 $this->ctrl->getLinkTargetByClass(
385 "ilinfoscreengui", "showSummary"),
386 "showSummary");
387 }
388 }
389
394 {
395 global $ilAccess, $ilTabs, $ilCtrl;
396
397 // edit permissions
398 if($ilAccess->checkAccess('edit_permission', "", $this->object->getRefId()))
399 {
400 $ilTabs->addTarget("perm_settings",
401 $ilCtrl->getLinkTargetByClass("ilpermissiongui", "perm"),
402 array("perm","info","owner"), 'ilpermissiongui');
403 }
404 }
405
406
410 function infoScreen()
411 {
412 global $ilAccess, $ilUser, $lng, $ilCtrl, $tpl, $ilTabs;
413
414 $ilTabs->setTabActive("info_short");
415
416 $this->checkPermission("visible");
417
418 include_once("./Services/InfoScreen/classes/class.ilInfoScreenGUI.php");
419 $info = new ilInfoScreenGUI($this);
420 $info->enablePrivateNotes();
421
422 // general information
423 $lng->loadLanguageModule("meta");
424
425 $this->addInfoItems($info);
426
427 // forward the command
428 $ret = $ilCtrl->forwardCommand($info);
429 //$tpl->setContent($ret);
430 }
431
436 {
437 }
438
442 public static function _goto($a_target)
443 {
444 global $ilCtrl, $ilAccess, $lng;
445
446 $t = explode("_", $a_target[0]);
447 $ref_id = (int) $t[0];
448 $class_name = $a_target[1];
449
450 if ($ilAccess->checkAccess("read", "", $ref_id))
451 {
452 $ilCtrl->initBaseClass("ilObjPluginDispatchGUI");
453 $ilCtrl->setTargetScript("ilias.php");
454 $ilCtrl->getCallStructure(strtolower("ilObjPluginDispatchGUI"));
455 $ilCtrl->setParameterByClass($class_name, "ref_id", $ref_id);
456 $ilCtrl->redirectByClass(array("ilobjplugindispatchgui", $class_name), "");
457 }
458 else if($ilAccess->checkAccess("visible", "", $ref_id))
459 {
460 $ilCtrl->initBaseClass("ilObjPluginDispatchGUI");
461 $ilCtrl->setTargetScript("ilias.php");
462 $ilCtrl->getCallStructure(strtolower("ilObjPluginDispatchGUI"));
463 $ilCtrl->setParameterByClass($class_name, "ref_id", $ref_id);
464 $ilCtrl->redirectByClass(array("ilobjplugindispatchgui", $class_name), "infoScreen");
465 }
466 else if ($ilAccess->checkAccess("read", "", ROOT_FOLDER_ID))
467 {
468 ilUtil::sendFailure(sprintf($lng->txt("msg_no_perm_read_item"),
470 include_once("./Services/Object/classes/class.ilObjectGUI.php");
472 }
473 }
474
475
479 protected function supportsExport() {
480 global $ilPluginAdmin;
481
482 return $ilPluginAdmin->supportsExport(IL_COMP_SERVICE, "Repository", "robj", $this->getPlugin()->getPluginName());
483 }
484
485
489 protected function lookupParentTitleInCreationMode() {
491 }
492}
sprintf('%.4f', $callTime)
$_GET["client_id"]
An exception for terminatinating execution or to throw for unit testing.
const IL_COMP_SERVICE
static getInstanceFromAjaxCall()
(Re-)Build instance from ajax call
Export User Interface Class.
This class represents a file property in a property form.
Class ilInfoScreenGUI.
Class ilObjUserTrackingGUI.
New implementation of ilObjectGUI.
getType()
Functions that must be overwritten.
setTabs()
create tabs (repository/workspace switch)
fillCloneTemplate($a_tpl_varname, $a_type)
Fill object clone template This method can be called from any object GUI class that wants to offer ob...
checkPermission($a_perm, $a_cmd="", $a_type="", $a_ref_id=null)
Check permission and redirect on error.
getCreationMode()
get creation mode
setLocator()
set Locator
addAdminLocatorItems($a_do_not_add_object=false)
should be overwritten to add object specific items (repository items are preloaded)
GUI class for the workflow of copying objects.
setAdminTabs()
set admin tabs @access public
static _gotoRepositoryRoot($a_raise_error=false)
Goto repository root.
initEditForm()
Init object update form.
getPlugin()
Get plugin object.
executeCommand()
execute command
getAfterCreationCmd()
Cmd that will be redirected to after creation of a new object.
initCreationForms($a_new_type)
Init creation froms.
addInfoTab()
Add info screen tab.
infoScreen()
show information screen
addInfoItems($info)
Add items to info screen.
static _goto($a_target)
Goto redirection.
getCreationFormTitle($a_form_type)
Use custom creation form titles.
__construct($a_ref_id=0, $a_id_type=self::REPOSITORY_NODE_ID, $a_parent_node_id=0)
Constructor.
addLocatorItems()
Add object to locator.
afterSave(ilObject $newObj)
After saving @access public.
initImportForm($a_new_type)
Init object import form.
initCreateForm($a_new_type)
Init object creation form.
txt($a_var)
Wrapper for txt function.
addPermissionTab()
Add permission tab.
Class ilObject Basic functions for all objects.
static _lookupObjId($a_id)
const TITLE_LENGTH
max length of object title
static _lookupTitle($a_id)
lookup object title
getRefId()
get reference id @access public
static _getIcon($a_obj_id="", $a_size="big", $a_type="", $a_offline=false)
Get icon for repository item.
New PermissionGUI (extends from old ilPermission2GUI) RBAC related output.
static getPluginObject($a_ctype, $a_cname, $a_slot_id, $a_pname)
Get plugin object.
static lookupNameForId($a_ctype, $a_cname, $a_slot_id, $a_plugin_id)
Lookup name for id.
This class represents a property form user interface.
This class represents a text area property in a property form.
This class represents a text property in a property form.
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
$info
Definition: example_052.php:80
$GLOBALS['loaded']
Global hash that tracks already loaded includes.
global $ilCtrl
Definition: ilias.php:18
$ret
Definition: parser.php:6
$cmd
Definition: sahs_server.php:35
$ilUser
Definition: imgupload.php:18