ILIAS  Release_4_1_x_branch Revision 61804
 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  $this->tpl->setCurrentBlock("responsible_mail");
197  $this->tpl->setVariable("VAL_PLUGIN_RESPONSIBLE_MAIL", $a_set["responsible_mail"]);
198  $this->tpl->parseCurrentBlock();
199  $this->tpl->setCurrentBlock("responsible");
200  $this->tpl->setVariable("TXT_RESPONSIBLE", $lng->txt("cmps_responsible"));
201  $this->tpl->setVariable("VAL_PLUGIN_RESPONSIBLE", $a_set["responsible"]);
202  $this->tpl->parseCurrentBlock();
203  }
204 
205  $this->tpl->setVariable("VAL_PLUGIN_NAME", $a_set["name"]);
206  $this->tpl->setVariable("VAL_PLUGIN_ID", $a_set["id"]);
207  $this->tpl->setVariable("TXT_PLUGIN_NAME", $lng->txt("cmps_name"));
208  $this->tpl->setVariable("TXT_PLUGIN_ID", $lng->txt("cmps_id"));
209  $this->tpl->setVariable("TXT_PLUGIN_VERSION", $lng->txt("cmps_version"));
210  $this->tpl->setVariable("TXT_PHP_FILE", "plugin.php");
211  $this->tpl->setVariable("TXT_CLASS_FILE", $lng->txt("cmps_class_file"));
212  $this->tpl->setVariable("VAL_CLASS_FILE", $a_set["class_file"]);
213  $this->tpl->setVariable("TXT_VERSION", $lng->txt("cmps_version"));
214  $this->tpl->setVariable("VAL_PLUGIN_VERSION", $a_set["version"]);
215  $this->tpl->setVariable("TXT_ILIAS_MIN", $lng->txt("cmps_ilias_min_version"));
216  $this->tpl->setVariable("VAL_ILIAS_MIN", $a_set["ilias_min_version"]);
217  $this->tpl->setVariable("TXT_ILIAS_MAX", $lng->txt("cmps_ilias_max_version"));
218  $this->tpl->setVariable("VAL_ILIAS_MAX", $a_set["ilias_max_version"]);
219  $this->tpl->setVariable("TXT_STATUS", $lng->txt("cmps_status"));
220 
221  if ($a_set["is_active"])
222  {
223  $this->tpl->setVariable("VAL_STATUS", $lng->txt("cmps_active"));
224  }
225  else
226  {
227  $r = ($a_set["inactive_reason"] != "")
228  ? " (".$a_set["inactive_reason"].")"
229  : "";
230 
231  $this->tpl->setVariable("VAL_STATUS", $lng->txt("cmps_inactive").$r);
232  }
233 
234  if ($a_set["plugin_php_file_status"])
235  {
236  $this->tpl->setVariable("VAL_PLUGIN_PHP_FILE_STATUS", $lng->txt("cmps_available"));
237  }
238  else
239  {
240  $this->tpl->setVariable("VAL_PLUGIN_PHP_FILE_STATUS", $lng->txt("cmps_missing"));
241  }
242  if ($a_set["class_file_status"])
243  {
244  $this->tpl->setVariable("VAL_CLASS_FILE_STATUS", $lng->txt("cmps_available"));
245  }
246  else
247  {
248  $this->tpl->setVariable("VAL_CLASS_FILE_STATUS", $lng->txt("cmps_missing"));
249  }
250  }
251 
252 }
253 ?>