19 include_once (
"FDL/enum_choice.php");
32 header(
'Content-type: text/xml; charset=utf-8');
34 $action->lay->setEncoding(
"utf-8");
35 if ($enum !=
"") $attrid = $enum;
54 $isInAbstract =
false;
57 $fieldSet =
$doc->attr[
"FIELD_HIDDENS"];
63 $oattr =
new NormalAttribute($attrid,
$doc->id,
$label,
"text",
$format, $repeat, $order, $link, $visibility, $needed, $isInTitle, $isInAbstract, $fieldSet, $phpfile, $phpfunc, $elink, $phpconstraint, $usefor, $eformat, $options);
65 $oattr =
$doc->GetAttribute($attrid);
66 if (!$oattr)
$err = sprintf(_(
"unknown attribute %s") , $attrid);
71 if (preg_match(
"/([a-z]*)-alone/", $sorm, $reg)) {
75 $action->lay->set(
"notalone", $notalone);
77 $action->parent->AddJsRef(
$action->GetParam(
"CORE_STANDURL") .
"app=FDL&action=ENUMCHOICEJS");
78 $phpfunc = $oattr->phpfunc;
82 if ($phpfunc[0] ==
"[") {
83 if (preg_match(
'/\[(.*)\](.*)/', $phpfunc, $reg)) {
84 $oattr->phpfunc = $reg[2];
86 $ititle = addslashes($reg[1]);
90 $linkprefix =
"ilink_";
91 $action->lay->set(
"ititle", $ititle);
95 $canitem = (!$oattr->existEnum(trim($skey)));
96 if (trim($skey) ==
'' && strpos($oattr->phpfunc,
"linkenum") !==
false) {
98 } elseif ((strlen($oattr->phpfunc)>2) && strlen($oattr->phpfile)>2) {
101 $eval = $oattr->phpfunc;
103 $oattr->phpfile =
"fdl.php";
104 $eval = str_replace(array(
111 $oattr->phpfunc = sprintf(
"lenumvalues('%s,'%s):li_%s,%s", str_replace(array(
119 ) , $eval) , str_replace(array(
127 ) , $skey) , $oattr->id, $oattr->id);
128 } elseif ($oattr->type ==
"docid") {
131 $multi = $oattr->getOption(
"multiple");
132 $cible = ($multi ==
"yes") ?
"mdocid_work" :
"";
133 if (!$oattr->phpfile) {
137 $docrev = $oattr->getOption(
"docrev");
138 if ($docrev ==
"fixed") {
140 } elseif ($docrev !=
"latest") {
144 if (preg_match(
"/^state\(([a-zA-Z0-9_:-]+)\)/", $docrev, $matches)) {
145 $filter[] =
"state='" . pg_escape_string($matches[1]) .
"'";
150 $oattr->phpfunc =
"lfamily(D,$famid,${linkprefix}${aname},0,$sfilter,'$idid):${cible}${aname},${linkprefix}${aname}";
151 $oattr->phpfile =
"fdl.php";
154 $phpfunc = preg_replace(
'/([\s|,|:])CT([\s|,|\)]|$)/',
'$1' . $linkprefix . $aname .
'$2', $oattr->phpfunc);
155 $phpfunc = str_replace(
"):$aname,",
"):${cible}${aname},", $phpfunc);
156 $phpfunc = str_replace(
"):" . strtoupper($aname) .
",",
"):${cible}${aname},", $phpfunc);
157 $oattr->phpfunc = $phpfunc;
160 $oattr->phpfunc = preg_replace(
'/([\s|,|:])CT\[([^]]+)\]/e',
"'\\1'.$linkprefix.strtolower('\\2')", $oattr->phpfunc);
163 if (!is_array($res)) {
164 if ($res ==
"") $res = sprintf(_(
"error in calling function %s\n%s") , $oattr->phpfunc, $res);
168 if (count($res) == 0) {
169 $err = sprintf(_(
"no match for %s") , $oattr->getLabel());
172 $err = sprintf(_(
"existing key item %s") , $skey);
174 if ($oattr->getOption(
"etype") ==
"open") {
177 sprintf(_(
"new item %s") , $skey) ,
178 $skey .
' ' . _(
"(new item)") ,
183 } elseif ($oattr->getOption(
"etype") ==
"free") {
186 sprintf(_(
"free item %s") , $skey) ,
187 $skey .
' ' . _(
"(free item)") ,
193 $err = sprintf(_(
"unknow item %s") , $skey);
198 if ($enum && (trim($skey) !=
"")) {
199 foreach ($res as $kr => $kv) {
200 if (($kv[1] == trim($skey)) || ($kv[2] == trim($skey))) $canitem =
false;
203 if ($oattr->getOption(
"etype") ==
"free") {
205 sprintf(_(
"free item %s") , $skey) ,
206 $skey .
' ' . _(
"(free item)") ,
210 } elseif ($oattr->getOption(
"etype") ==
"open") {
212 sprintf(_(
"new item %s") , $skey) ,
213 $skey .
' ' . _(
"(new item)") ,
224 while (list($k, $v) = each($rargids)) {
225 $linkprefix =
"ilink_";
227 $attrId = $rargids[$k];
228 if (substr($attrId, 0, strlen($linkprefix)) == $linkprefix) {
229 $attrId = substr($attrId, strlen($linkprefix));
232 $docAttr =
$doc->getAttribute($attrId);
233 if (is_object($docAttr) && !$docAttr->inArray()) {
234 $targid = trim(strtolower($attrId));
236 $targid = trim(strtolower($attrId . $domindex));
239 $targid = $linkprefix . $targid;
241 $targids[][
"attrid"] = $targid;
244 $action->lay->SetBlockData(
"cibles", $targids);
246 foreach ($res as $k => $v) {
247 $topt[$k][
"choice"] = $v[0];
248 $topt[$k][
"cindex"] = $k;
250 $topt[$k][
"values"] =
'<val><![CDATA[' . stripslashes(implode(
"]]></val><val><![CDATA[", $v)) .
']]></val>';
253 $action->lay->SetBlockData(
"SELECT", $topt);
254 $action->lay->Set(
"count", count($tselect));
267 global
$_POST, $ZONE_ARGS;
269 foreach ($_POST as $k => $v) {
271 foreach ($v as $kv => $vv) $ZONE_ARGS[$k][$kv] = utf8_decode($vv);
273 $ZONE_ARGS[$k] = utf8_decode($v);