Esempio n. 1
0
 /**
  * A method to include a plugin, and call a method statically on the plugin class.
  *
  * @static
  * @param string $module The plugin module name (i.e. /plugins/module directory).
  * @param string $package The plugin package name (i.e. /plugins/module/package
  *                        directory).
  * @param string $name Optional name of the PHP file which contains the plugin,
  *                     otherwise the plugin with the same name as the package
  *                     is assumed.
  * @param string $staticMethod The name of the method of the plugin to call statically.
  * @param array $aParams An optional array of parameters to pass to the method called.
  * @return mixed The result of the static method call, or false on failure to include
  *               the plugin.
  */
 function &callStaticMethod($module, $package, $name = null, $staticMethod, $aParams = null)
 {
     if ($name === null) {
         $name = $package;
     }
     if (!MAX_Plugin::_isEnabledPlugin($module, $package, $name)) {
         return false;
     }
     if (!MAX_Plugin::_includePluginFile($module, $package, $name)) {
         return false;
     }
     $className = MAX_Plugin::_getPluginClassName($module, $package, $name);
     // PHP4/5 compatibility for get_class_methods.
     $aClassMethods = array_map(strtolower, get_class_methods($className));
     if (!$aClassMethods) {
         $aClassMethods = array();
     }
     if (!in_array(strtolower($staticMethod), $aClassMethods)) {
         MAX::raiseError("Method '{$staticMethod}()' not defined in class '{$className}'.", MAX_ERROR_INVALIDARGS);
         return false;
     }
     if (is_null($aParams)) {
         return call_user_func(array($className, $staticMethod));
     } else {
         return call_user_func_array(array($className, $staticMethod), $aParams);
     }
 }