ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
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 
18 {
19  private $mode;
20 
21 
22  public function __construct($a_parent_obj, $a_parent_cmd = "")
23  {
24  global $DIC;
25  $this->lng = $DIC->language();
26  $this->ctrl = $DIC->ctrl();
27 
28  parent::__construct($a_parent_obj, $a_parent_cmd);
29 
30  $this->setId("cmpspl");
31 
32  $this->addColumn($this->lng->txt("cmps_plugin"), "plugin_name");
33  $this->addColumn($this->lng->txt("id"), "plugin_id");
34  $this->addColumn($this->lng->txt("cmps_plugin_slot"), "slot_name");
35  $this->addColumn($this->lng->txt("cmps_component"), "component_name");
36  $this->addColumn($this->lng->txt("active"), "plugin_active");
37  $this->addColumn($this->lng->txt("action"));
38 
39  $this->setDefaultOrderField("plugin_name");
40 
41  $this->setEnableHeader(true);
42  $this->setFormAction($this->ctrl->getFormAction($a_parent_obj));
43  $this->setRowTemplate(
44  "tpl.plugin_overview_row.html",
45  "Services/Component"
46  );
47  $this->getComponents();
48  $this->setLimit(10000);
49 
50  include_once("./Services/UIComponent/AdvancedSelectionList/classes/class.ilAdvancedSelectionListGUI.php");
51  }
52 
53 
57  public function getComponents()
58  {
59  $plugins = array();
60  $modules = $this->getModulesCoreItems();
61  $this->addPluginData($plugins, $modules, IL_COMP_MODULE);
62 
63  $services = $this->getServicesCoreItems();
64  $this->addPluginData($plugins, $services, IL_COMP_SERVICE);
65 
66  $this->setData($plugins);
67  }
68 
69 
75  protected function getModulesCoreItems()
76  {
77  include_once("./Services/Component/classes/class.ilModule.php");
78 
80  }
81 
82 
88  protected function getServicesCoreItems()
89  {
90  include_once("./Services/Component/classes/class.ilService.php");
91 
93  }
94 
95 
105  protected function addPluginData(array &$plugins, array $core_items, $core_type)
106  {
107  foreach ($core_items as $core_item) {
108  $plugin_slots = ilComponent::lookupPluginSlots($core_type, $core_item["subdir"]);
109  foreach ($plugin_slots as $plugin_slot) {
110  $slot = new ilPluginSlot($core_type, $core_item["subdir"], $plugin_slot["id"]);
111  foreach ($slot->getPluginsInformation() as $plugin) {
112  if ($core_type && $slot && $core_item["subdir"] && is_array($plugin) && count($plugin) > 0) {
113  $plugins[] = $this->gatherPluginData($core_type, $slot, $core_item["subdir"], $plugin);
114  }
115  }
116  }
117  }
118  }
119 
120 
131  protected function gatherPluginData($a_type, ilPluginSlot $a_slot, $a_slot_subdir, array $a_plugin)
132  {
133  if (!$a_plugin["component_type"]) {
134  return array();
135  }
136  $plugin_db_data = ilPlugin::getPluginRecord($a_plugin["component_type"], $a_plugin["component_name"], $a_plugin["slot_id"], $a_plugin["name"]);
137 
138  $config_class = null;
139  if (ilPlugin::hasConfigureClass($a_slot->getPluginsDirectory(), $a_plugin, $plugin_db_data)
140  && $this->ctrl->checkTargetClass(ilPlugin::getConfigureClassName($a_plugin))
141  ) {
142  $config_class = strtolower(ilPlugin::getConfigureClassName($a_plugin));
143  }
144 
145  return array("slot_name" => $a_slot->getSlotName(),
146  "component_type" => $a_type,
147  "component_name" => $a_slot_subdir,
148  "slot_id" => $a_slot->getSlotId(),
149  "plugin_id" => $a_plugin["id"],
150  "plugin_name" => $a_plugin["name"],
151  "must_install" => $a_plugin["must_install"],
152  "plugin_active" => $a_plugin["is_active"],
153  "activation_possible" => $a_plugin["activation_possible"],
154  "needs_update" => $a_plugin["needs_update"],
155  "config_class" => $config_class,
156  "has_lang" => (bool) sizeof(
158  $a_slot->getPluginsDirectory() . "/" . $a_plugin["name"] . "/lang"
159  )
160  ));
161  }
162 
163 
168  protected function fillRow($a_set)
169  {
170  global $DIC;
171  $rbacsystem = $DIC->rbac()->system();
172 
173  $this->tpl->setVariable("TXT_SLOT_NAME", $a_set["slot_name"]);
174  $this->tpl->setVariable(
175  "TXT_COMP_NAME",
176  $a_set["component_type"] . "/" . $a_set["component_name"]
177  );
178 
179  if ($a_set["plugin_active"]) {
180  $this->tpl->setCurrentBlock("active");
181  $this->tpl->setVariable("TXT_ACTIVE", $this->lng->txt("yes"));
182  $this->tpl->parseCurrentBlock();
183  } else {
184  $this->tpl->setCurrentBlock("inactive");
185  $this->tpl->setVariable("TXT_INACTIVE", $this->lng->txt("no"));
186  $this->tpl->parseCurrentBlock();
187  }
188 
189  $this->tpl->setVariable("TXT_PLUGIN_NAME", $a_set["plugin_name"]);
190  $this->tpl->setVariable("TXT_PLUGIN_ID", $a_set["plugin_id"]);
191 
192  if ($rbacsystem->checkAccess('write', $_GET['ref_id'])) {
193  $actions = $this->getActionMenuEntries($a_set);
194  $this->tpl->setVariable("ACTION_SELECTOR", $this->getActionMenu($actions, $a_set["plugin_id"]));
195  }
196  }
197 
198 
207  protected function getActionMenu(array $actions, $plugin_id)
208  {
209  $alist = new ilAdvancedSelectionListGUI();
210  $alist->setId($plugin_id);
211  $alist->setListTitle($this->lng->txt("actions"));
212 
213  foreach ($actions as $caption => $cmd) {
214  $alist->addItem($caption, "", $cmd);
215  }
216 
217  return $alist->getHTML();
218  }
219 
220 
228  protected function getActionMenuEntries(array $a_set)
229  {
230  $this->setParameter($a_set);
231 
232  $actions = array();
233  $this->ctrl->setParameter($this->parent_obj, "plugin_id", $a_set["plugin_id"]);
234  $this->addCommandToActions($actions, "info", "showPlugin");
235  $this->ctrl->setParameter($this->parent_obj, "plugin_id", null);
236 
237  if ($a_set["must_install"]) {
238  $this->addCommandToActions($actions, "cmps_install", "installPlugin");
239  } else {
240  if ($a_set["config_class"]) {
241  $actions[$this->lng->txt("cmps_configure")]
242  = $this->ctrl->getLinkTargetByClass($a_set["config_class"], "configure");
243  }
244 
245  if ($a_set["has_lang"]) {
246  $this->addCommandToActions($actions, "cmps_refresh", "refreshLanguages");
247  }
248 
249  if ($a_set["plugin_active"]) {
250  $this->addCommandToActions($actions, "cmps_deactivate", "deactivatePlugin");
251  }
252 
253  if ($a_set["activation_possible"]) {
254  $this->addCommandToActions($actions, "cmps_activate", "activatePlugin");
255  }
256 
257  // update button
258  if ($a_set["needs_update"]) {
259  $this->addCommandToActions($actions, "cmps_update", "updatePlugin");
260  }
261 
262  // #17428
263  $this->addCommandToActions($actions, "cmps_uninstall", "confirmUninstallPlugin");
264  }
265 
266  $this->clearParameter();
267 
268  return $actions;
269  }
270 
271 
279  protected function setParameter(array $a_set)
280  {
281  $this->ctrl->setParameter($this->parent_obj, "ctype", $a_set["component_type"]);
282  $this->ctrl->setParameter($this->parent_obj, "cname", $a_set["component_name"]);
283  $this->ctrl->setParameter($this->parent_obj, "slot_id", $a_set["slot_id"]);
284  $this->ctrl->setParameter($this->parent_obj, "pname", $a_set["plugin_name"]);
285  }
286 
287 
293  protected function clearParameter()
294  {
295  $this->ctrl->setParameter($this->parent_obj, "ctype", null);
296  $this->ctrl->setParameter($this->parent_obj, "cname", null);
297  $this->ctrl->setParameter($this->parent_obj, "slot_id", null);
298  $this->ctrl->setParameter($this->parent_obj, "pname", null);
299  }
300 
301 
311  protected function addCommandToActions(array &$actions, $caption, $command)
312  {
313  $actions[$this->lng->txt($caption)]
314  = $this->ctrl->getLinkTarget($this->parent_obj, $command);
315  }
316 }
setDefaultOrderField($a_defaultorderfield)
Set Default order field.
getSlotName()
Get Slot Name.
setParameter(array $a_set)
Set parameter for plugin.
global $DIC
Definition: saml.php:7
$_GET["client_id"]
getActionMenu(array $actions, $plugin_id)
Get action menu for each row.
static getAvailableLangFiles(string $a_lang_directory)
Get array of all language files in the plugin.
gatherPluginData($a_type, ilPluginSlot $a_slot, $a_slot_subdir, array $a_plugin)
Process plugin data for table row.
addPluginData(array &$plugins, array $core_items, $core_type)
Get plugin informations.
getActionMenuEntries(array $a_set)
Get entries for action menu.
static getPluginRecord(string $a_ctype, string $a_cname, string $a_slot_id, string $a_pname)
setId($a_val)
Set id.
addCommandToActions(array &$actions, $caption, $command)
Add command to actions.
$a_type
Definition: workflow.php:92
Class ilTable2GUI.
static getAvailableCoreServices()
Get all available core services.
Plugin Slot.
static hasConfigureClass(string $a_slot_dir, array $plugin_data, array $plugin_db_data)
Has the plugin a configure class?
getSlotId()
Get Slot ID.
const IL_COMP_MODULE
setRowTemplate($a_template, $a_template_dir="")
Set row template.
static getConfigureClassName(array $plugin_data)
Get plugin configure class name.
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.
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.
getPluginsDirectory()
Get directory of.
fillRow($a_set)
Standard Version of Fill Row.
setEnableHeader($a_enableheader)
Set Enable Header.
getServicesCoreItems()
Get all available services.
getModulesCoreItems()
Get all available modules.
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="")