ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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 
19 {
20  private $mode;
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 
56  public function getComponents()
57  {
58  $plugins = array();
59  $modules = $this->getModulesCoreItems();
60  $this->addPluginData($plugins, $modules, IL_COMP_MODULE);
61 
62  $services = $this->getServicesCoreItems();
63  $this->addPluginData($plugins, $services, IL_COMP_SERVICE);
64 
65  $this->setData($plugins);
66  }
67 
73  protected function getModulesCoreItems()
74  {
75  include_once("./Services/Component/classes/class.ilModule.php");
77  }
78 
84  protected function getServicesCoreItems()
85  {
86  include_once("./Services/Component/classes/class.ilService.php");
88  }
89 
99  protected function addPluginData(array &$plugins, array $core_items, $core_type)
100  {
101  foreach ($core_items as $core_item) {
102  $plugin_slots = ilComponent::lookupPluginSlots($core_type, $core_item["subdir"]);
103  foreach ($plugin_slots as $plugin_slot) {
104  $slot = new ilPluginSlot($core_type, $core_item["subdir"], $plugin_slot["id"]);
105  foreach ($slot->getPluginsInformation() as $plugin) {
106  $plugins[] = $this->gatherPluginData($core_type, $slot, $core_item["subdir"], $plugin);
107  }
108  }
109  }
110  }
111 
121  protected function gatherPluginData($a_type, ilPluginSlot $a_slot, $a_slot_subdir, array $a_plugin)
122  {
123  $config_class = null;
124  if (ilPlugin::hasConfigureClass($a_slot->getPluginsDirectory(), $a_plugin["name"]) &&
125  $this->ctrl->checkTargetClass(ilPlugin::getConfigureClassName($a_plugin["name"]))) {
126  $config_class = strtolower(ilPlugin::getConfigureClassName($a_plugin["name"]));
127  }
128 
129  return array("slot_name" => $a_slot->getSlotName(),
130  "component_type" => $a_type,
131  "component_name" => $a_slot_subdir,
132  "slot_id" => $a_slot->getSlotId(),
133  "plugin_id" => $a_plugin["id"],
134  "plugin_name" => $a_plugin["name"],
135  "must_install" => $a_plugin["must_install"],
136  "plugin_active" => $a_plugin["is_active"],
137  "activation_possible" => $a_plugin["activation_possible"],
138  "needs_update" => $a_plugin["needs_update"],
139  "config_class" => $config_class,
140  "has_lang" => (bool) sizeof(ilPlugin::getAvailableLangFiles(
141  $a_slot->getPluginsDirectory() . "/" . $a_plugin["name"] . "/lang"
142  )));
143  }
144 
149  protected function fillRow($a_set)
150  {
151  global $rbacsystem;
152 
153  $this->tpl->setVariable("TXT_SLOT_NAME", $a_set["slot_name"]);
154  $this->tpl->setVariable(
155  "TXT_COMP_NAME",
156  $a_set["component_type"] . "/" . $a_set["component_name"]
157  );
158 
159  if ($a_set["plugin_active"]) {
160  $this->tpl->setCurrentBlock("active");
161  $this->tpl->setVariable("TXT_ACTIVE", $this->lng->txt("yes"));
162  $this->tpl->parseCurrentBlock();
163  } else {
164  $this->tpl->setCurrentBlock("inactive");
165  $this->tpl->setVariable("TXT_INACTIVE", $this->lng->txt("no"));
166  $this->tpl->parseCurrentBlock();
167  }
168 
169  $this->tpl->setVariable("TXT_PLUGIN_NAME", $a_set["plugin_name"]);
170  $this->tpl->setVariable("TXT_PLUGIN_ID", $a_set["plugin_id"]);
171 
172  if ($rbacsystem->checkAccess('write', $_GET['ref_id'])) {
173  $actions = $this->getActionMenuEntries($a_set);
174  $this->tpl->setVariable("ACTION_SELECTOR", $this->getActionMenu($actions, $a_set["plugin_id"]));
175  }
176  }
177 
186  protected function getActionMenu(array $actions, $plugin_id)
187  {
188  $alist = new ilAdvancedSelectionListGUI();
189  $alist->setId($plugin_id);
190  $alist->setListTitle($this->lng->txt("actions"));
191 
192  foreach ($actions as $caption => $cmd) {
193  $alist->addItem($caption, "", $cmd);
194  }
195 
196  return $alist->getHTML();
197  }
198 
206  protected function getActionMenuEntries(array $a_set)
207  {
208  $this->setParameter($a_set);
209 
210  $actions = array();
211  $this->ctrl->setParameter($this->parent_obj, "plugin_id", $a_set["plugin_id"]);
212  $this->addCommandToActions($actions, "info", "showPlugin");
213  $this->ctrl->setParameter($this->parent_obj, "plugin_id", null);
214 
215  if ($a_set["must_install"]) {
216  $this->addCommandToActions($actions, "cmps_install", "installPlugin");
217  } else {
218  if ($a_set["config_class"]) {
219  $actions[$this->lng->txt("cmps_configure")] =
220  $this->ctrl->getLinkTargetByClass($a_set["config_class"], "configure");
221  }
222 
223  if ($a_set["has_lang"]) {
224  $this->addCommandToActions($actions, "cmps_refresh", "refreshLanguages");
225  }
226 
227  if ($a_set["plugin_active"]) {
228  $this->addCommandToActions($actions, "cmps_deactivate", "deactivatePlugin");
229  }
230 
231  if ($a_set["activation_possible"]) {
232  $this->addCommandToActions($actions, "cmps_activate", "activatePlugin");
233  }
234 
235  // update button
236  if ($a_set["needs_update"]) {
237  $this->addCommandToActions($actions, "cmps_update", "updatePlugin");
238  }
239 
240  // #17428
241  $this->addCommandToActions($actions, "cmps_uninstall", "confirmUninstallPlugin");
242  }
243 
244  $this->clearParameter();
245 
246  return $actions;
247  }
248 
256  protected function setParameter(array $a_set)
257  {
258  $this->ctrl->setParameter($this->parent_obj, "ctype", $a_set["component_type"]);
259  $this->ctrl->setParameter($this->parent_obj, "cname", $a_set["component_name"]);
260  $this->ctrl->setParameter($this->parent_obj, "slot_id", $a_set["slot_id"]);
261  $this->ctrl->setParameter($this->parent_obj, "pname", $a_set["plugin_name"]);
262  }
263 
269  protected function clearParameter()
270  {
271  $this->ctrl->setParameter($this->parent_obj, "ctype", null);
272  $this->ctrl->setParameter($this->parent_obj, "cname", null);
273  $this->ctrl->setParameter($this->parent_obj, "slot_id", null);
274  $this->ctrl->setParameter($this->parent_obj, "pname", null);
275  }
276 
286  protected function addCommandToActions(array &$actions, $caption, $command)
287  {
288  $actions[$this->lng->txt($caption)] =
289  $this->ctrl->getLinkTarget($this->parent_obj, $command);
290  }
291 }
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.
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 getConfigureClassName($a_name)
Get plugin configure class name.
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.
getSlotId()
Get Slot ID.
const IL_COMP_MODULE
setRowTemplate($a_template, $a_template_dir="")
Set row template.
Create styles array
The data for the language used.
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?
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.
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.
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="")