function _warden_generate_site_data in Warden 6
Same name and namespace in other branches
- 7 warden.page.inc \_warden_generate_site_data()
Generate all the site's data for Warden.
Return value
array The site's data as an array.
1 call to _warden_generate_site_data()
- _warden_update_warden in ./
warden.page.inc - Update Warden with latest site data.
File
- ./
warden.page.inc, line 39 - Logic for warden output
Code
function _warden_generate_site_data() {
global $base_url;
$drupal_modules = module_list();
$system_themes = list_themes(TRUE);
$system_modules = array();
foreach ($drupal_modules as $name) {
$path = drupal_get_path('module', $name) . '/' . $name . '.info';
$info = drupal_parse_info_file($path);
$system_modules[$info['name']] = new stdClass();
$system_modules[$info['name']]->info = $info;
$system_modules[$info['name']]->filename = $path;
}
// Needless initialisation, but hey.
$res = array(
'core' => array(),
'contrib' => array(),
'custom' => array(),
'url' => $base_url,
);
// Go over themes.
foreach ($system_themes as $theme) {
if (isset($theme->info['project']) && $theme->info['project'] == "drupal") {
continue;
}
if (isset($theme->info['version']) && isset($theme->info['project'])) {
$res['contrib'][$theme->info['project']] = array(
"version" => $theme->info['version'],
);
}
}
// Go over modules.
foreach ($system_modules as $module => $module_info) {
$filename = $module_info->filename;
// Match for custom modules.
if (variable_get('warden_match_custom', TRUE)) {
$regex = variable_get('warden_preg_match_custom', '{^sites\\/([A-z,\\.,\\-]+)\\/modules\\/custom\\/*}');
if (preg_match($regex, $filename)) {
// if this is part of a project, only set the project.
if (isset($module_info->info['project'])) {
$res['custom'][$module_info->info['project']] = array(
"version" => $module_info->info['version'],
);
}
else {
$res['custom'][$module] = array(
"version" => $module_info->info['version'],
);
}
}
}
else {
$res['custom'] = "disabled";
}
// Match for contrib modules.
if (variable_get('warden_match_contrib', TRUE)) {
$regex = variable_get('warden_preg_match_contrib', '{^sites\\/([A-z,\\.,\\-]+)\\/modules\\/contrib\\/*}');
if (preg_match($regex, $filename)) {
// if this is part of a project, only set the project.
if (isset($module_info->info['project'])) {
$res['contrib'][$module_info->info['project']] = array(
"version" => $module_info->info['version'],
);
}
else {
$res['contrib'][$module] = array(
"version" => $module_info->info['version'],
);
}
}
}
else {
$res['contrib'] = "disabled";
}
// Core modules.
if (variable_get('warden_match_core', TRUE)) {
if ($module_info->info['package'] == "Core - required") {
$res['core'][$module] = array(
"version" => $module_info->info['version'],
);
}
}
else {
$res['core'] = "disabled";
}
}
// Include Drupal core version.
if (!isset($res['core']['drupal'])) {
$res['core']['drupal'] = array(
"version" => VERSION,
);
}
// Site name.
$res['site_name'] = variable_get('site_name', $base_url);
// Sign the request with our local key and the timestamp.
$res['key'] = _warden_get_local_token();
$res['time'] = time();
return $res;
}