diff --git a/framework/model.class.php b/framework/model.class.php index 062cf998c9..977e69c42b 100644 --- a/framework/model.class.php +++ b/framework/model.class.php @@ -367,12 +367,28 @@ class model extends baseModel public static function __callStatic($method, $arguments) { global $app; - $moduleName = get_called_class(); - $taoClass = 'ext' . $moduleName . 'Tao'; - if(is_callable("{$taoClass}::{$method}")) return call_user_func_array("{$taoClass}::{$method}", $arguments); - $taoClass = $moduleName . 'Tao'; - if(is_callable("{$taoClass}::{$method}")) return call_user_func_array("{$taoClass}::{$method}", $arguments); + $moduleName = strtolower(get_called_class()); + + preg_match_all('/^(ext)?(\w+)model/', $moduleName, $matches); + if(isset($matches[2][0])) + { + $moduleName = $matches[2][0]; + } + else + { + preg_match_all('/^(ext)?(\w+)tao/', $moduleName, $matches); + if(isset($matches[2][0])) $moduleName = $matches[2][0]; + } + + $modelClass = 'ext' . $moduleName . 'Model'; + if(method_exists($modelClass, $method)) return call_user_func_array("{$modelClass}::{$method}", $arguments); + + $taoClass = 'ext' . $moduleName . 'Tao'; + if(method_exists($taoClass, $method)) return call_user_func_array("{$taoClass}::{$method}", $arguments); + + $taoClass = $moduleName . 'Tao'; + if(method_exists($taoClass, $method)) return call_user_func_array("{$taoClass}::{$method}", $arguments); $app->triggerError("the module {$moduleName} has no {$method} method", __FILE__, __LINE__, $exit = true); }