Core  3.2
PHP API documentation
 All Data Structures Namespaces Files Functions Variables Pages
generateDocumentClass.php
Go to the documentation of this file.
1 <?php
2 /*
3  * @author Anakeen
4  * @package FDL
5 */
6 /**
7  * Generate Php Document Classes
8  *
9  * @subpackage
10  */
11 /**
12  */
13 // refreah for a classname
14 // use this only if you have changed title attributes
15 include_once ("FDL/Lib.Attr.php");
16 include_once ("FDL/Class.DocFam.php");
17 
19 $appl->Set("FDL", $core);
20 
21 $dbaccess = $appl->dbaccess;
22 if ($dbaccess == "") {
23  print "Database not found : appl->dbaccess";
24  exit;
25 }
26 $usage = new ApiUsage();
27 $usage->setDefinitionText("Generate Php Document Classes");
28 $docid = $usage->addOptionalParameter("docid", "special docid", null, 0);
29 $usage->verify();
30 
31 if (($docid !== 0) && (!is_numeric($docid))) {
32  $odocid = $docid;
34  if (!$docid) {
35  print sprintf(_("family %s not found") . "\n", $odocid);
36  exit(1);
37  }
38 }
39 
40 $query = new QueryDb($dbaccess, "DocFam");
41 $query->AddQuery("doctype='C'");
42 $query->order_by = "id";
43 
44 ini_set("memory_limit", -1);
45 
46 if ($docid > 0) {
47  $query->AddQuery("id=$docid");
48  $tid = $query->Query(0, 0, "TABLE");
49 } else {
50  // sort id by dependance
51  $table1 = $query->Query(0, 0, "TABLE");
52  $tid = array();
53  pushfam(0, $tid, $table1);
54 }
55 if ($query->nb > 0) {
57  if ($query->nb > 1) {
58  $tii = array(
59  1,
60  2,
61  3,
62  4,
63  5,
64  6,
65  20,
66  21
67  );
68  foreach ($tii as $ii) {
69  updateDoc($dbaccess, $tid[$ii]);
70  unset($tid[$ii]);
71  }
72  }
73  // workflow at the end
74  foreach ($tid as $k => $v) {
75  if (strstr($v["usefor"], 'W')) {
76  updateDoc($dbaccess, $v);
77  /*
78  * @var WDOc $wdoc
79  */
80  $wdoc = createDoc($dbaccess, $v["id"]);
81  $wdoc->CreateProfileAttribute(); // add special attribute for workflow
83  }
84  }
85  foreach ($tid as $k => $v) {
86  if (strstr($v["usefor"], 'W') === false) {
87  updateDoc($dbaccess, $v);
88  }
89  }
90 }
91 function updateDoc($dbaccess, $v)
92 {
93  require_once 'FDL/Lib.Attr.php';
94  try {
96  if ($err) {
97  error_log($err);
98  }
99  }
100  catch(\Dcp\Exception $e) {
101  print $v["id"] . "[" . $v["title"] . "(" . $v["name"] . ")]\n";
102  error_log($e->getMessage());
103  }
104 }
105 // recursive sort by fromid
106 function pushfam($fromid, &$tid, $tfam)
107 {
108 
109  foreach ($tfam as $k => $v) {
110 
111  if ($v["fromid"] == $fromid) {
112  $tid[$v["id"]] = $v;
113 
114  pushfam($v["id"], $tid, $tfam);
115  }
116  }
117 }
global $pubdir
Definition: vault_init.php:18
if($query->nb > 0) updateDoc($dbaccess, $v)
const DEFAULT_PUBDIR
Definition: Lib.Prefix.php:28
createDoc($dbaccess, $fromid, $control=true, $defaultvalues=true, $temporary=false)
if($dbaccess=="") $usage
getFamIdFromName($dbaccess, $name)
print
Definition: checklist.php:49
switch($command) exit
Definition: checkVault.php:46
pushfam($fromid, &$tid, $tfam)
static buildFamilyFilesAndTables($dbaccess, $familyData, $interactive=false)
if(($docid!==0)&&(!is_numeric($docid))) $query
if($file) if($subject==""&&$file) if($subject=="") $err
Verify arguments for wsh programs.
$core
Definition: chgpasswd.php:33
static activateTrigger($dbaccess, $docid)
← centre documentaire © anakeen