Exemplo n.º 1
0
 protected function get_field($field, $type)
 {
     global $charset;
     global $msg;
     global $lang;
     //Récupération des valeurs du POST
     $field_name = $this->get_field_name($field, $type);
     $values = $this->get_values_from_field($field_name, $type);
     $display = "<div class='row'>";
     $display .= "<label class='etiquette'>" . get_msg_to_display($field['TITLE']) . "</label>";
     $display .= "</div>";
     $display .= "<div class='row'>";
     switch ($field['INPUT_TYPE']) {
         case "authoritie":
             if ($values[0] != 0) {
                 switch ($field['INPUT_OPTIONS']['SELECTOR']) {
                     case "auteur":
                         $aut = new auteur($values[0]);
                         if ($aut->rejete) {
                             $libelle = $aut->name . ', ' . $aut->rejete;
                         } else {
                             $libelle = $aut->name;
                         }
                         if ($aut->date) {
                             $libelle .= " ({$aut->date})";
                         }
                         break;
                     case "categorie":
                         $libelle = categories::getlibelle($values[0], $lang);
                         break;
                     case "editeur":
                         $ed = new editeur($values[0]);
                         $libelle = $ed->name;
                         if ($ed->ville) {
                             if ($ed->pays) {
                                 $libelle .= " ({$ed->ville} - {$ed->pays})";
                             } else {
                                 $libelle .= " ({$ed->ville})";
                             }
                         }
                         break;
                     case "collection":
                         $coll = new collection($values[0]);
                         $libelle = $coll->name;
                         break;
                     case "subcollection":
                         $coll = new subcollection($values[0]);
                         $libelle = $coll->name;
                         break;
                     case "serie":
                         $serie = new serie($values[0]);
                         $libelle = $serie->name;
                         break;
                     case "indexint":
                         $indexint = new indexint($values[0]);
                         if ($indexint->comment) {
                             $libelle = $indexint->name . " - " . $indexint->comment;
                         } else {
                             $libelle = $indexint->name;
                         }
                         if ($thesaurus_classement_mode_pmb != 0) {
                             $libelle = "[" . $indexint->name_pclass . "] " . $libelle;
                         }
                         break;
                     case "titre_uniforme":
                         $tu = new titre_uniforme($values[0]);
                         $libelle = $tu->name;
                         break;
                     default:
                         $libelle = $values[0];
                         break;
                 }
             } else {
                 $libelle = "";
             }
             if ($field['INPUT_OPTIONS']['ATT_ID_FILTER']) {
                 $att_id_filter = "att_id_filter='" . $field['INPUT_OPTIONS']['ATT_ID_FILTER'] . "'";
             } else {
                 $att_id_filter = "";
             }
             $display .= "<input type='text' id='" . $field_name . "' name='" . $field_name . "[]' autfield='" . $field_name . "' autocomplete='off' completion='" . $field["INPUT_OPTIONS"]["AJAX"] . "'  value='" . htmlentities($libelle, ENT_QUOTES, $charset) . "' class='saisie-80em' {$att_id_filter} />";
             break;
         case "text":
             if ($field['INPUT_OPTIONS']['IFSEARCHEMPTY']) {
                 $this->js_dynamic_check_form .= "if(!document.getElementById('" . $field_name . "').value) document.getElementById('" . $field_name . "').value='" . $field['INPUT_OPTIONS']['IFSEARCHEMPTY'] . "';";
             }
             if (substr($field['INPUT_OPTIONS']['PLACEHOLDER'], 0, 4) == "msg:") {
                 $input_placeholder = $msg[substr($field['INPUT_OPTIONS']['PLACEHOLDER'], 4, strlen($field['INPUT_OPTIONS']['PLACEHOLDER']) - 4)];
             } else {
                 $input_placeholder = $field['INPUT_OPTIONS']["PLACEHOLDER"];
             }
             $display .= "<input type='text' id='" . $field_name . "' name='" . $field_name . "[]' value='" . htmlentities($values[0], ENT_QUOTES, $charset) . "' class='saisie-80em' " . ($input_placeholder ? "placeholder='" . htmlentities($input_placeholder, ENT_QUOTES, $charset) . "'" : "") . "/>";
             break;
         case "query_list":
             $query = $field["INPUT_OPTIONS"]["QUERY"][0]["value"];
             if ($field["INPUT_OPTIONS"]["FILTERING"] == "yes") {
                 $query = str_replace("!!acces_j!!", "", $query);
                 $query = str_replace("!!statut_j!!", "", $query);
                 $query = str_replace("!!statut_r!!", "", $query);
             }
             if ($field["INPUT_OPTIONS"]["QUERY"][0]["USE_GLOBAL"]) {
                 $use_global = explode(",", $field["INPUT_OPTIONS"]["QUERY"][0]["USE_GLOBAL"]);
                 for ($j = 0; $j < count($use_global); $j++) {
                     $var_global = $use_global[$j];
                     global ${$var_global};
                     $query = str_replace("!!" . $var_global . "!!", ${$var_global}, $query);
                 }
             }
             $display .= "<select name='" . $field_name . "[]' style='width:40em;'>";
             if ($field["INPUT_OPTIONS"]["QUERY"][0]["ALLCHOICE"] == "yes") {
                 $display .= "<option value=''>" . htmlentities(get_msg_to_display($field["INPUT_OPTIONS"]["QUERY"][0]["TITLEALLCHOICE"]), ENT_QUOTES, $charset) . "</option>";
             }
             $result = pmb_mysql_query($query);
             while ($row = pmb_mysql_fetch_array($result)) {
                 $display .= "<option value='" . htmlentities($row[0], ENT_QUOTES, $charset) . "' ";
                 $as = array_search($row[0], $values);
                 if ($as !== null && $as !== false) {
                     $display .= " selected";
                 }
                 $display .= ">" . htmlentities($row[1], ENT_QUOTES, $charset) . "</option>";
             }
             $display .= "</select>";
             break;
         case "list":
             $options = $field["INPUT_OPTIONS"]["OPTIONS"][0];
             $display .= "<select name='" . $field_name . "[]' style='width:40em;'>";
             sort($options["OPTION"]);
             for ($i = 0; $i < count($options["OPTION"]); $i++) {
                 $display .= "<option value='" . htmlentities($options["OPTION"][$i]["VALUE"], ENT_QUOTES, $charset) . "' ";
                 $as = array_search($options["OPTION"][$i]["VALUE"], $values);
                 if ($as !== null && $as !== false) {
                     $display .= " selected";
                 }
                 if (substr($options["OPTION"][$i]["value"], 0, 4) == "msg:") {
                     $display .= ">" . htmlentities($msg[substr($options["OPTION"][$i]["value"], 4, strlen($options["OPTION"][$i]["value"]) - 4)], ENT_QUOTES, $charset) . "</option>";
                 } else {
                     $display .= ">" . htmlentities($options["OPTION"][$i]["value"], ENT_QUOTES, $charset) . "</option>";
                 }
             }
             $display .= "</select>";
             break;
         case "marc_list":
             $options = new marc_list($field["INPUT_OPTIONS"]["NAME"][0]["value"]);
             $tmp = array();
             $tmp = $options->table;
             $tmp = array_map("convert_diacrit", $tmp);
             //On enlève les accents
             $tmp = array_map("strtoupper", $tmp);
             //On met en majuscule
             asort($tmp);
             //Tri sur les valeurs en majuscule sans accent
             foreach ($tmp as $key => $value) {
                 $tmp[$key] = $options->table[$key];
                 //On reprend les bons couples clé / libellé
             }
             $options->table = $tmp;
             reset($options->table);
             // gestion restriction par code utilise.
             $existrestrict = false;
             if ($field["INPUT_OPTIONS"]["RESTRICTQUERY"][0]["value"]) {
                 $restrictquery = pmb_mysql_query($field["INPUT_OPTIONS"]["RESTRICTQUERY"][0]["value"]);
                 if ($restrictqueryrow = @pmb_mysql_fetch_row($restrictquery)) {
                     if ($restrictqueryrow[0]) {
                         $restrictqueryarray = explode(",", $restrictqueryrow[0]);
                         $existrestrict = true;
                     }
                 }
             }
             $display .= "<select name='" . $field_name . "[]' class=\"ext_search_txt\">";
             if ($field["INPUT_OPTIONS"]["RESTRICTQUERY"][0]["ALLCHOICE"] == "yes") {
                 $display .= "<option value=''>" . htmlentities(get_msg_to_display($field["INPUT_OPTIONS"]["RESTRICTQUERY"][0]["TITLEALLCHOICE"]), ENT_QUOTES, $charset) . "</option>";
             }
             while (list($key, $val) = each($options->table)) {
                 if ($existrestrict && array_search($key, $restrictqueryarray) !== false) {
                     $display .= "<option value='" . htmlentities($key, ENT_QUOTES, $charset) . "' ";
                     $as = array_search($key, $values);
                     if ($as !== null && $as !== false) {
                         $display .= " selected";
                     }
                     $display .= ">" . htmlentities($val, ENT_QUOTES, $charset) . "</option>";
                 } elseif (!$existrestrict) {
                     $display .= "<option value='" . htmlentities($key, ENT_QUOTES, $charset) . "' ";
                     $as = array_search($key, $values);
                     if ($as !== null && $as !== false) {
                         $display .= " selected";
                     }
                     $display .= ">" . htmlentities($val, ENT_QUOTES, $charset) . "</option>";
                 }
             }
             $display .= "</select>";
             break;
         case "date":
             $date_formatee = format_date_input($values[0]);
             $date_clic = "onClick=\"openPopUp('./select.php?what=calendrier&caller=search_form&date_caller=" . str_replace('-', '', $values[0]) . "&param1=" . $field_name . "_date&param2=" . $field_name . "[]&auto_submit=NO&date_anterieure=YES&format_return=IN', '" . $field_name . "_date', 250, 300, -2, -2, 'toolbar=no, dependent=yes, resizable=yes')\"  ";
             if (substr($field['INPUT_OPTIONS']["PLACEHOLDER"], 0, 4) == "msg:") {
                 $input_placeholder = $msg[substr($field['INPUT_OPTIONS']["PLACEHOLDER"], 4, strlen($field['INPUT_OPTIONS']["PLACEHOLDER"]) - 4)];
             } else {
                 $input_placeholder = $field['INPUT_OPTIONS']["PLACEHOLDER"];
             }
             $display .= "<input type='hidden' name='" . $field_name . "_date' value='" . str_replace('-', '', $values[0]) . "' />\n\t\t\t\t\t<input type='text' name='" . $field_name . "[]' value='" . htmlentities($date_formatee, ENT_QUOTES, $charset) . "' " . ($input_placeholder ? "placeholder='" . htmlentities($input_placeholder, ENT_QUOTES, $charset) . "'" : "") . "/>\n\t\t\t\t\t<input class='bouton_small' type='button' name='" . $field_name . "_date_lib_bouton' value='" . $msg["bouton_calendrier"] . "' " . $date_clic . " />";
             break;
     }
     $display .= "</div>";
     return $display;
 }
Exemplo n.º 2
0
 function get_field($i, $n, $search, $pp)
 {
     global $charset;
     global $aff_list_empr_search;
     global $msg;
     global $include_path;
     global $thesaurus_classement_mode_pmb;
     global $pmb_map_size_search_edition;
     $r = "";
     $s = explode("_", $search);
     //Champ
     $val = "field_" . $i . "_" . $search;
     global ${$val};
     $v = ${$val};
     if ($v == "") {
         $v = array();
     }
     //Variables
     $fieldvar_ = "fieldvar_" . $i . "_" . $search;
     global ${$fieldvar_};
     $fieldvar = ${$fieldvar_};
     if ($s[0] == "f") {
         //Champs fixes
         $ff = $this->fixedfields[$s[1]];
         //Variables globales et input
         for ($j = 0; $j < count($ff["VAR"]); $j++) {
             switch ($ff["VAR"][$j]["TYPE"]) {
                 case "input":
                     $valvar = "fieldvar_" . $i . "_" . $search . "[\"" . $ff["VAR"][$j]["NAME"] . "\"]";
                     global ${$valvar};
                     $vvar[$ff["VAR"][$j]["NAME"]] = ${$valvar};
                     if ($vvar[$ff["VAR"][$j]["NAME"]] == "") {
                         $vvar[$ff["VAR"][$j]["NAME"]] = array();
                     }
                     $var_table[$ff["VAR"][$j]["NAME"]] = $vvar[$ff["VAR"][$j]["NAME"]];
                     break;
                 case "global":
                     $global_name = $ff["VAR"][$j]["NAME"];
                     global ${$global_name};
                     $var_table[$ff["VAR"][$j]["NAME"]] = ${$global_name};
                     break;
             }
         }
         switch ($ff["INPUT_TYPE"]) {
             case "authoritie_external":
                 $r = "";
                 $op = "op_" . $i . "_" . $search;
                 global ${$op};
                 global $lang;
                 $libelle = "";
                 if (${$op} == "AUTHORITY") {
                     if ($v[0] != 0) {
                         switch ($ff['INPUT_OPTIONS']['SELECTOR']) {
                             case "auteur":
                                 $aut = new auteur($v[0]);
                                 if ($aut->rejete) {
                                     $libelle = $aut->name . ', ' . $aut->rejete;
                                 } else {
                                     $libelle = $aut->name;
                                 }
                                 if ($aut->date) {
                                     $libelle .= " ({$aut->date})";
                                 }
                                 break;
                             case "categorie":
                                 $libelle = categories::getlibelle($v[0], $lang);
                                 break;
                             case "editeur":
                                 $ed = new editeur($v[0]);
                                 $libelle = $ed->name;
                                 if ($ed->ville) {
                                     if ($ed->pays) {
                                         $libelle .= " ({$ed->ville} - {$ed->pays})";
                                     } else {
                                         $libelle .= " ({$ed->ville})";
                                     }
                                 }
                                 break;
                             case "collection":
                                 $coll = new collection($v[0]);
                                 $libelle = $coll->name;
                                 break;
                             case "subcollection":
                                 $coll = new subcollection($v[0]);
                                 $libelle = $coll->name;
                                 break;
                             case "serie":
                                 $serie = new serie($v[0]);
                                 $libelle = $serie->name;
                                 break;
                             case "indexint":
                                 $indexint = new indexint($v[0]);
                                 if ($indexint->comment) {
                                     $libelle = $indexint->name . " - " . $indexint->comment;
                                 } else {
                                     $libelle = $indexint->name;
                                 }
                                 if ($thesaurus_classement_mode_pmb != 0) {
                                     $libelle = "[" . $indexint->name_pclass . "] " . $libelle;
                                 }
                                 break;
                             case "titre_uniforme":
                                 $tu = new titre_uniforme($v[0]);
                                 $libelle = $tu->name;
                                 break;
                             case "notice":
                                 $requete = "select if(serie_name is not null,if(tnvol is not null,concat(serie_name,', ',tnvol,'. ',tit1),concat(serie_name,'. ',tit1)),tit1) AS tit from notices left join series on serie_id=tparent_id where notice_id='" . $v[0] . "' ";
                                 $res = pmb_mysql_query($requete);
                                 if ($res && pmb_mysql_num_rows($res)) {
                                     $libelle = pmb_mysql_result($res, 0, 0);
                                 } else {
                                     $libelle = $v[0];
                                 }
                                 break;
                             default:
                                 $libelle = $v[0];
                                 break;
                         }
                     }
                     ${$op} == "BOOLEAN";
                     $r = "<script>document.forms['search_form']." . $op . ".options[0].selected=true;</script>";
                 }
                 if ($libelle) {
                     $r .= "<input type='text' name='field_" . $n . "_" . $search . "[]' value='" . htmlentities($libelle, ENT_QUOTES, $charset) . "'/>";
                 } else {
                     $r .= "<input type='text' name='field_" . $n . "_" . $search . "[]' value='" . htmlentities($v[0], ENT_QUOTES, $charset) . "'/>";
                 }
                 break;
             case "authoritie":
                 $fnamesans = "field_" . $n . "_" . $search;
                 $fname = "field_" . $n . "_" . $search . "[]";
                 $fname_id = "field_" . $n . "_" . $search . "_id";
                 $fnamesanslib = "field_" . $n . "_" . $search . "_lib";
                 $fnamelib = "field_" . $n . "_" . $search . "_lib[]";
                 $fname_name_aut_id = "fieldvar_" . $n . "_" . $search . "[authority_id][]";
                 $fname_aut_id = "fieldvar_" . $n . "_" . $search . "_authority_id";
                 $ajax = $ff["INPUT_OPTIONS"]["AJAX"];
                 $selector = $ff["INPUT_OPTIONS"]["SELECTOR"];
                 $p1 = $ff["INPUT_OPTIONS"]["P1"];
                 $p2 = $ff["INPUT_OPTIONS"]["P2"];
                 global $thesaurus_mode_pmb;
                 if ($ajax == "categories_mul" and $thesaurus_mode_pmb == 1) {
                     $fnamevar_id = "linkfield=\"fieldvar_" . $n . "_" . $search . "[id_thesaurus][]\"";
                     $fnamevar_id_js = "fieldvar_" . $n . "_" . $search . "[id_thesaurus][]";
                 } else {
                     $fnamevar_id = "";
                     $fnamevar_id_js = "";
                 }
                 $op = "op_" . $i . "_" . $search;
                 global ${$op};
                 global $lang;
                 $nb_values = count($v);
                 if (!$nb_values) {
                     //Création de la ligne
                     $nb_values = 1;
                 }
                 $nb_max_aut = $nb_values - 1;
                 $r = "<input type='hidden' id='{$fnamesans}" . "_max_aut' value='" . $nb_max_aut . "'>";
                 $r .= "<input class='bouton' value='...' id='{$fnamesans}" . "_authority_selector' onclick=\"openPopUp('./select.php?what={$selector}&caller=search_form&mode=un&p1=" . $fname_id . "_0&p2=" . $fnamesanslib . "_0&deb_rech='+" . pmb_escape() . "(document.getElementById('" . $fnamesanslib . "_0').value)+'&callback=authoritySelected&infield=" . $fnamesans . "_0', 'select_author0', 400, 400, -2, -2, 'scrollbars=yes, toolbar=no, dependent=yes, resizable=yes')\" type=\"button\">";
                 $r .= "<input class='bouton' type='button' value='+' onclick='add_line(\"{$fnamesans}\")'>";
                 $r .= "<div id='el{$fnamesans}'>";
                 for ($inc = 0; $inc < $nb_values; $inc++) {
                     $r .= "<input id='" . $fnamesans . "_" . $inc . "' name='{$fname}' value='" . htmlentities($v[$inc], ENT_QUOTES, $charset) . "' type='hidden' />";
                     if (${$op} == "AUTHORITY") {
                         if ($v[$inc] != 0) {
                             switch ($ff['INPUT_OPTIONS']['SELECTOR']) {
                                 case "auteur":
                                     $aut = new auteur($v[$inc]);
                                     if ($aut->rejete) {
                                         $libelle = $aut->name . ', ' . $aut->rejete;
                                     } else {
                                         $libelle = $aut->name;
                                     }
                                     if ($aut->date) {
                                         $libelle .= " ({$aut->date})";
                                     }
                                     break;
                                 case "categorie":
                                     $libelle = categories::getlibelle($v[$inc], $lang);
                                     break;
                                 case "editeur":
                                     $ed = new editeur($v[$inc]);
                                     $libelle = $ed->name;
                                     if ($ed->ville) {
                                         if ($ed->pays) {
                                             $libelle .= " ({$ed->ville} - {$ed->pays})";
                                         } else {
                                             $libelle .= " ({$ed->ville})";
                                         }
                                     }
                                     break;
                                 case "collection":
                                     $coll = new collection($v[$inc]);
                                     $libelle = $coll->name;
                                     break;
                                 case "subcollection":
                                     $coll = new subcollection($v[$inc]);
                                     $libelle = $coll->name;
                                     break;
                                 case "serie":
                                     $serie = new serie($v[$inc]);
                                     $libelle = $serie->name;
                                     break;
                                 case "indexint":
                                     $indexint = new indexint($v[$inc]);
                                     if ($indexint->comment) {
                                         $libelle = $indexint->name . " - " . $indexint->comment;
                                     } else {
                                         $libelle = $indexint->name;
                                     }
                                     if ($thesaurus_classement_mode_pmb != 0) {
                                         $libelle = "[" . $indexint->name_pclass . "] " . $libelle;
                                     }
                                     break;
                                 case "titre_uniforme":
                                     $tu = new titre_uniforme($v[$inc]);
                                     $libelle = $tu->name;
                                     break;
                                 default:
                                     $libelle = $v[$inc];
                                     break;
                             }
                         } else {
                             $libelle = "";
                         }
                         $r .= "<input autfield='" . $fname_id . "_" . $inc . "' onkeyup='fieldChanged(\"" . $fnamesans . "\"," . $inc . ",this.value,event)' callback='authoritySelected' completion='{$ajax}' {$fnamevar_id} id='" . $fnamesanslib . "_" . $inc . "' name='{$fnamelib}' value='" . htmlentities($libelle, ENT_QUOTES, $charset) . "' type='text' class='saisie-20emr'/>\n\t\t\t\t\t\t\t\t";
                     } else {
                         $r .= "<input autfield='" . $fname_id . "_" . $inc . "' onkeyup='fieldChanged(\"" . $fnamesans . "\"," . $inc . ",this.value,event)' callback='authoritySelected' completion='{$ajax}' {$fnamevar_id} id='" . $fnamesanslib . "_" . $inc . "' name='{$fnamelib}' value='" . htmlentities($v[$inc], ENT_QUOTES, $charset) . "' type='text' />\n\t\t\t\t\t\t\t\t";
                     }
                     $r .= "<input class='bouton' type='button' onclick='this.form." . $fnamesanslib . "_" . $inc . ".value=\"\";this.form." . $fnamesans . "_" . $inc . ".value=\"0\";' value='X'>";
                     $r .= "<input type='hidden' value='" . ($fieldvar['authority_id'][$inc] ? $fieldvar['authority_id'][$inc] : "") . "' id='" . $fname_aut_id . "_" . $inc . "' name='{$fname_name_aut_id}' />";
                     $r .= "<input name='{$fname_id}' id='" . $fname_id . "_" . $inc . "' value='" . htmlentities($v[$inc], ENT_QUOTES, $charset) . "' type='hidden'><br>";
                 }
                 $r .= "</div>";
                 if ($nb_values > 1) {
                     $r .= "<script>\n\t\t\t\t\t\t\t\t\tdocument.getElementById('op_" . $i . "_" . $search . "').disabled=true;\n\t\t\t\t\t\t\t\t\toperators_to_enable.push('op_" . $i . "_" . $search . "');\n\t\t\t\t\t\t\t\t</script>";
                 }
                 break;
             case "text":
                 if (substr($ff['INPUT_OPTIONS']["PLACEHOLDER"], 0, 4) == "msg:") {
                     $input_placeholder = $msg[substr($ff['INPUT_OPTIONS']["PLACEHOLDER"], 4, strlen($ff['INPUT_OPTIONS']["PLACEHOLDER"]) - 4)];
                 } else {
                     $input_placeholder = $ff['INPUT_OPTIONS']["PLACEHOLDER"];
                 }
                 $r = "<input type='text' name='field_" . $n . "_" . $search . "[]' value='" . htmlentities($v[0], ENT_QUOTES, $charset) . "' " . ($input_placeholder ? "placeholder='" . htmlentities($input_placeholder, ENT_QUOTES, $charset) . "'" : "") . "/>";
                 break;
             case "query_list":
                 $requete = $ff["INPUT_OPTIONS"]["QUERY"][0]["value"];
                 if ($ff["INPUT_OPTIONS"]["FILTERING"] == "yes") {
                     $requete = str_replace("!!acces_j!!", "", $requete);
                     $requete = str_replace("!!statut_j!!", "", $requete);
                     $requete = str_replace("!!statut_r!!", "", $requete);
                 }
                 if ($ff["INPUT_OPTIONS"]["QUERY"][0]["USE_GLOBAL"]) {
                     $use_global = explode(",", $ff["INPUT_OPTIONS"]["QUERY"][0]["USE_GLOBAL"]);
                     for ($j = 0; $j < count($use_global); $j++) {
                         $var_global = $use_global[$j];
                         global ${$var_global};
                         $requete = str_replace("!!" . $var_global . "!!", ${$var_global}, $requete);
                     }
                 }
                 $resultat = pmb_mysql_query($requete);
                 $r = "<select name='field_" . $n . "_" . $search . "[]' multiple size='5' style='width:40em;'>";
                 while ($opt = pmb_mysql_fetch_row($resultat)) {
                     $r .= "<option value='" . htmlentities($opt[0], ENT_QUOTES, $charset) . "' ";
                     $as = array_search($opt[0], $v);
                     if ($as !== null && $as !== false) {
                         $r .= " selected";
                     }
                     $r .= ">" . htmlentities($opt[1], ENT_QUOTES, $charset) . "</option>";
                 }
                 $r .= "</select>";
                 break;
             case "list":
                 $options = $ff["INPUT_OPTIONS"]["OPTIONS"][0];
                 $r = "<select name='field_" . $n . "_" . $search . "[]' multiple size='5' style='width:40em;'>";
                 sort($options["OPTION"]);
                 for ($i = 0; $i < count($options["OPTION"]); $i++) {
                     $r .= "<option value='" . htmlentities($options["OPTION"][$i]["VALUE"], ENT_QUOTES, $charset) . "' ";
                     $as = array_search($options["OPTION"][$i]["VALUE"], $v);
                     if ($as !== null && $as !== false) {
                         $r .= " selected";
                     }
                     if (substr($options["OPTION"][$i]["value"], 0, 4) == "msg:") {
                         $r .= ">" . htmlentities($msg[substr($options["OPTION"][$i]["value"], 4, strlen($options["OPTION"][$i]["value"]) - 4)], ENT_QUOTES, $charset) . "</option>";
                     } else {
                         $r .= ">" . htmlentities($options["OPTION"][$i]["value"], ENT_QUOTES, $charset) . "</option>";
                     }
                 }
                 $r .= "</select>";
                 break;
             case "marc_list":
                 $options = new marc_list($ff["INPUT_OPTIONS"]["NAME"][0]["value"]);
                 $tmp = array();
                 $tmp = $options->table;
                 $tmp = array_map("convert_diacrit", $tmp);
                 //On enlève les accents
                 $tmp = array_map("strtoupper", $tmp);
                 //On met en majuscule
                 asort($tmp);
                 //Tri sur les valeurs en majuscule sans accent
                 foreach ($tmp as $key => $value) {
                     $tmp[$key] = $options->table[$key];
                     //On reprend les bons couples clé / libellé
                 }
                 $options->table = $tmp;
                 reset($options->table);
                 // gestion restriction par code utilise.
                 if ($ff["INPUT_OPTIONS"]["RESTRICTQUERY"][0]["value"]) {
                     $restrictquery = pmb_mysql_query($ff["INPUT_OPTIONS"]["RESTRICTQUERY"][0]["value"]);
                     if ($restrictqueryrow = @pmb_mysql_fetch_row($restrictquery)) {
                         if ($restrictqueryrow[0]) {
                             $restrictqueryarray = explode(",", $restrictqueryrow[0]);
                             $existrestrict = true;
                         } else {
                             $existrestrict = false;
                         }
                     } else {
                         $existrestrict = false;
                     }
                 } else {
                     $existrestrict = false;
                 }
                 $r = "<select name='field_" . $n . "_" . $search . "[]' multiple size='5' class=\"ext_search_txt\">";
                 while (list($key, $val) = each($options->table)) {
                     if ($existrestrict && array_search($key, $restrictqueryarray) !== false) {
                         $r .= "<option value='" . htmlentities($key, ENT_QUOTES, $charset) . "' ";
                         $as = array_search($key, $v);
                         if ($as !== null && $as !== false) {
                             $r .= " selected";
                         }
                         $r .= ">" . htmlentities($val, ENT_QUOTES, $charset) . "</option>";
                     } elseif (!$existrestrict) {
                         $r .= "<option value='" . htmlentities($key, ENT_QUOTES, $charset) . "' ";
                         $as = array_search($key, $v);
                         if ($as !== null && $as !== false) {
                             $r .= " selected";
                         }
                         $r .= ">" . htmlentities($val, ENT_QUOTES, $charset) . "</option>";
                     }
                 }
                 $r .= "</select>";
                 break;
             case "date":
                 $date_formatee = format_date_input($v[0]);
                 $date_clic = "onClick=\"openPopUp('./select.php?what=calendrier&caller=search_form&date_caller=" . str_replace('-', '', $v[0]) . "&param1=field_" . $n . "_" . $search . "_date&param2=field_" . $n . "_" . $search . "[]&auto_submit=NO&date_anterieure=YES&format_return=IN', 'field_" . $n . "_" . $search . "_date', 250, 300, -2, -2, 'toolbar=no, dependent=yes, resizable=yes')\"  ";
                 if (substr($ff['INPUT_OPTIONS']["PLACEHOLDER"], 0, 4) == "msg:") {
                     $input_placeholder = $msg[substr($ff['INPUT_OPTIONS']["PLACEHOLDER"], 4, strlen($ff['INPUT_OPTIONS']["PLACEHOLDER"]) - 4)];
                 } else {
                     $input_placeholder = $ff['INPUT_OPTIONS']["PLACEHOLDER"];
                 }
                 $r = "<input type='hidden' name='field_" . $n . "_" . $search . "_date' value='" . str_replace('-', '', $v[0]) . "' />\n    \t\t\t\t\t<input type='text' name='field_" . $n . "_" . $search . "[]' value='" . htmlentities($date_formatee, ENT_QUOTES, $charset) . "' " . ($input_placeholder ? "placeholder='" . htmlentities($input_placeholder, ENT_QUOTES, $charset) . "'" : "") . "/>\n    \t\t\t\t\t<input class='bouton_small' type='button' name='field_" . $n . "_" . $search . "_date_lib_bouton' value='" . $msg["bouton_calendrier"] . "' " . $date_clic . " />";
                 break;
             case "map":
                 global $pmb_map_base_layer_type;
                 global $pmb_map_base_layer_params;
                 global $dbh;
                 $layer_params = json_decode($pmb_map_base_layer_params, true);
                 $baselayer = "baseLayerType: dojox.geo.openlayers.BaseLayerType." . $pmb_map_base_layer_type;
                 if (count($layer_params)) {
                     if ($layer_params['name']) {
                         $baselayer .= ",baseLayerName:\"" . $layer_params['name'] . "\"";
                     }
                     if ($layer_params['url']) {
                         $baselayer .= ",baseLayerUrl:\"" . $layer_params['url'] . "\"";
                     }
                     if ($layer_params['options']) {
                         $baselayer .= ",baseLayerOptions:" . json_encode($layer_params['options']);
                     }
                 }
                 $size = explode("*", $pmb_map_size_search_edition);
                 if (count($size) != 2) {
                     $map_size = "width:800px; height:480px;";
                 }
                 $map_size = "width:" . $size[0] . "px; height:" . $size[1] . "px;";
                 $map_holds = array();
                 foreach ($v as $map_hold) {
                     $map_holds[] = array("wkt" => $map_hold, "type" => "search", "color" => null, "objects" => array());
                 }
                 $r = "<div id='map_search_" . $n . "_" . $search . "' data-dojo-type='apps/map/map_controler' style='{$map_size}' data-dojo-props='" . $baselayer . ",mode:\"search_criteria\",hiddenField:\"field_" . $n . "_" . $search . "\",searchHolds:" . json_encode($map_holds, true) . "'></div>";
                 break;
         }
         //Traitement des variables d'entree
         //Variables
         for ($j = 0; $j < count($ff["VAR"]); $j++) {
             if ($ff["VAR"][$j]["TYPE"] == "input") {
                 $varname = $ff["VAR"][$j]["NAME"];
                 $visibility = 1;
                 $vis = $ff["VAR"][$j]["OPTIONS"]["VAR"][0];
                 if ($vis["NAME"]) {
                     $vis_name = $vis["NAME"];
                     global ${$vis_name};
                     if ($vis["VISIBILITY"] == "no") {
                         $visibility = 0;
                     }
                     for ($k = 0; $k < count($vis["VALUE"]); $k++) {
                         if ($vis["VALUE"][$k]["value"] == ${$vis_name}) {
                             if ($vis["VALUE"][$k]["VISIBILITY"] == "no") {
                                 $sub_vis = 0;
                             } else {
                                 $sub_vis = 1;
                             }
                             if ($vis["VISIBILITY"] == "no") {
                                 $visibility |= $sub_vis;
                             } else {
                                 $visibility &= $sub_vis;
                             }
                             break;
                         }
                     }
                 }
                 //Recherche de la valeur par defaut
                 $vdefault = $ff["VAR"][$j]["OPTIONS"]["DEFAULT"][0];
                 if ($vdefault) {
                     switch ($vdefault["TYPE"]) {
                         case "var":
                             $default = $var_table[$vdefault["value"]];
                             break;
                         case "value":
                         default:
                             $default = $vdefault["value"];
                     }
                 } else {
                     $vdefault = "";
                 }
                 if ($visibility) {
                     $r .= "&nbsp;" . $ff["VAR"][$j]["COMMENT"];
                     $input = $ff["VAR"][$j]["OPTIONS"]["INPUT"][0];
                     switch ($input["TYPE"]) {
                         case "query_list":
                             if (!$fieldvar[$varname] && $default) {
                                 $fieldvar[$varname][0] = $default;
                             }
                             $r .= "&nbsp;<select id=\"fieldvar_" . $n . "_" . $search . "[" . $varname . "][]\" name=\"fieldvar_" . $n . "_" . $search . "[" . $varname . "][]\">\n";
                             $query_list_result = @pmb_mysql_query($input["QUERY"][0]["value"]);
                             $var_tmp = $concat = "";
                             while ($line = pmb_mysql_fetch_array($query_list_result)) {
                                 if ($concat) {
                                     $concat .= ",";
                                 }
                                 $concat .= $line[0];
                                 $var_tmp .= "<option value=\"" . htmlentities($line[0], ENT_QUOTES, $charset) . "\"";
                                 $as = @array_search($line[0], $fieldvar[$varname]);
                                 if ($as !== false && $as !== NULL) {
                                     $var_tmp .= " selected";
                                 }
                                 $var_tmp .= ">" . htmlentities($line[1], ENT_QUOTES, $charset) . "</option>\n";
                             }
                             if ($input["QUERY"][0]["ALLCHOICE"] == "yes") {
                                 $r .= "<option value=\"" . htmlentities($concat, ENT_QUOTES, $charset) . "\"";
                                 $as = @array_search($concat, $fieldvar[$varname]);
                                 if ($as !== false && $as !== NULL) {
                                     $r .= " selected";
                                 }
                                 $r .= ">" . htmlentities($msg[substr($input["QUERY"][0]["TITLEALLCHOICE"], 4, strlen($input["QUERY"][0]["TITLEALLCHOICE"]) - 4)], ENT_QUOTES, $charset) . "</option>\n";
                             }
                             $r .= $var_tmp;
                             $r .= "</select>";
                             break;
                         case "checkbox":
                             if (!$input["DEFAULT_ON"]) {
                                 if (!$fieldvar[$varname] && $default) {
                                     $fieldvar[$varname][0] = $default;
                                 }
                             } elseif (!$fieldvar[$input["DEFAULT_ON"]][0]) {
                                 $fieldvar[$varname][0] = $default;
                             }
                             $r .= "&nbsp;<input type=\"checkbox\" name=\"fieldvar_" . $n . "_" . $search . "[" . $varname . "][]\" value=\"" . $input["VALUE"][0]["value"] . "\" ";
                             if ($input["VALUE"][0]["value"] == $fieldvar[$varname][0]) {
                                 $r .= "checked";
                             }
                             $r .= "/>\n";
                             break;
                         case "radio":
                             if (!$fieldvar[$varname] && $default) {
                                 $fieldvar[$varname][0] = $default;
                             }
                             foreach ($input["OPTIONS"][0]["LABEL"] as $radio_value) {
                                 $r .= "&nbsp;<input type=\"radio\" name=\"fieldvar_" . $n . "_" . $search . "[" . $varname . "][]\" value=\"" . $radio_value["VALUE"] . "\" ";
                                 if ($radio_value["VALUE"] == $fieldvar[$varname][0]) {
                                     $r .= "checked";
                                 }
                                 $r .= "/>" . htmlentities($msg[substr($radio_value["value"], 4, strlen($radio_value["value"]) - 4)], ENT_QUOTES, $charset);
                             }
                             $r .= "\n";
                             break;
                         case "hidden":
                             if (!$fieldvar[$varname] && $default) {
                                 $fieldvar[$varname][0] = $default;
                             }
                             if (is_array($input["VALUE"][0])) {
                                 $hidden_value = $input["VALUE"][0]["value"];
                             } else {
                                 $hidden_value = $fieldvar[$varname][0];
                             }
                             $r .= "<input type='hidden' name=\"fieldvar_" . $n . "_" . $search . "[" . $varname . "][]\" value=\"" . htmlentities($hidden_value, ENT_QUOTES, $charset) . "\"/>";
                             break;
                     }
                 } else {
                     if ($vis["HIDDEN"] != "no") {
                         $r .= "<input type='hidden' name=\"fieldvar_" . $n . "_" . $search . "[" . $varname . "][]\" value=\"" . htmlentities($default, ENT_QUOTES, $charset) . "\"/>";
                     }
                 }
             }
         }
     } elseif (array_key_exists($s[0], $this->pp)) {
         //Recuperation du champ
         $field = array();
         $field[ID] = $s[1];
         $field[NAME] = $this->pp[$s[0]]->t_fields[$s[1]][NAME] . "_" . $n;
         $field[MANDATORY] = $this->pp[$s[0]]->t_fields[$s[1]][MANDATORY];
         $field[ALIAS] = $this->pp[$s[0]]->t_fields[$s[1]][TITRE];
         $field[DATATYPE] = $this->pp[$s[0]]->t_fields[$s[1]][DATATYPE];
         $field[OPTIONS][0] = _parser_text_no_function_("<?xml version='1.0' encoding='" . $charset . "'?>\n" . $this->pp[$s[0]]->t_fields[$s[1]][OPTIONS], "OPTIONS");
         $field[VALUES] = $v;
         $field[PREFIX] = $this->pp[$s[0]]->prefix;
         eval("\$r=" . $aff_list_empr_search[$this->pp[$s[0]]->t_fields[$s[1]][TYPE]] . "(\$field,\$check_scripts,\"field_" . $n . "_" . $search . "\");");
     } elseif ($s[0] == "authperso") {
         $r = "<span class='search_value'><input type='text' name='field_" . $n . "_" . $search . "[]' value='" . htmlentities($v[0], ENT_QUOTES, $charset) . "' class='ext_search_txt'/></span>";
     } elseif ($s[0] == "s") {
         //appel de la fonction get_input_box de la classe du champ special
         $type = $this->specialfields[$s[1]]["TYPE"];
         for ($is = 0; $is < count($this->tableau_speciaux["TYPE"]); $is++) {
             if ($this->tableau_speciaux["TYPE"][$is]["NAME"] == $type) {
                 $sf = $this->specialfields[$s[1]];
                 if ($this->full_path && file_exists($this->full_path . "/specials/" . $this->tableau_speciaux["TYPE"][$is]["PATH"] . "/search.class.php")) {
                     require_once $this->full_path . "/specials/" . $this->tableau_speciaux["TYPE"][$is]["PATH"] . "/search.class.php";
                 } else {
                     require_once $include_path . "/search_queries/specials/" . $this->tableau_speciaux["TYPE"][$is]["PATH"] . "/search.class.php";
                 }
                 $specialclass = new $this->tableau_speciaux["TYPE"][$is]["CLASS"]($s[1], $n, $sf, $this);
                 $r = $specialclass->get_input_box();
                 break;
             }
         }
     }
     return $r;
 }
Exemplo n.º 3
0
 function get_field($i, $n, $search, $pp)
 {
     global $charset;
     global $aff_list_empr_search;
     global $msg;
     global $include_path;
     global $thesaurus_classement_mode_pmb;
     $r = "";
     $s = explode("_", $search);
     //Champ
     $val = "field_" . $i . "_" . $search;
     global ${$val};
     $v = ${$val};
     if ($v == "") {
         $v = array();
     }
     //Variables
     $fieldvar_ = "fieldvar_" . $i . "_" . $search;
     global ${$fieldvar_};
     $fieldvar = ${$fieldvar_};
     if ($s[0] == "f") {
         //Champs fixes
         $ff = $this->fixedfields[$s[1]];
         //Variables globales et input
         for ($j = 0; $j < count($ff["VAR"]); $j++) {
             switch ($ff["VAR"][$j]["TYPE"]) {
                 case "input":
                     $valvar = "fieldvar_" . $i . "_" . $search . "[\"" . $ff["VAR"][$j]["NAME"] . "\"]";
                     global ${$valvar};
                     $vvar[$ff["VAR"][$j]["NAME"]] = ${$valvar};
                     if ($vvar[$ff["VAR"][$j]["NAME"]] == "") {
                         $vvar[$ff["VAR"][$j]["NAME"]] = array();
                     }
                     $var_table[$ff["VAR"][$j]["NAME"]] = $vvar[$ff["VAR"][$j]["NAME"]];
                     break;
                 case "global":
                     $global_name = $ff["VAR"][$j]["NAME"];
                     global ${$global_name};
                     $var_table[$ff["VAR"][$j]["NAME"]] = ${$global_name};
                     break;
             }
         }
         switch ($ff["INPUT_TYPE"]) {
             case "authoritie_external":
                 $r = "";
                 $op = "op_" . $i . "_" . $search;
                 global ${$op};
                 global $lang;
                 $libelle = "";
                 if (${$op} == "AUTHORITY") {
                     if ($v[0] != 0) {
                         switch ($ff['INPUT_OPTIONS']['SELECTOR']) {
                             case "auteur":
                                 $aut = new auteur($v[0]);
                                 if ($aut->rejete) {
                                     $libelle = $aut->name . ', ' . $aut->rejete;
                                 } else {
                                     $libelle = $aut->name;
                                 }
                                 if ($aut->date) {
                                     $libelle .= " ({$aut->date})";
                                 }
                                 break;
                             case "categorie":
                                 $libelle = categories::getlibelle($v[0], $lang);
                                 break;
                             case "editeur":
                                 $ed = new publisher($v[0]);
                                 $libelle = $ed->name;
                                 if ($ed->ville) {
                                     if ($ed->pays) {
                                         $libelle .= " ({$ed->ville} - {$ed->pays})";
                                     } else {
                                         $libelle .= " ({$ed->ville})";
                                     }
                                 }
                                 break;
                             case "collection":
                                 $coll = new collection($v[0]);
                                 $libelle = $coll->name;
                                 break;
                             case "subcollection":
                                 $coll = new subcollection($v[0]);
                                 $libelle = $coll->name;
                                 break;
                             case "serie":
                                 $serie = new serie($v[0]);
                                 $libelle = $serie->name;
                                 break;
                             case "indexint":
                                 $indexint = new indexint($v[0]);
                                 $libelle = $indexint->display;
                                 break;
                             case "titres_uniformes":
                                 $tu = new titre_uniforme($v[0]);
                                 $libelle = $tu->name;
                                 break;
                             default:
                                 $libelle = $v[0];
                                 break;
                         }
                     }
                     ${$op} == "BOOLEAN";
                     $r = "<script>document.forms['search_form']." . $op . ".options[0].selected=true;</script>";
                 }
                 if ($libelle) {
                     $r = "<span class='search_value'><input type='text' name='field_" . $n . "_" . $search . "[]' value='" . htmlentities($libelle, ENT_QUOTES, $charset) . "' class='ext_search_txt'/></span>";
                 } else {
                     $r = "<span class='search_value'><input type='text' name='field_" . $n . "_" . $search . "[]' value='" . htmlentities($v[0], ENT_QUOTES, $charset) . "' class='ext_search_txt'/></span>";
                 }
                 break;
             case "authoritie":
                 $fnamesans = "field_" . $n . "_" . $search;
                 $fname = "field_" . $n . "_" . $search . "[]";
                 $fname_id = "field_" . $n . "_" . $search . "_id";
                 $fnamesanslib = "field_" . $n . "_" . $search . "_lib";
                 $fnamelib = "field_" . $n . "_" . $search . "_lib[]";
                 $fname_name_aut_id = "fieldvar_" . $n . "_" . $search . "[authority_id][]";
                 $fname_aut_id = "fieldvar_" . $n . "_" . $search . "_authority_id";
                 $ajax = $ff["INPUT_OPTIONS"]["AJAX"];
                 $selector = $ff["INPUT_OPTIONS"]["SELECTOR"];
                 $p1 = $ff["INPUT_OPTIONS"]["P1"];
                 $p2 = $ff["INPUT_OPTIONS"]["P2"];
                 global $opac_thesaurus;
                 if ($ajax == "categories" and $opac_thesaurus == 1) {
                     $fnamevar_id = "linkfield=\"fieldvar_" . $n . "_" . $search . "[id_thesaurus][]\"";
                 } else {
                     $fnamevar_id = "";
                 }
                 $op = "op_" . $i . "_" . $search;
                 global ${$op};
                 global $lang;
                 $r = "\n\t\t\t\t\t\t<input id='{$fnamesans}' name='{$fname}' value='" . htmlentities($v[0], ENT_QUOTES, $charset) . "' type='hidden' />\n\t\t\t\t\t\t";
                 if (${$op} == "AUTHORITY") {
                     if ($v[0] != 0) {
                         switch ($ff['INPUT_OPTIONS']['SELECTOR']) {
                             case "auteur":
                                 $aut = new auteur($v[0]);
                                 if ($aut->rejete) {
                                     $libelle = $aut->name . ', ' . $aut->rejete;
                                 } else {
                                     $libelle = $aut->name;
                                 }
                                 if ($aut->date) {
                                     $libelle .= " ({$aut->date})";
                                 }
                                 break;
                             case "categorie":
                                 $libelle = categories::getlibelle($v[0], $lang);
                                 break;
                             case "editeur":
                                 $ed = new publisher($v[0]);
                                 $libelle = $ed->name;
                                 if ($ed->ville) {
                                     if ($ed->pays) {
                                         $libelle .= " ({$ed->ville} - {$ed->pays})";
                                     } else {
                                         $libelle .= " ({$ed->ville})";
                                     }
                                 }
                                 break;
                             case "collection":
                                 $coll = new collection($v[0]);
                                 $libelle = $coll->name;
                                 break;
                             case "subcollection":
                                 $coll = new subcollection($v[0]);
                                 $libelle = $coll->name;
                                 break;
                             case "serie":
                                 $serie = new serie($v[0]);
                                 $libelle = $serie->name;
                                 break;
                             case "indexint":
                                 $indexint = new indexint($v[0]);
                                 $libelle = $indexint->display;
                                 break;
                             case "titres_uniformes":
                                 $tu = new titre_uniforme($v[0]);
                                 $libelle = $tu->name;
                                 break;
                             case "notice":
                                 $requete = "select if(serie_name is not null,if(tnvol is not null,concat(serie_name,', ',tnvol,'. ',tit1),concat(serie_name,'. ',tit1)),tit1) AS tit from notices left join series on serie_id=tparent_id where notice_id='" . $v[0] . "' ";
                                 $res = mysql_query($requete);
                                 if ($res && mysql_num_rows($res)) {
                                     $libelle = mysql_result($res, 0, 0);
                                 } else {
                                     $libelle = $v[0];
                                 }
                                 break;
                             default:
                                 $libelle = $v[0];
                                 break;
                         }
                     } else {
                         $libelle = "";
                     }
                     $r .= "<span class='search_value'><input autfield='{$fname_id}' onkeyup='fieldChanged(\"{$fnamesans}\",this.value,event);' callback='authoritySelected' completion='{$ajax}' {$fnamevar_id} id='{$fnamesanslib}' name='{$fnamelib}' value='" . htmlentities($libelle, ENT_QUOTES, $charset) . "' type='text' class='" . ($fieldvar['authority_id'][0] ? "authorities " : "") . "ext_search_txt' /></span>\n\t\t\t\t\t\t\t";
                 } else {
                     $r .= "<span class='search_value'><input autfield='{$fname_id}' onkeyup='fieldChanged(\"{$fnamesans}\",this.value,event);' callback='authoritySelected' completion='{$ajax}' {$fnamevar_id} id='{$fnamesanslib}' name='{$fnamelib}' value='" . htmlentities($v[0], ENT_QUOTES, $charset) . "' type='text' class='ext_search_txt' /></span>\n\t\t\t\t\t\t\t";
                 }
                 $r .= "<span class='search_dico'><img src='images/dictionnaire.png' align='middle' onClick=\"document.getElementById('{$fnamesanslib}').focus();simulate_event('{$fnamesanslib}');\"></span>\n\t\t\t\t\t<input type='hidden' value='" . ($fieldvar['authority_id'][0] ? $fieldvar['authority_id'][0] : "") . "' id='{$fname_aut_id}' name='{$fname_name_aut_id}' />\n\t\t\t\t\t<input name='{$fname_id}' id='{$fname_id}' value='" . ($fieldvar['id'][0] ? $fieldvar['id'][0] : "") . "' type='hidden'/>";
                 break;
             case "text":
                 if (substr($ff['INPUT_OPTIONS']["PLACEHOLDER"], 0, 4) == "msg:") {
                     $input_placeholder = $msg[substr($ff['INPUT_OPTIONS']["PLACEHOLDER"], 4, strlen($ff['INPUT_OPTIONS']["PLACEHOLDER"]) - 4)];
                 } else {
                     $input_placeholder = $ff['INPUT_OPTIONS']["PLACEHOLDER"];
                 }
                 $r = "<span class='search_value'><input type='text' name='field_" . $n . "_" . $search . "[]' value='" . htmlentities($v[0], ENT_QUOTES, $charset) . "' " . ($input_placeholder ? "placeholder='" . htmlentities($input_placeholder, ENT_QUOTES, $charset) . "' alt='" . htmlentities($input_placeholder, ENT_QUOTES, $charset) . "' title='" . htmlentities($input_placeholder, ENT_QUOTES, $charset) . "'" : "") . " class='ext_search_txt'/></span>";
                 break;
             case "query_list":
                 $requete = $ff["INPUT_OPTIONS"]["QUERY"][0]["value"];
                 if ($ff["INPUT_FILTERING"] == "yes") {
                     $this->access_rights();
                     $requete = str_replace("!!acces_j!!", $this->tableau_access_rights["acces_j"], $requete);
                     $requete = str_replace("!!statut_j!!", $this->tableau_access_rights["statut_j"], $requete);
                     $requete = str_replace("!!statut_r!!", $this->tableau_access_rights["statut_r"], $requete);
                 }
                 $resultat = mysql_query($requete);
                 $r = "<span class='search_value'><select name='field_" . $n . "_" . $search . "[]' multiple size='5' class=\"ext_search_txt\">";
                 while ($opt = mysql_fetch_row($resultat)) {
                     $r .= "<option value='" . htmlentities($opt[0], ENT_QUOTES, $charset) . "' ";
                     $as = array_search($opt[0], $v);
                     if ($as !== null && $as !== false) {
                         $r .= " selected";
                     }
                     $r .= ">" . htmlentities($opt[1], ENT_QUOTES, $charset) . "</option>";
                 }
                 $r .= "</select></span>";
                 break;
             case "list":
                 $options = $ff["INPUT_OPTIONS"]["OPTIONS"][0];
                 $r = "<span class='search_value'><select name='field_" . $n . "_" . $search . "[]' multiple size='5' class=\"ext_search_txt\">";
                 sort($options["OPTION"]);
                 for ($i = 0; $i < count($options["OPTION"]); $i++) {
                     $r .= "<option value='" . htmlentities($options["OPTION"][$i]["VALUE"], ENT_QUOTES, $charset) . "' ";
                     $as = array_search($options["OPTION"][$i]["VALUE"], $v);
                     if ($as !== null && $as !== false) {
                         $r .= " selected";
                     }
                     if (substr($options["OPTION"][$i]["value"], 0, 4) == "msg:") {
                         $r .= ">" . htmlentities($msg[substr($options["OPTION"][$i]["value"], 4, strlen($options["OPTION"][$i]["value"]) - 4)], ENT_QUOTES, $charset) . "</option>";
                     } else {
                         $r .= ">" . htmlentities($options["OPTION"][$i]["value"], ENT_QUOTES, $charset) . "</option>";
                     }
                 }
                 $r .= "</select></span>";
                 break;
             case "marc_list":
                 $options = new marc_list($ff["INPUT_OPTIONS"]["NAME"][0]["value"]);
                 // gestion restriction par code utilise.
                 if ($ff["INPUT_OPTIONS"]["RESTRICTQUERY"][0]["value"]) {
                     $restrictquery = @mysql_query($ff["INPUT_OPTIONS"]["RESTRICTQUERY"][0]["value"]);
                     if ($restrictqueryrow = @mysql_fetch_row($restrictquery)) {
                         if ($restrictqueryrow[0]) {
                             $restrictqueryarray = explode(",", $restrictqueryrow[0]);
                             $existrestrict = true;
                         } else {
                             $existrestrict = false;
                         }
                     } else {
                         $existrestrict = false;
                     }
                 } else {
                     $existrestrict = false;
                 }
                 $r = "<span class='search_value'><select name='field_" . $n . "_" . $search . "[]' multiple size='5' class=\"ext_search_txt\">";
                 while (list($key, $val) = each($options->table)) {
                     if ($existrestrict && array_search($key, $restrictqueryarray) !== false) {
                         $r .= "<option value='" . htmlentities($key, ENT_QUOTES, $charset) . "' ";
                         $as = array_search($key, $v);
                         if ($as !== null && $as !== false) {
                             $r .= " selected";
                         }
                         $r .= ">" . htmlentities($val, ENT_QUOTES, $charset) . "</option>";
                     } elseif (!$existrestrict) {
                         $r .= "<option value='" . htmlentities($key, ENT_QUOTES, $charset) . "' ";
                         $as = array_search($key, $v);
                         if ($as !== null && $as !== false) {
                             $r .= " selected";
                         }
                         $r .= ">" . htmlentities($val, ENT_QUOTES, $charset) . "</option>";
                     }
                 }
                 $r .= "</select></span>";
                 break;
             case "date":
                 $date_formatee = format_date_input($v[0]);
                 $date_clic = "onClick=\"openPopUp('./select.php?what=calendrier&caller=search_form&date_caller=" . str_replace('-', '', $v[0]) . "&param1=field_" . $n . "_" . $search . "_date&param2=field_" . $n . "_" . $search . "[]&auto_submit=NO&date_anterieure=YES&format_return=IN', 'field_" . $n . "_" . $search . "_date', 250, 300, -2, -2, 'toolbar=no, dependent=yes, resizable=yes')\"  ";
                 if (substr($ff['INPUT_OPTIONS']["PLACEHOLDER"], 0, 4) == "msg:") {
                     $input_placeholder = $msg[substr($ff['INPUT_OPTIONS']["PLACEHOLDER"], 4, strlen($ff['INPUT_OPTIONS']["PLACEHOLDER"]) - 4)];
                 } else {
                     $input_placeholder = $ff['INPUT_OPTIONS']["PLACEHOLDER"];
                 }
                 $r = "<span class='search_value'>\n    \t\t\t\t\t<input type='hidden' name='field_" . $n . "_" . $search . "_date' value='" . str_replace('-', '', $v[0]) . "' />\n    \t\t\t\t\t<input type='text' name='field_" . $n . "_" . $search . "[]' value='" . htmlentities($date_formatee, ENT_QUOTES, $charset) . "' class=\"ext_search_txt\" " . ($input_placeholder ? "placeholder='" . htmlentities($input_placeholder, ENT_QUOTES, $charset) . "'" : "") . "/>\n    \t\t\t\t\t<img src='./images/calendar.jpg' " . $date_clic . " style='cursor:pointer' />\n    \t\t\t\t\t</span>";
                 break;
         }
         //Traitement des variables d'entree
         //Variables
         for ($j = 0; $j < count($ff["VAR"]); $j++) {
             if ($ff["VAR"][$j]["TYPE"] == "input") {
                 $varname = $ff["VAR"][$j]["NAME"];
                 $visibility = 1;
                 $vis = $ff["VAR"][$j]["OPTIONS"]["VAR"][0];
                 if ($vis["NAME"]) {
                     $vis_name = $vis["NAME"];
                     global ${$vis_name};
                     if ($vis["VISIBILITY"] == "no") {
                         $visibility = 0;
                     }
                     for ($k = 0; $k < count($vis["VALUE"]); $k++) {
                         if ($vis["VALUE"][$k]["value"] == ${$vis_name}) {
                             if ($vis["VALUE"][$k]["VISIBILITY"] == "no") {
                                 $sub_vis = 0;
                             } else {
                                 $sub_vis = 1;
                             }
                             if ($vis["VISIBILITY"] == "no") {
                                 $visibility |= $sub_vis;
                             } else {
                                 $visibility &= $sub_vis;
                             }
                             break;
                         }
                     }
                 }
                 //Recherche de la valeur par defaut
                 $vdefault = $ff["VAR"][$j]["OPTIONS"]["DEFAULT"][0];
                 if ($vdefault) {
                     switch ($vdefault["TYPE"]) {
                         case "var":
                             $default = $var_table[$vdefault["value"]];
                             break;
                         case "value":
                         default:
                             $default = $vdefault["value"];
                     }
                 } else {
                     $vdefault = "";
                 }
                 if ($visibility) {
                     $r .= "&nbsp;" . $ff["VAR"][$j]["COMMENT"];
                     $input = $ff["VAR"][$j]["OPTIONS"]["INPUT"][0];
                     switch ($input["TYPE"]) {
                         case "query_list":
                             if (!$fieldvar[$varname] && $default) {
                                 $fieldvar[$varname][0] = $default;
                             }
                             $r .= "&nbsp;<span class='search_value'><select id=\"fieldvar_" . $n . "_" . $search . "[" . $varname . "][]\" name=\"fieldvar_" . $n . "_" . $search . "[" . $varname . "][]\">\n";
                             $query_list_result = @mysql_query($input["QUERY"][0]["value"]);
                             $var_tmp = $concat = "";
                             while ($line = mysql_fetch_array($query_list_result)) {
                                 if ($concat) {
                                     $concat .= ",";
                                 }
                                 $concat .= $line[0];
                                 $var_tmp .= "<option value=\"" . htmlentities($line[0], ENT_QUOTES, $charset) . "\"";
                                 $as = @array_search($line[0], $fieldvar[$varname]);
                                 if ($as !== false && $as !== NULL) {
                                     $var_tmp .= " selected";
                                 }
                                 $var_tmp .= ">" . htmlentities($line[1], ENT_QUOTES, $charset) . "</option>\n";
                             }
                             if ($input["QUERY"][0]["ALLCHOICE"] == "yes") {
                                 $r .= "<option value=\"" . htmlentities($concat, ENT_QUOTES, $charset) . "\"";
                                 $as = @array_search($concat, $fieldvar[$varname]);
                                 if ($as !== false && $as !== NULL) {
                                     $r .= " selected";
                                 }
                                 $r .= ">" . htmlentities($msg[substr($input["QUERY"][0]["TITLEALLCHOICE"], 4, strlen($input["QUERY"][0]["TITLEALLCHOICE"]) - 4)], ENT_QUOTES, $charset) . "</option>\n";
                             }
                             $r .= $var_tmp;
                             $r .= "</select></span>";
                             break;
                         case "checkbox":
                             if (!$input["DEFAULT_ON"]) {
                                 if (!$fieldvar[$varname] && $default) {
                                     $fieldvar[$varname][0] = $default;
                                 }
                             } elseif (!$fieldvar[$input["DEFAULT_ON"]][0]) {
                                 $fieldvar[$varname][0] = $default;
                             }
                             $r .= "&nbsp;<input type=\"checkbox\" name=\"fieldvar_" . $n . "_" . $search . "[" . $varname . "][]\" value=\"" . $input["VALUE"][0]["value"] . "\" ";
                             if ($input["VALUE"][0]["value"] == $fieldvar[$varname][0]) {
                                 $r .= "checked";
                             }
                             $r .= "/>\n";
                             break;
                         case "hidden":
                             if (!$fieldvar[$varname] && $default) {
                                 $fieldvar[$varname][0] = $default;
                             }
                             if (is_array($input["VALUE"][0])) {
                                 $hidden_value = $input["VALUE"][0]["value"];
                             } else {
                                 $hidden_value = $fieldvar[$varname][0];
                             }
                             $r .= "<input type='hidden' name=\"fieldvar_" . $n . "_" . $search . "[" . $varname . "][]\" value=\"" . htmlentities($hidden_value, ENT_QUOTES, $charset) . "\"/>";
                             break;
                     }
                 } else {
                     if ($vis["HIDDEN"] != "no") {
                         $r .= "<input type='hidden' name=\"fieldvar_" . $n . "_" . $search . "[" . $varname . "][]\" value=\"" . htmlentities($default, ENT_QUOTES, $charset) . "\"/>";
                     }
                 }
             }
         }
     } elseif (array_key_exists($s[0], $this->pp)) {
         //Recuperation du champ
         $field = array();
         $field[ID] = $s[1];
         $field[NAME] = $this->pp[$s[0]]->t_fields[$s[1]][NAME];
         $field[MANDATORY] = $this->pp[$s[0]]->t_fields[$s[1]][MANDATORY];
         $field[ALIAS] = $this->pp[$s[0]]->t_fields[$s[1]][TITRE];
         $field[DATATYPE] = $this->pp[$s[0]]->t_fields[$s[1]][DATATYPE];
         $field[OPTIONS][0] = _parser_text_no_function_("<?xml version='1.0' encoding='" . $charset . "'?>\n" . $this->pp[$s[0]]->t_fields[$s[1]][OPTIONS], "OPTIONS");
         $field[VALUES] = $v;
         $field[PREFIX] = $this->pp[$s[0]]->prefix;
         $r = $aff_list_empr_search[$this->pp[$s[0]]->t_fields[$s[1]][TYPE]]($field, $check_scripts, "field_" . $n . "_" . $search);
     } elseif ($s[0] == "s") {
         //appel de la fonction get_input_box de la classe du champ special
         $type = $this->specialfields[$s[1]]["TYPE"];
         for ($is = 0; $is < count($this->tableau_speciaux["TYPE"]); $is++) {
             if ($this->tableau_speciaux["TYPE"][$is]["NAME"] == $type) {
                 $sf = $this->specialfields[$s[1]];
                 require_once $include_path . "/search_queries/specials/" . $this->tableau_speciaux["TYPE"][$is]["PATH"] . "/search.class.php";
                 $specialclass = new $this->tableau_speciaux["TYPE"][$is]["CLASS"]($s[1], $n, $sf, $this);
                 $r = $specialclass->get_input_box();
                 break;
             }
         }
     }
     return $r;
 }