Platform  3.1
PHP API documentation
 All Data Structures Namespaces Files Functions Variables Pages
fdl_export1nf.php
Go to the documentation of this file.
1 <?php
2 /*
3  * @author Anakeen
4  * @license http://creativecommons.org/licenses/by-nc-sa/2.0/fr/ Anakeen - licence CC
5  * @package FDL
6 */
7 
8 include_once ('WHAT/Lib.Common.php');
9 include_once ('FDL/freedom_util.php');
10 include_once ('FDL/Class.SearchDoc.php');
11 include_once ('WHAT/Lib.System.php');
12 
13 include_once ('FDL/Class.Form1NF.php');
14 
15 ini_set('memory_limit', '1G');
16 
17 function usage()
18 {
19  echo "Usage:\n";
20  echo " " . __FILE__ . "\n";
21  echo " --config=<config.xml>\n";
22  echo " --outputsql=<file_name> | --outputpgservice=<pgservice>]\n";
23  echo " [--tmppgservice=<tmp_pgservice_name>] (default tmp_1nf)\n";
24  echo " [--tmpschemaname=<tmp_schemaname>] (default 1nf)\n";
25  echo " [--tmpemptydb=<yes|no>] (default yes)\n";
26  echo " [--sqllog=<file>] (default none)\n";
27  exit(1);
28 }
29 /**
30  * Args
31  */
32 $parms = array(
33  'config' => '',
34  'outputsql' => '',
35  'outputpgservice' => '',
36  'tmppgservice' => 'tmp_1nf',
37  'tmpschemaname' => 'tmp_1nf',
38  'tmpemptydb' => 'yes',
39  'sqllog' => '',
40 );
41 
42 foreach ($parms as $key => $value) {
43  $parms[$key] = getHttpVars($key, $value);
44 }
45 /**
46  * Checks
47  */
48 if (empty($parms['config'])) {
49  $action->error(sprintf(_("Error: missing or empty --config")));
50  usage();
51 }
52 if (!is_file($parms['config'])) {
53  $action->error(sprintf(_("Error: config file '%s' is not a file.", $parms['config'])));
54  usage();
55 }
56 if (empty($parms['outputsql']) && empty($parms['outputpgservice'])) {
57  $action->error(sprintf(_("Error: at least one of those parameters is mandatory --outputsql --outputpgservice")));
58  usage();
59 }
60 if (empty($parms['tmppgservice'])) {
61  $action->error(sprintf(_("Error: missing or empty --tmppgservice")));
62  usage();
63 }
64 if (empty($parms['tmpschemaname'])) {
65  $action->error(sprintf(_("Error: missing or empty --tmpschemaname")));
66  usage();
67 }
68 $parms['tmpemptydb'] = strtolower($parms['tmpemptydb']);
69 if ($parms['tmpemptydb'] != '' && in_array($parms['tmpemptydb'], array(
70  'no',
71  'n',
72  'non',
73  '0',
74  'false'
75 ))) {
76  $parms['tmpemptydb'] = 'no';
77 } elseif ($parms['tmpemptydb'] == '' || in_array($parms['tmpemptydb'], array(
78  'yes',
79  'y',
80  'oui',
81  'o',
82  '1',
83  'true'
84 ))) {
85  $parms['tmpemptydb'] = 'yes';
86 } else {
87  $action->error(sprintf(_("Error: parameter tmpemptydb '%s' is not allowed.")));
88  usage();
89 }
90 /**
91  * RUN
92  */
94 
95 $ret = $form1NF->run();
96 ?>
← centre documentaire © anakeen - published under CC License - Dynacase