19 include_once (
"FDL/Class.Doc.php");
20 include_once (
"FDL/Class.DocAttr.php");
31 $action->parent->AddJsRef(
$action->GetParam(
"CORE_JSURL") .
"/geometry.js");
32 $action->parent->AddJsRef(
"FDL/Layout/common.js");
50 $isInAbstract =
false;
53 $fieldSet =
$doc->attr[
"FIELD_HIDDENS"];
59 $oattr =
new NormalAttribute($attrid,
$doc->id,
$label,
"text",
$format, $repeat, $order, $link, $visibility, $needed, $isInTitle, $isInAbstract, $fieldSet, $phpfile, $phpfunc, $elink, $phpconstraint, $usefor, $eformat, $options);
61 $oattr =
$doc->GetAttribute($attrid);
62 if (!$oattr)
$action->exitError(sprintf(_(
"unknown attribute %s") , $attrid));
66 if (preg_match(
"/([a-z]*)-alone/", $sorm, $reg)) {
70 $action->lay->set(
"notalone", $notalone);
72 $action->parent->AddJsRef(
$action->GetParam(
"CORE_STANDURL") .
"app=FDL&action=ENUMCHOICEJS");
73 $phpfunc = $oattr->phpfunc;
77 if ($phpfunc[0] ==
"[") {
78 if (preg_match(
'/\[(.*)\](.*)/', $phpfunc, $reg)) {
79 $oattr->phpfunc = $reg[2];
81 $ititle = addslashes($reg[1]);
84 $action->lay->set(
"ititle", $ititle);
88 if (!is_array($res)) {
89 if ($res ==
"") $res = sprintf(_(
"error in calling function %s") , $oattr->phpfunc);
92 if (count($res) == 0)
$action->exitError(sprintf(_(
"no match for %s") , $oattr->getLabel()));
94 if ($sorm ==
"single") {
96 $action->lay->SetBlockData(
"SELECTSINGLE", array(
103 $action->lay->SetBlockData(
"SELECTMULTIPLE", array(
108 $action->lay->Set(
"nselect", (count($tselect) > 7) ? 7 : count($tselect));
111 foreach ($rargids as $k => $v) {
112 $rargids[$k] = trim($v);
113 $rargids[$k].= $domindex;
116 $sattrid.= strtolower(
"'" . implode(
"','", $rargids) .
"'");
118 $action->lay->Set(
"attrid", $sattrid);
119 $action->lay->SetBlockData(
"SELECT", $tselect);
120 $action->lay->SetBlockData(
"ATTRVAL", $tval);
128 if (preg_match(
"/([a-z]*)-alone/", $sorm, $reg)) {
132 $action->lay->set(
"notalone", $notalone);
137 if ($whttpvars)
return GetHttpVars(
"_" . strtolower($n) , $def);
141 if (!$oa)
return ($n);
142 if (($oa->repeat) || $oa->inArray())
$r =
$doc->getTValue($n);
143 else $r =
$doc->getValue($n);
144 if (
$r ===
"")
return false;
148 function getResPhpFunc(&
$doc, &$oattr, &$rargids, &$tselect, &$tval, $whttpvars =
true, $index =
"")
152 $phpfunc = $oattr->phpfunc;
153 $phpfunc = str_replace(array(
160 if (!preg_match(
"/(.*)\((.*)\)\:(.*)/", $phpfunc, $reg)) {
161 return sprintf(_(
"the pluggins function description '%s' is not conform for %s attribut") , $phpfunc, $oattr->id);
164 if (!function_exists($callfunc)) {
165 if (!@file_exists(
"EXTERNALS/$oattr->phpfile")) {
166 return sprintf(_(
"the external pluggin file %s cannot be read") , $oattr->phpfile);
168 include_once (
"EXTERNALS/$oattr->phpfile");
171 if (!function_exists($callfunc)) {
172 return sprintf(_(
"function '%s' declared in %s is not found") , $callfunc, $oattr->id);
174 $rargids = explode(
",", $reg[3]);
176 $iarg = preg_replace(
"/\{([^\}]+)\}/e",
178 "getAttr('\\1')", $reg[2]);
179 $argids = explode(
",", $iarg);
180 foreach ($argids as $k => $v) {
181 $v = str_replace(array(
188 if ($v !=
" ") $v = trim($v);
190 $unser = unserialize($v);
191 if ($unser !=
"")
$arg[$k] = $unser;
195 }
else if ($v ==
"D")
$arg[$k] =
$doc->dbaccess;
196 else if ($v ==
"I")
$arg[$k] =
$doc->id;
197 else if ($v ==
"WIID")
$arg[$k] = getHttpVars(
"wiid");
198 else if ($v ==
"K")
$arg[$k] = $index;
199 else if ($v ==
"T")
$arg[$k] = &
$doc;
200 else if (($v[0] ==
"'") || ($v[0] ==
'"')) {
201 $lc = substr($v, -1);
202 if ($lc == $v[0])
$arg[$k] = mb_substr($v, 1, -1);
203 else $arg[$k] = mb_substr($v, 1);
204 }
else if (
$doc->getProperty($v) !==
false)
$arg[$k] =
$doc->getProperty($v);
207 $a =
$doc->GetAttribute($v);
210 if (
$ta ===
false)
return false;
217 if (
$a && (
$a->usefor ==
"Q")) {
218 if ((
$a->fieldSet->id == $oattr->fieldSet->id)) {
220 if (
$ta ===
false)
return false;
225 }
else if (
$a &&
$a->inArray()) {
226 if ((
$a->fieldSet->id == $oattr->fieldSet->id)) {
228 if (
$ta ===
false)
return false;
232 if (
$ta ===
false)
return false;
242 if (
$ta ===
false)
return false;
244 if ($index !==
"")
$arg[$k] = trim(
$ta[$index]);
249 if (
$a && (
$a->usefor ==
"Q")) {
255 $res = call_user_func_array($callfunc,
$arg);
257 if (is_array($res) && (count($res) > 0)) {
260 foreach ($res as $k => $v) {
261 foreach ($v as $k2 => $v2) {
263 if ($k2 > 0) $res[$k][$k2] = addslashes(str_replace(
"\r",
"", str_replace(
"\n",
"\\n", $v2)));
264 else $res[$k][$k2] = str_replace(array(
277 while (list($k, $v) = each($res)) {
278 $tselect[$k][
"choice"] = $v[0];
279 $tselect[$k][
"cindex"] = $ki;
280 $tval[$k][
"index"] = $ki;
283 $tval[$k][
"attrv"] =
"['" . implode(
"','", $v) .
"']";