1
|
1 |
<?php
|
|
2 |
|
|
3 |
/*
|
|
4 |
* Enano - an open-source CMS capable of wiki functions, Drupal-like sidebar blocks, and everything in between
|
294
|
5 |
* Version 1.0.5 (Ferrishyn)
|
1
|
6 |
* Copyright (C) 2006-2007 Dan Fuhry
|
|
7 |
*
|
|
8 |
* This program is Free Software; you can redistribute and/or modify it under the terms of the GNU General Public License
|
|
9 |
* as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
|
|
10 |
*
|
|
11 |
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
|
|
12 |
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for details.
|
|
13 |
*/
|
|
14 |
|
|
15 |
class pluginLoader {
|
|
16 |
var $hook_list;
|
|
17 |
var $load_list;
|
|
18 |
var $loaded_plugins;
|
|
19 |
var $system_plugins = Array('SpecialUserFuncs.php','SpecialUserPrefs.php','SpecialPageFuncs.php','SpecialAdmin.php','SpecialCSS.php','SpecialUpdownload.php','SpecialSearch.php','PrivateMessages.php','SpecialGroups.php');
|
|
20 |
function loadAll()
|
|
21 |
{
|
|
22 |
$dir = ENANO_ROOT.'/plugins/';
|
|
23 |
|
|
24 |
$this->load_list = Array();
|
|
25 |
|
|
26 |
$plugins = Array();
|
|
27 |
|
|
28 |
// Open a known directory, and proceed to read its contents
|
|
29 |
|
|
30 |
if (is_dir($dir))
|
|
31 |
{
|
|
32 |
if ($dh = opendir($dir))
|
|
33 |
{
|
|
34 |
while (($file = readdir($dh)) !== false)
|
|
35 |
{
|
|
36 |
if(preg_match('#^(.*?)\.php$#is', $file))
|
|
37 |
{
|
|
38 |
if(getConfig('plugin_'.$file) == '1' || in_array($file, $this->system_plugins))
|
|
39 |
{
|
|
40 |
$this->load_list[] = $dir . $file;
|
|
41 |
$plugid = substr($file, 0, strlen($file)-4);
|
|
42 |
$f = file_get_contents($dir . $file);
|
|
43 |
$f = explode("\n", $f);
|
|
44 |
$f = array_slice($f, 2, 7);
|
|
45 |
$f[0] = substr($f[0], 13);
|
|
46 |
$f[1] = substr($f[1], 12);
|
|
47 |
$f[2] = substr($f[2], 13);
|
|
48 |
$f[3] = substr($f[3], 8 );
|
|
49 |
$f[4] = substr($f[4], 9 );
|
|
50 |
$f[5] = substr($f[5], 12);
|
|
51 |
$plugins[$plugid] = Array();
|
|
52 |
$plugins[$plugid]['name'] = $f[0];
|
|
53 |
$plugins[$plugid]['uri'] = $f[1];
|
|
54 |
$plugins[$plugid]['desc'] = $f[2];
|
|
55 |
$plugins[$plugid]['auth'] = $f[3];
|
|
56 |
$plugins[$plugid]['vers'] = $f[4];
|
|
57 |
$plugins[$plugid]['aweb'] = $f[5];
|
|
58 |
}
|
|
59 |
}
|
|
60 |
}
|
|
61 |
closedir($dh);
|
|
62 |
}
|
|
63 |
}
|
|
64 |
$this->loaded_plugins = $plugins;
|
|
65 |
//die('<pre>'.htmlspecialchars(print_r($plugins, true)).'</pre>');
|
|
66 |
}
|
|
67 |
function setHook($name, $opts = Array()) {
|
|
68 |
/*
|
|
69 |
$r = Array();
|
|
70 |
if(isset($this->hook_list[$name])) {
|
|
71 |
for($i=0;$i<sizeof($this->hook_list[$name]);$i++) {
|
|
72 |
$ret = eval($this->hook_list[$name][$i]);
|
|
73 |
if($ret !== null) $r[] = $ret;
|
|
74 |
}
|
|
75 |
}
|
|
76 |
if(sizeof($r) > 0) return $r;
|
|
77 |
else return false;
|
|
78 |
*/
|
|
79 |
if(isset($this->hook_list[$name]) && is_array($this->hook_list[$name]))
|
|
80 |
{
|
|
81 |
return $this->hook_list[$name];
|
|
82 |
}
|
|
83 |
else
|
|
84 |
{
|
|
85 |
return Array();
|
|
86 |
}
|
|
87 |
}
|
|
88 |
function attachHook($name, $code) {
|
|
89 |
if(!isset($this->hook_list[$name]))
|
|
90 |
{
|
|
91 |
$this->hook_list[$name] = Array();
|
|
92 |
}
|
|
93 |
$this->hook_list[$name][] = $code;
|
|
94 |
}
|
|
95 |
function loaded($plugid)
|
|
96 |
{
|
|
97 |
return isset( $this->loaded_plugins[$plugid] );
|
|
98 |
}
|
|
99 |
}
|
|
100 |
|
|
101 |
?>
|