28 var
$defaultview = "FREEDOM:VIEWDSEARCH";
#N_("not include") N_("begin by") N_("not equal") N_("> or equal") N_("< or equal") N_("one word equal") N_("content file word") N_("content file expression")
39 else $cdirid = $dirid;
46 if ($cond ===
false)
return array(
50 if (
$latest ==
"lastfixed") $distinct =
true;
51 if ($cond !=
"") $filters[] = $cond;
52 if ($this->
getValue(
"se_famonly") ==
"yes") {
66 $filtersType = $this->
getTValue(
"se_typefilter");
67 if ((count($this->getTvalue(
"se_filter")) > 0) && ($filtersType[0] !=
"generated")) {
72 if (
$q) $queries[] =
$q;
76 return parent::getQuery();
82 $err = parent::postModify();
96 if (count($this->getTvalue(
"se_filter")) == 1) {
99 $filtersType = $this->
getTValue(
"se_typefilter");
101 $filterType = $filtersType[0];
102 if ($filterType !=
"generated") {
103 $root = simplexml_load_string(
$filter);
106 if (!is_numeric($std->family)) {
107 if (preg_match(
"/([\w:]*)\s?(strict)?/", trim($std->family) , $reg)) {
108 if (!is_numeric($reg[1])) $reg[1] =
getFamIdFromName($this->dbaccess, $reg[1]);
109 if ($reg[2] ==
"strict")
$famid =
'-' . $reg[1];
116 $err = $this->setValue(
"se_famid", abs(
$famid));
117 $err.= $this->setValue(
"se_famonly", (
$famid > 0) ?
"no" :
"yes");
132 if (count($this->getTvalue(
"se_filter")) < 2) {
134 $filters = $this->
getTValue(
"se_filter");
135 $typeFilters = $this->
getTValue(
"se_typefilter");
136 if (count($this->getTvalue(
"se_filter")) == 1) {
137 if ($typeFilters[0] !=
"generated")
return '';
141 $filterXml = sprintf(
"<filter><family>%s%s</family>", $this->
getValue(
"se_famid") , ($this->
getValue(
"se_famonly") ==
"yes" ?
" strict" :
""));
144 foreach ($details as $k => $v) {
151 $filterXml.=
"</filter>";
152 $this->setValue(
"se_typefilter",
"generated");
153 $this->setValue(
"se_filter", $filterXml);
165 $root = simplexml_load_string($xml);
173 if (count(
$q) == 1) {
188 if ($xml->count() == 0) {
189 return current($xml);
191 foreach ($xml as $k => $se) {
192 if (isset($std->$k)) {
193 if (!is_array($std->$k)) $std->$k = array(
196 array_push($std->$k, $this->simpleXml2StdClass($se));
207 if (count($this->getTvalue(
"se_filter")) > 0) {
208 if ($this->defaultview ==
"FREEDOM:VIEWDSEARCH") {
209 $type = $this->getTvalue(
"se_typefilter");
210 if (
$type[0] !=
"generated") {
211 $this->defaultview =
"FDL:VIEWBODYCARD";
219 if (count($this->getTvalue(
"se_filter")) > 0) {
220 $type = $this->getTvalue(
"se_typefilter");
221 if (
$type[0] !=
"generated") {
222 $this->defaultedit =
"FDL:EDITBODYCARD";
224 $oa->setVisibility(
'R');
226 $oa->setVisibility(
'W');
229 $oa->setVisibility(
'W');
247 foreach ($tlp as $lp)
if ($lp ==
"yes") $clp++;
248 foreach ($tlr as $lr)
if ($lr ==
"yes") $clr++;
249 if ($clp != $clr)
$err = sprintf(_(
"parenthesis number mismatch : %d left, %d right") , $clp, $clr);
264 if ((!$this->searchfam) || ($this->searchfam->id != $this->getValue(
"se_famid"))) {
265 $this->searchfam = new_doc($this->dbaccess, $this->
getValue(
"se_famid"));
267 $col = trim(strtok($col,
' '));
269 if (($col ==
"revdate") && ($val !=
'') && (!is_numeric($val))) {
270 $val = stringdatetounixts($val);
276 $oa = $this->searchfam->getAttribute($col);
278 if ($oa) $atype = $oa->type;
279 else if ($this->infofields[$col]) $atype = $this->infofields[$col][
"type"];
280 if (($atype ==
"date" || $atype ==
"timestamp")) {
281 if ($col ==
'revdate') {
283 $val2 = $val + 85399;
287 if (($atype ==
"timestamp")) {
288 $pos = strpos($val,
' ');
291 $hms = substr($val, $pos + 1);
299 if ($oa->isMultiple() &&
getLcdate() !=
'iso') {
304 if (($atype ==
"timestamp") && ($op ==
"=")) {
307 if (strlen($val) == 10) {
309 $val2 = $val .
" 23:59:59";
312 } elseif (strlen($hms) == 2) {
313 $val2 = $val .
' ' . $hms .
":59:59";
314 $val.=
' ' . $hms .
":00:00";
316 } elseif (strlen($hms) == 5) {
317 $val2 = $val .
' ' . $hms .
":59";
318 $val.=
' ' . $hms .
":00";
335 $cond = sprintf(
" (%s is null or %s = 0) ", $col, $col);
340 $cond = sprintf(
" (%s is null) ", $col);
344 $cond = sprintf(
" (%s is null or %s = '') ", $col, $col);
350 $cond =
" " . $col .
" " . trim($op) .
" ";
354 if (trim($val) !=
"") $cond =
" " . $col .
" " . trim($op) .
" " . $this->_pg_val($val) .
" ";
358 if (trim($val) !=
"") $cond =
" " . $col .
"~* '^" . pg_escape_string(trim($val)) .
"' ";
362 if (!is_array($val)) $val = $this->
_val2array($val);
363 if (count($val) > 0) $cond =
" " . $col .
" ~ '\\\\y(" . pg_escape_string(implode(
'|', $val)) .
")\\\\y' ";
368 if ((trim($val) !=
"") && (trim($val2) !=
"")) {
369 $cond = sprintf(
"%s >= %s and %s <= %s", $col, $this->_pg_val($val) , $col, $this->_pg_val($val2));
376 $err =
simpleQuery(
getDbAccessCore() , sprintf(
"select id from users where firstname ~* '%s' or lastname ~* '%s'", pg_escape_string($val) , pg_escape_string($val)) , $ids,
true);
378 if (count($ids) == 0) $cond =
"false";
379 elseif (count($ids) == 1) {
380 $cond =
" " . $col .
" = " . intval($ids[0]) .
" ";
382 $cond =
" " . $col .
" in (" . implode(
',', $ids) .
") ";
389 $otitle = $oa->getOption(
"doctitle");
392 if (!$fid)
$err = sprintf(_(
"no compatible type with operator %s") , $op);
394 if (!is_numeric($fid)) $fid = getFamidFromName($this->dbaccess, $fid);
395 $err =
simpleQuery($this->dbaccess, sprintf(
"select id from doc%d where title ~* '%s'", $fid, pg_escape_string($val)) , $ids,
true);
397 if (count($ids) == 0) $cond =
"false";
398 elseif (count($ids) == 1) {
399 $cond =
" " . $col .
" = '" . intval($ids[0]) .
"' ";
401 $cond =
" " . $col .
" in ('" . implode(
"','", $ids) .
"') ";
406 if ($otitle ==
"auto") $otitle = $oa->id .
"_title";
407 $oat = $this->searchfam->getAttribute($otitle);
409 $cond =
" " . $oat->id .
" ~* '" . pg_escape_string(trim($val)) .
"' ";
411 $err = sprintf(_(
"attribute %s : cannot detect title attribute") , $col);
414 } elseif ($col ==
"fromid") {
415 $err =
simpleQuery($this->dbaccess, sprintf(
"select id from docfam where title ~* '%s'", pg_escape_string($val)) , $ids,
true);
417 if (count($ids) == 0) $cond =
"false";
418 elseif (count($ids) == 1) {
419 $cond =
" " . $col .
" = " . intval($ids[0]) .
" ";
421 $cond =
" " . $col .
" in (" . implode(
",", $ids) .
") ";
428 if ($atype)
$err = sprintf(_(
"attribute %s : %s type is not allowed with %s operator") , $col, $atype, $op);
429 else $err = sprintf(_(
"attribute %s not found [%s]") , $col, $atype);
434 if (trim($val) !=
"") {
435 $cond =
" " . $col .
'_txt' .
" ~ '" . strtolower($val) .
"' ";
441 if (trim($val) !=
"") {
442 $tstatickeys = explode(
' ', $val);
443 if (count($tstatickeys) > 1) {
444 $keyword.= str_replace(
" ",
"&", trim($val));
448 if ($op ==
"@@") $cond =
" " . $col .
'_vec' .
" @@ to_tsquery('french','." .
unaccent(strtolower(
$keyword)) .
"') ";
449 else if ($op ==
"=@") $cond =
"fulltext @@ to_tsquery('french','" .
unaccent(strtolower(
$keyword)) .
"') ";
457 $enum = $oa->getEnum();
458 if (strrpos($val,
'.') !==
false) $val = substr($val, strrpos($val,
'.') + 1);
460 foreach ($enum as $k => $v) {
461 if (in_array($val, explode(
".", $k))) {
462 $tkids[] = substr($k, strrpos(
"." . $k,
'.'));
468 $cond =
" " . $col .
" ~ '\\\\y(" . pg_escape_string(implode(
'|', $tkids)) .
")\\\\y' ";
470 $cond =
" $col='" . implode(
"' or $col='", $tkids) .
"'";
472 } elseif ($op ==
'!=') {
474 $cond1 =
" " . $col .
" !~ '\\\\y(" . pg_escape_string(implode(
'|', $tkids)) .
")\\\\y' ";
476 $cond1 =
" $col !='" . implode(
"' and $col != '", $tkids) .
"'";
478 $cond =
" (($cond1) or ($col is null))";
479 } elseif ($op ==
'!~*') {
480 $cond = sprintf(
"( (%s is null) or (%s %s %s) )", $col, $col, trim($op) , $this->_pg_val($val));
486 if (!is_numeric($val)) $val =
getIdFromName($this->dbaccess, $val);
488 $cond1 =
" " . $col .
" " . trim($op) . $this->_pg_val($val) .
" ";
489 if (($op ==
'!=') || ($op ==
'!~*')) {
490 $cond =
"(($cond1) or ($col is null))";
491 }
else $cond = $cond1;
495 if (!$cond) $cond =
"true";
499 private static function _pg_val(
$s)
501 if (substr(
$s, 0, 2) ==
':@') {
502 return " " . trim(strtok(substr(
$s, 2) ,
" \t")) .
" ";
503 }
else return " '" . pg_escape_string(trim(
$s)) .
"' ";
523 $this->setValue(
"SE_OL", $ol);
527 if ($ol ==
"") $ol =
"and";
529 if (!$this->searchfam) {
530 $this->searchfam = new_doc($this->dbaccess, $this->
getValue(
"se_famid"));
532 if ((count($taid) > 1) || ($taid[0] !=
"")) {
534 foreach ($tkey as $k => $v) {
535 if (strtolower(substr($v, 0, 5)) ==
"::get") {
537 $workdoc = $this->getSearchFamilyDocument();
538 if ($workdoc) $rv = $workdoc->ApplyMethod($v);
539 else $rv = $this->ApplyMethod($v);
542 if (substr($v, 0, 1) ==
"?") {
544 $rv = getHttpVars(substr($v, 1) ,
"-");
545 if ($rv ==
"-")
return (
false);
546 if ($rv ===
"" || $rv ===
" ") unset($taid[$k]);
547 else $tkey[$k] = $rv;
549 if ($taid[$k] ==
"revdate") {
550 list($dd, $mm, $yyyy) = explode(
"/", $tkey[$k]);
551 if ($yyyy > 0) $tkey[$k] = mktime(0, 0, 0, $mm, $dd, $yyyy);
554 foreach ($taid as $k => $v) {
555 $cond1 = $this->
getSqlCond($taid[$k], trim(
$tf[$k]) , $tkey[$k]);
557 if ($tlp[$k] ==
"yes") $cond =
'(' . $cond1 .
" ";
558 else $cond = $cond1 .
" ";
559 if ($tlr[$k] ==
"yes") $cond.=
')';
560 } elseif ($cond1 !=
"") {
561 if ($tols[$k] !=
"") $ol1 = $tols[$k];
563 if ($tlp[$k] ==
"yes") $cond.= $ol1 .
' (' . $cond1 .
" ";
564 else $cond.= $ol1 .
" " . $cond1 .
" ";
565 if ($tlr[$k] ==
"yes") $cond.=
') ';
569 if (trim($cond) ==
"") $cond =
"true";
579 if ((count($tkey) > 1) || ($tkey[0] !=
"")) {
581 foreach ($tkey as $k => $v) {
599 if ((count($tkey) > 1) || ($tkey[0] !=
"")) {
601 foreach ($tkey as $k => $v) {
604 if (getHttpVars(substr($v, 1) ,
"-") ==
"-")
return true;
617 if ((count($tkey) > 1) || ($tkey[0] !=
"")) {
619 foreach ($tkey as $k => $v) {
622 if (getHttpVars(substr($v, 1) ,
"-") !=
"-") {
623 $l.=
'&' . substr($v, 1) .
"=" . getHttpVars(substr($v, 1));
639 if ((count($tkey) > 1) || ($tkey[0] !=
"")) {
641 foreach ($tkey as $k => $v) {
644 $vh = getHttpVars(substr($v, 1) ,
"-");
645 if (($vh !=
"-") && ($vh !=
"")) {
647 if (is_numeric($vh)) {
648 $fam = $this->getSearchFamilyDocument();
650 $oa = $fam->getAttribute($taid[$k]);
651 if ($oa && $oa->type ==
"docid") {
660 if (count($tl) > 0) {
661 $l =
" (" . implode(
", ", $tl) .
")";
664 return $this->
getValue(
"ba_title") . $l;
677 if ((count($taid) > 1) || ($taid[0] !=
"")) {
680 $zpi =
$fdoc->GetNormalAttributes();
681 $zpi[
"state"] =
new BasicAttribute(
"state", $this->fromid, _(
"state"));
682 $zpi[
"title"] =
new BasicAttribute(
"title", $this->fromid, _(
"doctitle"));
683 $zpi[
"revdate"] =
new BasicAttribute(
"revdate", $this->fromid, _(
"revdate"));
684 $zpi[
"cdate"] =
new BasicAttribute(
"cdate", $this->fromid, _(
"cdate") ,
'W',
'',
'',
'date');
685 $zpi[
"revision"] =
new BasicAttribute(
"cdate", $this->fromid, _(
"revision"));
686 $zpi[
"owner"] =
new BasicAttribute(
"owner", $this->fromid, _(
"owner"));
687 $zpi[
"locked"] =
new BasicAttribute(
"owner", $this->fromid, _(
"locked"));
688 $zpi[
"allocated"] =
new BasicAttribute(
"owner", $this->fromid, _(
"allocated"));
689 $zpi[
"svalues"] =
new BasicAttribute(
"svalues", $this->fromid, _(
"any values"));
691 foreach ($taid as $k => $v) {
692 $label = $zpi[$taid[$k]]->getLabel();
694 $tcond[][
"condition"] = sprintf(
"%s %s %s",
$label, $this->
getOperatorLabel(
$tf[$k], $zpi[$taid[$k]]->
type) , ($tkey[$k] !=
"") ? _($tkey[$k]) : $tkey[$k]);
695 if ($tkey[$k][0] ==
'?') {
696 $tparm[substr($tkey[$k], 1) ] = $taid[$k];
699 $this->lay->SetBlockData(
"COND", $tcond);
701 $this->lay->Set(
"ddetail",
"");
709 return ($this->
getValue(
"se_static") !=
"");
715 private function getSearchFamilyDocument()
732 if ((count($taid) > 1) || ($taid[0] !=
"")) {
735 $zpi =
$fdoc->GetNormalAttributes();
736 $zpi[
"state"] =
new BasicAttribute(
"state", $this->fromid, _(
"state"));
737 $zpi[
"title"] =
new BasicAttribute(
"title", $this->fromid, _(
"doctitle"));
738 $zpi[
"revdate"] =
new BasicAttribute(
"revdate", $this->fromid, _(
"revdate"));
739 $zpi[
"cdate"] =
new BasicAttribute(
"cdate", $this->fromid, _(
"cdate") ,
'W',
'',
'',
'date');
740 $zpi[
"revision"] =
new BasicAttribute(
"cdate", $this->fromid, _(
"revision"));
741 $zpi[
"owner"] =
new BasicAttribute(
"owner", $this->fromid, _(
"owner"));
742 $zpi[
"locked"] =
new BasicAttribute(
"owner", $this->fromid, _(
"locked"));
743 $zpi[
"allocated"] =
new BasicAttribute(
"owner", $this->fromid, _(
"allocated"));
744 $zpi[
"svalues"] =
new BasicAttribute(
"svalues", $this->fromid, _(
"any values"));
746 foreach ($taid as $k => $v) {
747 if ($tkey[$k][0] ==
'?') {
748 $tparm[substr($tkey[$k], 1) ] = $taid[$k];
749 $toperator[substr($tkey[$k], 1) ] =
$tf[$k];
752 $this->lay->SetBlockData(
"COND", $tcond);
755 $this->lay->Set(
"ddetail",
"");
756 if (count($tparm) > 0) {
757 include_once (
"FDL/editutil.php");
761 $doc = $this->getSearchFamilyDocument();
764 foreach ($tparm as $k => $v) {
765 if (isset($inputset[$v])) {
767 $vz = $v .
"Z" . $ki;
768 $zpi[$vz] = $zpi[$v];
772 if ($zpi[$v]->fieldSet->type ==
'array') $zpi[$v]->fieldSet->type =
'frame';
774 $inputset[$v] =
true;
776 $ttransfert[] = array(
779 "value" => getHttpVars($k)
781 $tinputs[$k][
"label"] = $zpi[$v]->getLabel();
783 if (($toperator[$k] ==
"=~*" || $toperator[$k] ==
"~*") && $zpi[$v]->
type ==
"docid") $zpi[$v]->type =
"text";
784 if ($zpi[$v]->visibility ==
'R') $zpi[$v]->mvisibility =
'W';
785 if ($zpi[$v]->visibility ==
'S') $zpi[$v]->mvisibility =
'W';
786 if (isset($zpi[$v]->
id)) {
787 $zpi[$v]->isAlone =
true;
791 if ($v ==
"revdate") $aotxt->type =
"date";
795 $this->lay->setBlockData(
"PARAM", $tinputs);
796 $this->lay->setBlockData(
"TRANSFERT", $ttransfert);
797 $this->lay->setBlockData(
"PINPUTS", $ttransfert);
798 $this->lay->Set(
"ddetail",
"none");
799 $this->lay->set(
"stext", _(
"send search"));
800 $this->lay->set(
"saction", getHttpVars(
"saction",
"FREEDOM_VIEW"));
801 $this->lay->set(
"sapp", getHttpVars(
"sapp",
"FREEDOM"));
802 $this->lay->set(
"sid", getHttpVars(
"sid",
"dirid"));
803 $this->lay->set(
"starget", getHttpVars(
"starget",
""));
804 $this->lay->set(
"icon", $this->
getIcon());
815 $this->lay->set(
"ACTION", $action->name);
816 $tclassdoc = array();
817 $action->parent->AddJsRef($action->GetParam(
"CORE_PUBURL") .
"/FDL/Layout/edittable.js");
818 $action->parent->AddJsRef($action->GetParam(
"CORE_PUBURL") .
"/FREEDOM/Layout/editdsearch.js");
822 if (method_exists(
$dir,
"isAuthorized")) {
823 if (
$dir->isAuthorized($classid)) {
825 if (
$dir->hasNoRestriction()) {
826 $tclassdoc =
GetClassesDoc($this->dbaccess, $action->user->id, $classid,
"TABLE");
827 $tclassdoc[] = array(
829 "title" => _(
"any families")
832 $tclassdoc =
$dir->getAuthorizedFamilies();
833 $this->lay->set(
"restrict",
true);
836 $tclassdoc =
$dir->getAuthorizedFamilies();
837 $first = current($tclassdoc);
838 $famid1 = ($first[
"id"]);
839 $this->lay->set(
"restrict",
true);
840 $tfamids = array_keys($tclassdoc);
844 $tclassdoc =
GetClassesDoc($this->dbaccess, $action->user->id, $classid,
"TABLE");
849 if (!is_numeric($onlysubfam)) $onlysubfam =
getFamIdFromName($this->dbaccess, $onlysubfam);
850 $cdoc =
new_Doc($this->dbaccess, $onlysubfam);
851 $tsub = $cdoc->GetChildFam($cdoc->id,
false);
853 $tclassdoc[$classid] = array(
855 "title" => $cdoc->title
857 $tclassdoc = array_merge($tclassdoc, $tsub);
861 $first = current($tclassdoc);
862 if ($classid ==
"") $classid = $first[
"id"];
864 $tclassdoc =
GetClassesDoc($this->dbaccess, $action->user->id, $classid,
"TABLE");
865 $tclassdoc[] = array(
867 "title" => _(
"any families")
872 $this->lay->set(
"onlysubfam", $onlysubfam);
874 foreach ($tclassdoc as $k => $cdoc) {
875 $selectclass[$k][
"idcdoc"] = $cdoc[
"id"];
876 $selectclass[$k][
"classname"] = $cdoc[
"title"];
877 if (abs($cdoc[
"id"]) == abs(
$famid)) {
879 $selectclass[$k][
"selected"] =
"selected";
880 if (
$famid < 0) $this->lay->set(
"selfam", $cdoc[
"title"] .
" " . _(
"(only)"));
881 else $this->lay->set(
"selfam", $cdoc[
"title"]);
882 }
else $selectclass[$k][
"selected"] =
"";
886 if ($this->
id &&
$famid) {
887 $selectclass[] = array(
890 "selected" =>
"selected"
894 $first = current($tclassdoc);
898 $this->lay->Set(
"dirid", $dirid);
899 $this->lay->Set(
"classid", $this->fromid);
900 $this->lay->SetBlockData(
"SELECTCLASS", $selectclass);
905 "title" => _(
"doctitle") ,
906 "revdate" => _(
"revdate") ,
907 "cdate" => _(
"cdate") ,
908 "revision" => _(
"revision") ,
909 "owner" => _(
"id owner") ,
910 "locked" => _(
"id locked") ,
911 "allocated" => _(
"id allocated") ,
912 "svalues" => _(
"any values")
918 "attrdisabled" =>
"disabled",
919 "attrname" => _(
"DocProperties") ,
923 foreach ($internals as $k => $v) {
924 if ($k ==
"revdate")
$type =
"date";
925 else if ($k ==
"owner")
$type =
"docid";
926 else if ($k ==
"locked")
$type =
"docid";
927 else if ($k ==
"allocated")
$type =
"docid";
928 else if ($k ==
"cdate")
$type =
"date";
929 else if ($k ==
"revision")
$type =
"int";
930 else if ($k ==
"state")
$type =
"docid";
935 "ismultiple" =>
'no',
937 "attrdisabled" =>
"",
943 $zpi =
$fdoc->GetNormalAttributes();
945 foreach ($zpi as $k => $v) {
946 if ($v->type ==
"array")
continue;
948 if ($lastSet[0] != $v->fieldSet->id) {
949 $tset = $this->editGetSetAttribute($v->fieldSet);
950 if (count($tset) > 0) $tattr = array_merge($tattr, array_reverse($tset));
955 "ismultiple" => ($v->isMultiple()) ?
'yes' :
'no',
957 "attrdisabled" =>
"",
958 "attrname" => $v->getLabel()
962 $this->lay->SetBlockData(
"ATTR", $tattr);
964 foreach ($this->top as $k => $v) {
966 if (isset($v[
"type"])) {
967 $ctype = implode(
",", $v[
"type"]);
968 if (!in_array(
'text', $v[
"type"])) $display =
'none';
974 "functype" => $ctype,
975 "funcdisplay" => $display,
976 "funcname" => _($v[
"label"])
979 $this->lay->SetBlockData(
"FUNC", $tfunc);
980 foreach ($tfunc as $k => $v) {
981 if (($v[
"functype"] !=
"") && (strpos($v[
"functype"],
"enum") ===
false)) unset($tfunc[$k]);
983 $this->lay->SetBlockData(
"FUNCSTATE", $tfunc);
984 $this->lay->Set(
"icon",
$fdoc->getIcon());
986 if ($this->
getValue(
"SE_LATEST") ==
"no") $this->lay->Set(
"select_all",
"selected");
987 else $this->lay->Set(
"select_all",
"");
990 if (
$fdoc->wid > 0) {
995 while (list($k, $v) = each(
$states)) {
1001 $this->lay->SetBlockData(
"STATE", $tstates);
1002 $this->lay->Set(
"dstate",
"inline");
1004 $this->lay->Set(
"dstate",
"none");
1018 if ((count($taid) > 1) || ($taid[0] !=
"")) {
1019 foreach ($taid as $k => $va) {
1022 $oa =
$fdoc->getAttribute($taid[$k]);
1024 "OLCOND" =>
"olcond$k",
1025 "ATTRCOND" =>
"attrcond$k",
1026 "FUNCCOND" =>
"funccond$k",
1027 "ISENUM" => (($taid[$k] ==
"state") || ($oa->type ==
"enum")) ,
1028 "SSTATE" =>
"sstate$k",
1029 "ols_and_selected" => (
$tol[$k] ==
"and") ?
"selected" :
"",
1030 "ols_or_selected" => (
$tol[$k] ==
"or") ?
"selected" :
"",
1031 "leftp_none_selected" => ($tlp[$k] !=
"yes") ?
"selected" :
"",
1032 "leftp_open_selected" => ($tlp[$k] ==
"yes") ?
"selected" :
"",
1033 "rightp_none_selected" => ($trp[$k] !=
"yes") ?
"selected" :
"",
1034 "rightp_open_selected" => ($trp[$k] ==
"yes") ?
"selected" :
"",
1039 if ($taid[$k] ==
"state") {
1041 $stateselected =
false;
1042 foreach (
$states as $ks => $vs) {
1045 "sstate_selected" => ($vs == $v) ?
"selected" :
"",
1046 "sstatename" => _($vs)
1048 if ($vs == $v) $stateselected =
true;
1050 if (!$stateselected) $tcond[$k][
"ISENUM"] =
false;
1051 $this->lay->SetBlockData(
"sstate$k", $tstates);
1054 "attrid" => $taid[$k],
1055 "ismultiple" =>
'no',
1056 "attrtype" =>
"docid",
1057 "attrselected" =>
"selected",
1058 "attrname" => _(
"state")
1061 if ($oa->type ==
"enum") {
1062 $te = $oa->getEnum();
1064 $enumselected =
false;
1065 foreach ($te as $ks => $vs) {
1068 "sstate_selected" => ($ks == $v) ?
"selected" :
"",
1071 if ($ks == $v) $enumselected =
true;
1073 $this->lay->SetBlockData(
"sstate$k", $tstates);
1074 if (!$enumselected) $tcond[$k][
"ISENUM"] =
false;
1078 "attrid" =>
"_prop",
1079 "ismultiple" =>
'no',
1080 "attrtype" =>
"set",
1081 "attrdisabled" =>
"disabled",
1082 "attrselected" =>
"",
1083 "attrname" => _(
"DocProperties")
1086 foreach ($internals as $ki => $vi) {
1087 if ($ki ==
"revdate")
$type =
"date";
1088 else if ($ki ==
"owner")
$type =
"docid";
1089 else $type =
"text";
1093 "ismultiple" =>
'no',
1094 "attrtype" =>
$type,
1095 "attrselected" => ($taid[$k] == $ki) ?
"selected" :
"",
1096 "attrdisabled" =>
"",
1101 $this->editGetSetAttribute(null,
true);
1102 foreach ($zpi as $ki => $vi) {
1104 if ($lastSet[0] != $vi->fieldSet->id) {
1106 $tset = $this->editGetSetAttribute($vi->fieldSet);
1107 if (count($tset) > 0) $tattr = array_merge($tattr, array_reverse($tset));
1111 "attrid" => $vi->id,
1112 "ismultiple" => ($vi->isMultiple()) ?
'yes' :
'no',
1113 "attrtype" =>
$type,
1114 "attrselected" => ($taid[$k] == $vi->id) ?
"selected" :
"",
1115 "attrdisabled" =>
"",
1116 "attrname" => $vi->getLabel()
1120 $this->lay->SetBlockData(
"attrcond$k", $tattr);
1124 foreach ($this->top as $ki => $vi) {
1125 $oa =
$fdoc->getAttribute($taid[$k]);
1128 if ($taid[$k] ==
"title")
$type =
"text";
1129 elseif ($taid[$k] ==
"cdate")
$type =
"date";
1130 elseif ($taid[$k] ==
"revision")
$type =
"int";
1131 elseif ($taid[$k] ==
"allocated")
$type =
"docid";
1132 elseif ($taid[$k] ==
"locked")
$type =
"docid";
1133 elseif ($taid[$k] ==
"revdate")
$type =
"date";
1134 elseif ($taid[$k] ==
"owner")
$type =
"docid";
1135 elseif ($taid[$k] ==
"svalues")
$type =
"text";
1136 elseif ($taid[$k] ==
"state")
$type =
"enum";
1138 if ($oa->inArray() && ($oa->type !=
'file'))
$type =
"array";
1142 if (isset($vi[
"type"])) {
1143 if (!in_array(
$type, $vi[
"type"])) $display =
'none';
1144 $ctype = implode(
",", $vi[
"type"]);
1146 if (
$tf[$k] == $ki &&
$type ==
'docid' && $display ==
'' && ($ki ==
'=' || $ki ==
'!=')) {
1147 $docid_aid = $taid[$k];
1151 "func_selected" => (
$tf[$k] == $ki) ?
"selected" :
"",
1152 "func_display" => $display,
1153 "func_type" => $ctype,
1154 "func_name" => _($vi[
"label"])
1157 $this->lay->SetBlockData(
"funccond$k", $tfunc);
1160 foreach ($this->tol as $ki => $vi) {
1163 "ol_selected" => (
$tol[$k] == $ki) ?
"selected" :
"",
1167 $this->lay->SetBlockData(
"olcond$k", $tols);
1168 if (is_numeric($v) && (!empty($docid_aid))) {
1169 $tcond[$k][
"ISENUM"] =
false;
1170 $tcond[$k][
"ISDOCID"] =
true;
1171 $tcond[$k][
"DOCID_AID"] = $docid_aid;
1172 $tcond[$k][
"DOCID_AIDINDEX"] = $docid_aid . $k;
1173 $tcond[$k][
"DOCID_TITLE"] = $this->
getTitle($v);
1174 $tcond[$k][
"FAMID"] = abs(
$famid);
1176 $tcond[$k][
"ISDOCID"] =
false;
1177 $tcond[$k][
"DOCID_AID"] = 0;
1178 $tcond[$k][
"DOCID_AIDINDEX"] = 0;
1179 $tcond[$k][
"DOCID_TITLE"] =
'';
1180 $tcond[$k][
"FAMID"] = abs(
$famid);
1184 if (count($tcond) > 0) $this->lay->SetBlockData(
"CONDITIONS", $tcond);
1187 foreach ($zpi as $k => $v) {
1188 if (($v->type ==
"enum") || ($v->type ==
"enumlist")) {
1190 "SELENUM" =>
"ENUM$k",
1193 $tenum = $v->getEnum();
1195 foreach ($tenum as $ke => $ve) {
1201 $this->lay->setBlockData(
"ENUM$k", $te);
1205 $this->lay->setBlockData(
"ENUMS", $tenums);
1207 $this->lay->Set(
"id", $this->
id);
1211 private function editGetSetAttribute($fs, $reset =
false)
1213 static $setAttribute = array();
1216 if ($reset) $setAttribute = array();
1217 while ($fs && $fs->id !=
'FIELD_HIDDENS') {
1218 if (!in_array($fs->id, $setAttribute)) {
1220 "attrid" => $fs->id,
1221 "attrtype" =>
"set",
1222 "attrdisabled" =>
"disabled",
1223 "attrselected" =>
"",
1224 "attrname" => $fs->getLabel()
1226 $setAttribute[] = $fs->id;
1228 $fs = $fs->fieldSet;