Core  3.2
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  * @package FDL
5 */
6 
7 include_once ('WHAT/Lib.Common.php');
8 include_once ('FDL/freedom_util.php');
9 include_once ('FDL/Class.SearchDoc.php');
10 include_once ('WHAT/Lib.System.php');
11 
12 include_once ('FDL/Class.Form1NF.php');
13 
14 ini_set('memory_limit', '1G');
15 
16 function usage()
17 {
18  echo "Usage:\n";
19  echo " " . __FILE__ . "\n";
20  echo " --config=<config.xml>\n";
21  echo " --outputsql=<file_name> | --outputpgservice=<pgservice>]\n";
22  echo " [--tmppgservice=<tmp_pgservice_name>] (default tmp_1nf)\n";
23  echo " [--tmpschemaname=<tmp_schemaname>] (default 1nf)\n";
24  echo " [--tmpemptydb=<yes|no>] (default yes)\n";
25  echo " [--sqllog=<file>] (default none)\n";
26  exit(1);
27 }
28 
29 $usage = new ApiUsage();
30 $usage->setDefinitionText("Export 1nf");
31 /**
32  * Args
33  */
34 $parms = array(
35  'config' => $usage->addRequiredParameter("config", "configuration file") ,
36  'outputsql' => $usage->addOptionalParameter("outputsql", "File to output sql", null, "") ,
37  'outputpgservice' => $usage->addOptionalParameter("outputpgservice", "Pgservice to output", null, "") ,
38  'tmppgservice' => $usage->addOptionalParameter("tmppgservice", "Tmp pgservice name", null, 'tmp_1nf') ,
39  'tmpschemaname' => $usage->addOptionalParameter('tmpschemaname', "Tmp shema name", null, 'tmp_1nf') ,
40  'tmpemptydb' => $usage->addOptionalParameter("tmpemptydb", "Tmp empty database", null, "yes") ,
41  'sqllog' => $usage->addOptionalParameter("sqllog", "File to log", null, "") ,
42 );
43 
44 $usage->verify();
45 /**
46  * Checks
47  */
48 if (!is_file($parms['config'])) {
49  $action->error(sprintf(_("Error: config file '%s' is not a file.", $parms['config'])));
50  usage();
51 }
52 if (empty($parms['outputsql']) && empty($parms['outputpgservice'])) {
53  $action->error(sprintf(_("Error: at least one of those parameters is mandatory --outputsql --outputpgservice")));
54  usage();
55 }
56 if (empty($parms['tmppgservice'])) {
57  $action->error(sprintf(_("Error: missing or empty --tmppgservice")));
58  usage();
59 }
60 if (empty($parms['tmpschemaname'])) {
61  $action->error(sprintf(_("Error: missing or empty --tmpschemaname")));
62  usage();
63 }
64 $parms['tmpemptydb'] = strtolower($parms['tmpemptydb']);
65 if ($parms['tmpemptydb'] != '' && in_array($parms['tmpemptydb'], array(
66  'no',
67  'n',
68  'non',
69  '0',
70  'false'
71 ))) {
72  $parms['tmpemptydb'] = 'no';
73 } elseif ($parms['tmpemptydb'] == '' || in_array($parms['tmpemptydb'], array(
74  'yes',
75  'y',
76  'oui',
77  'o',
78  '1',
79  'true'
80 ))) {
81  $parms['tmpemptydb'] = 'yes';
82 } else {
83  $action->error(sprintf(_("Error: parameter tmpemptydb '%s' is not allowed.")));
84  usage();
85 }
86 /**
87  * RUN
88  */
90 
91 $ret = $form1NF->run();
92 ?>
global $action
$form1NF
$ret
$usage
usage()
$parms
switch($command) exit
Definition: checkVault.php:46
Verify arguments for wsh programs.
← centre documentaire © anakeen