19 include_once (
"FDL/import_file.php");
22 define(
"TAREXTRACT",
"/extract/");
23 define(
"TARTARS",
"/tars/");
27 $dtar =
$action->getParam(
"FREEDOM_UPLOADDIR");
33 $dtar =
$action->getParam(
"FREEDOM_UPLOADDIR");
53 global $importedFiles;
58 if ($handle = opendir(
$ldir)) {
60 while (
false !== (
$file = readdir($handle))) {
61 $absfile =
"$ldir/$file";
62 $absfile = str_replace(
"//",
"/",
"$ldir/$file");
64 if (is_file($absfile) && (
$file ==
"fdl.csv")) {
68 if ($lfamid > 0)
$famid = $lfamid;
69 if ($lfldid > 0) $dfldid = $lfldid;
73 if (!$defaultdoc)
$action->AddWarningMsg(sprintf(_(
"you cannot create this kind [%s] of document") ,
$famid));
74 if (($lfamid == 0) && (
$famid == 7)) {
76 $fimgattr = $defaultimg->GetFirstFileAttributes();
79 if (!$newdir)
$action->AddWarningMsg(sprintf(_(
"you cannot create this kind [%s] of folder") , $dfldid));
80 $ffileattr = $defaultdoc->GetFirstFileAttributes();
87 while (
false !== (
$file = readdir($handle))) {
89 $absfile = str_replace(
"//",
"/",
"$ldir/$file");
90 $level = substr_count($absfile,
"/");
91 $index =
"f$level/$nfile";
92 if (is_file($absfile)) {
94 if (!isset($importedFiles[$absfile])) {
98 "err" => ($defaultdoc) ?
"" : sprintf(_(
"you cannot create this kind [%s] of document") ,
$famid) ,
100 "foldername" =>
$ldir,
105 "anaclass" =>
"fileclass",
106 "familyid" => $ddoc->fromid,
113 $tr[$index][
"err"] =
$err;
115 if (($lfamid == 0) && (
$famid == 7) && (substr($vfid, 0, 5) ==
"image")) {
116 $ddoc = & $defaultimg;
117 $fattr = $fimgattr->id;
119 $ddoc = & $defaultdoc;
120 $fattr = $ffileattr->id;
122 $tr[$index][
"familyid"] = $ddoc->fromid;
123 $tr[$index][
"action"] = _(
"to be add");
126 $ddoc->setValue($fattr, $vfid);
129 $tr[$index][
"action"] = _(
"not added");
131 $ddoc->addComment(sprintf(
"create by import from archive %s", substr(basename(
$ldir) , 0, -2)));
132 $tr[$index][
"action"] = _(
"added");
133 $tr[$index][
"id"] = $ddoc->id;
137 $dir->AddFile($ddoc->id);
139 $tr[$index][
"title"] = $ddoc->getTitle();
140 $tr[$index][
"id"] = $ddoc->id;
141 $tr[$index][
"familyid"] = $ddoc->fromid;
142 $tr[$index][
"familyname"] = $ddoc->fromname;
148 }
else if (is_dir($absfile) && (
$file[0] !=
'.')) {
153 if ((!$onlycsv) || (!preg_match(
"/^[0-9]+-.*_D$/i",
$file))) {
155 "err" => ($newdir) ?
"" : sprintf(_(
"you cannot create this kind [%s] of folder") , $dfldid) ,
157 "foldername" =>
$ldir,
162 "anaclass" =>
"fldclass",
163 "familyid" => $newdir->fromid,
165 "action" => _(
"to be add")
169 $newdir->setTitle(
$file);
170 $err = $newdir->Add();
172 $tr[$index][
"action"] = _(
"not added");
174 $tr[$index][
"action"] = _(
"added");
176 $dir->AddFile($newdir->id);
182 $tr = array_merge($tr, $itr);
190 $err = sprintf(
"cannot open local directory %s",
$ldir);
200 $fcsv = fopen($fdlcsv,
"r");
202 $ldir = dirname($fdlcsv);
203 while ($data = fgetcsv($fcsv, 0,
";")) {
205 $level = substr_count(
$ldir,
"/");
206 $index =
"c$level/$nline";
222 if (is_numeric($data[1])) $orfromid = $data[1];
225 $tcolorder[$orfromid] =
getOrder($data);
226 $tr[$index][
"action"] = sprintf(_(
"new column order %s") , implode(
" - ", $tcolorder[$orfromid]));
230 if (is_numeric($data[1])) $orfromid = $data[1];
233 $tkeys[$orfromid] =
getOrder($data);
234 if (($tkeys[$orfromid][0] ==
"") || (count($tkeys[$orfromid]) == 0)) {
235 $tr[$index][
"err"] = sprintf(_(
"error in import keys : %s") , implode(
" - ", $tkeys[$orfromid]));
236 unset($tkeys[$orfromid]);
237 $tr[$index][
"action"] =
"ignored";
239 $tr[$index][
"action"] = sprintf(_(
"new import keys : %s") , implode(
" - ", $tkeys[$orfromid]));
244 if (is_numeric($data[1])) $fromid = $data[1];
246 if (isset($tkeys[$fromid])) $tk = $tkeys[$fromid];
251 if ($tr[$index][
"err"] ==
"") $nbdoc++;
252 if ($tr[$index][
"action"] !=
"") $tr[$index][
"action"] = _($tr[$index][
"action"]);
288 for ($i = 0; $i < strlen(
$s); $i++) {
289 if (isset($td[ord(
$s[$i]) ])) $s2[$i] = $td[ord(
$s[$i]) ];
300 $handle = opendir(
$ldir);
301 while (
false !== (
$file = readdir($handle))) {
302 if (
$file[0] !=
".") {
303 $afile =
"$ldir/$file";
305 if (is_file($afile)) {
307 }
else if (is_dir($afile)) {