ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
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  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  {
59  $tpl = $this->tpl;
60  $ilAccess = $this->access;
61  $lng = $this->lng;
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  if ($ilAccess->checkAccess('read', '', $this->object->getRefId())) {
84  $ilNavigationHistory->addItem(
85  $this->object->getRefId(),
86  ilLink::_getLink($this->object->getRefId(), $this->object->getType()),
87  $this->object->getType()
88  );
89  }
90  } else {
91  // show info of parent
92  $tpl->setTitle($this->lookupParentTitleInCreationMode());
93  $tpl->setTitleIcon(
94  ilObject::_getIcon(ilObject::_lookupObjId($_GET["ref_id"]), "big"),
95  $lng->txt("obj_" . ilObject::_lookupType($_GET["ref_id"], true))
96  );
97  $this->setLocator();
98  }
99 
100  $next_class = $this->ctrl->getNextClass($this);
101  $cmd = $this->ctrl->getCmd();
102 
103  switch ($next_class) {
104  case "ilinfoscreengui":
105  $this->checkPermission("visible");
106  $this->infoScreen(); // forwards command
107  break;
108 
109  case 'ilpermissiongui':
110  include_once("Services/AccessControl/classes/class.ilPermissionGUI.php");
111  $perm_gui = new ilPermissionGUI($this);
112  $ilTabs->setTabActive("perm_settings");
113  $ilCtrl->forwardCommand($perm_gui);
114  break;
115 
116  case 'ilobjectcopygui':
117  include_once './Services/Object/classes/class.ilObjectCopyGUI.php';
118  $cp = new ilObjectCopyGUI($this);
119  $cp->setType($this->getType());
120  $this->ctrl->forwardCommand($cp);
121  break;
122 
123  case 'ilexportgui':
124  // only if plugin supports it?
125  $this->tabs->setTabActive("export");
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 
234  case self::CFORM_IMPORT:
235  return $this->lng->txt("import");
236 
237  case self::CFORM_CLONE:
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  {
315  $lng = $this->lng;
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->getCallStructure(strtolower("ilObjPluginDispatchGUI"));
381 
382  $ilCtrl->setParameterByClass(get_class($this), "ref_id", $newObj->getRefId());
383  $ilCtrl->redirectByClass(array("ilobjplugindispatchgui", get_class($this)), $this->getAfterCreationCmd());
384  }
385 
389  abstract public function getAfterCreationCmd();
390 
391  abstract public function getStandardCmd();
392 
393  // abstract function performCommand();
394 
398  public function addInfoTab()
399  {
400  $ilAccess = $this->access;
401  $ilTabs = $this->tabs;
402 
403  // info screen
404  if ($ilAccess->checkAccess('visible', "", $this->object->getRefId())) {
405  $ilTabs->addTarget(
406  "info_short",
407  $this->ctrl->getLinkTargetByClass(
408  "ilinfoscreengui",
409  "showSummary"
410  ),
411  "showSummary"
412  );
413  }
414  }
415 
419  public function addPermissionTab()
420  {
421  $ilAccess = $this->access;
422  $ilTabs = $this->tabs;
424 
425  // edit permissions
426  if ($ilAccess->checkAccess('edit_permission', "", $this->object->getRefId())) {
427  $ilTabs->addTarget(
428  "perm_settings",
429  $ilCtrl->getLinkTargetByClass("ilpermissiongui", "perm"),
430  array("perm","info","owner"),
431  'ilpermissiongui'
432  );
433  }
434  }
435 
436 
440  public function addExportTab()
441  {
442  // write
443  if ($this->access->checkAccess('write', "", $this->object->getRefId())) {
444  $this->tabs->addTarget(
445  'export',
446  $this->ctrl->getLinkTargetByClass("ilexportgui", ''),
447  'export',
448  'ilexportgui'
449  );
450  }
451  }
452 
456  public function infoScreen()
457  {
458  $lng = $this->lng;
460  $ilTabs = $this->tabs;
461 
462  $ilTabs->activateTab("info_short");
463 
464  $this->checkPermission("visible");
465 
466  include_once("./Services/InfoScreen/classes/class.ilInfoScreenGUI.php");
467  $info = new ilInfoScreenGUI($this);
468  $info->enablePrivateNotes();
469 
470  // general information
471  $lng->loadLanguageModule("meta");
472 
473  $this->addInfoItems($info);
474 
475  // forward the command
476  $ilCtrl->forwardCommand($info);
477  }
478 
483  public function addInfoItems($info)
484  {
485  }
486 
490  public static function _goto($a_target)
491  {
492  global $DIC;
493 
494  $ilCtrl = $DIC->ctrl();
495  $ilAccess = $DIC->access();
496  $lng = $DIC->language();
497 
498  $t = explode("_", $a_target[0]);
499  $ref_id = (int) $t[0];
500  $class_name = $a_target[1];
501 
502  if ($ilAccess->checkAccess("read", "", $ref_id)) {
503  $ilCtrl->initBaseClass("ilObjPluginDispatchGUI");
504  $ilCtrl->getCallStructure(strtolower("ilObjPluginDispatchGUI"));
505  $ilCtrl->setParameterByClass($class_name, "ref_id", $ref_id);
506  $ilCtrl->redirectByClass(array("ilobjplugindispatchgui", $class_name), "");
507  } elseif ($ilAccess->checkAccess("visible", "", $ref_id)) {
508  $ilCtrl->initBaseClass("ilObjPluginDispatchGUI");
509  $ilCtrl->getCallStructure(strtolower("ilObjPluginDispatchGUI"));
510  $ilCtrl->setParameterByClass($class_name, "ref_id", $ref_id);
511  $ilCtrl->redirectByClass(array("ilobjplugindispatchgui", $class_name), "infoScreen");
512  } elseif ($ilAccess->checkAccess("read", "", ROOT_FOLDER_ID)) {
513  ilUtil::sendFailure(sprintf(
514  $lng->txt("msg_no_perm_read_item"),
516  ));
517  include_once("./Services/Object/classes/class.ilObjectGUI.php");
519  }
520  }
521 
522 
526  protected function supportsExport()
527  {
528  $ilPluginAdmin = $this->plugin_admin;
529 
530  return $ilPluginAdmin->supportsExport(IL_COMP_SERVICE, "Repository", "robj", $this->getPlugin()->getPluginName());
531  }
532 
533 
537  protected function lookupParentTitleInCreationMode()
538  {
540  }
541 }
setLocator()
set Locator
initCreationForms($a_new_type)
Init creation froms.
static getPluginObject(string $a_ctype, string $a_cname, string $a_slot_id, string $a_pname)
checkPermission($a_perm, $a_cmd="", $a_type="", $a_ref_id=null)
Class ilInfoScreenGUI.
This class represents a property form user interface.
New implementation of ilObjectGUI.
GUI class for the workflow of copying objects.
global $DIC
Definition: saml.php:7
const TITLE_LENGTH
max length of object title
txt($a_var)
Wrapper for txt function.
$_GET["client_id"]
__construct($a_ref_id=0, $a_id_type=self::REPOSITORY_NODE_ID, $a_parent_node_id=0)
Constructor.
This class represents a file property in a property form.
addInfoItems($info)
Add items to info screen.
fillCloneTemplate($a_tpl_varname, $a_type)
static _gotoRepositoryRoot($a_raise_error=false)
Goto repository root.
static _lookupTitle($a_id)
lookup object title
addExportTab()
Add export tab.
static _goto($a_target)
Goto redirection.
user()
Definition: user.php:4
getPlugin()
Get plugin object.
global $ilCtrl
Definition: ilias.php:18
executeCommand()
execute command
static lookupNameForId(string $a_ctype, string $a_cname, string $a_slot_id, string $a_plugin_id)
Export User Interface Class.
initImportForm($a_new_type)
Init object import form.
addPermissionTab()
Add permission tab.
getAfterCreationCmd()
Cmd that will be redirected to after creation of a new object.
if(isset($_POST['submit'])) $form
initCreateForm($a_new_type)
Init object creation form.
getType()
Functions that must be overwritten.
static _lookupObjId($a_id)
setSize($a_size)
Set Size.
This class represents a text property in a property form.
static _lookupType($a_id, $a_reference=false)
lookup object type
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
setTabs()
create tabs (repository/workspace switch)
addLocatorItems()
Add object to locator.
This class represents a text area property in a property form.
addInfoTab()
Add info screen tab.
initEditForm()
Init object update form.
getCreationFormTitle($a_form_type)
Use custom creation form titles.
getRefId()
get reference id public
New PermissionGUI (extends from old ilPermission2GUI) RBAC related output.
afterSave(ilObject $newObj)
After saving public.
addAdminLocatorItems($a_do_not_add_object=false)
$info
Definition: index.php:5
setSuffixes($a_suffixes)
Set Accepted Suffixes.
infoScreen()
show information screen
Class ilObjUserTrackingGUI.
const IL_COMP_SERVICE
static getInstanceFromAjaxCall()
(Re-)Build instance from ajax call
$GLOBALS['JPEG_Segment_Names']
Global Variable: XMP_tag_captions.
setAdminTabs()
set admin tabs public