|
@@ -12,28 +12,23 @@ if(!defined('entry') || !entry) die('Not a valid page');
|
12
|
12
|
=========================== */
|
13
|
13
|
?>
|
14
|
14
|
<?php
|
15
|
|
- class plugin {
|
|
15
|
+ class plugin {
|
16
|
16
|
|
17
|
17
|
var $actions = array();
|
18
|
18
|
var $exists = array();
|
19
|
19
|
|
20
|
|
- function call($name) {
|
21
|
|
-
|
|
20
|
+ function call($name) {
|
|
21
|
+
|
22
|
22
|
if (!$this->exists($name)) {
|
23
|
23
|
return false;
|
24
|
|
- }
|
25
|
|
-
|
26
|
|
- /*echo "<br />==========<br />";
|
27
|
|
- echo $name;
|
28
|
|
- echo "<br />";*/
|
|
24
|
+ }
|
29
|
25
|
|
30
|
26
|
$index = 0;
|
31
|
|
- //foreach (plugins::$instances as $plugin) {
|
|
27
|
+
|
32
|
28
|
foreach ($GLOBALS['plugins::$instances'] as $plugin) {
|
33
|
29
|
if(array_key_exists($index,$this->actions[$name])){
|
34
|
30
|
$action = $this->actions[$name][$index][1];
|
35
|
|
- if (is_callable(array($plugin, $action))) {
|
36
|
|
- //echo "ejecutar: ".$action."()<br/>";
|
|
31
|
+ if (is_callable(array($plugin, $action))) {
|
37
|
32
|
$plugin->$action();
|
38
|
33
|
$index++;
|
39
|
34
|
}
|
|
@@ -44,18 +39,9 @@ if(!defined('entry') || !entry) die('Not a valid page');
|
44
|
39
|
function exists($name) {
|
45
|
40
|
if (isset($this->exists[$name])) {
|
46
|
41
|
return $this->exists[$name];
|
47
|
|
- }
|
48
|
|
-
|
49
|
|
- //foreach (plugins::$instances as $plugin) {
|
50
|
|
- foreach ($GLOBALS['plugins::$instances'] as $plugin) {
|
51
|
|
- /*print_r(plugins::$instances);
|
52
|
|
- echo "<br />";
|
53
|
|
- print_r($plugin);
|
54
|
|
- echo "<br />";
|
55
|
|
- print_r($this->actions[$name]);
|
56
|
|
- echo "<br />";
|
57
|
|
- echo $this->actions[$name][0][1];
|
58
|
|
- echo "<br />";*/
|
|
42
|
+ }
|
|
43
|
+
|
|
44
|
+ foreach ($GLOBALS['plugins::$instances'] as $plugin) {
|
59
|
45
|
if(array_key_exists($name,$this->actions)){
|
60
|
46
|
if (is_callable(array($plugin, $this->actions[$name][0][1]))) {
|
61
|
47
|
return $this->exists[$name] = true;
|
|
@@ -65,16 +51,15 @@ if(!defined('entry') || !entry) die('Not a valid page');
|
65
|
51
|
|
66
|
52
|
return $this->exists[$name] = false;
|
67
|
53
|
}
|
68
|
|
-
|
69
|
|
- function instance(){
|
70
|
|
- //$instance;
|
71
|
|
- if( !isset($GLOBALS['$instance']) ) {
|
72
|
|
- $GLOBALS['$instance'] = new plugin();
|
|
54
|
+
|
|
55
|
+ //I really hate you PHP4's OOP implementation
|
|
56
|
+ function &instance() {
|
|
57
|
+ static $instance;
|
|
58
|
+ if (!isset($instance)) {
|
|
59
|
+ $instance = new plugin();
|
73
|
60
|
}
|
74
|
|
- //print_r($GLOBALS['$instance']);
|
75
|
|
- //die();
|
76
|
|
- return $GLOBALS['$instance'];
|
77
|
|
- }
|
|
61
|
+ return $instance;
|
|
62
|
+ }
|
78
|
63
|
|
79
|
64
|
}
|
80
|
65
|
?>
|