ILIAS  release_4-3 Revision
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilPluginsTableGUI.php
Go to the documentation of this file.
1 <?php
2 
3 /* Copyright (c) 1998-2010 ILIAS open source, Extended GPL, see docs/LICENSE */
4 
5 include_once("Services/Table/classes/class.ilTable2GUI.php");
6 
7 
17 {
18  function ilPluginsTableGUI($a_parent_obj, $a_parent_cmd = "",
19  $a_c_type, $a_c_name, $a_slot_id)
20  {
21  global $ilCtrl, $lng;
22 
23  include_once("./Services/Component/classes/class.ilPluginSlot.php");
24  $this->slot = new ilPluginSlot($a_c_type, $a_c_name, $a_slot_id);
25 
26  parent::__construct($a_parent_obj, $a_parent_cmd);
27 
28  //$this->addColumn($lng->txt("cmps_module"));
29  $this->addColumn($lng->txt("cmps_plugin"));
30  $this->addColumn($lng->txt("cmps_basic_files"));
31  $this->addColumn($lng->txt("cmps_languages"));
32  $this->addColumn($lng->txt("cmps_database"));
33 
34  $this->setEnableHeader(true);
35  $this->setFormAction($ilCtrl->getFormAction($a_parent_obj));
36  $this->setRowTemplate("tpl.table_row_plugin.html",
37  "Services/Component");
38  $this->getPlugins();
39  //$this->setDefaultOrderField("subdir");
40  $this->setLimit(10000);
41 
42  // save options command
43  //$this->addCommandButton("saveOptions", $lng->txt("cmps_save_options"));
44 
45  $this->setTitle($lng->txt("cmps_plugins"));
46  }
47 
51  function getPlugins()
52  {
53  $plugins = $this->slot->getPluginsInformation();
54 //var_dump($plugins);
55  $this->setData($plugins);
56  }
57 
62  protected function fillRow($a_set)
63  {
64  global $lng, $ilCtrl, $ilDB;
65 
66  $ilCtrl->setParameter($this->parent_obj, "ctype", $_GET["ctype"]);
67  $ilCtrl->setParameter($this->parent_obj, "cname", $_GET["cname"]);
68  $ilCtrl->setParameter($this->parent_obj, "slot_id", $_GET["slot_id"]);
69  $ilCtrl->setParameter($this->parent_obj, "pname", $a_set["name"]);
70 
71  // dbupdate
72  $file = ilPlugin::getDBUpdateScriptName($_GET["ctype"], $_GET["cname"],
73  ilPluginSlot::lookupSlotName($_GET["ctype"], $_GET["cname"], $_GET["slot_id"]),
74  $a_set["name"]);
75 
76  if (@is_file($file))
77  {
78  include_once("./Services/Component/classes/class.ilPluginDBUpdate.php");
79  $dbupdate = new ilPluginDBUpdate($_GET["ctype"], $_GET["cname"],
80  $_GET["slot_id"], $a_set["name"], $ilDB, true, "");
81 
82  // update command
83 /* if ($dbupdate->getFileVersion() > $dbupdate->getCurrentVersion())
84  {
85  $this->tpl->setCurrentBlock("db_update_cmd");
86  $this->tpl->setVariable("TXT_UPDATE_DB",
87  $lng->txt("cmps_update_db"));
88  $this->tpl->setVariable("HREF_UPDATE_DB",
89  $ilCtrl->getLinkTarget($this->parent_obj, "updatePluginDB"));
90  $this->tpl->parseCurrentBlock();
91  }
92 */
93 
94  // db version
95  $this->tpl->setCurrentBlock("db_versions");
96  $this->tpl->setVariable("TXT_CURRENT_VERSION",
97  $lng->txt("cmps_current_version"));
98  $this->tpl->setVariable("VAL_CURRENT_VERSION",
99  $dbupdate->getCurrentVersion());
100  $this->tpl->setVariable("TXT_FILE_VERSION",
101  $lng->txt("cmps_file_version"));
102  $this->tpl->setVariable("VAL_FILE_VERSION",
103  $dbupdate->getFileVersion());
104  $this->tpl->parseCurrentBlock();
105 
106  $this->tpl->setCurrentBlock("db_update");
107  $this->tpl->setVariable("DB_UPDATE_FILE",
108  "dbupdate.php");
109  }
110  else
111  {
112  $this->tpl->setCurrentBlock("db_update");
113  $this->tpl->setVariable("DB_UPDATE_FILE",
114  $lng->txt("cmps_no_db_update_file_available"));
115  }
116  $this->tpl->parseCurrentBlock();
117 
118 
119  // language files
120  $langs = ilPlugin::getAvailableLangFiles($this->slot->getPluginsDirectory()."/".
121  $a_set["name"]."/lang");
122  if (count($langs) == 0)
123  {
124  $this->tpl->setCurrentBlock("lang");
125  $this->tpl->setVariable("VAL_LANG_FILE",
126  $lng->txt("cmps_no_language_file_available"));
127  $this->tpl->parseCurrentBlock();
128  }
129  foreach($langs as $lang)
130  {
131  $this->tpl->setCurrentBlock("lang");
132  $this->tpl->setVariable("VAL_LANG_FILE",
133  $lang["file"]);
134  $this->tpl->parseCurrentBlock();
135  }
136 
137  // activation button
138  if ($a_set["activation_possible"])
139  {
140  $this->tpl->setCurrentBlock("activate");
141  $this->tpl->setVariable("HREF_ACTIVATE",
142  $ilCtrl->getLinkTarget($this->parent_obj, "activatePlugin"));
143  $this->tpl->setVariable("TXT_ACTIVATE",
144  $lng->txt("cmps_activate"));
145  $this->tpl->parseCurrentBlock();
146  }
147 
148  // deactivation/refresh languages button
149  if ($a_set["is_active"])
150  {
151  // deactivate button
152  $this->tpl->setCurrentBlock("deactivate");
153  $this->tpl->setVariable("HREF_DEACTIVATE",
154  $ilCtrl->getLinkTarget($this->parent_obj, "deactivatePlugin"));
155  $this->tpl->setVariable("TXT_DEACTIVATE",
156  $lng->txt("cmps_deactivate"));
157  $this->tpl->parseCurrentBlock();
158 
159  // refresh languages button
160  if (count($langs) > 0)
161  {
162  $this->tpl->setCurrentBlock("refresh_langs");
163  $this->tpl->setVariable("HREF_REFRESH_LANGS",
164  $ilCtrl->getLinkTarget($this->parent_obj, "refreshLanguages"));
165  $this->tpl->setVariable("TXT_REFRESH_LANGS",
166  $lng->txt("cmps_refresh"));
167  $this->tpl->parseCurrentBlock();
168  }
169 
170  // configure button
171  if (ilPlugin::hasConfigureClass($this->slot->getPluginsDirectory(), $a_set["name"]) &&
172  $ilCtrl->checkTargetClass(ilPlugin::getConfigureClassName($a_set["name"])))
173  {
174  $this->tpl->setCurrentBlock("configure");
175  $this->tpl->setVariable("HREF_CONFIGURE",
176  $ilCtrl->getLinkTargetByClass(strtolower(ilPlugin::getConfigureClassName($a_set["name"])), "configure"));
177  $this->tpl->setVariable("TXT_CONFIGURE",
178  $lng->txt("cmps_configure"));
179  $this->tpl->parseCurrentBlock();
180  }
181  }
182 
183  // update button
184  if ($a_set["needs_update"])
185  {
186  $this->tpl->setCurrentBlock("update");
187  $this->tpl->setVariable("HREF_UPDATE",
188  $ilCtrl->getLinkTarget($this->parent_obj, "updatePlugin"));
189  $this->tpl->setVariable("TXT_UPDATE",
190  $lng->txt("cmps_update"));
191  $this->tpl->parseCurrentBlock();
192  }
193 
194  if (strlen($a_set["responsible"]))
195  {
196  $responsibles = explode('/', $a_set["responsible_mail"]);
197  $first_handled = false;
198  foreach($responsibles as $responsible)
199  {
200  if(!strlen($responsible = trim($responsible)))
201  {
202  continue;
203  }
204 
205  if($first_handled)
206  {
207  $this->tpl->touchBlock('plugin_responsible_sep');
208  }
209 
210  $this->tpl->setCurrentBlock("plugin_responsible");
211  $this->tpl->setVariable("VAL_PLUGIN_RESPONSIBLE_MAIL", $responsible);
212  $this->tpl->parseCurrentBlock();
213  $first_handled = true;
214  }
215 
216  $this->tpl->setCurrentBlock("responsible_mail");
217  $this->tpl->parseCurrentBlock();
218 
219  $this->tpl->setCurrentBlock("responsible");
220  $this->tpl->setVariable("TXT_RESPONSIBLE", $lng->txt("cmps_responsible"));
221  $this->tpl->setVariable("VAL_PLUGIN_RESPONSIBLE", $a_set["responsible"]);
222  $this->tpl->parseCurrentBlock();
223  }
224 
225  $this->tpl->setVariable("VAL_PLUGIN_NAME", $a_set["name"]);
226  $this->tpl->setVariable("VAL_PLUGIN_ID", $a_set["id"]);
227  $this->tpl->setVariable("TXT_PLUGIN_NAME", $lng->txt("cmps_name"));
228  $this->tpl->setVariable("TXT_PLUGIN_ID", $lng->txt("cmps_id"));
229  $this->tpl->setVariable("TXT_PLUGIN_VERSION", $lng->txt("cmps_version"));
230  $this->tpl->setVariable("TXT_PHP_FILE", "plugin.php");
231  $this->tpl->setVariable("TXT_CLASS_FILE", $lng->txt("cmps_class_file"));
232  $this->tpl->setVariable("VAL_CLASS_FILE", $a_set["class_file"]);
233  $this->tpl->setVariable("TXT_VERSION", $lng->txt("cmps_version"));
234  $this->tpl->setVariable("VAL_PLUGIN_VERSION", $a_set["version"]);
235  $this->tpl->setVariable("TXT_ILIAS_MIN", $lng->txt("cmps_ilias_min_version"));
236  $this->tpl->setVariable("VAL_ILIAS_MIN", $a_set["ilias_min_version"]);
237  $this->tpl->setVariable("TXT_ILIAS_MAX", $lng->txt("cmps_ilias_max_version"));
238  $this->tpl->setVariable("VAL_ILIAS_MAX", $a_set["ilias_max_version"]);
239  $this->tpl->setVariable("TXT_STATUS", $lng->txt("cmps_status"));
240 
241  if ($a_set["is_active"])
242  {
243  $this->tpl->setVariable("VAL_STATUS", $lng->txt("cmps_active"));
244  }
245  else
246  {
247  $r = ($a_set["inactive_reason"] != "")
248  ? " (".$a_set["inactive_reason"].")"
249  : "";
250 
251  $this->tpl->setVariable("VAL_STATUS", $lng->txt("cmps_inactive").$r);
252  }
253 
254  if ($a_set["plugin_php_file_status"])
255  {
256  $this->tpl->setVariable("VAL_PLUGIN_PHP_FILE_STATUS", $lng->txt("cmps_available"));
257  }
258  else
259  {
260  $this->tpl->setVariable("VAL_PLUGIN_PHP_FILE_STATUS", $lng->txt("cmps_missing"));
261  }
262  if ($a_set["class_file_status"])
263  {
264  $this->tpl->setVariable("VAL_CLASS_FILE_STATUS", $lng->txt("cmps_available"));
265  }
266  else
267  {
268  $this->tpl->setVariable("VAL_CLASS_FILE_STATUS", $lng->txt("cmps_missing"));
269  }
270  }
271 
272 }
273 ?>