Plugins  LAST
 All Data Structures Files Functions Variables Pages
index.php
Go to the documentation of this file.
1 <?php
2 /*
3  * This file is part of NOALYSS.
4  *
5  * NOALYSS is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 2 of the License, or
8  * (at your option) any later version.
9  *
10  * NOALYSS is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with NOALYSS; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18  */
19 /* $Revision$ */
20 
21 // Copyright (c) 2002 Author Dany De Bontridder dany@alchimerys.be
22 
23 /* !\file
24  * \brief main file for importing card
25  */
27 $version_plugin=SVNINFO;
28 Extension::check_version(6910);
29 /*
30  * load javascript
31  */
32 $dossier=HtmlInput::default_value_request("gDossier", "0");
33 $ac=HtmlInput::default_value_request("ac", "exit");
34 $plugin_code=HtmlInput::default_value_request("plugin_code", "");
35 echo "<script>";
36 ?>
37 var js_dossier="<?php echo $dossier; ?>";
38 var js_ac="<?php echo $ac; ?>";
39 var js_plugin_code="<?php echo $plugin_code; ?>";
40 <?php
41 require_once __DIR__.'/importcard.js';
42 echo "</script>";
43 require_once('include/class_import_card.php');
44 global $cn;
45 echo '<div style="float:right"><a class="mtitle" style="font-size:140%" href="http://wiki.noalyss.eu/doku.php?id=importation_de_fiche" target="_blank">Aide</a>'.'<span style="font-size:0.8em;color:red;display:inline">vers:SVNINFO</span>'.
46 '</div>';
47 
48 $cn=Dossier::connect();
49 /*
50  * Check if schema exists , if not install it
51  */
52 if ( ! $cn->exist_schema("importcard")) {
53  $cn->execute_script(__DIR__."/sql/install.sql");
54 }
55 
56 /* delete old record */
57 $cn->exec_sql("delete from importcard.format where f_saved=0 and f_timestamp < now() - interval '2 hours'");
58 $cn->exec_sql("delete from importcard.file_csv where file_timestamp < now() - interval '2 hours'");
59 
60 // retrieve file and format if they exist
61 $format_id=HtmlInput::default_value_request("format", -1);
62 $record_id=HtmlInput::default_value_request("record", -1);
63 
65 
66 if (!isset($_REQUEST['sa']))
67 {
68  $upload->new_import();
69  exit();
70 }
71 if ($_REQUEST['sa']=='import')
72 {
73  /* We receive a file , we save and record an id for it */
74  $upload->save_file();
75  $upload->get_post_format();
76  $upload->propose_format();
77  $upload->test_import();
78  exit();
79 }
80 
81 /**
82  * apply the change of the format or record it
83  */
84 if ($_REQUEST['sa']=="test")
85 {
86  /**
87  * apply the change
88  */
89  if (isset($_POST["apply_format"]))
90  {
91  // retrieve information and store them into db
92  $upload->get_post_format();
93 
94  // Propose a template
95  $upload->show_template();
96 
97  // Display the parameter
98  $upload->propose_format();
99 
100  // Show the result
101  $upload->test_import();
102  exit();
103  }
104  /**
105  * Record the data into the db
106  */
107  if (isset($_POST["import_file"]))
108  {
109  // retriev info
110  $upload->get_post_format();
111 
112  // Propose to save the template
113  //
114  $upload->propose_save_template();
115  // Import
116  // show imported row
117  $upload->record_import();
118 
119  exit();
120  }
121 }
global $version_plugin
Definition: index.php:22
$upload
Definition: index.php:64
$plugin_code
Definition: index.php:34
$_REQUEST['sa']
Definition: index.php:68
$format_id
Definition: index.php:61
$ac
Definition: index.php:33
$dossier
Definition: index.php:32
$cn
Definition: index.php:42
$record_id
Definition: index.php:62