17 include_once (
"FDL/Lib.Dir.php");
18 include_once (
"FDL/Lib.Util.php");
19 include_once (
"FDL/Class.DocAttr.php");
20 include_once (
"VAULT/Class.VaultFile.php");
21 include_once (
"FDL/import_file.php");
47 $wprof = (
$usage->addOptionalParameter(
"wprof",
"With profil", array(
51 $wfile = (
$usage->addOptionalParameter(
"wfile",
"With files", array(
55 $wident = (
$usage->addOptionalParameter(
"wident",
"With document numeric identifiers", array(
60 $fileEncoding =
$usage->addOptionalParameter(
"code",
"File encoding", array(
64 $profilType =
$usage->addOptionalParameter(
"wproftype",
"Profil option type", array(
65 \Dcp\ExportDocument::useAclAccountType,
66 \Dcp\ExportDocument::useAclDocumentType
67 ) , \Dcp\ExportDocument::useAclAccountType);
68 $wutf8 = ($fileEncoding !==
"iso8859-15");
70 $nopref = (
$usage->addOptionalParameter(
"wcolumn",
"if - export preferences are ignored") ==
"-");
71 $eformat =
$usage->addOptionalParameter(
"eformat",
"Export format", array(
78 $selection =
$usage->addOptionalParameter(
"selection",
"export selection object (JSON)");
79 $statusOnly = (
$usage->addHiddenParameter(
"statusOnly",
"Export progress status") !=
"");
80 $exportId =
$usage->addHiddenParameter(
"exportId",
"Export status id");
81 if (!$aflid && !$selection && !$statusOnly) {
82 $fldid =
$usage->addRequiredParameter(
"id",
"Folder identifier");
84 $fldid =
$usage->addOptionalParameter(
"id",
"Folder identifier", array() , $aflid);
87 $csvSeparator =
$usage->addOptionalParameter(
"csv-separator",
"character to delimiter fields - generaly a comma",
function ($values, $argName,
ApiUsage $apiusage)
90 return sprintf(
' use single character or "auto"');
92 if (!is_string($values)) {
93 return sprintf(
"must be a character [%s] ", print_r($values,
true));
95 if ($values !=
"auto") {
96 if (mb_strlen($values) > 1) {
97 return sprintf(
"must be a only one character [%s] ", $values);
99 if (mb_strlen($values) === 0) {
100 return sprintf(
"empty separator is not allowed [%s] ", $values);
107 $csvEnclosure =
$usage->addOptionalParameter(
"csv-enclosure",
"character to enclose fields - generaly double-quote",
function ($values, $argName,
ApiUsage $apiusage)
110 return sprintf(
' use single character or "auto"');
112 if (!is_string($values)) {
113 return sprintf(
"must be a character [%s] ", print_r($values,
true));
115 if ($values !=
"auto") {
116 if (mb_strlen($values) > 1) {
117 return sprintf(
"must be a only one character [%s] ", $values);
127 header(
'Content-Type: application/json');
128 $action->lay->noparse =
true;
129 $action->lay->template = json_encode($action->read($exportId));
134 $exportCollection->setExportStatusId($exportId);
135 $exportCollection->setOutputFormat($eformat);
136 $exportCollection->setExportProfil($wprof);
137 $exportCollection->setExportDocumentNumericIdentiers($wident);
138 $exportCollection->setUseUserColumnParameter(!$nopref);
139 $exportCollection->setOutputFileEncoding($wutf8 ? Dcp\ExportCollection::utf8Encoding : Dcp\ExportCollection::latinEncoding);
140 $exportCollection->setVerifyAttributeAccess(!$exportInvisibleVisibilities);
141 $exportCollection->setProfileAccountType($profilType);
143 if ((!
$fldid) && $selection) {
144 $selection = json_decode($selection);
145 include_once (
"DATA/Class.DocumentSelection.php");
146 include_once (
"FDL/Class.SearchDoc.php");
148 $ids = $os->getIdentificators();
149 $exportCollection->recordStatus(_(
"Retrieve documents from database"));
151 $s->setObjectReturn(
true);
152 $s->addFilter(getSqlCond($ids,
"id",
true));
153 $s->setOrder(
"fromid, id");
155 $fname =
"selection";
161 $fname = str_replace(array(
167 ) , $fld->getTitle());
169 $exportCollection->recordStatus(_(
"Retrieve documents from database"));
172 $s->setObjectReturn(
true);
173 $s->setOrder(
"fromid, id");
174 $s->useCollection($fld->initid);
178 $exportCollection->setDocumentlist(
$s->getDocumentList());
179 $exportCollection->setExportFiles($wfile);
183 if (!is_dir($outputPath)) {
186 $foutname = $outputPath .
"/fdl.zip";
188 $foutname = $outputPath;
191 $foutname = uniqid(
getTmpDir() .
"/exportfld");
194 if (file_exists($foutname)) {
195 $action->
exitError(sprintf(
"export is not allowed to override existing file %s") , $outputPath);
198 $exportCollection->setOutputFilePath($foutname);
205 $exportCollection->export();
206 if (is_file($foutname)) {
210 $fileMime =
"text/xml";
215 $fileMime =
"application/x-zip";
222 $fileMime =
"application/x-zip";
225 $fileMime =
"text/csv";
228 $exportCollection->recordStatus(_(
"Export done") ,
true);
234 catch(Dcp\Exception $e) {
248 $action->register($exportId, array(
262 if (!is_dir(
$dirname))
return false;
266 if (
$d = opendir($dcur)) {
267 while ($f = readdir(
$d)) {
268 if ($f ==
'.' || $f ==
'..')
continue;
269 $f = $dcur .
'/' . $f;
deleteContentDirectory($dirname)
exportfld(Action &$action, $aflid="0", $famid="", $outputPath="", $exportInvisibleVisibilities=false)
const xmlArchiveOutputFormat
const xmlFileOutputFormat
recordStatus(Action &$action, $exportId, $msg, $endStatus=false)
exitError($texterr, $exit=true, $code="")
Verify arguments for action function.
new_Doc($dbaccess, $id= '', $latest=false)
Http_DownloadFile($filename, $name, $mime_type= '', $inline=false, $cache=true, $deleteafter=false)
setMaxExecutionTimeTo($limit)
Verify arguments for wsh programs.