Diff of /plugins/plugin.php [961ec0] .. [85d212]  Maximize  Restore

Switch to unified view

a/plugins/plugin.php b/plugins/plugin.php
...
...
22
    */
22
    */
23
    function AdminerPlugin($plugins) {
23
    function AdminerPlugin($plugins) {
24
        if ($plugins === null) {
24
        if ($plugins === null) {
25
            $plugins = array();
25
            $plugins = array();
26
            foreach (get_declared_classes() as $class) {
26
            foreach (get_declared_classes() as $class) {
27
                if (preg_match('~^Adminer.~i', $class) && strcasecmp($this->_findRootClass($class), 'Adminer')) { // can use interface since PHP 5
27
                if (preg_match('~^Adminer.~i', $class) && strcasecmp($this->_findRootClass($class), 'Adminer')) { //! can use interface
28
                    $plugins[$class] = new $class;
28
                    $plugins[$class] = new $class;
29
                }
29
                }
30
            }
30
            }
31
        }
31
        }
32
        $this->plugins = $plugins;
32
        $this->plugins = $plugins;
33
        // it is possible to use ReflectionObject in PHP 5 to find out which plugins defines which methods at once
33
        //! it is possible to use ReflectionObject to find out which plugins defines which methods at once
34
    }
34
    }
35
    
35
    
36
    function _callParent($function, $args) {
36
    function _callParent($function, $args) {
37
      switch (count($args)) { // call_user_func_array(array('parent', $function), $args) works since PHP 5
37
      return call_user_func_array(array('parent', $function), $args);
38
          case 0: return parent::$function();
39
          case 1: return parent::$function($args[0]);
40
          case 2: return parent::$function($args[0], $args[1]);
41
          case 3: return parent::$function($args[0], $args[1], $args[2]);
42
          case 4: return parent::$function($args[0], $args[1], $args[2], $args[3]);
43
          case 5: return parent::$function($args[0], $args[1], $args[2], $args[3], $args[4]);
44
          case 6: return parent::$function($args[0], $args[1], $args[2], $args[3], $args[4], $args[5]);
45
          default: trigger_error('Too many parameters.', E_USER_WARNING);
46
      }
47
    }
38
    }
48
    
39
    
49
    function _applyPlugin($function, $args) {
40
    function _applyPlugin($function, $args) {
50
        foreach ($this->plugins as $plugin) {
41
        foreach ($this->plugins as $plugin) {
51
            if (method_exists($plugin, $function)) {
42
            if (method_exists($plugin, $function)) {