Platform  3.1
PHP API documentation
 All Data Structures Namespaces Files Functions Variables Pages
generic_editimport.php
Go to the documentation of this file.
1 <?php
2 /*
3  * @author Anakeen
4  * @license http://creativecommons.org/licenses/by-nc-sa/2.0/fr/ Anakeen - licence CC
5  * @package FDL
6 */
7 /**
8  * Import document from CSV file
9  *
10  * @author Anakeen 2004
11  * @version $Id: generic_editimport.php,v 1.19 2008/08/14 09:59:14 eric Exp $
12  * @license http://creativecommons.org/licenses/by-nc-sa/2.0/fr/ Anakeen - licence CC
13  * @package FDL
14  * @subpackage
15  */
16 /**
17  */
18 
19 include_once ("FDL/Class.Dir.php");
20 include_once ("GENERIC/generic_util.php");
21 // -----------------------------------
23 {
24  // -----------------------------------
25  global $dbaccess;
26  $allcol = (GetHttpVars("allcol", "N") == "Y"); // special controlled view
27  $action->parent->AddJsRef($action->GetParam("CORE_JSURL") . "/subwindow.js");
28  $action->parent->AddJsRef($action->GetParam("CORE_JSURL") . "/selectbox.js");
29  $dbaccess = $action->GetParam("FREEDOM_DB");
30  $homefld = new_Doc($dbaccess, getDefFld($action));
31 
32  $stree = array();
33  if ($homefld->id > 0) $stree = getChildCatg($homefld->id, 1, true, 4);
34 
35  reset($stree);
36 
37  $action->lay->SetBlockData("CATG", $stree);
38  $action->lay->Set("topdir", getDefFld($action));
39 
41  // spec for csv file
42  $doc = new_Doc($dbaccess, $famid);
43  $famid = $doc->id;
44  if ($doc->name != "") $famname = $doc->name;
45  else $famname = $doc->id;
46  if ($doc->ccvid > 0) {
47  // special controlled view
48  $cvdoc = new_Doc($dbaccess, $doc->ccvid);
49  $cvid = $cvdoc->getValue("CV_IDCVIEW");
50  if ($cvid) {
51  $err = $cvdoc->control($cvid); // control special view
52  if ($err != "") $action->exitError($err);
53  $tview = $cvdoc->getView($cvid);
54  if (isset($tview["CV_MSKID"])) $doc->setMask($tview["CV_MSKID"]);
55  }
56  }
57 
58  $action->lay->Set("TITLE", $doc->title);
59 
60  $action->lay->Set("dtitle", sprintf(_("import <I>%s</I> documents from") , $doc->title));
61  if ($allcol) {
62  $lattr = $doc->GetNormalAttributes();
63  $action->lay->Set("dallcol", "");
64  $action->lay->Set("dnallcol", "none");
65  } else {
66  $lattr = $doc->GetImportAttributes();
67  $action->lay->Set("dallcol", "none");
68  $action->lay->Set("dnallcol", "");
69  }
70  $format = "DOC;" . $famname . ";0;" . getDefFld($action) . "; ";
71 
72  foreach ($lattr as $k => $attr) {
73  $format.= $attr->getLabel() . " ;";
74  }
75  $lattr = $doc->GetNormalAttributes();
76  foreach ($lattr as $k => $attr) {
77  if ($attr->visibility == "O") continue; // only valuated attribut
78  $tkey[] = array(
79  "idattr" => $attr->id,
80  "lattr" => $attr->getLabel()
81  );
82  }
83  if ($allcol) $lattr = $doc->GetNormalAttributes();
84  else $lattr = $doc->GetImportAttributes();
85  foreach ($lattr as $k => $attr) {
86  $tcol[] = array(
87  "idattr" => $attr->id,
88  "lattr" => $attr->getLabel()
89  );
90  }
91 
92  $action->lay->SetBlockData("AKEYS1", $tkey);
93  $action->lay->SetBlockData("AKEYS2", $tkey);
94  $action->lay->SetBlockData("COLUMNS", $tcol);
95  $action->lay->Set("format", $format);
96  $action->lay->Set("classid", $famid);
97  $action->lay->Set("classname", $famname);
98 }
99 ?>
← centre documentaire © anakeen - published under CC License - Dynacase