| 1 |
<?php |
<?php |
| 2 |
// $Id: module.inc,v 1.164 2009/11/01 22:10:07 webchick Exp $ |
// $Id: module.inc,v 1.165 2009/11/05 16:19:25 webchick Exp $ |
| 3 |
|
|
| 4 |
/** |
/** |
| 5 |
* @file |
* @file |
| 69 |
// locations in the file system. The ordering here must also be |
// locations in the file system. The ordering here must also be |
| 70 |
// consistent with the one used in module_implements(). |
// consistent with the one used in module_implements(). |
| 71 |
if ($bootstrap) { |
if ($bootstrap) { |
| 72 |
$result = db_query("SELECT name, filename FROM {system} WHERE type = 'module' AND status = 1 AND bootstrap = 1 ORDER BY weight ASC, name ASC"); |
$list = system_list('bootstrap'); |
| 73 |
} |
} |
| 74 |
else { |
else { |
| 75 |
$result = db_query("SELECT name, filename FROM {system} WHERE type = 'module' AND status = 1 ORDER BY weight ASC, name ASC"); |
$list = system_list('module'); |
|
} |
|
|
foreach ($result as $module) { |
|
|
if (file_exists($module->filename)) { |
|
|
// First call drupal_get_filename() to prime the static cache for |
|
|
// later lookups of the module path. Since we've already queried for |
|
|
// the filename and can pass that in as an argument, this avoids a |
|
|
// database hit for every module when drupal_get_filename() is |
|
|
// subsequently called by drupal_load(). |
|
|
drupal_get_filename('module', $module->name, $module->filename); |
|
|
$list[$module->name] = $module->name; |
|
|
} |
|
| 76 |
} |
} |
| 77 |
} |
} |
| 78 |
} |
} |
| 87 |
} |
} |
| 88 |
|
|
| 89 |
/** |
/** |
| 90 |
|
* Build a list of bootstrap modules and enabled modules and themes. |
| 91 |
|
* |
| 92 |
|
* @param $type |
| 93 |
|
* The type of list to return, either 'module', 'bootstrap', or 'theme'. |
| 94 |
|
* |
| 95 |
|
* @return |
| 96 |
|
* An associative array of modules or themes, keyed by name, with the minimum |
| 97 |
|
* data required to bootstrap. |
| 98 |
|
* |
| 99 |
|
* @see module_list() |
| 100 |
|
* @see list_themes() |
| 101 |
|
*/ |
| 102 |
|
function system_list($type) { |
| 103 |
|
$lists = &drupal_static(__FUNCTION__); |
| 104 |
|
|
| 105 |
|
if (!isset($lists)) { |
| 106 |
|
$lists = array('bootstrap' => array(), 'module' => array(), 'theme' => array()); |
| 107 |
|
$result = db_query("SELECT * FROM {system} WHERE status = 1 ORDER BY weight ASC, name ASC"); |
| 108 |
|
foreach ($result as $record) { |
| 109 |
|
// Build a list of all enabled modules. |
| 110 |
|
if ($record->type == 'module') { |
| 111 |
|
$lists['module'][$record->name] = $record->name; |
| 112 |
|
// Build a separate array of modules required for bootstrap. |
| 113 |
|
if ($record->bootstrap) { |
| 114 |
|
$lists['bootstrap'][$record->name] = $record->name; |
| 115 |
|
} |
| 116 |
|
} |
| 117 |
|
// Build a list of enabled themes. |
| 118 |
|
if ($record->type == 'theme') { |
| 119 |
|
$lists['theme'][$record->name] = $record; |
| 120 |
|
} |
| 121 |
|
|
| 122 |
|
// Additionally prime drupal_get_filename() with the filename and type |
| 123 |
|
// for each record, this prevents subsequent database lookups when |
| 124 |
|
// drupal_get_filename() is called without the 'file' argument. |
| 125 |
|
drupal_get_filename($record->type, $record->name, $record->filename); |
| 126 |
|
} |
| 127 |
|
} |
| 128 |
|
|
| 129 |
|
return $lists[$type]; |
| 130 |
|
} |
| 131 |
|
|
| 132 |
|
/** |
| 133 |
* Find dependencies any level deep and fill in required by information too. |
* Find dependencies any level deep and fill in required by information too. |
| 134 |
* |
* |
| 135 |
* @param $files |
* @param $files |
| 268 |
|
|
| 269 |
if (!empty($invoke_modules)) { |
if (!empty($invoke_modules)) { |
| 270 |
// Refresh the module list to exclude the disabled modules. |
// Refresh the module list to exclude the disabled modules. |
| 271 |
|
drupal_static_reset('system_list'); |
| 272 |
module_list(TRUE); |
module_list(TRUE); |
| 273 |
module_implements('', FALSE, TRUE); |
module_implements('', FALSE, TRUE); |
| 274 |
// Force to regenerate the stored list of hook implementations. |
// Force to regenerate the stored list of hook implementations. |
| 329 |
|
|
| 330 |
if (!empty($invoke_modules)) { |
if (!empty($invoke_modules)) { |
| 331 |
// Refresh the module list to exclude the disabled modules. |
// Refresh the module list to exclude the disabled modules. |
| 332 |
|
drupal_static_reset('system_list'); |
| 333 |
module_list(TRUE); |
module_list(TRUE); |
| 334 |
module_implements('', FALSE, TRUE); |
module_implements('', FALSE, TRUE); |
| 335 |
// Invoke hook_modules_disabled before disabling modules, |
// Invoke hook_modules_disabled before disabling modules, |