- Patch #713028 by hefox, jhodgdon, solotandem: drupal_system_listing() indicates incorrect key values.

merge-requests/26/head
Dries Buytaert 2010-04-30 20:17:28 +00:00
parent ca1fc09e1f
commit ed1e9a46a5
1 changed files with 41 additions and 21 deletions

View File

@ -4546,31 +4546,51 @@ function drupal_cron_cleanup() {
} }
/** /**
* Return an array of system file objects. * Returns information about system object files (modules, themes, etc.).
*
* This function is used to find all or some system object files (module files,
* theme files, etc.) that exist on the site. It searches in several locations,
* depending on what type of object you are looking for. For instance, if you
* are looking for modules and call:
* @code
* drupal_system_listing("/\.module$/", "modules", 'name', 0);
* @endcode
* this function will search the site-wide modules directory (i.e., /modules/),
* your install profile's directory (i.e.,
* /profiles/your_site_profile/modules/), the all-sites directory (i.e.,
* /sites/all/modules/), and your site-specific directory (i.e.,
* /sites/your_site_dir/modules/), in that order, and return information about
* all of the files ending in .module in those directories.
* *
* Returns an array of file objects of the given type from the site-wide * The information is returned in an associative array, which can be keyed on
* directory (i.e. modules/), the all-sites directory (i.e. sites/all/modules/), * the file name ($key = 'filename'), the file name without the extension ($key
* the profiles directory (i.e. profiles/your_site_profile/modules/), and the * = 'name'), or the full file stream URI ($key = 'uri'). If you use a key of
* site-specific directory (i.e. sites/your_site_dir/modules/). The returned * 'filename' or 'name', files found later in the search will take precedence
* array will be keyed using the key specified (uri, filename, or name). Using * over files found earlier; if you choose a key of 'uri', you will get all
* name or filename will cause site-specific files to be prioritized over * files found.
* similar files in the default directories. That is, if a file with the same
* name appears in both the site-wide directory and site-specific directory,
* only the site-specific version will be included.
* *
* @param $mask * @param string $mask
* The preg_match() regular expression of the files to find. * The preg_match() regular expression for the files to find.
* @param $directory * @param string $directory
* The subdirectory name in which the files are found. For example, * The subdirectory name in which the files are found. For example,
* 'modules' will search in both modules/ and * 'modules' will search in sub-directories of the top-level /modules
* sites/somesite/modules/. * directory, sub-directories of /sites/all/modules/, etc.
* @param $key * @param string $key
* The key to be passed to file_scan_directory(). * The key to be used for the associative array returned. Possible values are
* @param $min_depth * 'uri', for the file's URI; 'filename', for the basename of the file; and
* Minimum depth of directories to return files from. * 'name' for the name of the file without the extension. If you choose 'name'
* or 'filename', only the highest-precedence file will be returned.
* @param int $min_depth
* Minimum depth of directories to return files from, relative to each
* directory searched. For instance, a minimum depth of 2 would find modules
* inside /modules/node/tests, but not modules directly in /modules/node.
* *
* @return * @return array
* An array of file objects of the specified type. * An associative array of file objects, keyed on the chosen key. Each element
* in the array is an object containing file information, with properties:
* - 'uri': Full URI of the file.
* - 'filename': File name.
* - 'name': Name of file without the extension.
*/ */
function drupal_system_listing($mask, $directory, $key = 'name', $min_depth = 1) { function drupal_system_listing($mask, $directory, $key = 'name', $min_depth = 1) {
$config = conf_path(); $config = conf_path();