name."\n"; $lines[]= 'repository:'.$repository."\n"; $lines[]= 'path:'.$file->dir."\n"; if(is_file($file->dir.'/'.$file->name.'.mysql')) { $lines[]='schema: 1'; } //doesn't work for core, since the schema is in database.(my|pg)sql //fopen works with remote files if(function_exists($out_callback)) { $out_callback(' '.$file->name.' '); } if($hd=@fopen($file->filename,'r')) { //ugly, but works..., might be improved //UGLY - IMPROVE $content = fread($hd, filesize ($file->filename)); $depends=null; foreach($files as $fd) { if($test=preg_match('/'.$fd->name.'_[a-z_]+/',$content)&& ($fd->name!=$file->name)) { //match the first part of the function with a filename //to improve the precision match the function name in the file //$functions = dependency_parse_php(file_get_contents($fd->filename)); //if(in_array($test,$functions)) { $depends[]=$fd->name; //} } } if(is_array($depends)) { $lines[]='depends:'. implode(',',$depends)."\n"; } fclose ($hd); } } return $lines; } function dependency_parse_php($buffer){ $tokens = token_get_all($buffer); foreach ($tokens as $token) { if(is_array($token)&&$token[0]==T_FUNCTION) { $skip_white=true; } if($skip_white&&is_array($token)&&$token[0]==T_STRING) { $functions[]=$token[1]; $skip_white=false; } } return $functions; } function dependency_functions() { $modules=dependency_get_module_names(); $data = dependency_get_all(); $path = dependency_module_property(); foreach($modules as $name) { $path = dependency_module_property($name,'path'); $file = $path[0].'/'.$name.'.module'; $functions = dependency_parse_php(file_get_contents($file)); dependency_set_module_property($name, 'functions', $functions); } } ?>