ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
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("id"), "plugin_id");
30  $this->addColumn($lng->txt("cmps_plugin_slot"), "slot_name");
31  $this->addColumn($lng->txt("cmps_component"), "component_name");
32  $this->addColumn($lng->txt("active"), "plugin_active");
33  $this->addColumn($lng->txt("action"));
34 
35  $this->setDefaultOrderField("plugin_name");
36 
37  $this->setEnableHeader(true);
38  $this->setFormAction($ilCtrl->getFormAction($a_parent_obj));
39  $this->setRowTemplate("tpl.plugin_overview_row.html",
40  "Services/Component");
41  $this->getComponents();
42  $this->setLimit(10000);
43 
44  include_once("./Services/UIComponent/AdvancedSelectionList/classes/class.ilAdvancedSelectionListGUI.php");
45  }
46 
50  function getComponents()
51  {
52  $plugins = array();
53 
55  $log->debug("plugins - start processing components");
56 
57 
58  include_once("./Services/Component/classes/class.ilModule.php");
60  foreach ($modules as $m)
61  {
62  // $log->debug("module ".$m["subdir"].": looking for slots");
63 
65  $m["subdir"]);
66  foreach ($plugin_slots as $ps)
67  {
68  $log->debug("module ".$m["subdir"].": found slot (".$ps["id"].") ".$ps["name"]);
69 
70  include_once("./Services/Component/classes/class.ilPluginSlot.php");
71  $slot = new ilPluginSlot(IL_COMP_MODULE, $m["subdir"], $ps["id"]);
72  foreach ($slot->getPluginsInformation() as $p)
73  {
74  $log->debug("module ".$m["subdir"].": found plugin (".$p["id"].") ".$p["name"]);
75 
76  $plugins[] = $this->gatherPluginData(IL_COMP_MODULE, $slot, $m["subdir"], $p);
77  }
78  }
79  }
80  include_once("./Services/Component/classes/class.ilService.php");
82  foreach ($services as $s)
83  {
84  // $log->debug("service ".$s["subdir"].": looking for slots");
85 
87  $s["subdir"]);
88  foreach ($plugin_slots as $ps)
89  {
90  $log->debug("service ".$s["subdir"].": found slot (".$ps["id"].") ".$ps["name"]);
91 
92  $slot = new ilPluginSlot(IL_COMP_SERVICE, $s["subdir"], $ps["id"]);
93  foreach ($slot->getPluginsInformation() as $p)
94  {
95  $log->debug("service ".$s["subdir"].": found plugin (".$p["id"].") ".$p["name"]);
96 
97  $plugins[] = $this->gatherPluginData(IL_COMP_SERVICE, $slot, $s["subdir"], $p);
98  }
99  }
100  }
101  $this->setData($plugins);
102 
103  $log->debug("plugins - stop processing components");
104  }
105 
115  protected function gatherPluginData($a_type, ilPluginSlot $a_slot, $a_slot_subdir, array $a_plugin)
116  {
117  global $ilCtrl;
118 
119  $conf = false;
120  if(ilPlugin::hasConfigureClass($a_slot->getPluginsDirectory(), $a_plugin["name"]) &&
121  $ilCtrl->checkTargetClass(ilPlugin::getConfigureClassName($a_plugin["name"])))
122  {
123  $conf = true;
124  }
125 
126  return array("slot_name" => $a_slot->getSlotName(),
127  "component_type" => $a_type,
128  "component_name" => $a_slot_subdir,
129  "slot_id" => $a_slot->getSlotId(),
130  "plugin_id" => $a_plugin["id"],
131  "plugin_name" => $a_plugin["name"],
132  "plugin_active" => $a_plugin["is_active"],
133  "activation_possible" => $a_plugin["activation_possible"],
134  "needs_update" => $a_plugin["needs_update"],
135  "has_conf" => $conf,
136  "has_lang" => (bool)sizeof(ilPlugin::getAvailableLangFiles(
137  $a_slot->getPluginsDirectory()."/".$a_plugin["name"]."/lang")));
138  }
139 
144  protected function fillRow($a_set)
145  {
146  global $ilCtrl, $lng;
147 
148  // actions
149 
150  $ilCtrl->setParameter($this->parent_obj, "ctype", $a_set["component_type"]);
151  $ilCtrl->setParameter($this->parent_obj, "cname", $a_set["component_name"]);
152  $ilCtrl->setParameter($this->parent_obj, "slot_id", $a_set["slot_id"]);
153 
154  $action = array();
155 
156  $ilCtrl->setParameter($this->parent_obj, "plugin_id", $a_set["plugin_id"]);
157  $action[$lng->txt("info")] = $ilCtrl->getLinkTarget($this->parent_obj, "showPlugin");
158  $ilCtrl->setParameter($this->parent_obj, "plugin_id", "");
159 
160  $ilCtrl->setParameter($this->parent_obj, "pname", $a_set["plugin_name"]);
161 
162  if ($a_set["plugin_active"])
163  {
164  if ($a_set["has_lang"])
165  {
166  $action[$lng->txt("cmps_refresh")] =
167  $ilCtrl->getLinkTarget($this->parent_obj, "refreshLanguages");
168  }
169 
170  if ($a_set["has_conf"])
171  {
172  $action[$lng->txt("cmps_configure")] =
173  $ilCtrl->getLinkTargetByClass(strtolower(ilPlugin::getConfigureClassName($a_set["plugin_name"])), "configure");
174  }
175 
176  $action[$lng->txt("cmps_deactivate")] =
177  $ilCtrl->getLinkTarget($this->parent_obj, "deactivatePlugin");
178  }
179  else if ($a_set["activation_possible"])
180  {
181  $action[$lng->txt("cmps_activate")] =
182  $ilCtrl->getLinkTarget($this->parent_obj, "activatePlugin");
183  }
184 
185  // update button
186  if ($a_set["needs_update"])
187  {
188  $action[$lng->txt("cmps_update")] =
189  $ilCtrl->getLinkTarget($this->parent_obj, "updatePlugin");
190  }
191 
192  // #17428
193  $action[$lng->txt("cmps_uninstall")] =
194  $ilCtrl->getLinkTarget($this->parent_obj, "confirmUninstallPlugin");
195 
196  $ilCtrl->setParameter($this->parent_obj, "pname", "");
197 
198  if(sizeof($action))
199  {
200  $alist = new ilAdvancedSelectionListGUI();
201  $alist->setId($a_set["plugin_id"]);
202  $alist->setListTitle($lng->txt("actions"));
203 
204  foreach($action as $caption => $cmd)
205  {
206  $alist->addItem($caption, "", $cmd);
207  }
208 
209  $this->tpl->setVariable("ACTION_SELECTOR", $alist->getHTML());
210  }
211 
212  $this->tpl->setVariable("TXT_SLOT_NAME", $a_set["slot_name"]);
213  $this->tpl->setVariable("TXT_COMP_NAME",
214  $a_set["component_type"]."/".$a_set["component_name"]);
215 
216  $act_str = ($a_set["plugin_active"])
217  ? "<b>".$lng->txt("yes")."</b>"
218  : $lng->txt("no");
219  $this->tpl->setVariable("TXT_PLUGIN_NAME", $a_set["plugin_name"]);
220  $this->tpl->setVariable("TXT_PLUGIN_ID", $a_set["plugin_id"]);
221  $this->tpl->setVariable("TXT_ACTIVE", $act_str);
222  }
223 }
224 
225 ?>
setDefaultOrderField($a_defaultorderfield)
Set Default order field.
getSlotName()
Get Slot Name.
$cmd
Definition: sahs_server.php:35
gatherPluginData($a_type, ilPluginSlot $a_slot, $a_slot_subdir, array $a_plugin)
Process plugin data for table row.
static getConfigureClassName($a_name)
Get plugin configure class name.
setId($a_val)
Set id.
global $ilCtrl
Definition: ilias.php:18
Class ilTable2GUI.
static getAvailableCoreServices()
Get all available core services.
Plugin Slot.
getSlotId()
Get Slot ID.
const IL_COMP_MODULE
setRowTemplate($a_template, $a_template_dir="")
Set row template.
TableGUI class for components listing.
User interface class for advanced drop-down selection lists.
setFormAction($a_form_action, $a_multipart=false)
Set Form action parameter.
static hasConfigureClass($a_slot_dir, $a_name)
Has the plugin a configure class?
global $lng
Definition: privfeed.php:40
static getAvailableLangFiles($a_lang_directory)
Get array of all language files in the plugin.
getPluginsDirectory()
Get directory of.
fillRow($a_set)
Standard Version of Fill Row.
setEnableHeader($a_enableheader)
Set Enable Header.
static getLogger($a_component_id)
Get component logger.
addColumn($a_text, $a_sort_field="", $a_width="", $a_is_checkbox_action_column=false, $a_class="", $a_tooltip="", $a_tooltip_with_html=false)
Add a column to the header.
const IL_COMP_SERVICE
setLimit($a_limit=0, $a_default_limit=0)
static getAvailableCoreModules()
Get all available core modules.
static lookupPluginSlots($a_type, $a_name)
Lookup all plugin slots of a component.
__construct($a_parent_obj, $a_parent_cmd="")