ILIAS  Release_4_0_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilPluginsTableGUI.php
Go to the documentation of this file.
1 <?php
2 /*
3  +-----------------------------------------------------------------------------+
4  | ILIAS open source |
5  +-----------------------------------------------------------------------------+
6  | Copyright (c) 1998-2008 ILIAS open source, University of Cologne |
7  | |
8  | This program is free software; you can redistribute it and/or |
9  | modify it under the terms of the GNU General Public License |
10  | as published by the Free Software Foundation; either version 2 |
11  | of the License, or (at your option) any later version. |
12  | |
13  | This program is distributed in the hope that it will be useful, |
14  | but WITHOUT ANY WARRANTY; without even the implied warranty of |
15  | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16  | GNU General Public License for more details. |
17  | |
18  | You should have received a copy of the GNU General Public License |
19  | along with this program; if not, write to the Free Software |
20  | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
21  +-----------------------------------------------------------------------------+
22 */
23 
24 include_once("Services/Table/classes/class.ilTable2GUI.php");
25 
26 
36 {
37  function ilPluginsTableGUI($a_parent_obj, $a_parent_cmd = "",
38  $a_c_type, $a_c_name, $a_slot_id)
39  {
40  global $ilCtrl, $lng;
41 
42  include_once("./Services/Component/classes/class.ilPluginSlot.php");
43  $this->slot = new ilPluginSlot($a_c_type, $a_c_name, $a_slot_id);
44 
45  parent::__construct($a_parent_obj, $a_parent_cmd);
46 
47  //$this->addColumn($lng->txt("cmps_module"));
48  $this->addColumn($lng->txt("cmps_plugin"));
49  $this->addColumn($lng->txt("cmps_basic_files"));
50  $this->addColumn($lng->txt("cmps_languages"));
51  $this->addColumn($lng->txt("cmps_database"));
52 
53  $this->setEnableHeader(true);
54  $this->setFormAction($ilCtrl->getFormAction($a_parent_obj));
55  $this->setRowTemplate("tpl.table_row_plugin.html",
56  "Services/Component");
57  $this->getPlugins();
58  //$this->setDefaultOrderField("subdir");
59  $this->setLimit(10000);
60 
61  // save options command
62  //$this->addCommandButton("saveOptions", $lng->txt("cmps_save_options"));
63 
64  $this->setTitle($lng->txt("cmps_plugins"));
65  }
66 
70  function getPlugins()
71  {
72  $plugins = $this->slot->getPluginsInformation();
73 //var_dump($plugins);
74  $this->setData($plugins);
75  }
76 
81  protected function fillRow($a_set)
82  {
83  global $lng, $ilCtrl, $ilDB;
84 
85  $ilCtrl->setParameter($this->parent_obj, "ctype", $_GET["ctype"]);
86  $ilCtrl->setParameter($this->parent_obj, "cname", $_GET["cname"]);
87  $ilCtrl->setParameter($this->parent_obj, "slot_id", $_GET["slot_id"]);
88  $ilCtrl->setParameter($this->parent_obj, "pname", $a_set["name"]);
89 
90  // dbupdate
91  $file = ilPlugin::getDBUpdateScriptName($_GET["ctype"], $_GET["cname"],
92  ilPluginSlot::lookupSlotName($_GET["ctype"], $_GET["cname"], $_GET["slot_id"]),
93  $a_set["name"]);
94 
95  if (@is_file($file))
96  {
97  include_once("./Services/Component/classes/class.ilPluginDBUpdate.php");
98  $dbupdate = new ilPluginDBUpdate($_GET["ctype"], $_GET["cname"],
99  $_GET["slot_id"], $a_set["name"], $ilDB, true, "");
100 
101  // update command
102 /* if ($dbupdate->getFileVersion() > $dbupdate->getCurrentVersion())
103  {
104  $this->tpl->setCurrentBlock("db_update_cmd");
105  $this->tpl->setVariable("TXT_UPDATE_DB",
106  $lng->txt("cmps_update_db"));
107  $this->tpl->setVariable("HREF_UPDATE_DB",
108  $ilCtrl->getLinkTarget($this->parent_obj, "updatePluginDB"));
109  $this->tpl->parseCurrentBlock();
110  }
111 */
112 
113  // db version
114  $this->tpl->setCurrentBlock("db_versions");
115  $this->tpl->setVariable("TXT_CURRENT_VERSION",
116  $lng->txt("cmps_current_version"));
117  $this->tpl->setVariable("VAL_CURRENT_VERSION",
118  $dbupdate->getCurrentVersion());
119  $this->tpl->setVariable("TXT_FILE_VERSION",
120  $lng->txt("cmps_file_version"));
121  $this->tpl->setVariable("VAL_FILE_VERSION",
122  $dbupdate->getFileVersion());
123  $this->tpl->parseCurrentBlock();
124 
125  $this->tpl->setCurrentBlock("db_update");
126  $this->tpl->setVariable("DB_UPDATE_FILE",
127  "dbupdate.php");
128  }
129  else
130  {
131  $this->tpl->setCurrentBlock("db_update");
132  $this->tpl->setVariable("DB_UPDATE_FILE",
133  $lng->txt("cmps_no_db_update_file_available"));
134  }
135  $this->tpl->parseCurrentBlock();
136 
137 
138  // language files
139  $langs = ilPlugin::getAvailableLangFiles($this->slot->getPluginsDirectory()."/".
140  $a_set["name"]."/lang");
141  if (count($langs) == 0)
142  {
143  $this->tpl->setCurrentBlock("lang");
144  $this->tpl->setVariable("VAL_LANG_FILE",
145  $lng->txt("cmps_no_language_file_available"));
146  $this->tpl->parseCurrentBlock();
147  }
148  foreach($langs as $lang)
149  {
150  $this->tpl->setCurrentBlock("lang");
151  $this->tpl->setVariable("VAL_LANG_FILE",
152  $lang["file"]);
153  $this->tpl->parseCurrentBlock();
154  }
155 
156  // activation button
157  if ($a_set["activation_possible"])
158  {
159  $this->tpl->setCurrentBlock("activate");
160  $this->tpl->setVariable("HREF_ACTIVATE",
161  $ilCtrl->getLinkTarget($this->parent_obj, "activatePlugin"));
162  $this->tpl->setVariable("TXT_ACTIVATE",
163  $lng->txt("cmps_activate"));
164  $this->tpl->parseCurrentBlock();
165  }
166 
167  // deactivation/refresh languages button
168  if ($a_set["is_active"])
169  {
170  // deactivate button
171  $this->tpl->setCurrentBlock("deactivate");
172  $this->tpl->setVariable("HREF_DEACTIVATE",
173  $ilCtrl->getLinkTarget($this->parent_obj, "deactivatePlugin"));
174  $this->tpl->setVariable("TXT_DEACTIVATE",
175  $lng->txt("cmps_deactivate"));
176  $this->tpl->parseCurrentBlock();
177 
178  // refresh languages button
179  if (count($langs) > 0)
180  {
181  $this->tpl->setCurrentBlock("refresh_langs");
182  $this->tpl->setVariable("HREF_REFRESH_LANGS",
183  $ilCtrl->getLinkTarget($this->parent_obj, "refreshLanguages"));
184  $this->tpl->setVariable("TXT_REFRESH_LANGS",
185  $lng->txt("cmps_refresh"));
186  $this->tpl->parseCurrentBlock();
187  }
188 
189  }
190 
191  // update button
192  if ($a_set["needs_update"])
193  {
194  $this->tpl->setCurrentBlock("update");
195  $this->tpl->setVariable("HREF_UPDATE",
196  $ilCtrl->getLinkTarget($this->parent_obj, "updatePlugin"));
197  $this->tpl->setVariable("TXT_UPDATE",
198  $lng->txt("cmps_update"));
199  $this->tpl->parseCurrentBlock();
200  }
201 
202  if (strlen($a_set["responsible"]))
203  {
204  $this->tpl->setCurrentBlock("responsible_mail");
205  $this->tpl->setVariable("VAL_PLUGIN_RESPONSIBLE_MAIL", $a_set["responsible_mail"]);
206  $this->tpl->parseCurrentBlock();
207  $this->tpl->setCurrentBlock("responsible");
208  $this->tpl->setVariable("TXT_RESPONSIBLE", $lng->txt("cmps_responsible"));
209  $this->tpl->setVariable("VAL_PLUGIN_RESPONSIBLE", $a_set["responsible"]);
210  $this->tpl->parseCurrentBlock();
211  }
212 
213  $this->tpl->setVariable("VAL_PLUGIN_NAME", $a_set["name"]);
214  $this->tpl->setVariable("VAL_PLUGIN_ID", $a_set["id"]);
215  $this->tpl->setVariable("TXT_PLUGIN_NAME", $lng->txt("cmps_name"));
216  $this->tpl->setVariable("TXT_PLUGIN_ID", $lng->txt("cmps_id"));
217  $this->tpl->setVariable("TXT_PLUGIN_VERSION", $lng->txt("cmps_version"));
218  $this->tpl->setVariable("TXT_PHP_FILE", "plugin.php");
219  $this->tpl->setVariable("TXT_CLASS_FILE", $lng->txt("cmps_class_file"));
220  $this->tpl->setVariable("VAL_CLASS_FILE", $a_set["class_file"]);
221  $this->tpl->setVariable("TXT_VERSION", $lng->txt("cmps_version"));
222  $this->tpl->setVariable("VAL_PLUGIN_VERSION", $a_set["version"]);
223  $this->tpl->setVariable("TXT_ILIAS_MIN", $lng->txt("cmps_ilias_min_version"));
224  $this->tpl->setVariable("VAL_ILIAS_MIN", $a_set["ilias_min_version"]);
225  $this->tpl->setVariable("TXT_ILIAS_MAX", $lng->txt("cmps_ilias_max_version"));
226  $this->tpl->setVariable("VAL_ILIAS_MAX", $a_set["ilias_max_version"]);
227  $this->tpl->setVariable("TXT_STATUS", $lng->txt("cmps_status"));
228 
229  if ($a_set["is_active"])
230  {
231  $this->tpl->setVariable("VAL_STATUS", $lng->txt("cmps_active"));
232  }
233  else
234  {
235  $r = ($a_set["inactive_reason"] != "")
236  ? " (".$a_set["inactive_reason"].")"
237  : "";
238 
239  $this->tpl->setVariable("VAL_STATUS", $lng->txt("cmps_inactive").$r);
240  }
241 
242  if ($a_set["plugin_php_file_status"])
243  {
244  $this->tpl->setVariable("VAL_PLUGIN_PHP_FILE_STATUS", $lng->txt("cmps_available"));
245  }
246  else
247  {
248  $this->tpl->setVariable("VAL_PLUGIN_PHP_FILE_STATUS", $lng->txt("cmps_missing"));
249  }
250  if ($a_set["class_file_status"])
251  {
252  $this->tpl->setVariable("VAL_CLASS_FILE_STATUS", $lng->txt("cmps_available"));
253  }
254  else
255  {
256  $this->tpl->setVariable("VAL_CLASS_FILE_STATUS", $lng->txt("cmps_missing"));
257  }
258  }
259 
260 }
261 ?>