mirror of
https://github.com/vrana/adminer.git
synced 2025-08-11 09:04:02 +02:00
Fix plugin extending
http://forum.zdrojak.root.cz/index.php?topic=366.0
This commit is contained in:
@@ -8,13 +8,7 @@ function adminer_object() {
|
|||||||
include_once $filename;
|
include_once $filename;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* It is possible to combine customization and plugins:
|
$plugins = array(
|
||||||
class AdminerCustomization extends AdminerPlugin {
|
|
||||||
}
|
|
||||||
return new AdminerCustomization($plugins);
|
|
||||||
*/
|
|
||||||
|
|
||||||
return new AdminerPlugin(array(
|
|
||||||
// specify enabled plugins here
|
// specify enabled plugins here
|
||||||
new AdminerDumpZip,
|
new AdminerDumpZip,
|
||||||
new AdminerDumpXml,
|
new AdminerDumpXml,
|
||||||
@@ -25,7 +19,15 @@ function adminer_object() {
|
|||||||
new AdminerTranslation,
|
new AdminerTranslation,
|
||||||
new AdminerForeignSystem,
|
new AdminerForeignSystem,
|
||||||
new AdminerEnumOption,
|
new AdminerEnumOption,
|
||||||
));
|
);
|
||||||
|
|
||||||
|
/* It is possible to combine customization and plugins:
|
||||||
|
class AdminerCustomization extends AdminerPlugin {
|
||||||
|
}
|
||||||
|
return new AdminerCustomization($plugins);
|
||||||
|
*/
|
||||||
|
|
||||||
|
return new AdminerPlugin($plugins);
|
||||||
}
|
}
|
||||||
|
|
||||||
// include original Adminer or Adminer Editor (usually named adminer.php)
|
// include original Adminer or Adminer Editor (usually named adminer.php)
|
||||||
|
@@ -16,6 +16,17 @@ class AdminerPlugin extends Adminer {
|
|||||||
// it is possible to use ReflectionObject in PHP 5 to find out which plugins defines which methods at once
|
// it is possible to use ReflectionObject in PHP 5 to find out which plugins defines which methods at once
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function _callParent($function, $args) {
|
||||||
|
switch (count($args)) { // call_user_func_array(array('parent', $function), $args) works since PHP 5
|
||||||
|
case 0: return parent::$function();
|
||||||
|
case 1: return parent::$function($args[0]);
|
||||||
|
case 2: return parent::$function($args[0], $args[1]);
|
||||||
|
case 3: return parent::$function($args[0], $args[1], $args[2]);
|
||||||
|
case 4: return parent::$function($args[0], $args[1], $args[2], $args[3]);
|
||||||
|
default: trigger_error('Too many parameters.', E_USER_WARNING);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function _applyPlugin($function, $args) {
|
function _applyPlugin($function, $args) {
|
||||||
foreach ($this->plugins as $plugin) {
|
foreach ($this->plugins as $plugin) {
|
||||||
if (method_exists($plugin, $function)) {
|
if (method_exists($plugin, $function)) {
|
||||||
@@ -32,11 +43,11 @@ class AdminerPlugin extends Adminer {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return call_user_func_array(array($this, "parent::$function"), $args);
|
return $this->_callParent($function, $args);
|
||||||
}
|
}
|
||||||
|
|
||||||
function _appendPlugin($function, $args) {
|
function _appendPlugin($function, $args) {
|
||||||
$return = call_user_func_array(array($this, "parent::$function"), $args);
|
$return = $this->_callParent($function, $args);
|
||||||
foreach ($this->plugins as $plugin) {
|
foreach ($this->plugins as $plugin) {
|
||||||
if (method_exists($plugin, $function)) {
|
if (method_exists($plugin, $function)) {
|
||||||
$return += call_user_func_array(array($plugin, $function), $args);
|
$return += call_user_func_array(array($plugin, $function), $args);
|
||||||
|
Reference in New Issue
Block a user