PHP 4 compatible plugin engine
parent
fa676b0fa4
commit
eb69c37903
|
|
@ -233,7 +233,7 @@ if ($user->isAdmin()) {
|
||||||
<option value="0" <?php if(!$conf->check_version) echo "selected=\"selected\""; ?>><?php echo __("Deactive")?></option>
|
<option value="0" <?php if(!$conf->check_version) echo "selected=\"selected\""; ?>><?php echo __("Deactive")?></option>
|
||||||
</select>
|
</select>
|
||||||
</li>
|
</li>
|
||||||
<?php print_r($trigger);echo "<br>";die("Antes de trigger->call add options panel");
|
<?php
|
||||||
$trigger->call('add_options_panel');
|
$trigger->call('add_options_panel');
|
||||||
?>
|
?>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
|
||||||
|
|
@ -23,17 +23,12 @@ if(!defined('entry') || !entry) die('Not a valid page');
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*echo "<br />==========<br />";
|
|
||||||
echo $name;
|
|
||||||
echo "<br />";*/
|
|
||||||
|
|
||||||
$index = 0;
|
$index = 0;
|
||||||
//foreach (plugins::$instances as $plugin) {
|
|
||||||
foreach ($GLOBALS['plugins::$instances'] as $plugin) {
|
foreach ($GLOBALS['plugins::$instances'] as $plugin) {
|
||||||
if(array_key_exists($index,$this->actions[$name])){
|
if(array_key_exists($index,$this->actions[$name])){
|
||||||
$action = $this->actions[$name][$index][1];
|
$action = $this->actions[$name][$index][1];
|
||||||
if (is_callable(array($plugin, $action))) {
|
if (is_callable(array($plugin, $action))) {
|
||||||
//echo "ejecutar: ".$action."()<br/>";
|
|
||||||
$plugin->$action();
|
$plugin->$action();
|
||||||
$index++;
|
$index++;
|
||||||
}
|
}
|
||||||
|
|
@ -46,16 +41,7 @@ if(!defined('entry') || !entry) die('Not a valid page');
|
||||||
return $this->exists[$name];
|
return $this->exists[$name];
|
||||||
}
|
}
|
||||||
|
|
||||||
//foreach (plugins::$instances as $plugin) {
|
|
||||||
foreach ($GLOBALS['plugins::$instances'] as $plugin) {
|
foreach ($GLOBALS['plugins::$instances'] as $plugin) {
|
||||||
/*print_r(plugins::$instances);
|
|
||||||
echo "<br />";
|
|
||||||
print_r($plugin);
|
|
||||||
echo "<br />";
|
|
||||||
print_r($this->actions[$name]);
|
|
||||||
echo "<br />";
|
|
||||||
echo $this->actions[$name][0][1];
|
|
||||||
echo "<br />";*/
|
|
||||||
if(array_key_exists($name,$this->actions)){
|
if(array_key_exists($name,$this->actions)){
|
||||||
if (is_callable(array($plugin, $this->actions[$name][0][1]))) {
|
if (is_callable(array($plugin, $this->actions[$name][0][1]))) {
|
||||||
return $this->exists[$name] = true;
|
return $this->exists[$name] = true;
|
||||||
|
|
@ -66,15 +52,14 @@ if(!defined('entry') || !entry) die('Not a valid page');
|
||||||
return $this->exists[$name] = false;
|
return $this->exists[$name] = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
function instance(){
|
//I really hate you PHP4's OOP implementation
|
||||||
//$instance;
|
function &instance() {
|
||||||
if( !isset($GLOBALS['$instance']) ) {
|
static $instance;
|
||||||
$GLOBALS['$instance'] = new plugin();
|
if (!isset($instance)) {
|
||||||
|
$instance = new plugin();
|
||||||
}
|
}
|
||||||
//print_r($GLOBALS['$instance']);
|
return $instance;
|
||||||
//die();
|
}
|
||||||
return $GLOBALS['$instance'];
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
|
|
||||||
|
|
@ -12,11 +12,13 @@ if(!defined('entry') || !entry) die('Not a valid page');
|
||||||
=========================== */
|
=========================== */
|
||||||
?>
|
?>
|
||||||
<?php
|
<?php
|
||||||
$GLOBALS['plugins::$instances'] = array(); /* class static property */
|
/* Simulating a class static property */
|
||||||
|
$GLOBALS['plugins::$instances'] = array();
|
||||||
|
|
||||||
class plugins {
|
class plugins {
|
||||||
|
|
||||||
function addAction($name, $function) {
|
function addAction($name, $function) {
|
||||||
$plugEngine = plugin::instance();
|
$plugEngine =& plugin::instance(); //DO NOT remove the & after the =
|
||||||
$plugEngine->actions[$name][] = array($this, $function);
|
$plugEngine->actions[$name][] = array($this, $function);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -654,17 +654,17 @@ class util {
|
||||||
|
|
||||||
$actives = json_decode($conf->active_plugins,1);
|
$actives = json_decode($conf->active_plugins,1);
|
||||||
$actives = $actives[1];
|
$actives = $actives[1];
|
||||||
|
|
||||||
foreach ($actives as $index => $plugin) {
|
foreach ($actives as $index => $plugin) {
|
||||||
if (!file_exists(Absolute_Path."plugins/".$plugin)) {
|
if (!file_exists(Absolute_Path."plugins/".$plugin)) {
|
||||||
unset($actives[$index]);
|
unset($actives[$index]);
|
||||||
continue;
|
continue;
|
||||||
}else{
|
} else {
|
||||||
require_once(Absolute_Path.'plugins/'.$plugin);
|
require_once(Absolute_Path.'plugins/'.$plugin);
|
||||||
}
|
}
|
||||||
if (!class_exists($index)) {
|
if (!class_exists($index)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
//plugins::$instances[$index] = new $index;
|
|
||||||
$GLOBALS['plugins::$instances'][$index] = new $index;
|
$GLOBALS['plugins::$instances'][$index] = new $index;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,13 +2,12 @@
|
||||||
ob_start();
|
ob_start();
|
||||||
if(!defined('entry') || !entry) die('Not a valid page');
|
if(!defined('entry') || !entry) die('Not a valid page');
|
||||||
|
|
||||||
|
|
||||||
error_reporting (E_ALL);
|
error_reporting (E_ALL);
|
||||||
ini_set('display_errors', '1');
|
ini_set('display_errors', '1');
|
||||||
|
|
||||||
// PHP settings specific to Gelato
|
// PHP settings specific to Gelato
|
||||||
ini_set('pcre.backtrack_limit', '10000');
|
ini_set('pcre.backtrack_limit', '10000');
|
||||||
// Globals to be used throughout the application
|
|
||||||
define('Absolute_Path', dirname(__FILE__).DIRECTORY_SEPARATOR);
|
define('Absolute_Path', dirname(__FILE__).DIRECTORY_SEPARATOR);
|
||||||
$installed = true;
|
$installed = true;
|
||||||
$configFile = Absolute_Path.'config.php';
|
$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.'configuration.class.php');
|
||||||
require_once(Absolute_Path.'classes'.DIRECTORY_SEPARATOR.'util.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.'gelato.class.php');
|
||||||
require_once(Absolute_Path.'classes'.DIRECTORY_SEPARATOR.'templates.class.php');
|
require_once(Absolute_Path.'classes'.DIRECTORY_SEPARATOR.'templates.class.php');
|
||||||
require_once(Absolute_Path.'classes'.DIRECTORY_SEPARATOR.'themes.class.php');
|
require_once(Absolute_Path.'classes'.DIRECTORY_SEPARATOR.'themes.class.php');
|
||||||
|
|
@ -74,7 +72,7 @@ if($installed){
|
||||||
session_start();
|
session_start();
|
||||||
|
|
||||||
util::init_plugins();
|
util::init_plugins();
|
||||||
$trigger = plugin::instance();
|
$trigger =& plugin::instance(); //DO NOT remove the & after the =
|
||||||
|
|
||||||
$trigger->call('gelato_init');
|
$trigger->call('gelato_init');
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue