Core  3.2
PHP API documentation
 All Data Structures Namespaces Files Functions Variables Pages
freedom_import_xml.php
Go to the documentation of this file.
1 <?php
2 /*
3  * @author Anakeen
4  * @package FDL
5 */
6 /**
7  * Import directory with document descriptions
8  *
9  * @author Anakeen
10  * @version $Id: freedom_import_dir.php,v 1.5 2007/01/19 16:23:32 eric Exp $
11  * @package FDL
12  * @subpackage GED
13  */
14 /**
15  */
16 
17 include_once ("FDL/import_tar.php");
18 include_once ('FDL/Class.XMLSplitter.php');
19 /**
20  * export global xml file
21  * @param Action $action main action
22  * @param string $filename xml filename to import
23  * @return array
24  */
26 {
27 
28  $opt["analyze"] = (substr(strtolower(getHttpVars("analyze", "N")) , 0, 1) == "y");
29  $opt["policy"] = getHttpVars("policy", "update");
30  $opt["dirid"] = getHttpVars("dirid", getHttpVars("dir", 0));
31 
32  $dbaccess = $action->dbaccess;
33  global $_FILES;
34 
36  if ($filename == "") {
37  if (isset($_FILES["file"])) {
38  $filename = $_FILES["file"]['name'];
39  $xmlfiles = $_FILES["file"]['tmp_name'];
40  $ext = substr($filename, strrpos($filename, '.') + 1);
41  rename($xmlfiles, $xmlfiles . ".$ext");
42  $xmlfiles.= ".$ext";
43  } else {
44  $filename = GetHttpVars("file");
45  $xmlfiles = $filename;
46  }
47  } else {
48  $xmlfiles = $filename;
49  }
50 
51  $iXml = new \Dcp\Core\importXml();
52  $iXml->setPolicy($opt["policy"]);
53  $iXml->setImportDirectory($opt["dirid"]);
54  $iXml->analyzeOnly($opt["analyze"]);
55  return $iXml->importSingleXmlFile($xmlfiles);
56 }
57 /**
58  * export global xml file
59  * @param Action $action main action
60  * @param string $filename xml filename to import
61  * @return array
62  */
64 {
65 
66  $opt["analyze"] = (substr(strtolower(getHttpVars("analyze", "Y")) , 0, 1) == "y");
67  $opt["policy"] = getHttpVars("policy", "update");
68  $opt["dirid"] = getHttpVars("dirid", getHttpVars("dir", 0));
69 
70  global $_FILES;
72  if ($filename == "") {
73  if (isset($_FILES["file"])) {
74  $filename = $_FILES["file"]['name'];
75  $zipfiles = $_FILES["file"]['tmp_name'];
76  $ext = substr($filename, strrpos($filename, '.') + 1);
77  rename($zipfiles, $zipfiles . ".$ext");
78  $zipfiles.= ".$ext";
79  } else {
80  $filename = GetHttpVars("file");
81  $zipfiles = $filename;
82  }
83  } else {
84  $zipfiles = $filename;
85  }
86 
87  $iXml = new \Dcp\Core\importXml();
88  $iXml->setPolicy($opt["policy"]);
89  $iXml->setImportDirectory($opt["dirid"]);
90  $iXml->analyzeOnly($opt["analyze"]);
91 
92  $log = $iXml->importZipFile($zipfiles);
93  return $log;
94 }
95 /**
96  * read a directory to import all xml files
97  * @param string $splitdir
98  * @param array $opt options analyze (boolean) , policy (string)
99  * @deprecated use Dcp\Core\importXml::importXmlDirectory instead
100  * @return array
101  */
102 function importXmlDirectory($dbaccess, $splitdir, $opt)
103 {
104  $iXml = new \Dcp\Core\importXml();
105  $iXml->setPolicy($opt["policy"]);
106  $iXml->setImportDirectory($opt["dirid"]);
107  $iXml->analyzeOnly($opt["analyze"]);
108  return $iXml->importXmlDirectory($splitdir);
109 }
110 /**
111  * read a directory to extract all encoded files
112  * @param $splitdir
113  * @deprecated Dcp\Core\importXml::extractFilesFromXmlDirectory
114  * @return string
115  */
116 function extractFilesFromXmlDirectory($splitdir)
117 {
118  try {
120  }
121  catch(Exception $e) {
122  return $e->getMessage();
123  }
124  return "";
125 }
126 /**
127  * extract encoded base 64 file from xml and put it in local media directory
128  * the file is rewrite without encoded data and replace by href attribute
129  * @param $file
130  * @return string error message empty if no errors
131  * @deprecated use Dcp\Core\importXml::extractFileFromXmlDocument
132  */
134 {
135  try {
137  }
138  catch(Exception $e) {
139  return $e->getMessage();
140  }
141  return "";
142 }
143 /**
144  * @param $dbaccess
145  * @param $xmlfile
146  * @param $log
147  * @param $opt
148  * @sdeprecated use Dcp\Core\importXml::importXmlFileDocument
149  * @return string
150  */
151 function importXmlDocument($dbaccess, $xmlfile, &$log, $opt)
152 {
153  $iXml = new \Dcp\Core\importXml();
154  $iXml->setPolicy($opt["policy"]);
155  $iXml->setImportDirectory($opt["dirid"]);
156  $iXml->analyzeOnly($opt["analyze"]);
157  return $iXml->importXmlFileDocument($xmlfile, $log);
158 }
159 /**
160  * @param $zipfiles
161  * @param $splitdir
162  * @return string
163  * @deprecated use Dcp\Core\importXml::unZipXmlDocument
164  */
165 function splitZipXmlDocument($zipfiles, $splitdir)
166 {
167  $err = "";
168  $zipfiles = realpath($zipfiles);
169  $ll = exec(sprintf("cd %s && unzip %s", $splitdir, $zipfiles) , $out, $retval);
170  if ($retval != 0) $err = sprintf(_("export Xml : cannot unzip %s : %s") , $zipfiles, $ll);
171  return $err;
172 }
173 /**
174  * @param $xmlfiles
175  * @param $splitdir
176  * @return string
177  * @deprecated use Dcp\Core\importXml::splitXmlDocument
178  */
179 function splitXmlDocument($xmlfiles, $splitdir)
180 {
181  try {
182  return Dcp\Core\importXml::splitXmlDocument($xmlfiles, $splitdir);
183  }
184  catch(\Exception $e) {
185  return $e->getMessage();
186  }
187 }
188 /**
189  * @param $filename
190  * @deprecated use Dcp\Core\importXml::base64Decodefile instead
191  */
193 {
195 }
extractFilesFromXmlDirectory($splitdir)
global $action
static extractFileFromXmlDocument($file)
freedom_import_xmlzip(Action &$action, $filename="")
$filename
$file
importXmlDirectory($dbaccess, $splitdir, $opt)
importXmlDocument($dbaccess, $xmlfile, &$log, $opt)
splitXmlDocument($xmlfiles, $splitdir)
base64_decodefile($filename)
$log
Definition: wsh.php:33
static extractFilesFromXmlDirectory($splitdir)
freedom_import_xml(Action &$action, $filename="")
getHttpVars($name, $def="", $scope="all")
Definition: Lib.Http.php:124
extractFileFromXmlDocument($file)
static base64Decodefile($filename)
splitZipXmlDocument($zipfiles, $splitdir)
setMaxExecutionTimeTo($limit)
Definition: Lib.Common.php:121
$dbaccess
Definition: checkVault.php:17
if($file) if($subject==""&&$file) if($subject=="") $err
static splitXmlDocument($xmlfiles, $splitdir)
← centre documentaire © anakeen