56 if ($i !=
$r)
return $i;
69 if (!isset($this->_topt)) {
70 $topt = explode(
"|", $this->options);
71 $this->_topt = array();
72 foreach ($topt as $k => $v) {
73 list($vn, $vv) = explode(
"=", $v, 2);
74 $this->_topt[$vn] = $vv;
77 $r = $this->docname .
'#' . $this->
id .
'#' . $x;
79 if ($i !=
$r)
return $i;
80 $v = $this->_topt[$x];
81 return ($v ? $v : $def);
90 if (!isset($this->_topt)) {
105 if (!isset($this->_topt)) {
108 $this->_topt[$x] = $v;
117 $this->mvisibility = $vis;
126 $this->needed = $need;
135 return $this->
getOption(
"autocreated") !=
"yes";
147 return str_replace(array(
159 return str_replace(array(
177 if (get_class($this) ==
"NormalAttribute") {
178 if ($this->fieldSet->type ==
"array")
return true;
198 if ($this->
type ==
'tab')
return $this;
199 if ($this->fieldSet && ($this->fieldSet->id !=
'FIELD_HIDDENS'))
return $this->fieldSet->getTab();
209 return sprintf(
"<!-- no Schema %s (%s)-->", $this->
id, $this->
type);
218 return sprintf(
"<!-- no value %s (%s)-->", $this->
id, $this->
type);
239 $lay->set(
"aname", $this->
id);
240 $lay->set(
"label", $this->
encodeXml($this->labelText));
241 $lay->set(
"type", $this->
type);
242 $lay->set(
"visibility", $this->visibility);
243 $lay->set(
"isTitle", $this->isInTitle);
244 $lay->set(
"phpfile", $this->phpfile);
245 $lay->set(
"phpfunc", $this->phpfunc);
247 if (($this->ype ==
"enum") && (!$this->phpfile) || ($this->phpfile ==
"-")) {
248 $lay->set(
"phpfile",
false);
249 $lay->set(
"phpfunc",
false);
251 $lay->set(
"computed", ((!$this->phpfile) && (substr($this->phpfunc, 0, 2) ==
"::")));
252 $lay->set(
"link", $this->
encodeXml($this->link));
253 $lay->set(
"elink", $this->
encodeXml($this->elink));
254 $lay->set(
"default",
false);
255 $lay->set(
"constraint", $this->phpconstraint);
258 foreach ($tops as $k => $v) {
259 if ($k)
$t[] = array(
264 $lay->setBlockData(
"options",
$t);
266 $play->set(
"minOccurs", $this->needed ?
"1" :
"0");
267 $play->set(
"isnillable", $this->needed ?
"false" :
"true");
268 $play->set(
"maxOccurs", (($this->
getOption(
'multiple') ==
'yes') ?
"unbounded" :
"1"));
269 $play->set(
"aname", $this->
id);
270 $play->set(
"appinfos", $lay->gen());
330 function __construct(
$id,
$docid,
$label,
$type,
$format,
$repeat, $order,
$link,
$visibility,
$needed,
$isInTitle,
$isInAbstract, &
$fieldSet,
$phpfile,
$phpfunc,
$elink,
$phpconstraint =
"",
$usefor =
"",
$eformat =
"",
$options =
"",
$docname =
"")
334 $this->labelText =
$label;
338 $this->ordered = $order;
363 switch ($this->
type) {
394 return sprintf(
"<!-- no Schema %s (type %s)-->", $this->
id, $this->
type);;
407 if ($opt->index > - 1) $v = $doc->getTvalue($this->
id,
'', $opt->index);
408 else $v = $doc->
getValue($this->
id);
410 if ($this->
getOption(
"autotitle") ==
"yes")
return sprintf(
"<!--autotitle %s %s -->", $this->
id, $v);
411 if ((!$v) && ($this->
type !=
'array')) {
412 if (($this->
type ==
'file') || ($this->
type ==
'image'))
return sprintf(
'<%s mime="" title="" xsi:nil="true"/>', $this->
id);
413 else return sprintf(
'<%s xsi:nil="true"/>', $this->
id);
415 switch ($this->
type) {
419 return sprintf(
"<%s>%s</%s>", $this->
id, $v, $this->
id);
422 $xmlvalues = array();
423 $av = $doc->getAvalues($this->
id);
425 foreach ($av as $k => $col) {
426 $xmlvalues = array();
427 foreach ($col as $aid => $aval) {
429 if (empty($opt->exportAttributes[$doc->fromid]) || in_array($aid, $opt->exportAttributes[$doc->fromid])) {
431 $xmlvalues[] = $oa->getXmlValue($doc, $opt);
434 $axml[] = sprintf(
"<%s>%s</%s>", $this->
id, implode(
"\n", $xmlvalues) , $this->
id);
437 return implode(
"\n", $axml);
441 if ($opt->withIdentificator) $vid = $reg[2];
446 $href = $base . str_replace(
'&',
'&', $doc->
getFileLink($this->id));
447 if ($opt->withFile) {
450 if (is_file(
$path)) {
452 return sprintf(
'<%s vid="%d" mime="%s" title="%s">[FILE64:%s]</%s>', $this->
id, $vid, $mime,
$name,
$path, $this->
id);
454 return sprintf(
'<%s vid="%d" mime="%s" title="%s">%s</%s>', $this->
id, $vid, $mime,
$name, base64_encode(file_get_contents(
$path)) , $this->
id);
457 return sprintf(
'<!-- file not found --><%s vid="%d" mime="%s" title="%s"/>', $this->
id, $vid, $mime,
$name, $this->
id);
460 return sprintf(
'<%s vid="%d" mime="%s" href="%s" title="%s"/>', $this->
id, $vid, $mime, $href, $this->
encodeXml(
$name));
463 return sprintf(
"<%s>%s</%s>", $this->
id, $v, $this->
id);
466 $info =
getTDoc($doc->dbaccess, $v, array() , array(
476 $latestTitle = ($this->
getOption(
"docrev",
"latest") ==
"latest");
479 if ($info[
"locked"] == - 1) {
484 if ($opt->withIdentificator) {
485 return sprintf(
'<%s id="%s" name="%s">%s</%s>', $this->
id,
$docid, $info[
"name"], $this->
encodeXml($info[
"title"]) , $this->
id);
487 return sprintf(
'<%s name="%s">%s</%s>', $this->
id, $info[
"name"], $this->
encodeXml($info[
"title"]) , $this->
id);
490 if ($opt->withIdentificator) {
491 return sprintf(
'<%s id="%s">%s</%s>', $this->
id,
$docid, $this->
encodeXml($info[
"title"]) , $this->
id);
494 return sprintf(
'<%s>%s</%s>', $this->
id, $this->
encodeXml($info[
"title"]) , $this->
id);
498 if ((strpos($v,
'<BR>') ===
false) && (strpos($v,
"\n") ===
false)) {
499 return sprintf(
'<%s id="%s">%s</%s>', $this->
id, $v, _(
"unreferenced document") , $this->
id);
501 return sprintf(
'<%s id="%s">%s</%s>', $this->
id, str_replace(array(
504 ) ,
',', $v) , _(
"multiple document") , $this->
id);
508 return sprintf(
"<%s>%s</%s>", $this->
id, $this->
encodeXml($v) , $this->
id);
521 $lay->set(
"maxlength",
false);
522 $lay->set(
"pattern",
false);
537 foreach (
$la as $k => $v) {
543 $lay->setBlockData(
"enums", $te);
556 $lay->set(
"famid", $this->format);
656 $lay->set(
"minOccurs",
"0");
657 $lay->set(
"maxOccurs",
"unbounded");
659 foreach (
$la as $k => $v) {
660 if ($v->fieldSet && $v->fieldSet->id == $this->id) {
662 "axs" => $v->getXmlSchema(
$la)
666 $lay->setBlockData(
"ATTR", $tax);
682 $this->textualValueMultipleSeparator = (isset($configuration[
'multipleSeparator']) && is_array($configuration[
'multipleSeparator'])) ? $configuration[
'multipleSeparator'] : $this->textualValueMultipleSeparator;
684 switch ($this->
type) {
689 $return = $this->getTextualValueText($doc, $index);
694 $return = $this->getTextualValueFile($doc, $index);
698 $return = $this->getTextualValueEnum($doc, $index);
703 $return = $this->getTextualValueDocId($doc, $index);
708 $date = isset($configuration[
'dateFormat']) ? $configuration[
'dateFormat'] :
'US';
709 $return = $this->getTextualValueDate($doc, $index, $date);
717 $decimalSeparator = isset($configuration[
'decimalSeparator']) ? $configuration[
'decimalSeparator'] :
'.';
718 $return = $this->getTextualFloat($doc, $index, $decimalSeparator);
725 $return = $this->getTextualValueRaw($doc, $index);
727 $this->textualValueMultipleSeparator = $oldMultipleSep;
739 private function getTextualFloat(
Doc $doc, $index, $decimalSeparator)
741 $values = $this->getTextualValueRaw($doc, $index);
742 if ($decimalSeparator !=
".") {
743 return str_replace(
".", $decimalSeparator, $values);
756 private function getTextualValueText(
Doc $doc, $index = - 1)
760 return strip_tags($doc->
getTValue($this->id,
"", $index));
762 $nbValue = count($doc->
getTValue($this->id));
763 $returnValues = array();
764 for ($i = 0; $i < $nbValue; $i++) {
765 $returnValues[] = $this->getTextualValueText($doc, $i);
767 return implode($this->textualValueMultipleSeparator[0], $returnValues);
770 return strip_tags($doc->
getValue($this->id));
781 private function getTextualValueRaw(
Doc $doc, $index = - 1)
785 return $doc->
getTValue($this->
id,
"", $index);
787 $returnValues = $doc->
getTValue($this->
id);
788 return implode($this->textualValueMultipleSeparator[0], $returnValues);
803 private function getTextualValueDate(
Doc $doc, $index = - 1, $dateFormat)
805 $convertDate =
function ($date) use ($dateFormat)
807 if (strtoupper($dateFormat) ==
"US") {
810 } elseif (strtoupper($dateFormat) ==
"ISO") {
814 if (strlen($date) < 11) $date = substr($ldate, 0, strlen($date));
821 return $convertDate($doc->
getTValue($this->id,
"", $index));
823 $nbValue = count($doc->
getTValue($this->id));
824 $returnValues = array();
825 for ($i = 0; $i < $nbValue; $i++) {
826 $returnValues[] = $this->getTextualValueDate($doc, $i, $dateFormat);
828 return implode($this->textualValueMultipleSeparator[0], $returnValues);
831 return $convertDate($doc->
getValue($this->id));
842 private function getTextualValueFile(
Doc $doc, $index = - 1)
848 $nbValue = count($doc->
getTValue($this->id));
849 $returnValues = array();
850 for ($i = 0; $i < $nbValue; $i++) {
851 $returnValues[] = $this->getTextualValueFile($doc, $i);
853 return implode($this->textualValueMultipleSeparator[0], $returnValues);
867 private function getTextualValueEnum(
Doc $doc, $index = - 1)
873 $nbValue = count($doc->
getTValue($this->id));
874 $returnValues = array();
875 for ($i = 0; $i < $nbValue; $i++) {
876 $returnValues[] = $this->getTextualValueEnum($doc, $i);
878 return implode($this->textualValueMultipleSeparator[0], $returnValues);
881 if ($this->
getOption(
'multiple') ==
'yes') {
884 $returnValues = array();
885 foreach ($values as $currentKey) {
888 return implode($this->textualValueMultipleSeparator[1], $returnValues);
901 private function getTextualValueDocId(
Doc $doc, $index = - 1)
903 $optionDoc = $this->
getOption(
'docrev',
"");
904 $displayTitle =
function (
$id) use ($optionDoc, $doc)
906 if ($optionDoc ==
"fixed") {
914 if ($this->
getOption(
'multiple') ==
'yes') {
915 $values = explode(
"<BR>", $doc->
getTValue($this->id,
"", $index));
916 if (is_array($values)) {
917 $returnValues = array();
918 foreach ($values as $currentId) {
919 $returnValues[] = $displayTitle($currentId);
921 return implode($this->textualValueMultipleSeparator[1], $returnValues);
923 return $displayTitle($values);
925 return $displayTitle($doc->
getTValue($this->id,
"", $index));
928 $nbValue = count($doc->
getTValue($this->id));
929 $returnValues = array();
930 for ($i = 0; $i < $nbValue; $i++) {
931 $returnValues[] = $this->getTextualValueDocId($doc, $i);
933 return implode($this->textualValueMultipleSeparator[0], $returnValues);
936 if ($this->
getOption(
'multiple') ==
'yes') {
940 return $displayTitle($values[$index]);
942 $returnValues = array();
943 foreach ($values as $currentId) {
944 $returnValues[] = $displayTitle($currentId);
946 return implode($this->textualValueMultipleSeparator[1], $returnValues);
949 return $displayTitle($doc->
getValue($this->id));
963 if (isset($__tenum[$this->
id]))
return $__tenum[
$this->id];
964 if (($this->
type ==
"enum") || ($this->
type ==
"enumlist")) {
966 $this->
enum = array();
967 $this->enumlabel = array();
968 $br = $this->docname .
'#' . $this->
id .
'#';
969 if (($this->phpfile !=
"") && ($this->phpfile !=
"-")) {
971 if (!include_once (
"EXTERNALS/$this->phpfile")) {
973 $action->exitError(sprintf(_(
"the external pluggin file %s cannot be read") , $this->phpfile));
975 if (preg_match(
"/(.*)\((.*)\)/", $this->phpfunc, $reg)) {
976 $args = explode(
",", $reg[2]);
977 if (preg_match(
"/linkenum\((.*),(.*)\)/", $this->phpfunc, $dreg)) {
978 $br = $dreg[1] .
'#' . strtolower($dreg[2]) .
'#';
980 if (function_exists($reg[1])) {
981 $this->phpfunc = call_user_func_array($reg[1], $args);
983 AddWarningMsg(sprintf(_(
"function [%s] not exists") , $this->phpfunc));
987 AddWarningMsg(sprintf(_(
"invalid syntax for [%s] for enum attribute") , $this->phpfunc));
991 $sphpfunc = str_replace(
"\\.",
"-dot-", $this->phpfunc);
992 $sphpfunc = str_replace(
"\\,",
"-comma-", $sphpfunc);
993 if ($sphpfunc !=
"") {
994 $tenum = explode(
",", $sphpfunc);
995 foreach ($tenum as $k => $v) {
996 list($enumKey, $enumValue) = explode(
"|", $v);
997 $treeKeys = explode(
".", $enumKey);
998 $enumKey = trim($enumKey);
999 if (strlen($enumKey) == 0) $enumKey =
" ";
1000 $enumValue = trim($enumValue);
1001 $translatedEnumValue = _($br . $enumKey);
1002 if ($translatedEnumValue != $br . $enumKey) {
1003 $enumValue = $translatedEnumValue;
1006 $n = count($treeKeys);
1008 $enumValue = str_replace(array(
1015 $this->
enum[str_replace(array(
1021 ) , $enumKey) ] = $enumValue;
1022 $this->enumlabel[str_replace(array(
1028 ) , $enumKey) ] = $enumValue;
1033 foreach ($treeKeys as $i => $treeKey) {
1034 $enumlabelKey = $treeKey;
1043 $tmpKey = str_replace(array(
1050 $enumlabelValue = $this->
enum[$tmpKey] .
'/' . $enumValue;
1051 $enumlabelValue = str_replace(array(
1057 ) , $enumlabelValue);
1058 $this->
enum[str_replace(array(
1064 ) , $enumKey) ] = $enumValue;
1065 $this->enumlabel[str_replace(array(
1071 ) , $enumlabelKey) ] = $enumlabelValue;
1077 $__tlenum[
$this->id] = $this->enumlabel;
1095 if (isset($__tlenum[$this->
id])) {
1096 if ($enumid === null)
return $__tlenum[
$this->id];
1097 if (strstr($enumid,
"\n")) {
1098 $enumid = explode(
"\n", $enumid);
1101 if (is_array($enumid)) {
1103 foreach ($enumid as $v) {
1104 if (isset($__tlenum[$this->
id][$v])) $tv[] = $__tlenum[
$this->id][$v];
1105 else $tv[] = $enumid;
1107 if ($implode)
return implode(
"\n", $tv);
1110 if (isset($__tlenum[$this->
id][$enumid]))
return $__tlenum[
$this->id][$enumid];
1111 else return $enumid;
1126 if ($key ==
"")
return "";
1132 if (
$a->isAffected()) {
1135 $key = str_replace(array(
1140 $label = str_replace(array(
1145 if (!array_key_exists($key, $tenum)) {
1153 foreach ($tenum as $k => $v) {
1154 $v = str_replace(array(
1161 $k = str_replace(array(
1168 $tsenum[] =
"$k|$v";
1170 $senum = implode($tsenum,
',');
1171 $a->phpfunc = $senum;
1174 include_once (
"FDL/Lib.Attr.php");
1179 $err = sprintf(_(
"unknow attribute %s (family %s)") , $this->
id, $this->docid);
1193 if ($key ==
"")
return false;
1195 if (isset($this->
enum[$key]))
return true;
1227 $this->labelText =
$label;
1229 $this->usefor = $usefor;
1245 $lay->set(
"aname", $this->
id);
1248 $lay->set(
"minOccurs",
"0");
1249 $lay->set(
"maxOccurs",
"1");
1250 $lay->set(
"notop", ($this->fieldSet->id !=
'' && $this->fieldSet->id !=
'FIELD_HIDDENS'));
1252 foreach (
$la as $k => $v) {
1253 if ($v->fieldSet && $v->fieldSet->id == $this->id) {
1255 "axs" => $v->getXmlSchema(
$la)
1260 $lay->setBlockData(
"ATTR", $tax);
1274 $xmlvalues = array();
1275 foreach (
$la as $k => $v) {
1276 if ($v->fieldSet && $v->fieldSet->id == $this->id && (empty($opt->exportAttributes[$doc->fromid]) || in_array($v->id, $opt->exportAttributes[$doc->fromid]))) {
1277 $xmlvalues[] = $v->getXmlValue($doc, $opt);
1280 if ($opt->flat)
return implode(
"\n", $xmlvalues);
1281 else return sprintf(
"<%s>%s</%s>", $this->
id, implode(
"\n", $xmlvalues) , $this->
id);
1294 $this->labelText =
$label;
1295 $this->ordered = $order;
1296 $this->link =
$link;
1300 $this->
type =
"menu";
1316 $this->labelText =
$label;
1318 $this->ordered = $order;
1323 $this->
type =
"action";
1329 $batch = ($this->
getOption(
"batchfolder") ==
"yes");
1337 if (!stristr($this->waction,
"&id=")) $l.=
"&id=" .
$docid;