| 1 |
|
<?php |
| 2 |
|
// $Id$ |
| 3 |
|
|
| 4 |
|
/** |
| 5 |
|
* @file |
| 6 |
|
* Module builder code generating code specific to Drupal 7. |
| 7 |
|
*/ |
| 8 |
|
|
| 9 |
|
/** |
| 10 |
|
* Generate module info file code. |
| 11 |
|
* |
| 12 |
|
* @param $module_data |
| 13 |
|
* Same as for generate_module(). |
| 14 |
|
* An associative array of data for the module. The keys can *mostly* be taken |
| 15 |
|
* straight from form values. They are as follows: |
| 16 |
|
* - 'module_root_name' |
| 17 |
|
* - 'module_readable_name' |
| 18 |
|
* - 'module_short_description' |
| 19 |
|
* - 'module_help_text' |
| 20 |
|
* - 'hooks': An associative array whose keys are full hook names |
| 21 |
|
* (eg 'hook_menu'), where requested hooks have a value of TRUE. |
| 22 |
|
* Unwanted hooks may also be included as keys provided their value is FALSE. |
| 23 |
|
* - 'module_dependencies': a string of dependencies, eg 'forum views'. |
| 24 |
|
* - 'module_package': the module package. |
| 25 |
|
*/ |
| 26 |
|
function module_builder_generate_info($module_data) { |
| 27 |
|
//print_r($module_data); |
| 28 |
|
|
| 29 |
|
// Some defaults |
| 30 |
|
$module_data_defaults = array( |
| 31 |
|
'module_short_description' => 'TODO: Description of module', |
| 32 |
|
'module_readable_name' => ucfirst($module_data['module_root_name']), |
| 33 |
|
); |
| 34 |
|
foreach ($module_data as $key => $data) { |
| 35 |
|
if (!$data) { |
| 36 |
|
$module_data[$key] = $module_data_defaults[$key]; |
| 37 |
|
} |
| 38 |
|
} |
| 39 |
|
|
| 40 |
|
// The weird syntax stops this from getting mangled by CVS |
| 41 |
|
$info = '; $' . 'Id$' . "\n"; |
| 42 |
|
$info .= 'name = ' . $module_data['module_readable_name'] . "\n"; |
| 43 |
|
$info .= 'description = '. $module_data['module_short_description'] ."\n"; |
| 44 |
|
|
| 45 |
|
if (!empty($module_data['module_dependencies'])) { |
| 46 |
|
foreach (explode(' ', $module_data['module_dependencies']) as $dep) { |
| 47 |
|
$info .= 'dependencies[] = '. $dep ."\n"; |
| 48 |
|
} |
| 49 |
|
} |
| 50 |
|
|
| 51 |
|
if (!empty($module_data['module_package'])) { |
| 52 |
|
$info .= 'package = '. $module_data['module_package'] ."\n"; |
| 53 |
|
} |
| 54 |
|
$info .= "core = 6.x\n"; |
| 55 |
|
|
| 56 |
|
if (is_array($module_data['module_files'])) { |
| 57 |
|
foreach ($module_data['module_files'] as $file) { |
| 58 |
|
$info .= 'files[] = '. $file ."\n"; |
| 59 |
|
} |
| 60 |
|
} |
| 61 |
|
|
| 62 |
|
return $info; |
| 63 |
|
} |
| 64 |
|
|