| 1 |
#!/usr/bin/php
|
| 2 |
<?php
|
| 3 |
/**
|
| 4 |
* Script to generate custom modules in the modules directory
|
| 5 |
*/
|
| 6 |
function print_help() {
|
| 7 |
print "usage: generate_module.php domain type name\n";
|
| 8 |
exit;
|
| 9 |
}
|
| 10 |
|
| 11 |
|
| 12 |
/**
|
| 13 |
* include the configuration settings.
|
| 14 |
*/
|
| 15 |
include_once('script_settings.php');
|
| 16 |
|
| 17 |
/**
|
| 18 |
* include the parser
|
| 19 |
*/
|
| 20 |
include_once('common.php');
|
| 21 |
|
| 22 |
/**
|
| 23 |
* This is where the action happens.
|
| 24 |
*/
|
| 25 |
if (($domain = $argv[1]) &&
|
| 26 |
($type = $argv[2]) &&
|
| 27 |
($name = $argv[3])) {
|
| 28 |
$variables = array(
|
| 29 |
'domain' => $domain,
|
| 30 |
'type' => $type,
|
| 31 |
'name' => $name,
|
| 32 |
);
|
| 33 |
|
| 34 |
$file_name = $template_dir .'/'. $type .'.module';
|
| 35 |
$contents = parse_file($file_name, $variables);
|
| 36 |
|
| 37 |
if ($contents) {
|
| 38 |
//Make the modules directory
|
| 39 |
$dir = $drupal_dir .'/sites/'. $domain .'/modules/'. $name;
|
| 40 |
$status = mkdir($dir, 0770);
|
| 41 |
report_to_console($dir, 'Create', $status);
|
| 42 |
|
| 43 |
if ($status) {
|
| 44 |
//Make the module
|
| 45 |
$file_name = $dir .'/'. $name .'.module';
|
| 46 |
$status = file_put_contents($file_name, $contents);
|
| 47 |
report_to_console($file_name, 'Create', $status);
|
| 48 |
}
|
| 49 |
}
|
| 50 |
}
|
| 51 |
else {
|
| 52 |
print_help();
|
| 53 |
}
|
| 54 |
?>
|