diff --git a/admin/options.php b/admin/options.php index 09684da..b3ce103 100644 --- a/admin/options.php +++ b/admin/options.php @@ -233,8 +233,8 @@ if ($user->isAdmin()) { -";die("Antes de trigger->call add options panel"); - $trigger->call('add_options_panel'); +call('add_options_panel'); ?> diff --git a/classes/plugin.class.php b/classes/plugin.class.php index 398a71b..ef5b5bb 100644 --- a/classes/plugin.class.php +++ b/classes/plugin.class.php @@ -12,28 +12,23 @@ if(!defined('entry') || !entry) die('Not a valid page'); =========================== */ ?> exists($name)) { return false; - } - - /*echo "
==========
"; - echo $name; - echo "
";*/ + } $index = 0; - //foreach (plugins::$instances as $plugin) { + foreach ($GLOBALS['plugins::$instances'] as $plugin) { if(array_key_exists($index,$this->actions[$name])){ $action = $this->actions[$name][$index][1]; - if (is_callable(array($plugin, $action))) { - //echo "ejecutar: ".$action."()
"; + if (is_callable(array($plugin, $action))) { $plugin->$action(); $index++; } @@ -44,18 +39,9 @@ if(!defined('entry') || !entry) die('Not a valid page'); function exists($name) { if (isset($this->exists[$name])) { return $this->exists[$name]; - } - - //foreach (plugins::$instances as $plugin) { - foreach ($GLOBALS['plugins::$instances'] as $plugin) { - /*print_r(plugins::$instances); - echo "
"; - print_r($plugin); - echo "
"; - print_r($this->actions[$name]); - echo "
"; - echo $this->actions[$name][0][1]; - echo "
";*/ + } + + foreach ($GLOBALS['plugins::$instances'] as $plugin) { if(array_key_exists($name,$this->actions)){ if (is_callable(array($plugin, $this->actions[$name][0][1]))) { return $this->exists[$name] = true; @@ -65,16 +51,15 @@ if(!defined('entry') || !entry) die('Not a valid page'); return $this->exists[$name] = false; } - - function instance(){ - //$instance; - if( !isset($GLOBALS['$instance']) ) { - $GLOBALS['$instance'] = new plugin(); + + //I really hate you PHP4's OOP implementation + function &instance() { + static $instance; + if (!isset($instance)) { + $instance = new plugin(); } - //print_r($GLOBALS['$instance']); - //die(); - return $GLOBALS['$instance']; - } + return $instance; + } } ?> diff --git a/classes/plugins.class.php b/classes/plugins.class.php index ac7c33b..41dd6eb 100644 --- a/classes/plugins.class.php +++ b/classes/plugins.class.php @@ -12,12 +12,14 @@ if(!defined('entry') || !entry) die('Not a valid page'); =========================== */ ?> actions[$name][] = array($this, $function); + function addAction($name, $function) { + $plugEngine =& plugin::instance(); //DO NOT remove the & after the = + $plugEngine->actions[$name][] = array($this, $function); } } diff --git a/classes/util.class.php b/classes/util.class.php index 77a4bc8..55c3b50 100644 --- a/classes/util.class.php +++ b/classes/util.class.php @@ -654,17 +654,17 @@ class util { $actives = json_decode($conf->active_plugins,1); $actives = $actives[1]; + foreach ($actives as $index => $plugin) { if (!file_exists(Absolute_Path."plugins/".$plugin)) { unset($actives[$index]); continue; - }else{ + } else { require_once(Absolute_Path.'plugins/'.$plugin); } if (!class_exists($index)) { continue; } - //plugins::$instances[$index] = new $index; $GLOBALS['plugins::$instances'][$index] = new $index; } } diff --git a/entry.php b/entry.php index 0b023c1..0c709ec 100644 --- a/entry.php +++ b/entry.php @@ -2,13 +2,12 @@ ob_start(); if(!defined('entry') || !entry) die('Not a valid page'); - error_reporting (E_ALL); ini_set('display_errors', '1'); // PHP settings specific to Gelato ini_set('pcre.backtrack_limit', '10000'); -// Globals to be used throughout the application + define('Absolute_Path', dirname(__FILE__).DIRECTORY_SEPARATOR); $installed = true; $configFile = Absolute_Path.'config.php'; @@ -48,7 +47,6 @@ if (!extension_loaded('json')) { require_once(Absolute_Path.'classes'.DIRECTORY_SEPARATOR.'configuration.class.php'); require_once(Absolute_Path.'classes'.DIRECTORY_SEPARATOR.'util.class.php'); -//require_once(Absolute_Path.'classes'.DIRECTORY_SEPARATOR.'functions.php'); require_once(Absolute_Path.'classes'.DIRECTORY_SEPARATOR.'gelato.class.php'); require_once(Absolute_Path.'classes'.DIRECTORY_SEPARATOR.'templates.class.php'); require_once(Absolute_Path.'classes'.DIRECTORY_SEPARATOR.'themes.class.php'); @@ -74,7 +72,7 @@ if($installed){ session_start(); util::init_plugins(); - $trigger = plugin::instance(); + $trigger =& plugin::instance(); //DO NOT remove the & after the = $trigger->call('gelato_init');