Core  3.2
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  * @package FDL
5 */
6 /**
7  * Import document from CSV file
8  *
9  * @author Anakeen
10  * @version $Id: generic_editimport.php,v 1.19 2008/08/14 09:59:14 eric Exp $
11  * @package FDL
12  * @subpackage
13  */
14 /**
15  */
16 
17 include_once ("FDL/Class.Dir.php");
18 include_once ("GENERIC/generic_util.php");
19 // -----------------------------------
21 {
22  // -----------------------------------
23  global $dbaccess;
24  $allcol = (GetHttpVars("allcol", "N") == "Y"); // special controlled view
25  $action->parent->AddJsRef($action->GetParam("CORE_JSURL") . "/subwindow.js");
26  $action->parent->AddJsRef($action->GetParam("CORE_JSURL") . "/selectbox.js");
27  $dbaccess = $action->dbaccess;
28  $homefld = new_Doc($dbaccess, getDefFld($action));
29 
30  $stree = array();
31  if ($homefld->id > 0) $stree = getChildCatg($homefld->id, 1, true, 4);
32 
33  reset($stree);
34 
35  $action->lay->SetBlockData("CATG", $stree);
36  $action->lay->Set("topdir", getDefFld($action));
37 
38  $famid = getDefFam($action);
39  // spec for csv file
40 
41  /*
42  * @var DocFam $doc
43  */
44  $doc = new_Doc($dbaccess, $famid);
45  $famid = $doc->id;
46  if ($doc->name != "") $famname = $doc->name;
47  else $famname = $doc->id;
48  if ($doc->ccvid > 0) {
49  // special controlled view
50 
51  /*
52  * @var CVDoc $cvdoc
53  */
54  $cvdoc = new_Doc($dbaccess, $doc->ccvid);
55  $cvid = $cvdoc->getRawValue("CV_IDCVIEW");
56  if ($cvid) {
57  $err = $cvdoc->control($cvid); // control special view
58  if ($err != "") $action->exitError($err);
59  $tview = $cvdoc->getView($cvid);
60  if (isset($tview["CV_MSKID"])) $doc->setMask($tview["CV_MSKID"]);
61  }
62  }
63 
64  $action->lay->Set("TITLE", $doc->title);
65 
66  $action->lay->Set("dtitle", sprintf(_("import <I>%s</I> documents from") , $doc->title));
67  if ($allcol) {
68  $lattr = $doc->GetNormalAttributes();
69  $action->lay->Set("dallcol", "");
70  $action->lay->Set("dnallcol", "none");
71  } else {
72  $lattr = $doc->GetImportAttributes();
73  $action->lay->Set("dallcol", "none");
74  $action->lay->Set("dnallcol", "");
75  }
76  $format = "DOC;" . $famname . ";0;" . getDefFld($action) . "; ";
77 
78  foreach ($lattr as $k => $attr) {
79  $format.= $attr->getLabel() . " ;";
80  }
81  $lattr = $doc->GetNormalAttributes();
82  $tkey = array();
83  foreach ($lattr as $k => $attr) {
84  if ($attr->visibility == "O") continue; // only valuated attribut
85  $tkey[] = array(
86  "idattr" => $attr->id,
87  "lattr" => $attr->getLabel()
88  );
89  }
90  if ($allcol) $lattr = $doc->GetNormalAttributes();
91  else $lattr = $doc->GetImportAttributes();
92  $tcol = array();
93  foreach ($lattr as $k => $attr) {
94  $tcol[] = array(
95  "idattr" => $attr->id,
96  "lattr" => $attr->getLabel()
97  );
98  }
99 
100  $action->lay->SetBlockData("AKEYS1", $tkey);
101  $action->lay->SetBlockData("AKEYS2", $tkey);
102  $action->lay->SetBlockData("COLUMNS", $tcol);
103  $action->lay->Set("format", $format);
104  $action->lay->Set("classid", $famid);
105  $action->lay->Set("classname", $famname);
106 }
global $action
getDefFld(Action &$action)
getDefFam(Action &$action)
generic_editimport(Action &$action)
Set($name, &$parent)
exitError($texterr, $exit=true, $code="")
getChildCatg($docid, $level, $notfldsearch=false, $maxlevel=2)
new_Doc($dbaccess, $id= '', $latest=false)
$dbaccess
Definition: checkVault.php:17
if($file) if($subject==""&&$file) if($subject=="") $err
← centre documentaire © anakeen