ILIAS  Release_4_2_x_branch Revision 61807
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilComponentsTableGUI.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/Table/classes/class.ilTable2GUI.php");
5 include_once("Services/Component/classes/class.ilComponent.php");
6 
7 
17 {
18  private $mode;
19 
20  function ilComponentsTableGUI($a_parent_obj, $a_parent_cmd = "",
21  $a_mode = IL_COMP_MODULE)
22  {
23  global $ilCtrl, $lng;
24 
25  $this->mode = $a_mode;
26 
27  parent::__construct($a_parent_obj, $a_parent_cmd);
28 
29  if ($this->mode == IL_COMP_MODULE)
30  {
31  $this->addColumn($lng->txt("cmps_module"));
32  $this->addColumn($lng->txt("cmps_rep_object"));
33  }
34  else
35  {
36  $this->addColumn($lng->txt("cmps_service"));
37  }
38  $this->addColumn($lng->txt("cmps_plugin_slot"));
39  $this->setEnableHeader(true);
40  $this->setFormAction($ilCtrl->getFormAction($a_parent_obj));
41  $this->setRowTemplate("tpl.table_row_component.html",
42  "Services/Component");
43  $this->getComponents();
44  $this->setDefaultOrderField("subdir");
45  $this->setLimit(10000);
46 
47  if ($this->mode == IL_COMP_MODULE)
48  {
49  // save options command
50  $this->addCommandButton("saveOptions", $lng->txt("cmps_save_options"));
51 
52  $this->setTitle($lng->txt("cmps_modules"));
53  }
54  else
55  {
56  $this->setTitle($lng->txt("cmps_services"));
57  }
58  }
59 
63  function getComponents()
64  {
65  if ($this->mode == IL_COMP_MODULE)
66  {
67  include_once("./Services/Component/classes/class.ilModule.php");
69  $this->setData($modules);
70  }
71  else
72  {
73  include_once("./Services/Component/classes/class.ilService.php");
75  $this->setData($services);
76  }
77  }
78 
83  protected function fillRow($a_set)
84  {
85  global $lng, $ilCtrl, $ilSetting, $objDefinition;
86 
87  // plugin slots
88  $plugin_slots = ilComponent::lookupPluginSlots($this->mode, $a_set["subdir"]);
89 
90  foreach ($plugin_slots as $slot)
91  {
92  $this->tpl->setCurrentBlock("slot");
93  $this->tpl->setVariable("SLOT_NAME", $slot["name"]);
94  $this->tpl->setVariable("SLOT_ID", $slot["id"]);
95  $this->tpl->setVariable("TXT_DIR", $lng->txt("cmps_dir"));
96  $this->tpl->setVariable("SLOT_DIR", $slot["dir_pres"]);
97  $this->tpl->setVariable("TXT_LANG_PREFIX", $lng->txt("cmps_lang_prefix"));
98  $this->tpl->setVariable("LANG_PREFIX", $slot["lang_prefix"]);
99 
100  $ilCtrl->setParameter($this->parent_obj, "ctype", $this->mode);
101  $ilCtrl->setParameter($this->parent_obj, "cname", $a_set["subdir"]);
102  $ilCtrl->setParameter($this->parent_obj, "slot_id", $slot["id"]);
103  $this->tpl->setVariable("HREF_SHOW_SLOT",
104  $ilCtrl->getLinkTarget($this->parent_obj, "showPluginSlotInfo"));
105  $this->tpl->setVariable("TXT_SHOW_SLOT", $lng->txt("cmps_show_details"));
106  $this->tpl->parseCurrentBlock();
107  }
108 
109 
110  // repository object types
111  if ($this->mode == IL_COMP_MODULE)
112  {
113  $rep_types =
114  $objDefinition->getRepositoryObjectTypesForComponent(IL_COMP_MODULE, $a_set["subdir"]);
115 
116  foreach ($rep_types as $rt)
117  {
118  // we only want to display repository modules
119  if(!$rt["repository"])
120  {
121  continue;
122  }
123 
124  // group
125  if ($rt["grp"] != "")
126  {
127  $this->tpl->setCurrentBlock("group");
128  $this->tpl->setVariable("TXT_GROUP", $lng->txt("cmps_group"));
129  $gi = $objDefinition->getGroup($rt["grp"]);
130  $this->tpl->setVariable("VAL_GROUP", $gi["name"]);
131  $this->tpl->setVariable("VAL_GROUP_ID", $rt["grp"]);
132  $this->tpl->parseCurrentBlock();
133  }
134 
135  $this->tpl->setCurrentBlock("rep_object");
136  $this->tpl->setVariable("TXT_REP_OBJECT",
137  $rt["class_name"]);
138  $this->tpl->setVariable("TXT_REP_OBJECT_ID",
139  $rt["id"]);
140  $this->tpl->setVariable("IMG_REP_OBJECT",
141  ilUtil::getImagePath("icon_".$rt["id"].".gif"));
142 
143  // add new position
144  $this->tpl->setVariable("TXT_ADD_NEW_POS",
145  $lng->txt("cmps_add_new_rank"));
146  $this->tpl->setVariable("VAR_POS",
147  "obj_pos[".$rt["id"]."]");
148  $pos = ($ilSetting->get("obj_add_new_pos_".$rt["id"]) > 0)
149  ? $ilSetting->get("obj_add_new_pos_".$rt["id"])
150  : $rt["default_pos"];
151  $this->tpl->setVariable("VAL_POS",
153 
154  // disable creation
155  $this->tpl->setVariable("TXT_DISABLE_CREATION",
156  $lng->txt("cmps_disable_creation"));
157  $this->tpl->setVariable("VAR_DISABLE_CREATION",
158  "obj_dis_creation[".$rt["id"]."]");
159  if ($ilSetting->get("obj_dis_creation_".$rt["id"]))
160  {
161  $this->tpl->setVariable("CHECKED_DISABLE_CREATION",
162  ' checked="checked" ');
163  }
164 
165  $this->tpl->parseCurrentBlock();
166  }
167  $this->tpl->setCurrentBlock("rep_object_td");
168  if (count($rep_types) == 0)
169  {
170  $this->tpl->setVariable("DUMMY", "&nbsp;");
171  }
172  $this->tpl->parseCurrentBlock();
173  }
174 
175  $this->tpl->setVariable("TXT_MODULE_NAME", $a_set["subdir"]);
176  }
177 
178 }
179 ?>