/[drupal]/contributions/modules/phpfreechat/generate-form.php
ViewVC logotype

Contents of /contributions/modules/phpfreechat/generate-form.php

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.2 - (show annotations) (download) (as text)
Sat Jan 20 16:41:01 2007 UTC (2 years, 10 months ago) by grugnog
Branch: MAIN
CVS Tags: HEAD
Changes since 1.1: +2 -0 lines
File MIME type: text/x-php
Fixing install prefixes and adding some more Id strings
1 <?php
2 // $Id:
3
4 /*
5 * This is a command line script that generates a settings form definition
6 * for the phpfreechat module by parsing the phpfreechat INSTALL.en file
7 * php -f generate-form.php
8 * You should never need to use this!
9 */
10
11 $install_path = 'phpfreechat';
12 if (file_exists($install_path.'/INSTALL.en')) {
13 $file = file_get_contents($install_path.'/INSTALL.en');
14 $settings_start = strpos($file, 'full parameters list:');
15 $settings_finish = strpos($file, '2006 phpFreeChat', $settings_start) - 4;
16 $settings_section = substr($file, $settings_start, $settings_finish - $settings_start);
17 $matches = array();
18 preg_match_all('/\s{4}(\S.*)((?:\n\s{9}.*)*)/', $settings_section, $matches, PREG_SET_ORDER);
19 $settings = array();
20 foreach ($matches as $match) {
21 $setting_names = explode(' and ', $match['1']); // For x and y lines
22 foreach ($setting_names as $setting_name) {
23 $settings[$setting_name]['help'] = $match['2'];
24 // Find some of the common defaults
25 if (strstr($match['2'], '(true value by default')) $settings[$setting_name]['default'] = 'true';
26 if (strstr($match['2'], '(false value by default')) $settings[$setting_name]['default'] = 'false';
27 }
28 }
29 // print_r($settings);
30 $settings_list = "'";
31 foreach ($settings as $setting => $value) {
32 $settings_list .= $setting . "','";
33 $setting_title = ucwords(str_replace('_',' ',$setting));
34 if ($value['default'] == 'true' || $value['default'] == 'false') {
35 print '$form[\'phpfreechat_'.$setting.'\'] = array(' . "\n";
36 print ' \'#type\' => \'select\',' . "\n";
37 print ' \'#title\' => t(\''.str_replace("'", "\'", $setting_title).'\'),' . "\n";
38 print ' \'#default_value\' => variable_get(\'phpfreechat_'.$setting.'\', $value[\'default\']),' . "\n";
39 print ' \'#options\' => array(\'\' => \'default\', \'true\' => \'true\', \'false\' => \'false\'),' . "\n";
40 print ' \'#description\' => t(\''.str_replace("'", "\'", $value['help']).'\'),' . "\n";
41 print ');' . "\n\n";
42 }
43 else {
44 print '$form[\'phpfreechat_'.$setting.'\'] = array(' . "\n";
45 print ' \'#type\' => \'textfield\',' . "\n";
46 print ' \'#title\' => t(\''.str_replace("'", "\'", $setting_title).'\'),' . "\n";
47 print ' \'#default_value\' => variable_get(\'phpfreechat_'.$setting.'\', \'\'),' . "\n";
48 print ' \'#description\' => t(\''.str_replace("'", "\'", $value['help']).'\'),' . "\n";
49 print ');' . "\n\n";
50 }
51 }
52 $settings_list .= "'";
53 print "\n\nArray of settings:\n" . $settings_list . "\n\n";
54 }
55
56
57 ?>

  ViewVC Help
Powered by ViewVC 1.1.2