ILIAS  Release_4_0_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilComponentsTableGUI.php
Go to the documentation of this file.
1 <?php
2 /*
3  +-----------------------------------------------------------------------------+
4  | ILIAS open source |
5  +-----------------------------------------------------------------------------+
6  | Copyright (c) 1998-2008 ILIAS open source, University of Cologne |
7  | |
8  | This program is free software; you can redistribute it and/or |
9  | modify it under the terms of the GNU General Public License |
10  | as published by the Free Software Foundation; either version 2 |
11  | of the License, or (at your option) any later version. |
12  | |
13  | This program is distributed in the hope that it will be useful, |
14  | but WITHOUT ANY WARRANTY; without even the implied warranty of |
15  | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16  | GNU General Public License for more details. |
17  | |
18  | You should have received a copy of the GNU General Public License |
19  | along with this program; if not, write to the Free Software |
20  | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
21  +-----------------------------------------------------------------------------+
22 */
23 
24 include_once("Services/Table/classes/class.ilTable2GUI.php");
25 include_once("Services/Component/classes/class.ilComponent.php");
26 
27 
37 {
38  private $mode;
39 
40  function ilComponentsTableGUI($a_parent_obj, $a_parent_cmd = "",
41  $a_mode = IL_COMP_MODULE)
42  {
43  global $ilCtrl, $lng;
44 
45  $this->mode = $a_mode;
46 
47  parent::__construct($a_parent_obj, $a_parent_cmd);
48 
49  if ($this->mode == IL_COMP_MODULE)
50  {
51  $this->addColumn($lng->txt("cmps_module"));
52  $this->addColumn($lng->txt("cmps_rep_object"));
53  }
54  else
55  {
56  $this->addColumn($lng->txt("cmps_service"));
57  }
58  $this->addColumn($lng->txt("cmps_plugin_slot"));
59  $this->setEnableHeader(true);
60  $this->setFormAction($ilCtrl->getFormAction($a_parent_obj));
61  $this->setRowTemplate("tpl.table_row_component.html",
62  "Services/Component");
63  $this->getComponents();
64  $this->setDefaultOrderField("subdir");
65  $this->setLimit(10000);
66 
67  // save options command
68  $this->addCommandButton("saveOptions", $lng->txt("cmps_save_options"));
69 
70  if ($this->mode == IL_COMP_MODULE)
71  {
72  $this->setTitle($lng->txt("cmps_modules"));
73  }
74  else
75  {
76  $this->setTitle($lng->txt("cmps_services"));
77  }
78  }
79 
83  function getComponents()
84  {
85  if ($this->mode == IL_COMP_MODULE)
86  {
87  include_once("./Services/Component/classes/class.ilModule.php");
89  $this->setData($modules);
90  }
91  else
92  {
93  include_once("./Services/Component/classes/class.ilService.php");
95  $this->setData($services);
96  }
97  }
98 
103  protected function fillRow($a_set)
104  {
105  global $lng, $ilCtrl, $ilSetting, $objDefinition;
106 
107  // plugin slots
108  $plugin_slots = ilComponent::lookupPluginSlots($this->mode, $a_set["subdir"]);
109 
110  foreach ($plugin_slots as $slot)
111  {
112  $this->tpl->setCurrentBlock("slot");
113  $this->tpl->setVariable("SLOT_NAME", $slot["name"]);
114  $this->tpl->setVariable("SLOT_ID", $slot["id"]);
115  $this->tpl->setVariable("TXT_DIR", $lng->txt("cmps_dir"));
116  $this->tpl->setVariable("SLOT_DIR", $slot["dir_pres"]);
117  $this->tpl->setVariable("TXT_LANG_PREFIX", $lng->txt("cmps_lang_prefix"));
118  $this->tpl->setVariable("LANG_PREFIX", $slot["lang_prefix"]);
119 
120  $ilCtrl->setParameter($this->parent_obj, "ctype", $this->mode);
121  $ilCtrl->setParameter($this->parent_obj, "cname", $a_set["subdir"]);
122  $ilCtrl->setParameter($this->parent_obj, "slot_id", $slot["id"]);
123  $this->tpl->setVariable("HREF_SHOW_SLOT",
124  $ilCtrl->getLinkTarget($this->parent_obj, "showPluginSlot"));
125  $this->tpl->setVariable("TXT_SHOW_SLOT", $lng->txt("cmps_show_details"));
126  $this->tpl->parseCurrentBlock();
127  }
128 
129 
130  // repository object types
131  if ($this->mode == IL_COMP_MODULE)
132  {
133  $rep_types =
134  $objDefinition->getRepositoryObjectTypesForComponent(IL_COMP_MODULE, $a_set["subdir"]);
135 
136  foreach ($rep_types as $rt)
137  {
138  // group
139  if ($rt["grp"] != "")
140  {
141  $this->tpl->setCurrentBlock("group");
142  $this->tpl->setVariable("TXT_GROUP", $lng->txt("cmps_group"));
143  $gi = $objDefinition->getGroup($rt["grp"]);
144  $this->tpl->setVariable("VAL_GROUP", $gi["name"]);
145  $this->tpl->setVariable("VAL_GROUP_ID", $rt["grp"]);
146  $this->tpl->parseCurrentBlock();
147  }
148 
149  $this->tpl->setCurrentBlock("rep_object");
150  $this->tpl->setVariable("TXT_REP_OBJECT",
151  $rt["class_name"]);
152  $this->tpl->setVariable("TXT_REP_OBJECT_ID",
153  $rt["id"]);
154  $this->tpl->setVariable("IMG_REP_OBJECT",
155  ilUtil::getImagePath("icon_".$rt["id"].".gif"));
156 
157  // add new position
158  $this->tpl->setVariable("TXT_ADD_NEW_POS",
159  $lng->txt("cmps_add_new_rank"));
160  $this->tpl->setVariable("VAR_POS",
161  "obj_pos[".$rt["id"]."]");
162  $pos = ($ilSetting->get("obj_add_new_pos_".$rt["id"]) > 0)
163  ? $ilSetting->get("obj_add_new_pos_".$rt["id"])
164  : $rt["default_pos"];
165  $this->tpl->setVariable("VAL_POS",
167 
168  // disable creation
169  $this->tpl->setVariable("TXT_DISABLE_CREATION",
170  $lng->txt("cmps_disable_creation"));
171  $this->tpl->setVariable("VAR_DISABLE_CREATION",
172  "obj_dis_creation[".$rt["id"]."]");
173  if ($ilSetting->get("obj_dis_creation_".$rt["id"]))
174  {
175  $this->tpl->setVariable("CHECKED_DISABLE_CREATION",
176  ' checked="checked" ');
177  }
178 
179  $this->tpl->parseCurrentBlock();
180  }
181  $this->tpl->setCurrentBlock("rep_object_td");
182  if (count($rep_types) == 0)
183  {
184  $this->tpl->setVariable("DUMMY", "&nbsp;");
185  }
186  $this->tpl->parseCurrentBlock();
187  }
188 
189  $this->tpl->setVariable("TXT_MODULE_NAME", $a_set["subdir"]);
190  }
191 
192 }
193 ?>