ILIAS  Release_4_4_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilPluginsOverviewTableGUI.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 __construct($a_parent_obj, $a_parent_cmd = "")
21  {
22  global $ilCtrl, $lng;
23 
24  parent::__construct($a_parent_obj, $a_parent_cmd);
25 
26  $this->setId("cmpspl");
27 
28  $this->addColumn($lng->txt("cmps_plugin"), "plugin_name");
29  $this->addColumn($lng->txt("cmps_plugin_slot"), "slot_name");
30  $this->addColumn($lng->txt("cmps_component"), "component_name");
31  $this->addColumn($lng->txt("active"), "plugin_active");
32  $this->addColumn($lng->txt("action"));
33 
34  $this->setDefaultOrderField("plugin_name");
35 
36  $this->setEnableHeader(true);
37  $this->setFormAction($ilCtrl->getFormAction($a_parent_obj));
38  $this->setRowTemplate("tpl.plugin_overview_row.html",
39  "Services/Component");
40  $this->getComponents();
41  $this->setLimit(10000);
42 
43  include_once("./Services/UIComponent/AdvancedSelectionList/classes/class.ilAdvancedSelectionListGUI.php");
44  }
45 
49  function getComponents()
50  {
51  $plugins = array();
52 
53  include_once("./Services/Component/classes/class.ilModule.php");
55  foreach ($modules as $m)
56  {
58  $m["subdir"]);
59  foreach ($plugin_slots as $ps)
60  {
61  include_once("./Services/Component/classes/class.ilPluginSlot.php");
62  $slot = new ilPluginSlot(IL_COMP_MODULE, $m["subdir"], $ps["id"]);
63  foreach ($slot->getPluginsInformation() as $p)
64  {
65  $plugins[] = $this->gatherPluginData(IL_COMP_MODULE, $slot, $m["subdir"], $p);
66  }
67  }
68  }
69  include_once("./Services/Component/classes/class.ilService.php");
71  foreach ($services as $s)
72  {
74  $s["subdir"]);
75  foreach ($plugin_slots as $ps)
76  {
77  $slot = new ilPluginSlot(IL_COMP_SERVICE, $s["subdir"], $ps["id"]);
78  foreach ($slot->getPluginsInformation() as $p)
79  {
80  $plugins[] = $this->gatherPluginData(IL_COMP_SERVICE, $slot, $s["subdir"], $p);
81  }
82  }
83  }
84  $this->setData($plugins);
85  }
86 
96  protected function gatherPluginData($a_type, ilPluginSlot $a_slot, $a_slot_subdir, array $a_plugin)
97  {
98  global $ilCtrl;
99 
100  $conf = false;
101  if(ilPlugin::hasConfigureClass($a_slot->getPluginsDirectory(), $a_plugin["name"]) &&
102  $ilCtrl->checkTargetClass(ilPlugin::getConfigureClassName($a_plugin["name"])))
103  {
104  $conf = true;
105  }
106 
107  return array("slot_name" => $a_slot->getSlotName(),
108  "component_type" => $a_type,
109  "component_name" => $a_slot_subdir,
110  "slot_id" => $a_slot->getSlotId(),
111  "plugin_id" => $a_plugin["id"],
112  "plugin_name" => $a_plugin["name"],
113  "plugin_active" => $a_plugin["is_active"],
114  "activation_possible" => $a_plugin["activation_possible"],
115  "needs_update" => $a_plugin["needs_update"],
116  "has_conf" => $conf,
117  "has_lang" => (bool)sizeof(ilPlugin::getAvailableLangFiles(
118  $a_slot->getPluginsDirectory()."/".$a_plugin["name"]."/lang")));
119  }
120 
125  protected function fillRow($a_set)
126  {
127  global $ilCtrl, $lng;
128 
129  // actions
130 
131  $ilCtrl->setParameter($this->parent_obj, "ctype", $a_set["component_type"]);
132  $ilCtrl->setParameter($this->parent_obj, "cname", $a_set["component_name"]);
133  $ilCtrl->setParameter($this->parent_obj, "slot_id", $a_set["slot_id"]);
134 
135  $action = array();
136 
137  $ilCtrl->setParameter($this->parent_obj, "plugin_id", $a_set["plugin_id"]);
138  $action[$lng->txt("info")] = $ilCtrl->getLinkTarget($this->parent_obj, "showPlugin");
139  $ilCtrl->setParameter($this->parent_obj, "plugin_id", "");
140 
141  $ilCtrl->setParameter($this->parent_obj, "pname", $a_set["plugin_name"]);
142 
143  if ($a_set["plugin_active"])
144  {
145  if ($a_set["has_lang"])
146  {
147  $action[$lng->txt("cmps_refresh")] =
148  $ilCtrl->getLinkTarget($this->parent_obj, "refreshLanguages");
149  }
150 
151  if ($a_set["has_conf"])
152  {
153  $action[$lng->txt("cmps_configure")] =
154  $ilCtrl->getLinkTargetByClass(strtolower(ilPlugin::getConfigureClassName($a_set["plugin_name"])), "configure");
155  }
156 
157  $action[$lng->txt("cmps_deactivate")] =
158  $ilCtrl->getLinkTarget($this->parent_obj, "deactivatePlugin");
159  }
160  else if ($a_set["activation_possible"])
161  {
162  $action[$lng->txt("cmps_activate")] =
163  $ilCtrl->getLinkTarget($this->parent_obj, "activatePlugin");
164  }
165 
166  // update button
167  if ($a_set["needs_update"])
168  {
169  $action[$lng->txt("cmps_update")] =
170  $ilCtrl->getLinkTarget($this->parent_obj, "updatePlugin");
171  }
172 
173  $ilCtrl->setParameter($this->parent_obj, "pname", "");
174 
175  if(sizeof($action))
176  {
177  $alist = new ilAdvancedSelectionListGUI();
178  $alist->setId($a_set["plugin_id"]);
179  $alist->setListTitle($lng->txt("actions"));
180 
181  foreach($action as $caption => $cmd)
182  {
183  $alist->addItem($caption, "", $cmd);
184  }
185 
186  $this->tpl->setVariable("ACTION_SELECTOR", $alist->getHTML());
187  }
188 
189  $this->tpl->setVariable("TXT_SLOT_NAME", $a_set["slot_name"]);
190  $this->tpl->setVariable("TXT_COMP_NAME",
191  $a_set["component_type"]."/".$a_set["component_name"]);
192 
193  $act_str = ($a_set["plugin_active"])
194  ? "<b>".$lng->txt("yes")."</b>"
195  : $lng->txt("no");
196  $this->tpl->setVariable("TXT_PLUGIN_NAME", $a_set["plugin_name"]);
197  $this->tpl->setVariable("TXT_ACTIVE", $act_str);
198  }
199 }
200 
201 ?>