diff options
author | Dries Buytaert <dries@buytaert.net> | 2009-02-22 17:55:30 +0000 |
---|---|---|
committer | Dries Buytaert <dries@buytaert.net> | 2009-02-22 17:55:30 +0000 |
commit | 5d658d08481c22b5ef577b39a29cd647438b211f (patch) | |
tree | 74fca69f981d985604b126943aed71bb79d1bbcb /includes | |
parent | b3e36d655c831c63c26a710eb3c8bd82ca3b6fc5 (diff) | |
download | brdo-5d658d08481c22b5ef577b39a29cd647438b211f.tar.gz brdo-5d658d08481c22b5ef577b39a29cd647438b211f.tar.bz2 |
- Patch #380064 by c960657: make file_scan_directory() use save property names as file_load().
Diffstat (limited to 'includes')
-rw-r--r-- | includes/file.inc | 39 | ||||
-rw-r--r-- | includes/install.inc | 10 | ||||
-rw-r--r-- | includes/locale.inc | 29 | ||||
-rw-r--r-- | includes/module.inc | 26 | ||||
-rw-r--r-- | includes/registry.inc | 2 | ||||
-rw-r--r-- | includes/theme.inc | 6 |
6 files changed, 56 insertions, 56 deletions
diff --git a/includes/file.inc b/includes/file.inc index 878c1789b..7ffefe1f9 100644 --- a/includes/file.inc +++ b/includes/file.inc @@ -1395,9 +1395,9 @@ function file_download() { * the provided directory. Defaults to TRUE. * - 'key' * The key to be used for the returned array of files. Possible values are - * "filename", for the path starting with $dir, "basename", for the - * basename of the file, and "name" for the name of the file without an - * extension. Defaults to 'filename'. + * 'filepath', for the path starting with $dir, 'filename', for the + * basename of the file, and 'name' for the name of the file without an + * extension. Defaults to 'filepath'. * - 'min_depth' * Minimum depth of directories to return files from. Defaults to 0. * @param $depth @@ -1405,8 +1405,8 @@ function file_download() { * should not be passed. * @return * An associative array (keyed on the provided key) of objects with - * "filename", "basename", and "name" members corresponding to the - * matching files. + * 'filepath', 'filename', and 'name' members corresponding to the + * matching files. */ function file_scan_directory($dir, $mask, $options = array(), $depth = 0) { // Merge in defaults. @@ -1414,33 +1414,32 @@ function file_scan_directory($dir, $mask, $options = array(), $depth = 0) { 'nomask' => '/(\.\.?|CVS)$/', 'callback' => 0, 'recurse' => TRUE, - 'key' => 'filename', + 'key' => 'filepath', 'min_depth' => 0, ); - $options['key'] = (in_array($options['key'], array('filename', 'basename', 'name')) ? $options['key'] : 'filename'); + $options['key'] = in_array($options['key'], array('filepath', 'filename', 'name')) ? $options['key'] : 'filepath'; $files = array(); - if (is_dir($dir) && $handle = opendir($dir)) { - while (FALSE !== ($file = readdir($handle))) { - if (!preg_match($options['nomask'], $file) && $file[0] != '.') { - if (is_dir("$dir/$file") && $options['recurse']) { + while (FALSE !== ($filename = readdir($handle))) { + if (!preg_match($options['nomask'], $filename) && $filename[0] != '.') { + $filepath = "$dir/$filename"; + if (is_dir($filepath) && $options['recurse']) { // Give priority to files in this folder by merging them in after any subdirectory files. - $files = array_merge(file_scan_directory("$dir/$file", $mask, $options, $depth + 1), $files); + $files = array_merge(file_scan_directory($filepath, $mask, $options, $depth + 1), $files); } - elseif ($depth >= $options['min_depth'] && preg_match($mask, $file)) { + elseif ($depth >= $options['min_depth'] && preg_match($mask, $filename)) { // Always use this match over anything already set in $files with the // same $$options['key']. - $filename = "$dir/$file"; - $basename = basename($file); - $name = substr($basename, 0, strrpos($basename, '.')); - $files[${$options['key']}] = (object) array( + $file = (object) array( + 'filepath' => $filepath, 'filename' => $filename, - 'basename' => $basename, - 'name' => $name, + 'name' => pathinfo($filename, PATHINFO_FILENAME), ); + $key = $options['key']; + $files[$file->$key] = $file; if ($options['callback']) { - $options['callback']($filename); + $options['callback']($filepath); } } } diff --git a/includes/install.inc b/includes/install.inc index 36d1b6bcb..125989679 100644 --- a/includes/install.inc +++ b/includes/install.inc @@ -216,9 +216,9 @@ function drupal_detect_database_types() { // file for the driver explicitly. foreach (file_scan_directory(DRUPAL_ROOT . '/includes/database', '/^[a-z]*$/i', array('recurse' => FALSE)) as $file) { - include_once "{$file->filename}/install.inc"; - include_once "{$file->filename}/database.inc"; - $drivers[$file->basename] = $file->filename; + include_once "{$file->filepath}/install.inc"; + include_once "{$file->filepath}/database.inc"; + $drivers[$file->filename] = $file->filepath; } foreach ($drivers as $driver => $file) { @@ -934,7 +934,7 @@ function drupal_check_profile($profile) { // Collect requirement testing results $requirements = array(); foreach ($installs as $install) { - require_once DRUPAL_ROOT . '/' . $install->filename; + require_once DRUPAL_ROOT . '/' . $install->filepath; $function = $install->name. '_requirements'; if (function_exists($function)) { $requirements = array_merge($requirements, $function('install')); @@ -974,7 +974,7 @@ function drupal_check_module($module) { // Include install file $install = drupal_get_install_files(array($module)); if (isset($install[$module])) { - require_once DRUPAL_ROOT . '/' . $install[$module]->filename; + require_once DRUPAL_ROOT . '/' . $install[$module]->filepath; // Check requirements $requirements = module_invoke($module, 'requirements', 'install'); diff --git a/includes/locale.inc b/includes/locale.inc index 10e9729bf..322b5f7d1 100644 --- a/includes/locale.inc +++ b/includes/locale.inc @@ -2675,20 +2675,21 @@ function _locale_batch_build($files, $finished = NULL, $components = array()) { $operations = array(); foreach ($files as $file) { // We call _locale_batch_import for every batch operation. - $operations[] = array('_locale_batch_import', array($file->filename)); } - $batch = array( - 'operations' => $operations, - 'title' => $t('Importing interface translations'), - 'init_message' => $t('Starting import'), - 'error_message' => $t('Error importing interface translations'), - 'file' => 'includes/locale.inc', - // This is not a batch API construct, but data passed along to the - // installer, so we know what did we import already. - '#components' => $components, - ); - if (isset($finished)) { - $batch['finished'] = $finished; - } + $operations[] = array('_locale_batch_import', array($file->filepath)); + } + $batch = array( + 'operations' => $operations, + 'title' => $t('Importing interface translations'), + 'init_message' => $t('Starting import'), + 'error_message' => $t('Error importing interface translations'), + 'file' => 'includes/locale.inc', + // This is not a batch API construct, but data passed along to the + // installer, so we know what did we import already. + '#components' => $components, + ); + if (isset($finished)) { + $batch['finished'] = $finished; + } return $batch; } return FALSE; diff --git a/includes/module.inc b/includes/module.inc index ca5388e57..71db71f57 100644 --- a/includes/module.inc +++ b/includes/module.inc @@ -101,41 +101,41 @@ function module_rebuild_cache() { 'files' => array(), ); - foreach ($files as $filename => $file) { + foreach ($files as $filepath => $file) { // Look for the info file. - $file->info = drupal_parse_info_file(dirname($file->filename) . '/' . $file->name . '.info'); + $file->info = drupal_parse_info_file(dirname($file->filepath) . '/' . $file->name . '.info'); // Skip modules that don't provide info. if (empty($file->info)) { - unset($files[$filename]); + unset($files[$filepath]); continue; } // Merge in defaults and save. - $files[$filename]->info = $file->info + $defaults; + $files[$filepath]->info = $file->info + $defaults; // Invoke hook_system_info_alter() to give installed modules a chance to // modify the data in the .info files if necessary. - drupal_alter('system_info', $files[$filename]->info, $files[$filename]); + drupal_alter('system_info', $files[$filepath]->info, $files[$filepath]); // Update the contents of the system table: - if (isset($file->status) || (isset($file->old_filename) && $file->old_filename != $file->filename)) { + if (isset($file->status) || (isset($file->old_filepath) && $file->old_filepath != $file->filepath)) { db_update('system') ->fields(array( - 'info' => serialize($files[$filename]->info), + 'info' => serialize($files[$filepath]->info), 'name' => $file->name, - 'filename' => $file->filename)) - ->condition('filename', $file->old_filename) + 'filename' => $file->filepath)) + ->condition('filename', $file->old_filepath) ->execute(); } else { // This is a new module. - $files[$filename]->status = 0; + $files[$filepath]->status = 0; db_insert('system') ->fields(array( 'name' => $file->name, - 'info' => serialize($files[$filename]->info), + 'info' => serialize($files[$filepath]->info), 'type' => 'module', - 'filename' => $file->filename, + 'filename' => $file->filepath, 'status' => 0)) ->execute(); } @@ -535,7 +535,7 @@ function drupal_required_modules() { $files = drupal_system_listing('/\.info$/', 'modules', 'name', 0); $required = array(); foreach ($files as $name => $file) { - $info = drupal_parse_info_file($file->filename); + $info = drupal_parse_info_file($file->filepath); if (!empty($info) && !empty($info['required']) && $info['required']) { $required[] = $name; } diff --git a/includes/registry.inc b/includes/registry.inc index c3e88f1d0..35caaa3fb 100644 --- a/includes/registry.inc +++ b/includes/registry.inc @@ -43,7 +43,7 @@ function _registry_rebuild() { $files = array(); foreach (module_rebuild_cache() as $module) { if ($module->status) { - $dir = dirname($module->filename); + $dir = dirname($module->filepath); foreach ($module->info['files'] as $file) { $files["$dir/$file"] = array('module' => $module->name, 'weight' => $module->weight); } diff --git a/includes/theme.inc b/includes/theme.inc index 1b5d03afd..7f81b4c2a 100644 --- a/includes/theme.inc +++ b/includes/theme.inc @@ -831,7 +831,7 @@ function drupal_find_theme_templates($cache, $extension, $path) { $files = drupal_system_listing($regex, $path, 'name', 0); foreach ($files as $template => $file) { // Ignore sub-theme templates for the current theme. - if (strpos($file->filename, str_replace($subtheme_paths, '', $file->filename)) !== 0) { + if (strpos($file->filepath, str_replace($subtheme_paths, '', $file->filepath)) !== 0) { continue; } // Chop off the remaining extensions if there are any. $template already @@ -846,7 +846,7 @@ function drupal_find_theme_templates($cache, $extension, $path) { if (isset($cache[$hook])) { $templates[$hook] = array( 'template' => $template, - 'path' => dirname($file->filename), + 'path' => dirname($file->filepath), ); } // Ensure that the pattern is maintained from base themes to its sub-themes. @@ -872,7 +872,7 @@ function drupal_find_theme_templates($cache, $extension, $path) { // Put the underscores back in for the hook name and register this pattern. $templates[strtr($file, '-', '_')] = array( 'template' => $file, - 'path' => dirname($files[$match]->filename), + 'path' => dirname($files[$match]->filepath), 'arguments' => $info['arguments'], ); } |