15 include_once (
'FDL/Class.PFam.php');
26 create table docfam (cprofid int ,
39 configuration text) inherits (doc);
40 create unique index idx_idfam on docfam(id);";
78 private $_configuration;
81 private $defaultSortProperties = array(
105 private $FDLGEN_HasBeenLoaded =
false;
110 foreach ($this->addfields as $f) $this->fields[$f] = $f;
113 $this->doctype =
'C';
114 if ($include && ($this->
id > 0) && ($this->
isAffected())) {
117 if (include_once (
"FDL$GEN/Class.$adoc.php")) {
119 $this->attributes =
new $adoc();
120 $this->attributes->orderAttributes();
122 throw new Dcp\Exception(sprintf(
"cannot access attribute definition for %s (#%s) family", $this->
name, $this->
id));
124 $this->FDLGEN_HasBeenLoaded =
true;
130 $this->_xtdefval = null;
131 $this->_xtparam = null;
136 return _(
"cannot delete family");
145 $r = $this->
name .
'#title';
147 if ($i !=
$r)
return $i;
155 if ($i !=
$r)
return $i;
161 include_once (
"FDL/Lib.Attr.php");
168 if ($cdoc->isAlive()) {
169 if (!$this->ccvid) $this->ccvid = $cdoc->ccvid;
170 if (!$this->cprofid) $this->cprofid = $cdoc->cprofid;
171 if (!$this->defval) $this->defval = $cdoc->defval;
172 if (!$this->schar) $this->schar = $cdoc->schar;
173 if (!$this->usefor) $this->usefor = $cdoc->usefor;
174 if (!$this->tagable) $this->tagable = $cdoc->tagable;
185 if (strstr($this->usefor,
'W')) {
190 if (is_a($w,
"WDoc")) {
194 $err = $w->createProfileAttribute($this->
id);
198 $err =
"workflow need class";
211 $target =
"_self", $ulink =
true, $abstract =
false)
213 $d =
createDoc($this->dbaccess, $this->
id,
false,
true,
false);
215 $ownDefValues = $this->explodeX($this->defval);
216 $ownParValues = $this->explodeX($this->param);
217 $tDefVal = $tDefPar = array();
221 foreach ($tp as $aid => & $oa) {
222 if ($oa->type ==
"array")
continue;
223 $tDefPar[$aid] = array(
225 "alabel" => $oa->getLabel() ,
226 "defown" => isset($pPowns[$aid]) ? $pPowns[$aid] : null,
232 if ($this->fromid > 0) {
235 foreach ($defValues as $aid => $dv) {
236 $oa =
$d->getAttribute($aid);
238 $ownValue = isset($ownDefValues[$aid]) ? $ownDefValues[$aid] : null;
241 $oa->setVisibility(
'R');
242 $label = $oa->getLabel();
243 if ($oa->usefor ==
'Q') {
244 $value =
$d->getFamilyParameterValue($aid);
245 if (!empty($ownParValues[$aid])) {
246 $ownValue = $ownParValues[$aid];
248 if ($ownValue) $ownValue.=
' <em>(' . _(
"default value") .
")</em>";
256 if ($oa->usefor ==
'Q') {
258 $inhValue =
$parent->getParameterRawValue($aid);
260 $inhValue =
$parent->getDefValue($aid);
266 "defown" => $ownValue,
267 "definh" => $inhValue,
270 if ($oa && $oa->usefor ==
'Q') {
277 $this->lay->set(
"hasAncestor", $this->fromid > 0);
278 $this->lay->set(
"docid", $this->
id);
279 $this->lay->SetBlockData(
"DEFVAL", $tDefVal);
280 $this->lay->SetBlockData(
"DEFPAR", $tDefPar);
281 $this->lay->Set(
"NOVAL", count($tDefVal) == 0);
282 $this->lay->Set(
"NOPAR", count($tDefPar) == 0);
283 $this->lay->Set(
"canEdit", $this->
canEdit() ==
"");
293 $target =
"_self", $ulink =
true, $abstract =
false)
300 simpleQuery($this->dbaccess,
"SELECT count(*) FROM docperm WHERE docid=" . $this->
id, $nb_acl,
true,
true);
301 $this->lay->set(
"hasAcl", ($nb_acl !=
"0"));
303 $this->lay->set(
"modifyacl", ($this->
control(
"modifyacl") ==
""));
304 $this->lay->set(
"canInitProfil", $action->HasPermission(
"FREEDOM_ADMIN",
"FREEDOM"));
306 foreach ($this->fields as $k => $v) {
308 $this->lay->set(
"$v", $this->$v ? $this->$v :
false);
314 $this->lay->set(
"cmodifyacl", (
$tdoc->control(
"modifyacl") ==
""));
316 $this->lay->set(
"cproftitle",
$tdoc->title);
317 $this->lay->set(
"cprofdisplay",
"");
318 $hascontrol = ($this->
controlUserId($this->$v, $this->userid,
"modifyacl") ==
"");
319 $this->lay->set(
"ca_" . $v, $hascontrol);
321 $this->lay->set(
"cprofdisplay",
"none");
328 $this->lay->set(
"cfldtitle",
$tdoc->title);
329 $this->lay->set(
"cflddisplay",
"");
331 $this->lay->set(
"cflddisplay",
"none");
338 $this->lay->set(
"dfldtitle",
$tdoc->title);
339 $this->lay->set(
"dflddisplay",
"");
341 $this->lay->set(
"dflddisplay",
"none");
351 $this->lay->set(
"wtitle",
$tdoc->title);
352 $this->lay->set(
"wdisplay",
true);
353 $this->lay->set(
"wactif", (
$tdoc->profid > 0));
354 $hascontrol = (
$tdoc->control(
"modifyacl") ==
"");
355 $this->lay->set(
"wcontrol", $hascontrol);
356 $this->lay->set(
"wedit", (
$tdoc->control(
"edit") ==
""));
357 $states =
$tdoc->getStates();
359 $tnoprofilstates = array();
360 foreach ($states as $st) {
361 $pid =
$tdoc->getStateProfil($st);
363 $pdoc = new_doc($this->dbaccess, $pid);
364 $tstates[$pid][
"smodifyacl"] = ($pdoc->control(
"modifyacl") ==
"");
365 $tstates[$pid][
"sactif"] = $pdoc->profid;
366 $tstates[$pid][
"pstateid"] = $pid;
367 $tstates[$pid][
"states"][] = _($st);
369 $tnoprofilstates[_($st) ] = array(
370 "pstateattrid" =>
$tdoc->getStateProfilAttribute($st) ,
376 $this->lay->set(
"noprofilstate", implode(
", ", array_keys($tnoprofilstates)));
377 foreach ($tstates as $ka => $va) {
378 $tstates[$ka][
"states"] = implode(
", ", $va[
"states"]);
380 $this->lay->setBlockData(
"pstate", $tstates);
381 $this->lay->setBlockData(
"nopstate", $tnoprofilstates);
383 $this->lay->set(
"wdisplay",
false);
390 $this->lay->set(
"cvtitle",
$tdoc->title);
391 $this->lay->set(
"cvdisplay",
"");
393 $this->lay->set(
"cvdisplay",
"none");
398 if (!$this->maxrev) {
399 if ($this->schar ==
'S') {
400 $this->lay->set(
"maxrevision", _(
"no revisable"));
402 $this->lay->set(
"maxrevision", _(
"unlimited revisions"));
405 $this->lay->set(
"maxrevision", $this->maxrev);
438 $pValue = $this->
getXValue(
"param", $idp);
439 if ($pValue ===
'') {
441 if ($defsys !==
'') {
475 return $this->explodeX($this->param);
489 if ($index == - 1)
return $t;
490 if (isset($t[$index]))
return $t[$index];
504 $idp = strtolower($idp);
514 if (is_array($val)) {
515 if ($oa && $oa->type ==
'htmltext') {
521 if (!empty($val) && $oa && ($oa->type ==
"date" || $oa->type ==
"timestamp")) {
522 $err = $this->convertDateToiso($oa, $val);
527 if ($this->isComplete())
$err = $this->checkSyntax($idp, $val);
528 if (!
$err) $this->
setXValue(
"param", strtolower($idp) , $val);
535 if ($localeconfig !==
false) {
536 if ($oa->type ==
"date" || $oa->type ==
"timestamp") {
537 if ($oa->type ==
"date") {
538 $dateFormat = $localeconfig[
'dateFormat'];
540 $dateFormat = $localeconfig[
'dateTimeFormat'];
543 $tDates = explode(
"\n", $val);
544 foreach ($tDates as $k => $date) {
547 $val = implode(
"\n", $tDates);
549 return sprintf(_(
"local config for date not found"));
558 private function isComplete()
560 return ($this->attributes && $this->attributes->attr);
567 private function checkSyntax($aid, $val)
577 $val = explode(
"\n", $val);
580 if (is_array($val)) $vals = $val;
583 foreach ($vals as $ka => $av) {
584 if (!self::seemsMethod($av)) {
588 if (!empty($av) && (!is_numeric($av))) {
589 $err = sprintf(_(
"value [%s] is not a number") , $av);
595 if ((!is_numeric($av))) {
596 $err = sprintf(_(
"value [%s] is not a number") , $av);
598 if (!
$err && (!ctype_digit($av))) {
599 $err = sprintf(_(
"value [%s] is not a integer") , $av);
606 if ($oa->phpconstraint) {
627 $x = $this->
getXValue(
"defval", $idp, $def);
648 return $this->explodeX($this->defval);
660 $idp = strtolower($idp);
669 if (!empty($val) && $oa && ($oa->type ==
"date" || $oa->type ==
"timestamp")) {
670 $err = $this->convertDateToiso($oa, $val);
688 if (!isset($this->$tval)) $this->
getXValues($X);
690 $tval2 = $this->$tval;
691 $v = isset($tval2[strtolower($idp) ]) ? $tval2[strtolower($idp) ] :
'';
692 if ($v ==
"-")
return $def;
693 if ($v !==
"")
return $v;
701 private function explodeX($sx)
704 $tdefattr = explode(
"][", substr($sx, 1, strlen($sx) - 2));
705 foreach ($tdefattr as $k => $v) {
707 $aid = substr($v, 0, strpos($v,
'|'));
708 $dval = substr(strstr($v,
'|') , 1);
709 if ($aid) $txval[$aid] = $dval;
724 if ($this->$Xval)
return $this->$Xval;
727 $this->$Xval = array();
729 if ($this->attributes !== null && isset($this->attributes->fromids) && is_array($this->attributes->fromids)) {
730 $sql = sprintf(
"select id,%s from docfam where id in (%s)", pg_escape_string($X) , implode(
',', $this->attributes->fromids));
732 foreach ($rx as
$r) {
733 $XS[$r[
"id"]] = $r[$X];
735 $inhIds = array_values($this->attributes->fromids);
737 if (!in_array($this->
id, $inhIds)) $inhIds[] =
$this->id;
741 foreach ($inhIds as
$famId) {
742 $txvalh = $this->explodeX($XS[$famId]);
743 foreach ($txvalh as $aid => $dval) {
744 $txval[$aid] = ($dval ==
'-') ? null : $dval;
747 if ($this->isComplete()) {
748 uksort($txval, array(
753 $this->$Xval = $txval;
763 if ($oa1->ordered > $oa2->ordered)
return 1;
764 else if ($oa1->ordered < $oa2->ordered)
return -1;
781 $txval = $this->explodeX($this->$X);
783 $txval[strtolower($idp) ] = $val;
784 $this->$tval = $txval;
787 foreach ($txval as $k => $v) {
788 if ($k && ($v !==
'')) $tdefattr[] =
"$k|$v";
791 $this->$X =
"[" . implode(
"][", $tdefattr) .
"]";
800 if ((!$this->FDLGEN_HasBeenLoaded) || (!isset($this->attributes->attr))) {
804 $point = uniqid(__METHOD__);
809 $dvi->DeleteDoc($this->
id);
813 foreach ($tvid as $k => $vid) {
815 $dvi->vaultid = $vid;
827 if (is_resource($stream) && get_resource_type($stream) ==
"stream") {
831 while (!feof($stream)) {
832 if (
false === fwrite($tmpstream, fread($stream, 4096))) {
833 $err =
"403 Forbidden";
854 if (!$this->_configuration) {
856 $dxml =
new DomDocument();
858 if (!@$dxml->load($famfile)) {
863 $properties = $dxml->getElementsByTagName(
'property');
864 foreach ($properties as $prop) {
866 $name = $prop->getAttribute(
'name');
867 $value = $prop->nodeValue;
870 $views = $dxml->getElementsByTagName(
'view');
871 foreach (
$views as $view) {
873 $name = $view->getAttribute(
'name');
874 foreach ($view->attributes as
$a) {
875 $o->views[
$name][$a->name] = $a->value;
879 $this->_configuration =
$o;
882 return $this->_configuration;
888 function getXmlSchema($linkInclude =
false)
891 $lay->set(
"famname", strtolower($this->
name));
893 $lay->set(
"include", $linkInclude);
895 $lay->set(
"includefdlxsd",
"");
897 $xsd =
new DOMDocument();
899 $xsd->preserveWhiteSpace =
false;
900 $xsd->formatOutput =
true;
902 $rootNode = $xsd->documentElement;
906 foreach ($rootNode->childNodes as $subnode) {
907 $innerXml.= ($xsd->saveXML($subnode));
910 $lay->set(
"includefdlxsd", $innerXml);
917 foreach (
$la as $k => $v) {
918 if ((!$v) || ($v->getOption(
"autotitle") ==
"yes") || ($v->usefor ==
'Q')) unset(
$la[$k]);
920 foreach (
$la as $k => $v) {
921 if (($v->id != Adoc::HIDDENFIELD) && ($v->type ==
'frame' || $v->type ==
"tab") && ((!$v->fieldSet) || $v->fieldSet->id == Adoc::HIDDENFIELD)) {
926 "tax" => $v->getXmlSchema(
$la)
934 $lay->setBlockData(
"ATTR", $tax);
935 $lay->setBlockData(
"LEVEL1", $level1);
937 $xsd =
new DOMDocument();
938 $xsd->preserveWhiteSpace =
false;
939 $xsd->formatOutput =
true;
940 $xsd->loadXML(
$lay->gen());
942 return ($xsd->saveXML());
967 $this->configuration =
'';
978 $propName = strtolower($propName);
981 if ($confStore->load($this->configuration) ===
false) {
986 $pValue = $confStore->get(
$class, $propName, $pName);
987 if ($pValue ===
false) {
1007 $propName = strtolower($propName);
1010 if ($confStore->load($this->configuration) ===
false) {
1015 $confStore->add(
$class, $propName, $pName, $pValue);
1017 $conf = $confStore->getText();
1018 if ($conf ===
false) {
1022 $this->configuration = $conf;
1035 foreach ($this->defaultSortProperties as $propName => $params) {
1036 if (isset($params[
'sort']) && $params[
'sort'] !=
'no') {
1037 $res[$propName] = $params;
1041 if ($confStore->load($this->configuration) ===
false) {
1047 $props = $confStore->get(
'sortProperties', null,
'sort');
1048 if ($props === null) {
1051 foreach ($props as $propName => $params) {
1052 if (isset($params[
'sort']) && $params[
'sort'] !=
'no') {
1053 $res[$propName] = $params;
1065 return parent::PostUpdate();
Layout is a template generator.
setPropertyParameter($propName, $pName, $pValue)
newFreeVaultFile($dbaccess)
& getAttribute($idAttr, &$oa=null, $useMask=true)
stringDateToIso($date, $format=false, $withT=false)
print< H1 > Check Database< i > $dbaccess</i ></H1 > $a
print $fam getTitle() $fam name
static rawValueToArray($v)
Exception class use exceptionCode to identifiy correctly exception.
refreshPhpPgDoc($dbaccess, $docid)
getParameterFamilyRawValue($idp, $def)
canEdit($verifyDomain=true)
getParamTValue($idAttr, $def="", $index=-1)
saveVaultFile($vid, $stream)
resetPropertiesParameters()
getDefValue($idp, $def="")
static getError($code, $args=null)
getLocaleConfig($core_lang= '')
viewfamcard($target="_self", $ulink=true, $abstract=false)
getFamilyParameterValue($idp, $def="")
applyMethod($method, $def="", $index=-1, array $bargs=array(), array $mapArgs=array(), &$err= '')
getLayoutFile($app, $layfile)
setXValue($X, $idp, $val)
static getParameterClassMap($key=null)
__construct($dbaccess= '', $id= '', $res= '', $dbid=0, $include=true)
getXValue($X, $idp, $def="")
createDoc($dbaccess, $fromid, $control=true, $defaultvalues=true, $temporary=false)
if($updateExistingTable) $point
getTitle($id="-1", $def="", $latest=false)
getHtmlValue($oattr, $value, $target="_self", $htmllink=true, $index=-1, $entities=true, $abstract=false)
postImport(array $extra=array())
deprecatedFunction($msg= '')
new_Doc($dbaccess, $id= '', $latest=false)
postAffect(array $data, $more, $reset)
& getAttributes($useMask=true)
static getLangTitle($values)
getExtraSearchableDisplayValues($withLocale=true)
static arrayToRawValue($v, $br= '< BR >')
viewDefaultValues($target="_self", $ulink=true, $abstract=false)
setDefValue($idp, $val, $check=true)
simpleQuery($dbaccess, $query, &$result=array(), $singlecolumn=false, $singleresult=false, $useStrict=null)
getPropertyParameter($propName, $pName)
if($file) if($subject==""&&$file) if($subject=="") $err
setParam($idp, $val, $check=true)
getParamValue($idp, $def="")
controlUserId($docid, $uid, $aclname)
control($aclname, $strict=false)
getParameterRawValue($idp, $def="")