| 1 |
<?php |
<?php |
| 2 |
// $Id: generate.inc,v 1.1.2.18 2009/10/24 13:27:18 joachim Exp $ |
// $Id: generate.inc,v 1.1.2.19 2009/10/24 14:28:06 joachim Exp $ |
| 3 |
|
|
| 4 |
/** |
/** |
| 5 |
* @file |
* @file |
| 13 |
* Generate module code. |
* Generate module code. |
| 14 |
* |
* |
| 15 |
* @param $module_data |
* @param $module_data |
| 16 |
* An associative array of data for the module. The keys can *mostly* be taken |
* An associative array of data for the module, passed by reference so data |
| 17 |
* straight from form values. They are as follows: |
* on generated files can be added. |
| 18 |
|
* The keys can *mostly* be taken straight from form values. They are as follows: |
| 19 |
* - 'module_root_name' |
* - 'module_root_name' |
| 20 |
* - 'module_readable_name' |
* - 'module_readable_name' |
| 21 |
* - 'module_short_description' |
* - 'module_short_description' |
| 25 |
* Unwanted hooks may also be included as keys provided their value is FALSE. |
* Unwanted hooks may also be included as keys provided their value is FALSE. |
| 26 |
* - 'module_dependencies': a string of dependencies, eg 'forum views'. |
* - 'module_dependencies': a string of dependencies, eg 'forum views'. |
| 27 |
* - 'module_package': the module package. |
* - 'module_package': the module package. |
| 28 |
|
* - 'module_files': added by this function. A flat array of filenames that have been generated. |
| 29 |
* @param $bare |
* @param $bare |
| 30 |
* If true, omit header and footers and output only hook code. |
* If true, omit header and footers and output only hook code. |
| 31 |
* @return |
* @return |
| 32 |
* An array of code, indexed by filename. Eg, |
* An array of code, indexed by filename. Eg, |
| 33 |
* 'modulename.module' => CODE |
* 'modulename.module' => CODE |
| 34 |
*/ |
*/ |
| 35 |
function module_builder_generate_module($module_data, $bare = FALSE) { |
function module_builder_generate_module(&$module_data, $bare = FALSE) { |
| 36 |
// Get a set of hook declarations and function body templates for the hooks we want. |
// Get a set of hook declarations and function body templates for the hooks we want. |
| 37 |
// $hook_data is of the form: |
// $hook_data is of the form: |
| 38 |
// 'hook_foo' => array( 'declaration' => DATA, 'template' => DATA ) |
// 'hook_foo' => array( 'declaration' => DATA, 'template' => DATA ) |
| 40 |
if (is_null($hook_file_data)) { |
if (is_null($hook_file_data)) { |
| 41 |
return NULL; |
return NULL; |
| 42 |
} |
} |
| 43 |
|
|
| 44 |
//print_r($module_data); |
//print_r($module_data); |
| 45 |
//dsm($hook_file_data); |
//dsm($hook_file_data); |
| 46 |
|
|
| 104 |
//print $code; |
//print $code; |
| 105 |
|
|
| 106 |
$return[$filename] = $code; |
$return[$filename] = $code; |
| 107 |
|
// Add the generated filename to the module data for the info generation to find. |
| 108 |
|
$module_data['module_files'][] = $filename; |
| 109 |
} // foreach file |
} // foreach file |
| 110 |
|
|
| 111 |
|
//print_r($module_data); |
| 112 |
|
|
| 113 |
return $return; |
return $return; |
| 114 |
} |
} |
| 115 |
|
|