function array_merge_n() { // Initialization of the resulting array: $array = array(); // Arrays to be merged (function's arguments): $arrays =& func_get_args(); // Merging of each array with the resulting one: foreach ($arrays as $array_i) { if (is_array($array_i)) { array_merge_2($array, $array_i); } } return $array; }
function parsePhpFolder($folder) { //die($folder); $complete_config = array(); require_once 'php_parser.class.php'; $parser = new php_parser(); // test if folder is found if (file_exists($folder)) { $ressource = opendir($folder); // find files in this folder while (($file = readdir($ressource)) !== false) { // debug($file, 'xml_parser::parse_folder files'); if (is_file($folder . '/' . $file)) { $path_parts = pathinfo($file); // if it's an yaml file, parse it and store thge results in an array if ($path_parts['extension'] == 'php') { $we_have_config_files = true; $config = $parser->load($folder . '/' . $file); if (!$config) { trigger_error("we have a parsing error with {$file}"); } if (is_array($config)) { /* echo '<pre>Complete config'; echo '<hr>'; print_r ($complete_config); */ //$complete_config = array_merge($complete_config, $config); array_merge_2($complete_config, $config); /* echo '<pre>Complete config after'; echo '<hr>'; print_r ($complete_config); */ } } } } if (isset($we_have_config_files)) { //echo '<pre>'; //print_r($complete_config); return $complete_config; } else { trigger_error("thinkedit::parsePhpFolder() no config files found - aborting"); die; return false; } } else { trigger_error("thinkedit::parsePhpFolder() : {$folder} is not found - aborting"); die; return false; } }
/** Will parse all subfoders of the plugin folder to find config.php config files They are merged with the main config file */ function parsePhpPluginFolder($folder = '/plugin/') { $complete_config = array(); require_once 'php_parser.class.php'; $parser = new php_parser(); $folder = ROOT . $folder; // test if folder is found if (file_exists($folder)) { $ressource = opendir($folder); // find files in this folder while (($file = readdir($ressource)) !== false) { $plugin_folder = $folder . '/' . $file; if (is_dir($plugin_folder)) { $plugin_config_file = $plugin_folder . '/config.php'; if (file_exists($plugin_config_file)) { $config = $parser->load($plugin_config_file); if ($config) { array_merge_2($complete_config, $config); } } if (!isset($config)) { //trigger_error("we have a parsing error with $file"); } } } } return $complete_config; }