ILIAS  Release_4_0_x_branch Revision 61816
 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 
216  function afterSave($newObj)
217  {
218  global $ilCtrl;
219  // always send a message
220  ilUtil::sendSuccess($this->lng->txt("object_added"),true);
221 
222  $ilCtrl->initBaseClass("ilObjPluginDispatchGUI");
223  $ilCtrl->setTargetScript("ilias.php");
224  $ilCtrl->getCallStructure(strtolower("ilObjPluginDispatchGUI"));
225 
226 //var_dump($ilCtrl->call_node);
227 //var_dump($ilCtrl->forward);
228 //var_dump($ilCtrl->parent);
229 //var_dump($ilCtrl->root_class);
230 
231  $ilCtrl->setParameterByClass(get_class($this), "ref_id", $newObj->getRefId());
232  $ilCtrl->redirectByClass(array("ilobjplugindispatchgui", get_class($this)), $this->getAfterCreationCmd());
233  }
234 
238  abstract function getAfterCreationCmd();
239 
240  abstract function getStandardCmd();
241 
242 // abstract function performCommand();
243 
247  function addInfoTab()
248  {
249  global $ilAccess, $ilTabs;
250 
251  // info screen
252  if ($ilAccess->checkAccess('visible', "", $this->object->getRefId()))
253  {
254  $ilTabs->addTarget("info_short",
255  $this->ctrl->getLinkTargetByClass(
256  "ilinfoscreengui", "showSummary"),
257  "showSummary");
258  }
259  }
260 
264  function addPermissionTab()
265  {
266  global $ilAccess, $ilTabs, $ilCtrl;
267 
268  // edit permissions
269  if($ilAccess->checkAccess('edit_permission', "", $this->object->getRefId()))
270  {
271  $ilTabs->addTarget("perm_settings",
272  $ilCtrl->getLinkTargetByClass("ilpermissiongui", "perm"),
273  array("perm","info","owner"), 'ilpermissiongui');
274  }
275  }
276 
277 
281  function infoScreen()
282  {
283  global $ilAccess, $ilUser, $lng, $ilCtrl, $tpl, $ilTabs;
284 
285  $ilTabs->setTabActive("info_short");
286 
287  $this->checkPermission("visible");
288 
289  include_once("./Services/InfoScreen/classes/class.ilInfoScreenGUI.php");
290  $info = new ilInfoScreenGUI($this);
291  $info->enablePrivateNotes();
292 
293  // general information
294  $lng->loadLanguageModule("meta");
295 
296  $this->addInfoItems($info);
297 
298  // forward the command
299  $ret = $ilCtrl->forwardCommand($info);
300  //$tpl->setContent($ret);
301  }
302 
306  function addInfoItems($info)
307  {
308  }
309 
313  function _goto($a_target)
314  {
315  global $ilCtrl, $ilAccess, $lng;
316 
317  $t = explode("_", $a_target[0]);
318  $ref_id = (int) $t[0];
319  $class_name = $a_target[1];
320 
321  if ($ilAccess->checkAccess("read", "", $ref_id))
322  {
323  $ilCtrl->initBaseClass("ilObjPluginDispatchGUI");
324  $ilCtrl->setTargetScript("ilias.php");
325  $ilCtrl->getCallStructure(strtolower("ilObjPluginDispatchGUI"));
326  $ilCtrl->setParameterByClass($class_name, "ref_id", $ref_id);
327  $ilCtrl->redirectByClass(array("ilobjplugindispatchgui", $class_name), "");
328  }
329  else if($ilAccess->checkAccess("visible", "", $ref_id))
330  {
331  $ilCtrl->initBaseClass("ilObjPluginDispatchGUI");
332  $ilCtrl->setTargetScript("ilias.php");
333  $ilCtrl->getCallStructure(strtolower("ilObjPluginDispatchGUI"));
334  $ilCtrl->setParameterByClass($class_name, "ref_id", $ref_id);
335  $ilCtrl->redirectByClass(array("ilobjplugindispatchgui", $class_name), "infoScreen");
336  }
337  else if ($ilAccess->checkAccess("read", "", ROOT_FOLDER_ID))
338  {
339  $_GET["cmd"] = "frameset";
340  $_GET["target"] = "";
341  $_GET["ref_id"] = ROOT_FOLDER_ID;
342  ilUtil::sendFailure(sprintf($lng->txt("msg_no_perm_read_item"),
344  include("repository.php");
345  exit;
346  }
347  }
348 
349 }