X-Git-Url: http://git.dj3c1t.com/?a=blobdiff_plain;f=web%2Flibs%2Fempty_class.php;h=30814be61752fdd777d55ded10b60181d0e1a202;hb=29b6377f43bf4477e04b57069cf779ac1b913bdb;hp=72c5cd93b8c40782195d16524b9de5c69107e6e1;hpb=a21fbfe1301f83b72d2815899ff334445b7830cf;p=mtweb diff --git a/web/libs/empty_class.php b/web/libs/empty_class.php index 72c5cd9..30814be 100644 --- a/web/libs/empty_class.php +++ b/web/libs/empty_class.php @@ -31,56 +31,55 @@ */ - class empty_class - { + class empty_class{ var $root_inst; var $modules; - function empty_class($root_inst) - { if($root_inst === true) $this->root_inst = $this; + function empty_class($root_inst){ + if($root_inst === true) $this->root_inst = $this; else $this->root_inst = $root_inst; } - function load_modules($modules_path, $current_modules, $core_modules = null) - { $this->_load_modules($modules_path, $current_modules, $this->root_inst, true); - if(isset($core_modules) && $current_modules != $core_modules) - { $this->_load_modules($modules_path, $core_modules, $this->root_inst, true); + function load_modules($modules_path, $current_modules, $core_modules = null){ + $this->_load_modules($modules_path, $current_modules, $this->root_inst, true); + if(isset($core_modules) && $current_modules != $core_modules){ + $this->_load_modules($modules_path, $core_modules, $this->root_inst, true); } } - function _load_modules($modules_path, $modules_path_suffixe, $root_inst, $recursif = false) - { if(file_exists($modules_path.$modules_path_suffixe) && $dh = opendir($modules_path.$modules_path_suffixe)) - { while(($file = readdir($dh)) !== false) - { if(is_dir($modules_path.$modules_path_suffixe.$file)) - { if($recursif && substr($file, 0, 1) != ".") - { $this->_load_modules($modules_path, $modules_path_suffixe.$file."/", $root_inst, $recursif); + function _load_modules($modules_path, $modules_path_suffixe, $root_inst, $recursif = false){ + if(file_exists($modules_path.$modules_path_suffixe) && $dh = opendir($modules_path.$modules_path_suffixe)){ + while(($file = readdir($dh)) !== false){ + if(is_dir($modules_path.$modules_path_suffixe.$file)){ + if($recursif && substr($file, 0, 1) != "."){ + $this->_load_modules($modules_path, $modules_path_suffixe.$file."/", $root_inst, $recursif); } } - elseif(strcasecmp(substr($file, -4), ".php") == 0) - { $this->load($modules_path.$modules_path_suffixe.$file, $root_inst); + elseif(strcasecmp(substr($file, -4), ".php") == 0){ + $this->load($modules_path.$modules_path_suffixe.$file, $root_inst); } } closedir($dh); } } - function load($module_file, $root_inst) - { if($module_file && file_exists($module_file)) - { $v_path = explode("/", $module_file); + function load($module_file, $root_inst){ + if($module_file && file_exists($module_file)){ + $v_path = explode("/", $module_file); $file = $v_path[count($v_path) - 1]; - if(strcasecmp(substr($file, -4), ".php") == 0) - { $class_name = substr($file, 0, -4); - if(!class_exists($class_name)) - { require_once $module_file; - if(version_compare(PHP_VERSION, '5.0.0', '>=')) - { if(class_exists($class_name) && !isset($this->modules[$class_name])) - { $this->modules[$class_name] = new $class_name($root_inst); + if(strcasecmp(substr($file, -4), ".php") == 0){ + $class_name = substr($file, 0, -4); + if(!class_exists($class_name)){ + require_once $module_file; + if(version_compare(PHP_VERSION, '5.0.0', '>=')){ + if(class_exists($class_name) && !isset($this->modules[$class_name])){ + $this->modules[$class_name] = new $class_name($root_inst); } } - else - { if(class_exists($class_name)) - { aggregate($this, $class_name); + else{ + if(class_exists($class_name)){ + aggregate($this, $class_name); } } } @@ -88,21 +87,21 @@ } } - function __call($method_name, $arguments) - { return $this->empty_class_call($this->root_inst, $method_name, $arguments); + function __call($method_name, $arguments){ + return $this->empty_class_call($this->root_inst, $method_name, $arguments); } - function empty_class_call($inst, $method_name, $arguments) - { $r = false; + function empty_class_call($inst, $method_name, $arguments){ + $r = false; $args = ""; foreach($arguments as $i => $arg) $args .= ($args ? ", " : "")."\$arguments[".$i."]"; - if(isset($inst->modules)) foreach($inst->modules as $module_name => $module) - { if(method_exists($module, $method_name)) - { eval("\$r = \$module->".$method_name."(".$args.");"); + if(isset($inst->modules)) foreach($inst->modules as $module_name => $module){ + if(method_exists($module, $method_name)){ + eval("\$r = \$module->".$method_name."(".$args.");"); break; } - else - { $r = $this->empty_class_call($module, $method_name, $arguments); + else{ + $r = $this->empty_class_call($module, $method_name, $arguments); if($r !== false) break; } }