ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
class.ilPluginSlot.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
5include_once("./Services/Component/classes/class.ilPlugin.php");
6
20{
21
25 function __construct($a_c_type, $a_c_name, $a_slot_id)
26 {
27 $this->setComponentType($a_c_type);
28 $this->setComponentName($a_c_name);
29 $this->setSlotId($a_slot_id);
30
31 if ($a_slot_id != "")
32 {
33 $this->read();
34 }
35 }
36
40 function read()
41 {
42 $cached_component = ilCachedComponentData::getInstance();
43
44 $rec = $cached_component->lookupPluginSlotById($this->getSlotId());
45 //global $ilDB;
46
47 //$q = "SELECT * FROM il_pluginslot WHERE component = ".
48 // $ilDB->quote($this->getComponentType()."/".$this->getComponentName(), "text").
49 // " AND id = ".$ilDB->quote($this->getSlotId(), "text");
50 //$set = $ilDB->query($q);
51 //$rec = $ilDB->fetchAssoc($set);
52 $this->setSlotName($rec["name"]);
53 }
54
60 function setComponentType($a_componenttype)
61 {
62 $this->componenttype = $a_componenttype;
63 }
64
71 {
72 return $this->componenttype;
73 }
74
80 function setComponentName($a_componentname)
81 {
82 $this->componentname = $a_componentname;
83 }
84
91 {
92 return $this->componentname;
93 }
94
100 function setSlotId($a_slotid)
101 {
102 $this->slotid = $a_slotid;
103 }
104
110 function getSlotId()
111 {
112 return $this->slotid;
113 }
114
120 function setSlotName($a_slotname)
121 {
122 $this->slotname = $a_slotname;
123 }
124
130 function getSlotName()
131 {
132 return $this->slotname;
133 }
134
139 {
140 return "./Customizing/global/plugins/".$this->getComponentType().
141 "/".$this->getComponentName()."/".$this->getSlotName();
142 }
143
147 function _getPluginsDirectory($a_ctype, $a_cname, $a_slot_id)
148 {
149 return "./Customizing/global/plugins/".$a_ctype.
150 "/".$a_cname."/".ilPluginSlot::lookupSlotName($a_ctype, $a_cname, $a_slot_id);
151 }
152
153
157 function getPluginPhpFileName($a_plugin_name)
158 {
159 return $this->getPluginsDirectory()."/".
160 $a_plugin_name."/plugin.php";
161 }
162
166 function checkPluginPhpFileAvailability($a_plugin_name)
167 {
168 if (@is_file($this->getPluginPhpFileName($a_plugin_name)))
169 {
170 return true;
171 }
172
173 return false;
174 }
175
179 function getPluginClassFileName($a_plugin_name)
180 {
181 return $this->getPluginsDirectory()."/".
182 $a_plugin_name."/classes/class.il".$a_plugin_name."Plugin.php";
183 }
184
188 function checkClassFileAvailability($a_plugin_name)
189 {
190 if (@is_file($this->getPluginClassFileName($a_plugin_name)))
191 {
192 return true;
193 }
194
195 return false;
196 }
197
202 function getPrefix()
203 {
204 if ($this->prefix == "")
205 {
206 $this->prefix =
208 $this->getComponentName())."_".$this->getSlotId();
209 }
210
211 return $this->prefix;
212 }
213
218 {
219 global $ilPluginAdmin;
220
221 // read plugins directory
222 $pl_dir = $this->getPluginsDirectory();
223
224 if (!@is_dir($pl_dir))
225 {
226 return array();
227 }
228
229 $dir = opendir($pl_dir);
230
231 $plugins = array();
232 while($file = readdir($dir))
233 {
234 if ($file != "." and
235 $file != "..")
236 {
237 // directories
238 if (@is_dir($pl_dir."/".$file) && substr($file, 0, 1) != "." &&
239 is_file($pl_dir."/".$file."/plugin.php"))
240 {
241
242
243 $plugin = array();
244
246 $this->getComponentName(), $this->getSlotId(), $file);
247
248 // create record in il_plugin table (if not existing)
250 $this->getComponentName(), $this->getSlotId(), $file);
251
252 $pdata = $ilPluginAdmin->getAllData($this->getComponentType(),
253 $this->getComponentName(), $this->getSlotId(), $file);
254
255 $plugin["version"] = $pdata["version"];
256 $plugin["id"] = $pdata["id"];
257 $plugin["is_active"] = $pdata["is_active"];
258 $plugin["inactive_reason"] = $pdata["inactive_reason"];
259 $plugin["needs_update"] = $pdata["needs_update"];
260 $plugin["ilias_min_version"] = $pdata["ilias_min_version"];
261 $plugin["ilias_max_version"] = $pdata["ilias_max_version"];
262 $plugin["activation_possible"] = $pdata["activation_possible"];
263 $plugin["responsible"] = $pdata["responsible"];
264 $plugin["responsible_mail"] = $pdata["responsible_mail"];
265
266 $plugin["name"] = $file;
267 $plugin["plugin_php_file_status"] = $this->checkPluginPhpFileAvailability($file);
268 $plugin["class_file_status"] = $this->checkClassFileAvailability($file);
269 $plugin["class_file"] = "class.il".$plugin["name"]."Plugin.php";
270
271 $plugins[] = $plugin;
272 }
273 }
274 }
275
276 return $plugins;
277 }
278
282 static function lookupSlotId($a_ctype, $a_cname, $a_slot_name)
283 {
284 $cached_component = ilCachedComponentData::getInstance();
285 $rec = $cached_component->lookupPluginSlotByName($a_slot_name);
286
287 return $rec['id'];
288
289 //global $ilDB;
290
291 //$q = "SELECT * FROM il_pluginslot WHERE component = ".
292 // $ilDB->quote($a_ctype."/".$a_cname, "text").
293 // " AND name = ".$ilDB->quote($a_slot_name, "text");
294 //$set = $ilDB->query($q);
295 //$rec = $ilDB->fetchAssoc($set);
296 //return $rec["id"];
297 }
298
302 static function lookupSlotName($a_ctype, $a_cname, $a_slot_id)
303 {
304 $cached_component = ilCachedComponentData::getInstance();
305 $rec = $cached_component->lookupPluginSlotById($a_slot_id);
306
307 return $rec['name'];
308
309 //global $ilDB;
310
311 // $q = "SELECT * FROM il_pluginslot WHERE component = ".
312 // $ilDB->quote($a_ctype."/".$a_cname, "text").
313 // " AND id = ".$ilDB->quote($a_slot_id, "text");
314 //$set = $ilDB->query($q);
315 //$rec = $ilDB->fetchAssoc($set);
316 //return $rec["name"];
317 }
318
323 {
324 global $ilPluginAdmin;
325
326 return $ilPluginAdmin->getActivePluginsForSlot($this->getComponentType(),
327 $this->getComponentName(), $this->getSlotId());
328 }
329
330
334 static function getAllSlots()
335 {
336 $cached_component = ilCachedComponentData::getInstance();
337 $recs = $cached_component->getIlPluginslotById();
338
339 //global $ilDB;
340
341 //$set = $ilDB->query("SELECT * FROM il_pluginslot ");
342 //$slots = array();
343 //while ($rec = $ilDB->fetchAssoc($set))
344 foreach($recs as $rec)
345 {
346 $pos = strpos($rec["component"], "/");
347 $slots[] = array(
348 "component_type" => substr($rec["component"], 0, $pos),
349 "component_name" => substr($rec["component"], $pos + 1),
350 "slot_id" => $rec["id"],
351 "slot_name" => $rec["name"]
352 );
353 }
354
355 return $slots;
356 }
357
358}
359?>
print $file
static lookupId($a_type, $a_name)
Lookup ID of a component.
getSlotId()
Get Slot ID.
checkClassFileAvailability($a_plugin_name)
Check whether Plugin class file is available for plugin or not.
setComponentName($a_componentname)
Set Component Name.
__construct($a_c_type, $a_c_name, $a_slot_id)
Constructor.
getActivePlugins()
Get active plugins of slot.
static lookupSlotName($a_ctype, $a_cname, $a_slot_id)
Lookup slot name for component and slot id.
read()
Read properties from DB.
setSlotId($a_slotid)
Set Slot ID.
static getAllSlots()
Get all plugin slots.
getPluginPhpFileName($a_plugin_name)
Get File name for plugin.php.
getComponentType()
Get Component Type.
getPrefix()
Get slot prefix, used for lang vars and db tables.
getPluginsInformation()
Get information an all plugins and their status.
getComponentName()
Get Component Name.
setSlotName($a_slotname)
Set Slot Name.
getPluginClassFileName($a_plugin_name)
Get Class File name for plugin.
checkPluginPhpFileAvailability($a_plugin_name)
Check whether plugin.php file is available for plugin or not.
_getPluginsDirectory($a_ctype, $a_cname, $a_slot_id)
Get plugins directory.
getPluginsDirectory()
Get directory of.
setComponentType($a_componenttype)
Set Component Type.
static lookupSlotId($a_ctype, $a_cname, $a_slot_name)
Lookup slot ID for component and slot name.
getSlotName()
Get Slot Name.
static createPluginRecord($a_ctype, $a_cname, $a_slot_id, $a_pname)
static lookupStoredData($a_ctype, $a_cname, $a_slot_id, $a_pname)
Lookup information data in il_plugin.