36 $dir = dirname($fileName);
37 $temp = tempnam(
$dir, basename($fileName) .
'.tmp');
38 if ($temp ===
false) {
39 return sprintf(_(
"Error creating temporary file in '%s'.") ,
$dir);
41 if (file_put_contents($temp, $content) ===
false) {
43 return sprintf(_(
"Error writing content to file '%s'.") , $temp);
47 return sprintf(_(
"Syntax error in file '%s': %s") , $temp, join(
"\n", $output));
49 if (rename($temp, $fileName) ===
false) {
51 return sprintf(_(
"Error renaming '%s' to '%s'.") , $temp, $fileName);
70 $phpAdoc = new \Layout(
"FDL/Layout/Class.Doc.xml", $action);
72 if (
$tdoc[
"classname"] ==
"") {
73 if (
$tdoc[
"fromid"] == 0) {
74 $tdoc[
"classname"] =
'\Dcp\Family\Document';
79 $tdoc[
"classname"] =
'\\' .
$tdoc[
"classname"];
81 if (
$tdoc[
"fromid"] > 0) {
83 if ($fromName ==
'') {
84 throw new \Dcp\Exception(
"FAM0601",
$tdoc[
"fromid"],
$tdoc[
"name"]);
86 $tdoc[
"fromname"] = $fromName;
88 $tdoc[
"fromname"] =
"Document";
90 $phpAdoc->Set(
"docid",
$tdoc[
"id"]);
91 $phpAdoc->Set(
"include",
"");
92 $phpAdoc->Set(
"GEN",
"");
93 if (
$tdoc[
"fromid"] == 0) {
94 $phpAdoc->Set(
"DocParent",
$tdoc[
"classname"]);
95 $phpAdoc->Set(
"AParent",
"ADoc");
96 $phpAdoc->Set(
"fromid",
"");
97 $phpAdoc->Set(
"pinit",
'\DocCtrl');
100 if ((!file_exists($parentFile)) || filesize($parentFile) == 0) {
101 throw new \Dcp\Exception(
"FAM0600", $parentFile,
$tdoc[
"name"]);
103 $phpAdoc->Set(
"fromid",
$tdoc[
"fromid"]);
104 if (
$tdoc[
"classname"] !=
"Doc" .
$tdoc[
"fromid"]) {
105 $phpAdoc->Set(
"DocParent",
$tdoc[
"classname"]);
106 $phpAdoc->Set(
"pinit",
$tdoc[
"classname"]);
107 $phpAdoc->Set(
"include",
"include_once(\"FDL$GEN/Class.Doc" .
$tdoc[
"fromid"] .
".php\");");
109 $phpAdoc->Set(
"GEN", $GEN);
111 $phpAdoc->Set(
"DocParent",
'\\Dcp\\Family\\' . ucwords(strtolower(
$tdoc[
"fromname"])));
113 $phpAdoc->Set(
"DocParent",
'\\Doc' .
$tdoc[
"fromid"]);
115 $phpAdoc->Set(
"FileClassParent",
'Doc' .
$tdoc[
"fromid"]);
116 if (strstr(
$tdoc[
"usefor"],
'W')) {
117 $phpAdoc->Set(
"pinit",
'\WDoc');
120 $phpAdoc->Set(
"pinit",
'\DocCtrl');
123 $phpAdoc->Set(
"AParent",
"ADoc" .
$tdoc[
"fromid"]);
125 $phpAdoc->Set(
"title",
$tdoc[
"title"]);
128 $query->order_by =
"ordered";
130 $docDbAttrs =
$query->Query();
132 $phpAdoc->Set(
"sattr",
"");
134 $phpAdoc->set(
"hasattr",
false);
150 foreach ($docDbAttrs as $k => $v) {
151 $table1[strtolower($v->id) ] = $v;
154 foreach (
$table1 as $k => $v) {
155 $type = trim(strtok($v->type,
"("));
157 $parentDoctitle =
"";
158 if (isset($pa[substr($v->id, 1) ]) && preg_match(
"/doctitle=([A-Za-z0-9_-]+)/", $pa[substr($v->id, 1) ][
"options"], $reg)) {
159 $parentDoctitle = $reg[1];
162 if ($v->usefor !==
'Q' && preg_match(
"/doctitle=([A-Za-z0-9_-]+)/", $v->options, $reg)) {
164 if ($doctitle === $parentDoctitle) {
167 if ($doctitle ==
"auto") {
168 $doctitle = $v->id .
"_title";
170 $doctitle = strtolower($doctitle);
171 if (!isset(
$table1[strtolower($doctitle) ])) {
172 $table1[$doctitle] = clone ($v);
173 $table1[$doctitle]->id = $doctitle;
174 $table1[$doctitle]->type =
"text";
175 $table1[$doctitle]->visibility =
"H";
176 $table1[$doctitle]->phpfile =
"";
178 $table1[$doctitle]->options =
"autotitle=yes|relativeOrder=" . $v->id;
179 $table1[$doctitle]->title =
"N";
180 $table1[$doctitle]->abstract =
"N";
181 $table1[$doctitle]->needed =
"N";
182 $table1[$doctitle]->usefor =
"A";
184 $table1[$doctitle]->phpconstraint =
"";
185 $table1[$doctitle]->labeltext = $v->labeltext .
' ' . _(
"(title)");
186 $table1[$doctitle]->ordered = $v->ordered + 1;
188 if (empty(
$table1[$doctitle]->phpfunc)) {
189 if (!preg_match(
"/docrev=(fixed|state)/", $v->options)) {
190 $table1[$doctitle]->phpfunc =
"::getLastTitle(" . $v->id .
",' )";
192 $table1[$doctitle]->phpfunc =
"::getTitle(" . $v->id .
",' )";
198 $pM = new \parseFamilyMethod();
200 foreach ($pa as $parentAttr) {
202 if (preg_match(
"/relativeOrder=([A-Za-z0-9_:-]+)/", $parentAttr[
"options"], $reg)) {
203 $previousOrder = strtolower($reg[1]);
205 if ($parentAttr[
"id"][0] !==
":") {
206 $allAttributes[$parentAttr[
"id"] .
"/" . $parentAttr[
"docid"]] = [
"id" => $parentAttr[
"id"],
"parent" => $parentAttr[
"frameid"],
"family" => $parentAttr[
"docid"],
"prev" => $previousOrder,
"numOrder" => intval($parentAttr[
"ordered"]) ];
207 if (!$previousOrder) {
209 $allAttributes[$parentAttr[
"id"] .
"/" .
$tdoc[
"id"]] = $allAttributes[$parentAttr[
"id"] .
"/" . $parentAttr[
"docid"]];
210 $allAttributes[$parentAttr[
"id"] .
"/" .
$tdoc[
"id"]][
"family"] =
$tdoc[
"id"];
213 if (is_numeric($parentAttr[
"ordered"])) {
214 $pattern = sprintf(
"/%s\\/([0-9]+)/", substr($parentAttr[
"id"], 1));
216 foreach ($allAttributes as $ka => $attrData) {
217 if (preg_match($pattern, $ka, $reg)) {
219 if ($parentAttr[
"frameid"]) {
220 $allAttributes[$ka][
"parent"] = $parentAttr[
"frameid"];
222 $allAttributes[$ka][
"numOrder"] = $parentAttr[
"ordered"];
229 foreach (
$table1 as $k => $v) {
231 if ($v->id[0] ===
':') {
232 if (!$v->ordered && !$v->frameid) {
235 $v = self::completeAttribute(
$dbaccess, $v);
236 if (is_numeric($v->ordered)) {
237 $pattern = sprintf(
"/%s\\/([0-9]+)/", $v->id);
238 foreach ($allAttributes as $ka => $attrData) {
239 if (preg_match($pattern, $ka, $reg)) {
241 $allAttributes[$ka][
"parent"] = $v->frameid;
243 $allAttributes[$ka][
"numOrder"] = $v->ordered;
250 if (preg_match(
"/relativeOrder=([A-Za-z0-9_:-]+)/", $v->options, $reg)) {
251 $previous = strtolower($reg[1]);
254 $allAttributes[$v->id .
"/" . $v->docid] = [
"id" => $v->id,
"parent" => $v->frameid,
"family" => $v->docid,
"prev" => $previous,
"numOrder" => intval($v->ordered) ];
256 if ($v->visibility ==
"F") {
259 elseif ($v->visibility ==
"M") {
262 if ($v->type ==
"integer") {
266 switch (strtolower($v->type)) {
268 if (substr($v->link, 0, 2) ==
"::") {
269 if (preg_match(
'/::([^\(]+)\(([^\)]*)\)/', $v->link, $reg)) {
270 $v->link =
"%S%app=FDL&action=FDL_METHOD&id=%I%&method=" . urlencode($v->link);
273 $tmenu[strtolower($v->id) ] = array(
274 "attrid" => strtolower($v->id) ,
275 "label" => str_replace(
"\"",
"\\\"", $v->labeltext) ,
276 "order" => intval($v->ordered) ,
277 "link" => str_replace(
"\"",
"\\\"", $v->link) ,
278 "visibility" => $v->visibility,
279 "options" => str_replace(
"\"",
"\\\"", $v->options) ,
280 "precond" => self::doubleslash($v->phpfunc)
286 $tfield[strtolower($v->id) ] = array(
287 "attrid" => strtolower($v->id) ,
288 "visibility" => $v->visibility,
289 "label" => str_replace(
"\"",
"\\\"", $v->labeltext) ,
290 "usefor" => $v->usefor,
292 "options" => str_replace(
"\"",
"\\\"", $v->options) ,
293 "frame" => ($v->frameid ==
"") ? \Adoc::HIDDENFIELD : strtolower($v->frameid)
298 $taction[strtolower($v->id) ] = array(
299 "attrid" => strtolower($v->id) ,
300 "visibility" => $v->visibility,
301 "label" => str_replace(
"\"",
"\\\"", $v->labeltext) ,
302 "order" => intval($v->ordered) ,
303 "options" => str_replace(
"\"",
"\\\"", $v->options) ,
304 "wapplication" => $v->phpfile,
305 "waction" => self::doubleslash($v->phpfunc) ,
306 "precond" => str_replace(
"\"",
"\\\"", $v->phpconstraint)
311 if (preg_match(
'/^\[([a-z=0-9]+)\](.*)/', $v->phpfunc, $reg)) {
312 $v->phpfunc = $reg[2];
313 $funcformat = $reg[1];
318 if (preg_match(
"/([a-z]+)\\([\"'](.*)[\"']\\)/i", $v->type, $reg)) {
321 if ($atype ==
"idoc") {
322 if (!is_numeric($aformat)) {
331 if (preg_match(
"/([a-z]+)list/i", $atype, $reg)) {
335 if (strpos($v->options,
"multiple=yes") !==
false) {
338 if (isset($tnormal[strtolower($v->frameid) ])) {
339 if (self::getTypeMain($tnormal[strtolower($v->frameid) ][
"type"]) ==
"array") {
344 if (($repeat ==
"false") && isset($pa[strtolower($v->frameid) ])) {
345 if (self::getTypeMain($pa[strtolower($v->frameid) ][
"type"]) ==
"array") {
352 $atype = strtolower(trim($atype));
354 if ((!$v->phpfile) && preg_match(
'/^(?:(?:[a-z_][a-z0-9_]*\\\\)*[a-z_][a-z0-9_]*)?::[a-z_][a-z0-9_]*\(/i', $v->phpfunc, $reg) && ($v->usefor !=
'Q')) {
356 $pM->parse($v->phpfunc);
357 $error = $pM->getError();
359 throw new \Dcp\Exception($error);
361 if (!$pM->outputString) {
364 $oAid = $pM->outputs[0];
367 "callmethod" => self::doubleslash($v->phpfunc) ,
372 $v->id = chop(strtolower($v->id));
374 if (!$v->phpconstraint) {
375 if (($atype ==
"integer") || ($atype ==
"int")) {
376 $v->phpconstraint = sprintf(
"::isInteger(%s)", $v->id);
377 } elseif (($atype ==
"money") || ($atype ==
"double")) {
378 $v->phpconstraint = sprintf(
"::isFloat(%s)", $v->id);
381 if ($atype ==
"account") {
382 if (!$v->phpfile && !$v->phpfunc) {
383 $v->phpfile =
'fdl.php';
384 $options = $v->options;
389 $options.= sprintf(
"family=%s", $aformat);
391 $v->phpfunc = sprintf(
'fdlGetAccounts(CT,15,"%s"):%s,CT', str_replace(
'"',
'\\"', $options) , $v->id);
394 $tnormal[($v->id) ] = array(
395 "attrid" => ($v->id) ,
396 "label" => str_replace(
"\"",
"\\\"", $v->labeltext) ,
398 "format" => str_replace(
"\"",
"\\\"", $aformat) ,
399 "eformat" => str_replace(
"\"",
"\\\"", $funcformat) ,
400 "options" => self::doubleslash($v->options) ,
402 "order" => intval($v->ordered) ,
403 "link" => str_replace(
"\"",
"\\\"", $v->link) ,
404 "visibility" => $v->visibility,
405 "needed" => ($v->needed ==
"Y") ?
"true" :
"false",
406 "title" => ($v->title ==
"Y") ?
"true" :
"false",
408 "abstract" => ($v->abstract ==
"Y") ?
"true" :
"false",
409 "frame" => ($v->frameid ==
"") ? \Adoc::HIDDENFIELD : strtolower($v->frameid) ,
410 "elink" => $v->elink,
411 "phpfile" => $v->phpfile,
412 "phpfunc" => self::doubleslash(str_replace(
", |",
", |", $v->phpfunc)) ,
413 "phpconstraint" => str_replace(
"\"",
"\\\"", $v->phpconstraint) ,
414 "usefor" => $v->usefor
417 if (($atype !=
"array") && ($v->usefor !=
"Q")) {
418 if ($atype !=
"array") {
419 $tattr[$v->id] = array(
423 if ($repeat ==
"true") {
424 $attrids[$v->id] = ($v->id) .
" text";
431 $attrids[$v->id] = ($v->id) .
" float8";
436 $attrids[$v->id] = ($v->id) .
" int4";
440 $attrids[$v->id] = ($v->id) .
" date";
444 $attrids[$v->id] = ($v->id) .
" timestamp without time zone";
448 $attrids[$v->id] = ($v->id) .
" time";
452 $attrids[$v->id] = ($v->id) .
" text";
459 FamilyAbsoluteOrder::completeForNumericOrder($allAttributes,
$tdoc[
"id"]);
461 $absoluteOrders = FamilyAbsoluteOrder::getAbsoluteOrders($allAttributes,
$tdoc[
"id"]);
463 foreach ($absoluteOrders as $kOrder => $attrid) {
464 $tAbsOrders[] = sprintf(
'"%s"=>%d', $attrid, ($kOrder + 1) * 10);
466 $phpAdoc->Set(
"sattr", implode(
",", $attrids));
467 $phpAdoc->Set(
"sAbsoluteOrders", implode(
",", $tAbsOrders));
468 $phpAdoc->SetBlockData(
"MATTR", $tmenu);
469 $phpAdoc->SetBlockData(
"FATTR", $tfield);
470 $phpAdoc->SetBlockData(
"AATTR", $taction);
471 $phpAdoc->SetBlockData(
"NATTR", $tnormal);
472 $phpAdoc->SetBlockData(
"ATTRFIELD", $tattr);
474 $phpAdoc->set(
"hasattr", (count($tattr) > 0));
475 $phpAdoc->SetBlockData(
"ACALC", $tcattr);
477 $phpAdoc->Set(
"sAbsoluteOrders",
"");
480 $phpAdoc->Set(
"STARMETHOD",
false);
481 if (
$tdoc[
"name"] ==
'') {
484 if (
$tdoc[
"name"] !=
"") {
485 $phpAdoc->SetBlockData(
"CLASSALIAS", array(
490 $phpAdoc->Set(
"docName",
$tdoc[
"name"]);
491 $phpAdoc->Set(
"PHPclassName", sprintf(
'%s', str_replace(array(
494 ) ,
"_", ucwords(strtolower(
$tdoc[
"name"])))));
496 $phpAdoc->Set(
"docTitle", str_replace(
'"',
'\\"',
$tdoc[
"title"]));
497 $phpAdoc->set(
"HOOKALIAS",
"");
504 if (isset(
$tdoc[
"methods"]) && (
$tdoc[
"methods"] !=
"")) {
505 $tfmethods = explode(
"\n",
$tdoc[
"methods"]);
506 foreach ($tfmethods as $fmethods) {
507 if ($fmethods[0] ==
"*") {
508 $cmethod = substr($fmethods, 1);
510 $contents2 = self::getMethodFileInnerContents(
$filename);
512 if (strlen(trim($contents2)) <= 0) {
518 $innerContents = self::getMethodFileInnerContents(
$filename);
520 if (strlen(trim($innerContents)) > 0) {
521 $contents.= $innerContents;
528 $dm = new \deprecatedHookManager();
529 $dm->inspectContent(
"<?php\n" . $contents .
"\n?>");
530 $phpAdoc->set(
"HOOKALIAS", $dm->generateCompatibleMethods());
531 $phpAdoc->Set(
"METHODS", $contents);
532 $phpMethodName = sprintf(
"_Method_%s",
$tdoc[
"name"]);
533 $phpAdoc->set(
"PHPmethodName", $phpMethodName);
534 $phpAdoc->set(
"ClassDocParent", $phpAdoc->Get(
"DocParent"));
535 $phpAdoc->set(
"DocParent",
'\\' . $phpMethodName);
537 $phpAdoc->Set(
"METHODS",
"");
540 if ($cmethod !=
"") {
541 $phpAdoc->Set(
"METHODS2", $contents2);
542 $phpAdoc->Set(
"STARMETHOD",
true);
543 $phpAdoc->Set(
"docNameIndirect",
'_SMethod_Doc' .
$tdoc[
"id"] .
"__");
546 $phpAdoc->Set(
"RedirectDocParent", $phpAdoc->Get(
"ClassDocParent"));
547 $phpAdoc->Set(
"ClassDocParent",
'\\' . $phpAdoc->Get(
"docNameIndirect"));
549 $phpAdoc->Set(
"RedirectDocParent", $phpAdoc->Get(
"DocParent"));
550 $phpAdoc->Set(
"DocParent",
'\\' . $phpAdoc->Get(
"docNameIndirect"));
553 return $phpAdoc->gen();
558 $phpAdoc = new \Layout(
"FDL/Layout/Class.Attrid.xml");
560 if (
$tdoc[
"fromid"] == 0) {
561 $phpAdoc->Set(
"extend",
'');
564 if ($fromName ==
'') {
565 throw new \Dcp\Exception(
"FAM0602",
$tdoc[
"fromid"],
$tdoc[
"name"]);
567 $phpAdoc->Set(
"extend", ucwords(strtolower(str_replace(array(
570 ) ,
"_", $fromName))));
573 $phpAdoc->Set(
"fromid",
$tdoc[
"fromid"]);
574 $phpAdoc->Set(
"title",
$tdoc[
"title"]);
575 $phpAdoc->Set(
"className", ucfirst(strtolower(str_replace(array(
578 ) ,
"_",
$tdoc[
"name"]))));
581 $query->AddQuery(sprintf(
"docid=%d",
$tdoc[
"id"]));
582 $query->AddQuery(sprintf(
"id !~ ':'"));
583 $query->order_by =
"ordered";
584 $attrs =
$query->Query(0, 0,
"TABLE");
588 foreach ($attrs as $attr) {
589 $const[$attr[
"id"]] = array(
590 "attrid" => $attr[
"id"],
591 "type" => $attr[
"type"],
592 "label" => $attr[
"labeltext"],
593 "famName" =>
$tdoc[
"name"]
597 $phpAdoc->SetBlockData(
"CONST", $const);
600 return $phpAdoc->gen();
605 $s = str_replace(
'\\',
'\\\\',
$s);
606 $s = str_replace(
'"',
'\\"',
$s);
610 protected static function pgUpdateFamily(
$dbaccess,
$docid, $docname =
"")
612 $docname = strtolower($docname);
615 if (!self::tableExists(
$dbaccess,
"public",
"doc$docid")) {
616 $msg.= sprintf(
"Create table 'doc%d'\n",
$docid);
619 if (self::tableExists(
$dbaccess,
"public",
"doc$docid")) {
623 $msg.= sprintf(
"Could not create table 'doc%d'.\n",
$docid);
627 $pgatt = self::getTableColumns(
$dbaccess,
"public",
"doc$docid");
630 $qattr = new \QueryDb(
$dbaccess,
"DocAttr");
631 $qattr->AddQuery(
"docid=" .
$docid);
632 $qattr->AddQuery(
"type != 'menu'");
633 $qattr->AddQuery(
"type != 'frame'");
634 $qattr->AddQuery(
"type != 'tab'");
635 $qattr->AddQuery(
"type != 'action'");
636 $qattr->AddQuery(
"id !~ '^:'");
638 $qattr->AddQuery(
"visibility != 'M'");
639 $qattr->AddQuery(
"visibility != 'F'");
640 $qattr->AddQuery(
"usefor != 'Q' or usefor is null");
642 $oattr = $qattr->Query();
647 if ($qattr->nb > 0) {
651 foreach ($oattr as $ka => $attr) {
652 $tattr[strtolower($attr->id) ] = $attr;
653 if ($attr->type ==
'file') {
654 $tattr[strtolower($attr->id) .
'_txt'] = $attr;
655 $tattr[strtolower($attr->id) .
'_vec'] = clone ($attr);
656 $tattr[strtolower($attr->id) .
'_vec']->type =
'tsvector';
658 $type = trim(strtok($attr->type,
"("));
659 if (
$type ===
"docid" ||
$type ===
"account" ||
$type ===
"thesaurus") {
660 if ($attr->usefor !==
"Q" && preg_match(
"/doctitle=([A-Za-z0-9_-]+)/", $attr->options, $reg)) {
662 if ($doctitle ==
"auto") {
663 $doctitle = $attr->id .
"_title";
665 $doctitle = strtolower($doctitle);
666 $tattr[$doctitle] = $attr;
667 $tattr[$doctitle]->id = $doctitle;
668 $tattr[$doctitle]->type =
"text";
675 foreach ($tattr as $ka => $attr) {
676 $attr->id = chop($attr->id);
677 if (substr($attr->type, 0, 5) ==
"array") {
680 if ($attr->docid ==
$docid) {
681 if (!in_array($ka, $pgatt)) {
682 $msg.=
"add field $ka in table doc" .
$docid .
"\n";
683 $repeat = (strpos($attr->options,
"multiple=yes") !==
false);
685 $repeat = (isset($tattr[$attr->frameid]) && $tattr[$attr->frameid]->type ==
"array");
687 if (($repeat && ($attr->type !=
'tsvector'))) {
692 $rtype = strtok($attr->type,
"(");
697 $sqltype =
" float8";
710 $sqltype =
" timestamp without time zone";
718 $sqltype =
" tsvector";
725 self::alterTableAddColumn(
$dbaccess,
"public",
"doc$docid", $ka, $sqltype);
740 simpleQuery(
$dbaccess, sprintf(
"SELECT 'true' FROM information_schema.tables WHERE table_schema = %s AND table_name = %s", pg_escape_literal($schemaName) , pg_escape_literal($tableName)) , $res,
true,
true,
true);
741 return ($res ==
'true');
746 simpleQuery(
$dbaccess, sprintf(
"SELECT 'true' FROM information_schema.views WHERE table_schema = %s AND table_name = %s", pg_escape_literal($schemaName) , pg_escape_literal($viewName)) , $res,
true,
true,
true);
747 return ($res ==
'true');
754 $triggers = $cdoc->sqltrigger(
false,
true);
755 $cdoc->exec_query($triggers, 1);
763 simpleQuery(
$dbaccess, sprintf(
"SELECT refreshFamilySchemaViews(%s, %s)", pg_escape_literal($docname) , pg_escape_literal(intval(
$docid))) , $res,
true,
true,
true);
768 simpleQuery(
$dbaccess, sprintf(
"SELECT column_name FROM information_schema.columns WHERE table_schema = %s AND table_name = %s", pg_escape_literal($schemaName) , pg_escape_literal($tableName)) , $res,
true,
false,
true);
774 simpleQuery(
$dbaccess, sprintf(
"ALTER TABLE %s.%s ADD COLUMN %s %s", pg_escape_identifier($schemaName) , pg_escape_identifier($tableName) , pg_escape_identifier($columnName) , $columnType) , $res,
true,
true,
true);
781 $dfile =
"$pubdir/FDL$GEN/Class.Doc" .
$tdoc[
"id"] .
".php";
783 $err = self::__phpLintWriteFile($dfile, self::generateFamilyPhpClass(
$dbaccess,
$tdoc));
785 throw new \Dcp\Exception(sprintf(
"Error generating file '%s': %s", $dfile,
$err));
788 $attrfile =
"$pubdir/FDL$GEN/Class.Attrid" .
$tdoc[
"id"] .
".php";
792 throw new \Dcp\Exception(sprintf(
"Error generating file '%s': %s", $attrfile,
$err));
801 $cdoc->exec_query($cdoc->sqltrigger(
false,
true) , 1);
802 $sqlcmds = explode(
";", $cdoc->SqlTrigger());
805 foreach ($sqlcmds as $k => $sqlquery) {
806 if ($sqlquery !=
"") {
807 $cdoc->exec_query($sqlquery, 1);
815 $indexes = $cdoc->GetSqlIndex();
818 foreach ($indexes as $sqlIndex) {
819 $msg.= $cdoc->exec_query($sqlIndex);
836 $query->AddQuery(
"doctype='C'");
837 $query->AddQuery(
"id=$docid");
841 $err = self::buildFamilyFilesAndTables(
$dbaccess, $v,
false);
851 $savepointed =
false;
853 if ((
$err =
$doc->setMasterLock(
true)) !==
'') {
854 throw new \Dcp\Core\Exception(
$err);
857 if ((
$err =
$doc->savePoint(__METHOD__)) !==
'') {
858 throw new \Dcp\Core\Exception(
$err);
862 $phpfile = self::createDocFile(
$dbaccess, $familyData);
864 print "$phpfile [" . $familyData[
"title"] .
"(" . $familyData[
"name"] .
")]\n";
866 $msg = self::pgUpdateFamily(
$dbaccess, $familyData[
"id"], $familyData[
"name"]);
873 self::resetSystemEnum($familyData[
"id"]);
875 if ((
$err =
$doc->commitPoint(__METHOD__)) !==
'') {
876 throw new \Dcp\Core\Exception(
$err);
878 $savepointed =
false;
879 if ((
$err =
$doc->setMasterLock(
false)) !==
'') {
880 throw new \Dcp\Core\Exception(
$err);
885 $doc->rollbackPoint(__METHOD__);
888 $doc->setMasterLock(
false);
890 return $e->getMessage();
901 $sql = sprintf(
"select * from docattr where docid=%d and type = 'enum' and (phpfile is null or phpfile='-') and options ~ 'system=yes'",
$famid);
903 foreach ($results as $attr) {
904 $attrid = $attr[
"id"];
919 $ta->id = substr($ta->id, 1);
921 $tfromid[] = $fromid;
923 $tfromid[] = $fromid;
925 $tfromid[] = $ta->docid;
928 $query->AddQuery(
"id='" . pg_escape_string($ta->id) .
"'");
929 $query->order_by =
"docid";
930 $tas =
$query->Query(0, 0,
"TABLE");
933 error_log(
"MODATTR error for " . $ta->id);
938 foreach ($tas as $ta1) {
939 if (preg_match(
"/(.*)relativeOrder=([A-Za-z0-9_:-]+)(.*)/", $ta->options, $attrReg)) {
940 if (preg_match(
"/(.*)relativeOrder=([A-Za-z0-9_:-]+)(.*)/", $ta1[
"options"], $parentReg)) {
942 if (($parentReg[1] || $parentReg[3]) && (!$attrReg[1] && !$attrReg[3])) {
944 $tw->options = sprintf(
"%srelativeOrder=%s%s", $parentReg[1], $attrReg[2], $parentReg[3]);
949 foreach ($ta1 as $k => $v) {
950 if ($v && (!$ta->$k)) {
953 if ($ta->$k ==
"-") {
976 $query->AddQuery(sprintf(
"docid=%d", $fromid));
978 $pa =
$query->Query(0, 0,
"TABLE");
984 if ($nextfromid > 0) {
985 $pa = array_merge(self::getParentAttributes(
$dbaccess, $nextfromid) , $pa);
988 foreach ($pa as $v) {
990 if (preg_match(
'/\bdoctitle=(?P<attrid>[A-Za-z0-9_-]+)\b/', $v[
"options"], $m)) {
992 if ($m[
'attrid'] ==
'auto') {
993 $vtitle[
"id"] = $v[
"id"] .
"_title";
995 $vtitle[
"id"] = strtolower($m[
'attrid']);
997 $vtitle[
"type"] =
"text";
998 $vtitle[
"options"] =
"";
999 $paf[$vtitle[
"id"]] = $vtitle;
1016 if (preg_match(
'/^\s*(?P<type>[a-z]+)(?P<format>\(.+\))?\s*$/i',
$type, $m)) {
1018 if (empty($m[
'format'])) {
1021 $m[
'format'] = substr($m[
'format'], 1, -1);
1023 'type' => $m[
'type'],
1024 'format' => $m[
'format']
1042 return $p[
'format'];
1054 $contents = file_get_contents(
$filename);
1055 if ($contents ===
false) {
1058 $contents = preg_replace(
'%(?: //[^\n]*\@begin-method-ignore| /\*+[^/]*?\@begin-method-ignore)(.*?)(?: //[^\n]*\@end-method-ignore[^\n]*| /\*+[^/]*?\@end-method-ignore[^/]*?\*/)%xms',
'', $contents);
1059 $contents = str_replace(array(
1064 return (
string)$contents;
static getTypeFormat($type)
Exception class use exceptionCode to identifiy correctly exception.
static getTableColumns($dbaccess, $schemaName, $tableName)
static viewExists($dbaccess, $schemaName, $viewName)
static setSqlIndex($dbaccess, $docid)
static createFamilyTable($dbaccess, $docid)
static tableExists($dbaccess, $schemaName, $tableName)
static AttrIdToPhp($dbaccess, $tdoc)
static getParentAttributes($dbaccess, $fromid)
static recordEnum($famid, $attrid, $phpfunc, $reset=false)
static createDocFile($dbaccess, $tdoc)
static phpLintFile($fileName, &$output)
static __phpLintWriteFile($fileName, $content)
static recreateFamilyView($dbaccess, $docname, $docid)
static alterTableAddColumn($dbaccess, $schemaName, $tableName, $columnName, $columnType)
getFamIdFromName($dbaccess, $name)
static getTypeMain($type)
new_Doc($dbaccess, $id= '', $latest=false)
GetSqlCond($Table, $column, $integer=false)
getFamFromId($dbaccess, $id)
getNameFromId($dbaccess, $id)
static completeAttribute($dbaccess, $ta)
static buildFamilyFilesAndTables($dbaccess, $familyData, $interactive=false)
static getMethodFileInnerContents($filename)
if(($docid!==0)&&(!is_numeric($docid))) $query
simpleQuery($dbaccess, $query, &$result=array(), $singlecolumn=false, $singleresult=false, $useStrict=null)
createTmpDoc($dbaccess, $fromid, $defaultvalue=true)
static refreshPhpPgDoc($dbaccess, $docid)
if($file) if($subject==""&&$file) if($subject=="") $err
activateTrigger($dbaccess, $docid)
static resetSystemEnum($famid)
static activateTrigger($dbaccess, $docid)