ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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{
19 protected $nav_history;
20
24 protected $tabs;
25
29 protected $plugin_admin;
30
31
32 protected $plugin;
36 public function __construct($a_ref_id = 0, $a_id_type = self::REPOSITORY_NODE_ID, $a_parent_node_id = 0)
37 {
38 global $DIC;
39
40 $this->ctrl = $DIC->ctrl();
41 $this->tpl = $DIC["tpl"];
42 $this->access = $DIC->access();
43 $this->lng = $DIC->language();
44 $this->nav_history = $DIC["ilNavigationHistory"];
45 $this->tabs = $DIC->tabs();
46 $this->locator = $DIC["ilLocator"];
47 $this->plugin_admin = $DIC["ilPluginAdmin"];
48 $this->user = $DIC->user();
49 parent::__construct($a_ref_id, $a_id_type, $a_parent_node_id);
50 $this->plugin = $this->getPlugin();
51 }
52
56 public function executeCommand()
57 {
60 $ilAccess = $this->access;
62 $ilNavigationHistory = $this->nav_history;
63 $ilTabs = $this->tabs;
64
65 // get standard template (includes main menu and general layout)
66 $tpl->getStandardTemplate();
67
68 // set title
69 if (!$this->getCreationMode()) {
70 $tpl->setTitle($this->object->getTitle());
71 $tpl->setTitleIcon(ilObject::_getIcon($this->object->getId()));
72
73 // set tabs
74 if (strtolower($_GET["baseClass"]) != "iladministrationgui") {
75 $this->setTabs();
76 $this->setLocator();
77 } else {
78 $this->addAdminLocatorItems();
79 $tpl->setLocator();
80 $this->setAdminTabs();
81 }
82
83 // add entry to navigation history
84 if ($ilAccess->checkAccess("read", "", $_GET["ref_id"])) {
85 $ilNavigationHistory->addItem(
86 $_GET["ref_id"],
87 $ilCtrl->getLinkTarget($this, $this->getStandardCmd()),
88 $this->getType()
89 );
90 }
91 } else {
92 // show info of parent
93 $tpl->setTitle($this->lookupParentTitleInCreationMode());
94 $tpl->setTitleIcon(
96 $lng->txt("obj_" . ilObject::_lookupType($_GET["ref_id"], true))
97 );
98 $this->setLocator();
99 }
100
101 $next_class = $this->ctrl->getNextClass($this);
102 $cmd = $this->ctrl->getCmd();
103
104 switch ($next_class) {
105 case "ilinfoscreengui":
106 $this->checkPermission("visible");
107 $this->infoScreen(); // forwards command
108 break;
109
110 case 'ilpermissiongui':
111 include_once("Services/AccessControl/classes/class.ilPermissionGUI.php");
112 $perm_gui = new ilPermissionGUI($this);
113 $ilTabs->setTabActive("perm_settings");
114 $ilCtrl->forwardCommand($perm_gui);
115 break;
116
117 case 'ilobjectcopygui':
118 include_once './Services/Object/classes/class.ilObjectCopyGUI.php';
119 $cp = new ilObjectCopyGUI($this);
120 $cp->setType($this->getType());
121 $this->ctrl->forwardCommand($cp);
122 break;
123
124 case 'ilexportgui':
125 // only if plugin supports it?
126 include_once './Services/Export/classes/class.ilExportGUI.php';
127 $exp = new ilExportGUI($this);
128 $exp->addFormat('xml');
129 $this->ctrl->forwardCommand($exp);
130 break;
131
132 case 'illearningprogressgui':
133 $ilTabs->setTabActive("learning_progress");
134 include_once './Services/Tracking/classes/class.ilLearningProgressGUI.php';
135 $new_gui = new ilLearningProgressGUI(
137 $this->object->getRefId(),
138 $_GET['user_id'] ? $_GET['user_id'] : $GLOBALS['ilUser']->getId()
139 );
140 $this->ctrl->forwardCommand($new_gui);
141 break;
142 case 'ilcommonactiondispatchergui':
143 include_once("Services/Object/classes/class.ilCommonActionDispatcherGUI.php");
145 $this->ctrl->forwardCommand($gui);
146 break;
147 default:
148 if ($this->getCreationMode() || $cmd == "save") {
149 $this->$cmd();
150 return;
151 }
152// if (strtolower($_GET["baseClass"]) == "iladministrationgui")
153// {
154// $this->viewObject();
155// return;
156// }
157 if (!$cmd) {
158 $cmd = $this->getStandardCmd();
159 }
160 if ($cmd == "infoScreen") {
161 $ilCtrl->setCmd("showSummary");
162 $ilCtrl->setCmdClass("ilinfoscreengui");
163 $this->infoScreen();
164 } else {
165 $this->performCommand($cmd);
166 }
167 break;
168 }
169
170 if (!$this->getCreationMode()) {
171 $tpl->show();
172 }
173 }
174
178 public function addLocatorItems()
179 {
180 $ilLocator = $this->locator;
181
182 if (!$this->getCreationMode()) {
183 $ilLocator->addItem(
184 $this->object->getTitle(),
185 $this->ctrl->getLinkTarget($this, $this->getStandardCmd()),
186 "",
187 $_GET["ref_id"]
188 );
189 }
190 }
191
197 protected function getPlugin()
198 {
199 if (!$this->plugin) {
200 $this->plugin =
203 "Repository",
204 "robj",
205 ilPlugin::lookupNameForId(IL_COMP_SERVICE, "Repository", "robj", $this->getType())
206 );
207 if (!is_object($this->plugin)) {
208 throw new ilPluginException("ilObjectPluginGUI: Could not instantiate plugin object for type " . $this->getType() . ".");
209 }
210 }
211 return $this->plugin;
212 }
213
217 final protected function txt($a_var)
218 {
219 return $this->getPlugin()->txt($a_var);
220 }
221
228 protected function getCreationFormTitle($a_form_type)
229 {
230 switch ($a_form_type) {
231 case self::CFORM_NEW:
232 return $this->txt($this->getType() . "_new");
233
235 return $this->lng->txt("import");
236
238 return $this->txt("objs_" . $this->getType() . "_duplicate");
239 }
240 }
241
250 protected function initCreationForms($a_new_type)
251 {
252 $ilPluginAdmin = $this->plugin_admin;
253
254 $forms = array();
255 $forms[self::CFORM_NEW] = $this->initCreateForm($a_new_type);
256
257 if ($this->supportsExport()) {
258 $forms[self::CFORM_IMPORT] = $this->initImportForm($a_new_type);
259 }
260 if ($this->supportsCloning()) {
261 $forms[self::CFORM_CLONE] = $this->fillCloneTemplate(null, $a_new_type);
262 }
263
264 return $forms;
265 }
266
270 protected function supportsCloning()
271 {
272 return true;
273 }
274
281 public function initCreateForm($a_new_type)
282 {
283 include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
284 $form = new ilPropertyFormGUI();
285 $form->setTarget("_top");
286 $form->setFormAction($this->ctrl->getFormAction($this, "save"));
287 $form->setTitle($this->txt($a_new_type . "_new"));
288
289 // title
290 $ti = new ilTextInputGUI($this->lng->txt("title"), "title");
291 $ti->setSize(min(40, ilObject::TITLE_LENGTH));
292 $ti->setMaxLength(ilObject::TITLE_LENGTH);
293 $ti->setRequired(true);
294 $form->addItem($ti);
295
296 // description
297 $ta = new ilTextAreaInputGUI($this->lng->txt("description"), "desc");
298 $ta->setCols(40);
299 $ta->setRows(2);
300 $form->addItem($ta);
301
302 $form->addCommandButton("save", $this->txt($a_new_type . "_add"));
303 $form->addCommandButton("cancel", $this->lng->txt("cancel"));
304
305 return $form;
306 }
307
313 public function initEditForm()
314 {
317
318 include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
319 $form = new ilPropertyFormGUI();
320 $form->setTarget("_top");
321 $form->setFormAction($ilCtrl->getFormAction($this, "update"));
322 $form->setTitle($lng->txt("edit"));
323
324 // title
325 $ti = new ilTextInputGUI($lng->txt("title"), "title");
326 $ti->setSize(min(40, ilObject::TITLE_LENGTH));
327 $ti->setMaxLength(ilObject::TITLE_LENGTH);
328 $ti->setRequired(true);
329 $form->addItem($ti);
330
331 // description
332 $ta = new ilTextAreaInputGUI($lng->txt("description"), "desc");
333 $ta->setCols(40);
334 $ta->setRows(2);
335 $form->addItem($ta);
336
337 $form->addCommandButton("update", $lng->txt("save"));
338 // $this->form->addCommandButton("cancelUpdate", $lng->txt("cancel"));
339
340 return $form;
341 }
342
349 protected function initImportForm($a_new_type)
350 {
351 include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
352 $form = new ilPropertyFormGUI();
353 $form->setTarget("_top");
354 $form->setFormAction($this->ctrl->getFormAction($this, "importFile"));
355 $form->setTitle($this->lng->txt("import"));
356
357 include_once("./Services/Form/classes/class.ilFileInputGUI.php");
358 $fi = new ilFileInputGUI($this->lng->txt("import_file"), "importfile");
359 $fi->setSuffixes(array("zip"));
360 $fi->setRequired(true);
361 $form->addItem($fi);
362
363 $form->addCommandButton("importFile", $this->lng->txt("import"));
364 $form->addCommandButton("cancel", $this->lng->txt("cancel"));
365
366 return $form;
367 }
368
373 public function afterSave(ilObject $newObj)
374 {
376 // always send a message
377 ilUtil::sendSuccess($this->lng->txt("object_added"), true);
378
379 $ilCtrl->initBaseClass("ilObjPluginDispatchGUI");
380 $ilCtrl->setTargetScript("ilias.php");
381 $ilCtrl->getCallStructure(strtolower("ilObjPluginDispatchGUI"));
382
383 //var_dump($ilCtrl->call_node);
384 //var_dump($ilCtrl->forward);
385 //var_dump($ilCtrl->parent);
386 //var_dump($ilCtrl->root_class);
387
388 $ilCtrl->setParameterByClass(get_class($this), "ref_id", $newObj->getRefId());
389 $ilCtrl->redirectByClass(array("ilobjplugindispatchgui", get_class($this)), $this->getAfterCreationCmd());
390 }
391
395 abstract public function getAfterCreationCmd();
396
397 abstract public function getStandardCmd();
398
399 // abstract function performCommand();
400
404 public function addInfoTab()
405 {
406 $ilAccess = $this->access;
407 $ilTabs = $this->tabs;
408
409 // info screen
410 if ($ilAccess->checkAccess('visible', "", $this->object->getRefId())) {
411 $ilTabs->addTarget(
412 "info_short",
413 $this->ctrl->getLinkTargetByClass(
414 "ilinfoscreengui",
415 "showSummary"
416 ),
417 "showSummary"
418 );
419 }
420 }
421
425 public function addPermissionTab()
426 {
427 $ilAccess = $this->access;
428 $ilTabs = $this->tabs;
430
431 // edit permissions
432 if ($ilAccess->checkAccess('edit_permission', "", $this->object->getRefId())) {
433 $ilTabs->addTarget(
434 "perm_settings",
435 $ilCtrl->getLinkTargetByClass("ilpermissiongui", "perm"),
436 array("perm","info","owner"),
437 'ilpermissiongui'
438 );
439 }
440 }
441
442
446 public function infoScreen()
447 {
450 $ilTabs = $this->tabs;
451
452 $ilTabs->activateTab("info_short");
453
454 $this->checkPermission("visible");
455
456 include_once("./Services/InfoScreen/classes/class.ilInfoScreenGUI.php");
457 $info = new ilInfoScreenGUI($this);
458 $info->enablePrivateNotes();
459
460 // general information
461 $lng->loadLanguageModule("meta");
462
463 $this->addInfoItems($info);
464
465 // forward the command
466 $ilCtrl->forwardCommand($info);
467 }
468
473 public function addInfoItems($info)
474 {
475 }
476
480 public static function _goto($a_target)
481 {
482 global $DIC;
483
484 $ilCtrl = $DIC->ctrl();
485 $ilAccess = $DIC->access();
486 $lng = $DIC->language();
487
488 $t = explode("_", $a_target[0]);
489 $ref_id = (int) $t[0];
490 $class_name = $a_target[1];
491
492 if ($ilAccess->checkAccess("read", "", $ref_id)) {
493 $ilCtrl->initBaseClass("ilObjPluginDispatchGUI");
494 $ilCtrl->setTargetScript("ilias.php");
495 $ilCtrl->getCallStructure(strtolower("ilObjPluginDispatchGUI"));
496 $ilCtrl->setParameterByClass($class_name, "ref_id", $ref_id);
497 $ilCtrl->redirectByClass(array("ilobjplugindispatchgui", $class_name), "");
498 } elseif ($ilAccess->checkAccess("visible", "", $ref_id)) {
499 $ilCtrl->initBaseClass("ilObjPluginDispatchGUI");
500 $ilCtrl->setTargetScript("ilias.php");
501 $ilCtrl->getCallStructure(strtolower("ilObjPluginDispatchGUI"));
502 $ilCtrl->setParameterByClass($class_name, "ref_id", $ref_id);
503 $ilCtrl->redirectByClass(array("ilobjplugindispatchgui", $class_name), "infoScreen");
504 } elseif ($ilAccess->checkAccess("read", "", ROOT_FOLDER_ID)) {
506 $lng->txt("msg_no_perm_read_item"),
508 ));
509 include_once("./Services/Object/classes/class.ilObjectGUI.php");
511 }
512 }
513
514
518 protected function supportsExport()
519 {
520 $ilPluginAdmin = $this->plugin_admin;
521
522 return $ilPluginAdmin->supportsExport(IL_COMP_SERVICE, "Repository", "robj", $this->getPlugin()->getPluginName());
523 }
524
525
530 {
532 }
533}
sprintf('%.4f', $callTime)
user()
Definition: user.php:4
$_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
static _getIcon( $a_obj_id="", $a_size="big", $a_type="", $a_offline=false)
Get icon for repository item.
getRefId()
get reference id @access public
static _lookupType($a_id, $a_reference=false)
lookup object type
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.
$GLOBALS['loaded']
Global hash that tracks already loaded includes.
global $ilCtrl
Definition: ilias.php:18
$info
Definition: index.php:5
if(isset($_POST['submit'])) $form
global $DIC
Definition: saml.php:7