uid = $uid; $this->ufield=$ufield; $this->op=$op; $this->values=$values; $this->vars=$vars; $this->inter=$inter; $this->fieldvar=$fieldvar; } public function set_sub($sub) { $this->sub=$sub; } } class search { public $operators; public $op_empty; public $fixedfields; public $dynamicfields; public $dynamicfields_order; public $dynamicfields_hidebycustomname; public $specialfields; public $pp; public $error_message; public $link; public $link_expl; public $link_explnum; public $link_serial; public $link_analysis; public $link_bulletin; public $link_explnum_serial; public $tableau_speciaux; public $operator_multi_value; public $full_path=''; public $fichier_xml; public $tableau_access_rights; public $dynamics_not_visible; public $specials_not_visible; public $memory_engine_allowed = false; public $current_engine = 'MyISAM'; public $authpersos = array(); public $groups_used = false; public $groups = array(); public $filtered_objects_types = array(); public $keyName = ""; public $tableName = ""; public $elements_list_ui_class_name; protected $is_created_temporary_table = false; public static $ignore_subst_file = false; protected $list_criteria; /** * Script à appeler au chargement de la page (ne sert qu'à transmettre l'info au show_form()) * @var string */ protected $script_window_onload; protected $context_parameters; protected $misc_file_search_fields; public function __construct($fichier_xml="") { global $launch_search; $this->fichier_xml = $fichier_xml; $this->parse_search_file(); $this->strip_slashes(); foreach ( $this->dynamicfields as $key => $value ) { $this->pp[$key]=new parametres_perso($value["TYPE"]); } if(isset($this->dynamicfields['a'])) { $authpersos=authpersos::get_instance(); $this->authpersos=$authpersos->get_data(); } } //Parse du fichier de configuration protected function parse_search_file() { global $include_path,$base_path, $charset; global $msg, $KEY_CACHE_FILE_XML; global $lang; $filepath = ""; if(!$this->full_path){ if ($this->fichier_xml == '') { $this->fichier_xml = 'search_fields'; } if (!static::$ignore_subst_file && file_exists($include_path."/search_queries/".$this->fichier_xml."_subst.xml")) { $filepath = $include_path."/search_queries/".$this->fichier_xml."_subst.xml"; } else { $filepath = $include_path."/search_queries/".$this->fichier_xml.".xml"; } } else{ if (!static::$ignore_subst_file && file_exists($this->full_path.$this->fichier_xml."_subst.xml")) { $filepath =$this->full_path.$this->fichier_xml."_subst.xml"; } else { $filepath =$this->full_path.$this->fichier_xml.".xml"; } } $fileInfo = pathinfo($filepath); $fileName = preg_replace("/[^a-z0-9]/i","",$fileInfo['dirname'].$fileInfo['filename'].$lang.$charset); $tempFile = $base_path."/temp/XML".$fileName.".tmp"; $dejaParse = false; $cache_php=cache_factory::getCache(); $key_file=""; if ($cache_php) { $key_file=getcwd().$fileName.filemtime($filepath); $key_file=$KEY_CACHE_FILE_XML.md5($key_file); if($tmp_key = $cache_php->getFromCache($key_file)){ if($cache = $cache_php->getFromCache($tmp_key)){ if(is_array($cache) && (count($cache) == 15)){ $this->groups_used = $cache[0]; $this->groups = $cache[1]; $this->memory_engine_allowed = $cache[2]; $this->operators = $cache[3]; $this->op_empty = $cache[4]; $this->fixedfields = $cache[5]; $this->dynamics_not_visible = $cache[6]; $this->dynamicfields_order = $cache[7]; $this->dynamicfields_hidebycustomname = $cache[8]; $this->dynamicfields = $cache[9]; $this->specials_not_visible = $cache[10]; $this->tableau_speciaux = $cache[11]; $this->keyName = $cache[12]; $this->tableName = $cache[13]; $this->specialfields = $cache[14]; $dejaParse = true; } } } }else{ if (file_exists($tempFile) ) { //Le fichier XML original a-t-il été modifié ultérieurement ? if (filemtime($filepath) > filemtime($tempFile)) { //on va re-générer le pseudo-cache unlink($tempFile); } else { $dejaParse = true; } } if ($dejaParse) { $tmp = fopen($tempFile, "r"); $cache = unserialize(fread($tmp,filesize($tempFile))); fclose($tmp); if(is_array($cache) && (count($cache) == 15)){ $this->groups_used = $cache[0]; $this->groups = $cache[1]; $this->memory_engine_allowed = $cache[2]; $this->operators = $cache[3]; $this->op_empty = $cache[4]; $this->fixedfields = $cache[5]; $this->dynamics_not_visible = $cache[6]; $this->dynamicfields_order = $cache[7]; $this->dynamicfields_hidebycustomname = $cache[8]; $this->dynamicfields = $cache[9]; $this->specials_not_visible = $cache[10]; $this->tableau_speciaux = $cache[11]; $this->keyName = $cache[12]; $this->tableName = $cache[13]; $this->specialfields = $cache[14]; }else{ //SOUCIS de cache... unlink($tempFile); $dejaParse = false; } } } if(!$dejaParse){ $fp=fopen($filepath,"r") or die("Can't find XML file"); $size=filesize($filepath); $xml=fread($fp,$size); fclose($fp); $param=_parser_text_no_function_($xml, "PMBFIELDS"); if(isset($param['GROUPS'])){ $this->groups_used = true; $this->groups = array(); foreach($param['GROUPS'][0]['GROUP'] as $group){ $this->groups[$group['ID']] = array( 'label' => (substr($group['LABEL'][0]['value'],0,4) == "msg:" ? $msg[substr($group['LABEL'][0]['value'],4,strlen($group['LABEL'][0]['value'])-4)] : $group['LABEL'][0]['value']), 'order' => $group['ORDER'][0]['value'], 'objects_type' => (isset($group['OBJECTS_TYPE'][0]['value']) ? $group['OBJECTS_TYPE'][0]['value'] : '') ); } uasort($this->groups, array($this, 'sort_groups')); } //Lecture parametre memory_engine_allowed if(isset($param['MEMORYENGINEALLOWED'][0]['value']) && $param['MEMORYENGINEALLOWED'][0]['value']=='yes') { $this->memory_engine_allowed = true; } //Lecture des operateurs for ($i=0; $ioperators[$operator_["NAME"]]=$msg[substr($operator_["value"],4,strlen($operator_["value"])-4)]; } else { $this->operators[$operator_["NAME"]]=$operator_["value"]; } if (isset($operator_["EMPTYALLOWED"]) && ($operator_["EMPTYALLOWED"]=="yes")) { $this->op_empty[$operator_["NAME"]]=true; }else { $this->op_empty[$operator_["NAME"]]=false; } } //Lecture des champs fixes for ($i=0; $igroups_used){ $t["GROUP"]=(isset($ff["GROUP"]) ? $ff["GROUP"] : ''); } $t["SEPARATOR"] = ''; if(isset($ff["SEPARATOR"])) { if (substr($ff["SEPARATOR"],0,4)=="msg:") { $t["SEPARATOR"]=$msg[substr($ff["SEPARATOR"],4,strlen($ff["SEPARATOR"])-4)]; } else { $t["SEPARATOR"]=$ff["SEPARATOR"]; } } if(isset($ff["DELNOTALLOWED"]) && $ff["DELNOTALLOWED"]=="yes") { $t["DELNOTALLOWED"]=true; } else { $t["DELNOTALLOWED"]=false; } //Visibilite if(isset($ff["VISIBLE"]) && $ff["VISIBLE"]=="no") $t["VISIBLE"]=false; else $t["VISIBLE"]=true; //Moteur memory if(isset($ff['MEMORYENGINEFORBIDDEN']) && $ff['MEMORYENGINEFORBIDDEN']=='yes') $t['MEMORYENGINEFORBIDDEN']=true; else $t['MEMORYENGINEFORBIDDEN']=false; //Variables $t["VAR"] = array(); if(isset($ff["VARIABLE"])) { for ($j=0; $j $val) { if (is_array($val)) { $v["OPTIONS"][$key]=$val; } } $v["PLACE"]=(isset($vv["PLACE"]) ? $vv["PLACE"] : ''); $v["CLASS"]=(isset($vv["CLASS"]) ? $vv["CLASS"] : ''); $t["VAR"][]=$v; } } if (!isset($ff["VISIBILITY"])) $t["VISIBILITY"]=true; else if ($ff["VISIBILITY"]=="yes") $t["VISIBILITY"]=true; else $t["VISIBILITY"]=false; for ($j=0; $j $subfieldrestrict['SUB_FIELD'][0]['value'], 'values' => explode(',', $subfieldrestrict['VALUES'][0]['value']), 'op' => $subfieldrestrict['OP'][0]['value'], 'not' => (isset($subfieldrestrict['NOT'][0]['value']) ? $subfieldrestrict['NOT'][0]['value'] : '') ); } } $q[0]['FIELDSRESTRICT'][] = array( 'field' => $fieldrestrict['FIELD'][0]['value'], 'values' => explode(',', $fieldrestrict['VALUES'][0]['value']), 'op' => $fieldrestrict['OP'][0]['value'], 'not' => (isset($fieldrestrict['NOT'][0]['value']) ? $fieldrestrict['NOT'][0]['value'] : ''), 'sub' => $subfieldsrestrict ); } } } else if (isset($ff["QUERY"][$j]['CLASS'][0]['TYPE'])){ $q[0]['TYPE'] = $ff["QUERY"][$j]['CLASS'][0]['TYPE']; if(isset($ff["QUERY"][$j]['CLASS'][0]['MODE'])){ $q[0]['MODE'] = $ff["QUERY"][$j]['CLASS'][0]['MODE']; } if(isset($ff["QUERY"][$j]['CLASS'][0]['FIELDRESTRICT']) && count($ff["QUERY"][$j]['CLASS'][0]['FIELDRESTRICT'])) { $q[0]['FIELDSRESTRICT'] = array(); foreach ($ff["QUERY"][$j]['CLASS'][0]['FIELDRESTRICT'] as $fieldrestrict) { $subfieldsrestrict = array(); if(isset($fieldrestrict['SUB'])) { foreach ($fieldrestrict['SUB'][0]['FIELDRESTRICT'] as $subfieldrestrict) { $subfieldsrestrict[] = array( 'sub_field' => (isset($subfieldrestrict['SUB_FIELD'][0]['value'])) ? $subfieldrestrict['SUB_FIELD'][0]['value'] : '', 'values' => explode(',', $subfieldrestrict['VALUES'][0]['value']), 'op' => $subfieldrestrict['OP'][0]['value'], 'not' => (isset($subfieldrestrict['NOT'][0]['value']) ? $subfieldrestrict['NOT'][0]['value'] : '') ); } } $q[0]['FIELDSRESTRICT'][] = array( 'field' => $fieldrestrict['FIELD'][0]['value'], 'values' => explode(',', $fieldrestrict['VALUES'][0]['value']), 'op' => $fieldrestrict['OP'][0]['value'], 'not' => (isset($fieldrestrict['NOT'][0]['value']) ? $fieldrestrict['NOT'][0]['value'] : ''), 'sub' => $subfieldsrestrict ); } } } else { $q[0]['CLASS'] = $ff["QUERY"][$j]['CLASS'][0]['value']; } $q[0]['FOLDER'] = (isset($ff["QUERY"][$j]['CLASS'][0]['FOLDER']) ? $ff["QUERY"][$j]['CLASS'][0]['FOLDER'] : ''); $q[0]['FIELDS'] = (isset($ff["QUERY"][$j]['CLASS'][0]['FIELDS']) ? $ff["QUERY"][$j]['CLASS'][0]['FIELDS'] : ''); }else $q[0]["WORD"]=false; //fin modif arnaud if (isset($ff["QUERY"][$j]["ISBNSEARCH"]) && $ff["QUERY"][$j]["ISBNSEARCH"]=="yes") { $q[0]["ISBN"]=true; } else $q[0]["ISBN"]=false; if (isset($ff["QUERY"][$j]["DETECTDATE"])) { $q[0]["DETECTDATE"]=$ff["QUERY"][$j]["DETECTDATE"]; } else $q[0]["DETECTDATE"]=false; $q[0]["MAIN"]=(isset($ff["QUERY"][$j]["MAIN"][0]["value"]) ? $ff["QUERY"][$j]["MAIN"][0]["value"] : ''); $q[0]["MULTIPLE_TERM"]=(isset($ff["QUERY"][$j]["MULTIPLETERM"][0]["value"]) ? $ff["QUERY"][$j]["MULTIPLETERM"][0]["value"] : ''); $q[0]["MULTIPLE_OPERATOR"]=(isset($ff["QUERY"][$j]["MULTIPLEOPERATOR"][0]["value"]) ? $ff["QUERY"][$j]["MULTIPLEOPERATOR"][0]["value"] : ''); $t["QUERIES"][]=$q; $t["QUERIES_INDEX"][$q["OPERATOR"]]=count($t["QUERIES"])-1; } } // recuperation des visibilites parametrees $t["VARVIS"] = array(); if(isset($ff["VAR"])) { for ($j=0; $jfixedfields[$ff["ID"]]=$t; } //Lecture des champs dynamiques if (isset($param["DYNAMICFIELDS"][0]["VISIBLE"]) && $param["DYNAMICFIELDS"][0]["VISIBLE"]=="no") $this->dynamics_not_visible=true; if(!isset($param["DYNAMICFIELDS"][0]["FIELDTYPE"]) || !$param["DYNAMICFIELDS"][0]["FIELDTYPE"]){//Pour le cas de fichiers subst basés sur l'ancienne version $tmp=(isset($param["DYNAMICFIELDS"][0]["FIELD"]) ? $param["DYNAMICFIELDS"][0]["FIELD"] : ''); unset($param["DYNAMICFIELDS"]); $param["DYNAMICFIELDS"][0]["FIELDTYPE"][0]["PREFIX"]="d"; $param["DYNAMICFIELDS"][0]["FIELDTYPE"][0]["TYPE"]="notices"; $param["DYNAMICFIELDS"][0]["FIELDTYPE"][0]["FIELD"]=$tmp; unset($tmp); } //Ordre des champs persos if (isset($param["DYNAMICFIELDS"][0]["OPTION"][0]["ORDER"])) { $this->dynamicfields_order=$param["DYNAMICFIELDS"][0]["OPTION"][0]["ORDER"]; } else { $this->dynamicfields_order=''; } for ($h=0; $h dynamicfields_hidebycustomname[$ft["TYPE"]]=$ft["HIDEBYCUSTOMNAME"]; } if($this->groups_used){ $champType["GROUP"]=(isset($ft["GROUP"]) ? $ft["GROUP"] : ''); } for ($i=0; $i $subfieldrestrict['SUB_FIELD'][0]['value'], 'values' => explode(',', $subfieldrestrict['VALUES'][0]['value']), 'op' => $subfieldrestrict['OP'][0]['value'], 'not' => (isset($subfieldrestrict['NOT'][0]['value']) ? $subfieldrestrict['NOT'][0]['value'] : '') ); } } $q['FIELDSRESTRICT'][] = array( 'field' => $fieldrestrict['FIELD'][0]['value'], 'values' => explode(',', $fieldrestrict['VALUES'][0]['value']), 'op' => $fieldrestrict['OP'][0]['value'], 'not' => (isset($fieldrestrict['NOT'][0]['value']) ? $fieldrestrict['NOT'][0]['value'] : ''), 'sub' => $subfieldsrestrict ); } } }elseif(isset($ff["QUERY"][$j]['CLASS'][0]['TYPE'])) { $q['TYPE'] = $ff["QUERY"][$j]['CLASS'][0]['TYPE']; if(isset($ff["QUERY"][$j]['CLASS'][0]['MODE'])){ $q['MODE'] = $ff["QUERY"][$j]['CLASS'][0]['MODE']; } if(isset($ff["QUERY"][$j]['CLASS'][0]['FIELDRESTRICT']) && count($ff["QUERY"][$j]['CLASS'][0]['FIELDRESTRICT'])) { $q['FIELDSRESTRICT'] = array(); foreach ($ff["QUERY"][$j]['CLASS'][0]['FIELDRESTRICT'] as $fieldrestrict) { $subfieldsrestrict = array(); if(isset($fieldrestrict['SUB'])) { foreach ($fieldrestrict['SUB'][0]['FIELDRESTRICT'] as $subfieldrestrict) { $subfieldsrestrict[] = array( 'sub_field' => $subfieldrestrict['SUB_FIELD'][0]['value'], 'values' => explode(',', $subfieldrestrict['VALUES'][0]['value']), 'op' => $subfieldrestrict['OP'][0]['value'], 'not' => (isset($subfieldrestrict['NOT'][0]['value']) ? $subfieldrestrict['NOT'][0]['value'] : '') ); } } $q['FIELDSRESTRICT'][] = array( 'field' => $fieldrestrict['FIELD'][0]['value'], 'values' => explode(',', $fieldrestrict['VALUES'][0]['value']), 'op' => $fieldrestrict['OP'][0]['value'], 'not' => (isset($fieldrestrict['NOT'][0]['value']) ? $fieldrestrict['NOT'][0]['value'] : ''), 'sub' => $subfieldsrestrict ); } } }else{ $q['CLASS'] = $ff["QUERY"][$j]['CLASS'][0]['value']; } $q['FOLDER'] = (isset($ff["QUERY"][$j]['CLASS'][0]['FOLDER']) ? $ff["QUERY"][$j]['CLASS'][0]['FOLDER'] : ''); $q['FIELDS'] = (isset($ff["QUERY"][$j]['CLASS'][0]['FIELDS']) ? $ff["QUERY"][$j]['CLASS'][0]['FIELDS'] : ''); }else $q["WORD"]=false; if (isset($ff["QUERY"][$j]['SEARCHABLEONLY']) && $ff["QUERY"][$j]['SEARCHABLEONLY']=="yes"){ $q["SEARCHABLEONLY"]=true; }else $q["SEARCHABLEONLY"]=false; $q["MAIN"]=(isset($ff["QUERY"][$j]["MAIN"][0]["value"]) ? $ff["QUERY"][$j]["MAIN"][0]["value"] : ''); $q["MULTIPLE_TERM"]=(isset($ff["QUERY"][$j]["MULTIPLETERM"][0]["value"]) ? $ff["QUERY"][$j]["MULTIPLETERM"][0]["value"] : ''); $q["MULTIPLE_OPERATOR"]=(isset($ff["QUERY"][$j]["MULTIPLEOPERATOR"][0]["value"]) ? $ff["QUERY"][$j]["MULTIPLEOPERATOR"][0]["value"] : ''); $t["QUERIES"][]=$q; $t["QUERIES_INDEX"][$q["OPERATOR"]]=count($t["QUERIES"])-1; } $champType["FIELD"][$ff["ID"]]=$t; } $this->dynamicfields[$ft["PREFIX"]]=$champType; } //Lecture des champs speciaux if (isset($param["SPECIALFIELDS"][0]["VISIBLE"]) && $param["SPECIALFIELDS"][0]["VISIBLE"]=="no") { $this->specials_not_visible=true; } if(is_array($param["SPECIALFIELDS"][0]["FIELD"]) && count($param["SPECIALFIELDS"][0]["FIELD"])){ for ($i=0; $igroups_used){ $t["GROUP"]=(isset($sf["GROUP"]) ? $sf["GROUP"] : ''); } $t["NOTDISPLAYCOL"]=(isset($sf["NOTDISPLAYCOL"]) ? $sf["NOTDISPLAYCOL"] : ''); $t["UNIMARCFIELD"]=(isset($sf["UNIMARCFIELD"]) ? $sf["UNIMARCFIELD"] : ''); $t["SEPARATOR"]=''; if(isset($sf["SEPARATOR"])) { if (substr($sf["SEPARATOR"],0,4)=="msg:") { $t["SEPARATOR"]=$msg[substr($sf["SEPARATOR"],4,strlen($sf["SEPARATOR"])-4)]; } else { $t["SEPARATOR"]=$sf["SEPARATOR"]; } } $t["TYPE"]=$sf["TYPE"]; //Visibilite if(isset($sf["VISIBLE"]) && $sf["VISIBLE"]=="no") $t["VISIBLE"]=false; else $t["VISIBLE"]=true; if(isset($sf["DELNOTALLOWED"]) && $sf["DELNOTALLOWED"] == "yes") $t["DELNOTALLOWED"]=true; else $t["DELNOTALLOWED"]=false; $t["OPACVISIBILITY"]=(isset($sf["OPACVISIBILITY"]) && $sf["OPACVISIBILITY"] == "no" ? false : true); $this->specialfields[$sf["ID"]]=$t; } } if (is_array($this->specialfields) && (count($this->specialfields)!=0)) { if (file_exists($include_path."/search_queries/specials/catalog_subst.xml")) { $nom_fichier=$include_path."/search_queries/specials/catalog_subst.xml"; } else { $nom_fichier=$include_path."/search_queries/specials/catalog.xml"; } $parametres=file_get_contents($nom_fichier); $this->tableau_speciaux=_parser_text_no_function_($parametres, "SPECIALFIELDS"); } $this->keyName = (isset($param["KEYNAME"][0]["value"]) ? $param["KEYNAME"][0]["value"] : ''); if(($this->fichier_xml == 'search_fields_authorities') || ($this->fichier_xml == 'search_fields_authorities_gestion')) { if(!$this->keyName) { $this->keyName="id_authority"; } $this->tableName="authorities"; } else { if(!$this->keyName) { $this->keyName="notice_id"; } $this->tableName="notices"; } $tmp_array_cache=array( $this->groups_used, $this->groups, $this->memory_engine_allowed, $this->operators, $this->op_empty, $this->fixedfields, $this->dynamics_not_visible, $this->dynamicfields_order, $this->dynamicfields_hidebycustomname, $this->dynamicfields, $this->specials_not_visible, $this->tableau_speciaux, $this->keyName, $this->tableName, $this->specialfields); if ($key_file) { $key_file_content=$KEY_CACHE_FILE_XML.md5(serialize($tmp_array_cache)); $cache_php->setInCache($key_file_content, $tmp_array_cache); $cache_php->setInCache($key_file,$key_file_content); }else{ $tmp = fopen($tempFile, "wb"); fwrite($tmp,serialize($tmp_array_cache)); fclose($tmp); } } } // fin parse_search_file public function strip_slashes() { global $search, $explicit_search; if(isset($search) && is_array($search)) { for ($i=0; $iget_global_value("field_".$i."_".$search[$i]); if (is_object($this)) { $field=$this->make_stripslashes_test_array($field); } else { for ($j=0; $jget_global_value("field_".$i."_".$search[$i]."_1"); if (is_object($this)) { $field1=$this->make_stripslashes_test_array($field1); } else { for ($j=0; $jfixedfields[$s[1]]) ? $this->fixedfields[$s[1]] : []); if (isset($ff["INPUT_TYPE"])) { switch ($ff["INPUT_TYPE"]) { case "date": $op=$this->get_global_value("op_".$i."_".$search[$i]); switch ($op) { case 'LESS_THAN_DAYS': case 'MORE_THAN_DAYS': //Rien a faire break; default: if(!preg_match("/^\d{4}-\d{2}-\d{2}$/",$field[0])) { $field_temp=extraitdate($field[0]); $field[0]=$field_temp; } break; } break; default: //Rien a faire break; } } } } $this->set_global_value("field_".$i."_".$search[$i], $field); $this->set_global_value("field_".$i."_".$search[$i]."_1", $field1); //Fieldvar doit aussi être addslashé pour les shorturls $fieldvar=$this->get_global_value("fieldvar_".$i."_".$search[$i]); if ($fieldvar == '') $fieldvar = array(); if (is_object($this)) { $fieldvar=$this->make_stripslashes_test_array($fieldvar); } else { for ($j=0; $jset_global_value("fieldvar_".$i."_".$search[$i], $fieldvar); } } } public function make_stripslashes_test_array($value){ //stripslashes récursif car les facette sont des tableaux de tableaux if (is_array($value)) { foreach ($value as $k=>$v) { $value[$k] = $this->make_stripslashes_test_array($value[$k]); } return $value; } else { return stripslashes($value); } } public function get_id_from_datatype($datatype, $fieldType = "d") { if(!is_array($this->dynamicfields[$fieldType]["FIELD"])) return ''; foreach($this->dynamicfields[$fieldType]["FIELD"] as $key => $val){ if ($val["DATATYPE"]==$datatype) return $key; } return ''; } protected function get_completion_selection_field($i,$n,$search, $v, $params=array()) { global $charset; global $msg; $fnamesans="field_".$n."_".$search; $fname="field_".$n."_".$search."[]"; $fname_id="field_".$n."_".$search."_id"; $fnamesanslib="field_".$n."_".$search."_lib"; $fnamelib="field_".$n."_".$search."_lib[]"; $selector = $params['selector']; $p1 = $params['p1']; $p2 = $params['p2']; $op = $this->get_global_value("op_".$i."_".$search); $v=$this->clean_completion_empty_values($v); $nb_values=count($v); if(!$nb_values){ //Création de la ligne $nb_values=1; } $nb_max_aut=$nb_values-1; $r = ""; $r.= ""; $r.= "fichier_xml."&search_field_id=".$search."&deb_rech=&callback=selectionSelected&infield=".$fnamesans."_0', 'selector')\" type=\"button\">"; $r.= ""; $r.= ""; $r.= "
"; for($inc=0;$inc<$nb_values;$inc++){ if(!isset($v[$inc])) $v[$inc] = ''; $r.=""; switch ($op) { case 'EQ': if($v[$inc]){ $libelle = $this->get_selector_display($v[$inc], $params['selector'], $search); }else{ $libelle = ""; } break; default: $libelle = $v[$inc]; break; } $r.=" "; $r.="".$msg["10"].""; $r.= ""; $r.= "
"; } $r.= "
"; if($nb_values>1){ $r.=""; } return $r; } protected function get_completion_authority_field($i,$n,$search, $v, $params=array()) { global $charset; global $opac_thesaurus; global $msg; $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"; $fnamevar_id = ""; $authperso_id = 0; if($params['selector'] == 'authperso') { if($authperso_id_pos = strrpos($search,'_')) { $authperso_id = substr($search,$authperso_id_pos+1); } $fnamevar_id = ""; $fnamevar_id_js = ""; } $selector = $params['selector']; $p1 = $params['p1']; $p2 = $params['p2']; if($params['ajax'] == "categories" and $opac_thesaurus == 1){ $fnamevar_id = "linkfield=\"fieldvar_".$n."_".$search."[id_thesaurus][]\""; $fnamevar_id_js = "fieldvar_".$n."_".$search."[id_thesaurus][]"; }else if(($params['ajax'] == "onto") || ($params['ajax'] == "concepts")){ switch ($params['att_id_filter']) { case "http://www.w3.org/2004/02/skos/core#ConceptScheme" : $element = 'conceptscheme'; break; default : $element = 'concept'; break; } $selector .= "&dyn=4&element=".$element."&return_concept_id=1"; if (!$params['att_id_filter']) { $params['att_id_filter'] = 'http://www.w3.org/2004/02/skos/core#Concept'; } $fnamevar_id = "linkfield=\"fieldvar_".$n."_".$search."[id_scheme][]\" att_id_filter=\"".$params['att_id_filter']."\""; $fnamevar_id_js = "fieldvar_".$n."_".$search."[id_scheme][]"; }else if($params['selector'] == "collection" || $params['selector'] == "subcollection"){ $selector .= "&selfrom=rmc"; $fnamevar_id = ""; $fnamevar_id_js = ""; }else if($params['ajax'] == "vedette"){ $selector .= "&grammars=notice_authors,tu_authors"; $fnamevar_id = "linkfield=\"fieldvar_".$n."_".$search."[grammars][]\""; $fnamevar_id_js = "fieldvar_".$n."_".$search."[grammars][]"; }else{ $fnamevar_id = ""; $fnamevar_id_js = ""; } $op = $this->get_global_value("op_".$i."_".$search); $fieldvar=$this->get_global_value("fieldvar_".$i."_".$search); $v=$this->clean_completion_empty_values($v); $nb_values=count($v); if(!$nb_values){ //Création de la ligne $nb_values=1; } $nb_max_aut=$nb_values-1; $r = ""; $r.= ""; if ($params['selector'] != 'instruments') { $r.= ""; $r.= ""; } $r.= ""; $r.= "
"; for($inc=0;$inc<$nb_values;$inc++){ if(!isset($v[$inc])) $v[$inc] = ''; switch ($op) { case 'AUTHORITY': if ($params['selector'] == 'ontology') { // On vérifie si c'est un id transmis if ($v[$inc] && !is_numeric($v[$inc])) { // C'est une uri $v[$inc] = onto_common_uri::get_id($v[$inc]); } } if($v[$inc]!= 0){ $libelle = self::get_authoritie_display($v[$inc], $params['selector']); }else{ $libelle = ""; } break; default: $libelle = $v[$inc]; if ($params['selector'] == 'instruments') { $libelle = nomenclature_instrument::get_instrument_name_from_id($v[$inc]); } break; } $r.=""; $r.=" "; $r.="".$msg["10"].""; $r.= ""; $r.= ""; $r.= "
"; } $r.= "
"; if($nb_values>1){ $r.=""; } return $r; } public function get_options_list_field($ff, $start='', $limit=0) { $list = array(); switch ($ff["INPUT_TYPE"]) { case 'query_list': $requete=$ff["INPUT_OPTIONS"]["QUERY"][0]["value"]; if (isset($ff["INPUT_FILTERING"])) { 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); } } if(isset($ff["INPUT_OPTIONS"]["QUERY"][0]["USE_GLOBAL"])) { $use_global = explode(",", $ff["INPUT_OPTIONS"]["QUERY"][0]["USE_GLOBAL"]); for($j=0; $jinverse_of)) { // sous tableau genre ascendant descendant... foreach ($options->table as $table) { $tmp = array_merge($tmp, $table); } $options->table = $tmp; } else { $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; $restrictview=false; $restrictqueryarray=array(); if (!empty($_SESSION['opac_view'])) { $query = pmb_mysql_query('SELECT opac_view_query FROM opac_views WHERE opac_view_id = '.intval($_SESSION['opac_view'])); $result = pmb_mysql_fetch_row($query); if (!empty($result) && !empty($result[0])) { $restrictview = true; } } if ($ff["INPUT_OPTIONS"]["RESTRICTQUERY"][0]["value"]) { $query = $ff["INPUT_OPTIONS"]["RESTRICTQUERY"][0]["value"]; $restrictviewquery = ""; if ($restrictview && !empty($ff["INPUT_OPTIONS"]["RESTRICTVIEW"][0]["value"])) { $restrictviewquery = str_replace('!!opac_view!!', intval($_SESSION['opac_view']), $ff["INPUT_OPTIONS"]["RESTRICTVIEW"][0]["value"]); } $query = str_replace('!!restrictview!!', $restrictviewquery, $query); $restrictquery=pmb_mysql_query($query); if ($restrictqueryrow=@pmb_mysql_fetch_row($restrictquery)) { if ($restrictqueryrow[0]) { $restrictqueryarray=explode(",",$restrictqueryrow[0]); $existrestrict=true; } } } foreach ($options->table as $key => $val) { if (!$start || strtolower(substr($val,0,strlen($start)))==strtolower($start)) { if ((!$existrestrict) || (array_search($key,$restrictqueryarray)!==false)) { $list[$key] = $val; } } } break; } if($limit) { $list = array_slice($list, 0, $limit, true); } return $list; } protected function get_variable_field($var_field,$n,$search,$var_table,$fieldvar) { global $charset, $msg; if (empty($fieldvar)) { $fieldvar = array(); } $variable_field = ''; if ($var_field["TYPE"]=="input") { $varname=$var_field["NAME"]; $visibility=1; if(isset($var_field["OPTIONS"]["VAR"][0])) { $vis=$var_field["OPTIONS"]["VAR"][0]; if ($vis["NAME"]) { $vis_name=$vis["NAME"]; global ${$vis_name}; if ($vis["VISIBILITY"]=="no") $visibility=0; for ($k=0; $k"; } if (isset($var_field["OPTIONS"]["INPUT"][0]["CLASS"]) && $var_field["OPTIONS"]["INPUT"][0]["CLASS"]) { $variable_field.=""; } if (isset($var_field["SPAN"]) && $var_field["SPAN"]) { $variable_field.="".$var_field["COMMENT"].""; } else { $variable_field.=htmlentities($var_field["COMMENT"], ENT_QUOTES, $charset); } $input=$var_field["OPTIONS"]["INPUT"][0]; if(!empty($input["QUERY"][0]["TRANSLATIONTABLENAME"]) && !empty($input["QUERY"][0]["TRANSLATIONFIELDNAME"])) { $trans_table = $input["QUERY"][0]["TRANSLATIONTABLENAME"]; $trans_field = $input["QUERY"][0]["TRANSLATIONFIELDNAME"]; } else { $trans_table = ''; $trans_field = ''; } switch ($input["TYPE"]) { case "query_list": if ((!isset($fieldvar[$varname]) || !$fieldvar[$varname])&&($default)) $fieldvar[$varname][0]=$default; $variable_field.=" "; if (isset($var_field["OPTIONS"]["INPUT"][0]["CLASS"]) && $var_field["OPTIONS"]["INPUT"][0]["CLASS"]) { $variable_field.=""; } break; case "checkbox" : if(!isset($input["DEFAULT_ON"]) || !$input["DEFAULT_ON"]){ if ((!isset($fieldvar[$varname]) || !$fieldvar[$varname])&&($default)) $fieldvar[$varname][0]=$default; } elseif(!isset($fieldvar[$input["DEFAULT_ON"]][0]) || !$fieldvar[$input["DEFAULT_ON"]][0]) $fieldvar[$varname][0] =$default; $variable_field.=" "; if (isset($var_field["OPTIONS"]["INPUT"][0]["CLASS"]) && $var_field["OPTIONS"]["INPUT"][0]["CLASS"]) { $variable_field.=""; } break; case "number": if ((!isset($fieldvar[$varname]) || !$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]; $variable_field.=""; if (isset($var_field["OPTIONS"]["INPUT"][0]["CLASS"]) && $var_field["OPTIONS"]["INPUT"][0]["CLASS"]) { $variable_field.=""; } break; } if(isset($var_field["CLASS"]) && $var_field["CLASS"]) { $variable_field.=""; } $variable_field.=""; } else { if($vis["HIDDEN"] != "no") $variable_field.=""; } } return $variable_field; } public function get_field($i,$n,$search,$pp) { global $charset; global $aff_list_empr_search; global $msg; global $include_path; global $class_path; global $opac_map_base_layer_type; global $opac_map_base_layer_params; global $opac_map_size_search_edition, $opac_map_bounding_box; $r=""; $s=explode("_",$search); //Champ $v=$this->get_global_value("field_".$i."_".$search); if ($v=="") $v=array(); $v1=$this->get_global_value("field_".$i."_".$search.'_1'); if ($v1=="") $v1=array(); //Variables $fieldvar=$this->get_global_value("fieldvar_".$i."_".$search); if ($s[0]=="f") { //Champs fixes $ff=$this->fixedfields[$s[1]]; //Variables globales et input for ($j=0; $jget_variable_field($ff["VAR"][$j],$n,$search,$var_table,$fieldvar); } else { $r_bottom .= $this->get_variable_field($ff["VAR"][$j],$n,$search,$var_table,$fieldvar); } } //Affichage des variables ayant l'attribut place='top' $r.=$r_top; switch ($ff["INPUT_TYPE"]) { case "authoritie_external": $op = "op_".$i."_".$search; global ${$op}; $libelle = ""; if (${$op} == "AUTHORITY"){ if($v[0]!= 0){ $libelle = self::get_authoritie_display($v[0], $ff['INPUT_OPTIONS']['SELECTOR']); } ${$op} == "BOOLEAN"; $r.=""; } if($libelle){ $r.=""; }else{ $r.=""; } break; case "authoritie": $params = array( 'ajax' => $ff["INPUT_OPTIONS"]["AJAX"], 'selector' => $ff["INPUT_OPTIONS"]["SELECTOR"], 'p1' => $ff["INPUT_OPTIONS"]["P1"], 'p2' => $ff["INPUT_OPTIONS"]["P2"], 'att_id_filter' => (isset($ff["INPUT_OPTIONS"]["ATT_ID_FILTER"]) ? $ff["INPUT_OPTIONS"]["ATT_ID_FILTER"] : ''), 'param1' => (isset($ff["INPUT_OPTIONS"]["PARAM1"]) ? $ff["INPUT_OPTIONS"]["PARAM1"] : '') ); $r.= $this->get_completion_authority_field($i,$n,$search, $v, $params); break; case "text": $input_placeholder = ''; if(isset($ff['INPUT_OPTIONS']['PLACEHOLDER'])) { 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"]; } } if(!isset($v[0])) $v[0] = ''; $r.=""; break; case "query_list": case "list": case "marc_list": if(isset($ff["INPUT_OPTIONS"]["COMPLETION"]) && $ff["INPUT_OPTIONS"]["COMPLETION"] == 'yes') { $params = array( 'ajax' => $ff["INPUT_TYPE"], 'selector' => $ff["INPUT_TYPE"], 'p1' => 'p1', 'p2' => 'p2' ); $r.=$this->get_completion_selection_field($i,$n,$search, $v, $params); } else { $multiple = 'multiple'; if (isset($ff["INPUT_OPTIONS"]["MULTIPLE"]) && $ff["INPUT_OPTIONS"]["MULTIPLE"] == 'no') { $multiple = ''; } $r.=""; } break; case "checkbox_list": case "checkbox_marc_list": $r.=""; $list = $this->get_options_list_field($ff); if(count($list)) { $r .= ""; $r .= "".htmlentities($msg['check_uncheck'],ENT_QUOTES, $charset)."
"; foreach ($list as $key=>$value) { $r.=""; } } $r.=""; break; case "date": $op = "op_".$i."_".$search; global ${$op}; $field['OP'] = ${$op}; if(!isset($v[0])) $v[0] = ''; $field['VALUES'][0]=$v[0]; if(!isset($v1[0])) $v1[0] = ''; $field['VALUES1'][0]=$v1[0]; $r.="".$aff_list_empr_search['date_box']($field, $check_scripts, "field_".$n."_".$search).""; break; case "map" : $baselayer = "baseLayerType: dojox.geo.openlayers.BaseLayerType.".$opac_map_base_layer_type; if ($opac_map_base_layer_params) { $layer_params = json_decode($opac_map_base_layer_params,true); 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']); } } $initialFit = ''; if(!count($v)) { if( $opac_map_bounding_box) { $map_bounding_box = $opac_map_bounding_box; } else { $map_bounding_box = '-5 50,9 50,9 40,-5 40,-5 50'; } $map_hold = new map_hold_polygon("bounding", 0, "polygon((".$map_bounding_box."))"); if ($map_hold) { $coords = $map_hold->get_coords(); $initialFit = explode(',', map_objects_controler::get_coord_initialFit($coords)); } else{ $initialFit = array(0, 0, 0, 0); } } $size=explode("*",$opac_map_size_search_edition); if(count($size)!=2) { $map_size="width:800px; height:480px;"; } else { if (is_numeric($size[0])) $size[0].= 'px'; if (is_numeric($size[1])) $size[1].= 'px'; $map_size= "width:".$size[0]."; height:".$size[1].";"; } $map_holds=array(); foreach($v as $map_hold){ $map_holds[] = array( "wkt" => $map_hold, "type"=> "search", "color"=> null, "objects"=> array() ); } $r.="
"; break; } //Affichage des variables n'ayant pas l'attribut place='top' $r.=$r_bottom; } 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['NUMBER']=$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']=$this->pp[$s[0]]->t_fields[$s[1]]['OPTIONS']; $field['VALUES']=$v; $field['VALUES1']=$v1; $field['PREFIX']=$this->pp[$s[0]]->prefix; if(!empty($aff_list_empr_search[$this->pp[$s[0]]->t_fields[$s[1]]['TYPE']])) { $r="".$aff_list_empr_search[$this->pp[$s[0]]->t_fields[$s[1]]['TYPE']]($field, $check_scripts, "field_".$n."_".$search).""; } } elseif ($s[0]=="authperso") { $params = array( 'ajax' => $s[0].'_'.$s[1], 'selector' => $s[0], 'p1' => 'p1', 'p2' => 'p2' ); $r = $this->get_completion_authority_field($i,$n,$search, $v, $params); }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; $istableau_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; } public function make_search($prefixe="") { global $search; global $dbh; global $msg; global $include_path; global $class_path; global $opac_stemming_active; global $search_previous_table; $this->error_message=""; $main=""; $last_table=""; $field_keyName=$this->keyName; $field_tableName=$this->tableName; //Pour chaque champ if(is_array($search) && count($search)){ for ($i=0; $ifixedfields[$s[1]]; //Choix du moteur if ($this->memory_engine_allowed && !$ff['MEMORYENGINEFORBIDDEN'] ) { $this->current_engine = 'MEMORY'; } else { $this->current_engine = 'MyISAM'; } //Calcul des variables $var_table=array(); if(is_array($ff["VAR"]) && count($ff["VAR"])){ for ($j=0; $j $var_value) { $query_calc=str_replace("!!".$var_name."!!",$var_value,$query_calc); } $r_calc=pmb_mysql_query($query_calc); $var_table[$ff["VAR"][$j]["NAME"]]=@pmb_mysql_result($r_calc,0,0); break; } break; } } } $q_index=$ff["QUERIES_INDEX"]; //Recuperation de la requete associee au champ et a l'operateur $q=$ff["QUERIES"][$q_index[${$op}]]; //Si c'est une requete conditionnelle, on sélectionne la bonne requete et on supprime les autres if(isset($q[0]["CONDITIONAL"]) && $q[0]["CONDITIONAL"]){ $k_default=0; $q_temp = array(); $q_temp["OPERATOR"]=$q["OPERATOR"]; for($k=0; $k $var_value) { $q[$k]["MAIN"]=str_replace("!!".$var_name."!!",$var_value,$q[$k]["MAIN"]); $q[$k]["MULTIPLE_TERM"]=str_replace("!!".$var_name."!!",$var_value,$q[$k]["MULTIPLE_TERM"]); } } } $last_main_table=""; // pour les listes, si un opérateur permet une valeur vide, il en faut une... if($this->op_empty[${$op}] && !is_array($field) ){ $field = array(); $field[0] = ""; } if (!$this->op_empty[${$op}]) { // nettoyage des valeurs if (${$op}=='AUTHORITY') { $field = $this->clean_completion_empty_values($field); } else { $field = $this->clean_empty_values($field); } } //Pour chaque valeur du champ if(is_array($field) && count($field)){ for ($j=0; $jerror; else $err=$aq->error; if (!$err) { if (is_array($q[$z]["TABLE"])) { for ($z1=0; $z1get_query_members($q[$z]["TABLE"][$z1],$q[$z]["INDEX_L"][$z1],$q[$z]["INDEX_I"][$z1],$q[$z]["ID_FIELD"][$z1],$q[$z]["RESTRICT"][$z1],0,0,$is_fulltext); else $members=$aq1->get_query_members($q[$z]["TABLE"][$z1],$q[$z]["INDEX_L"][$z1],$q[$z]["INDEX_I"][$z1],$q[$z]["ID_FIELD"][$z1],$q[$z]["RESTRICT"][$z1],0,0,$is_fulltext); $main=str_replace("!!pert_term_".($z1+1)."!!",$members["select"],$main); $main=str_replace("!!where_term_".($z1+1)."!!",$members["where"],$main); } } else { $is_fulltext=false; if (isset($q[$z]["FULLTEXT"]) && $q[$z]["FULLTEXT"]) $is_fulltext=true; if (isset($q[$z]["KEEP_EMPTY_WORDS"]) && $q[$z]["KEEP_EMPTY_WORDS"]) $members=$aq1->get_query_members($q[$z]["TABLE"],$q[$z]["INDEX_L"],$q[$z]["INDEX_I"],$q[$z]["ID_FIELD"],(!empty($q[$z]["RESTRICT"]) ? $q[$z]["RESTRICT"] : ''),0,0,$is_fulltext); else $members=$aq->get_query_members($q[$z]["TABLE"],$q[$z]["INDEX_L"],$q[$z]["INDEX_I"],$q[$z]["ID_FIELD"],(!empty($q[$z]["RESTRICT"]) ? $q[$z]["RESTRICT"] : ''),0,0,$is_fulltext); $main=str_replace("!!pert_term!!",$members["select"],$main); $main=str_replace("!!where_term!!",$members["where"],$main); } } else { $main="select ".$field_keyName." from ".$this->tableName." where ".$field_keyName."=0"; $this->error_message=sprintf($msg["searcher_syntax_error_desc"],$aq->current_car,$aq->input_html,$aq->error_message); } }else if ($q[$z]["WORD"]){ //Pour savoir si la recherche tous champs inclut les docnum global $multi_crit_indexation_docnum_allfields; $multi_crit_indexation_docnum_allfields = -1; if (!empty($var_table["is_num"])) { $multi_crit_indexation_docnum_allfields = 1; } //Pour savoir si la recherche inclut les oeuvres global $multi_crit_indexation_oeuvre_title; $multi_crit_indexation_oeuvre_title = -1; if (!empty($var_table["oeuvre_query"])) { $multi_crit_indexation_oeuvre_title = 1; } if(isset($q[$z]['TYPE']) && $q[$z]['TYPE']){ $mode = ''; if(isset($q[$z]['MODE'])){ $mode = $q[$z]['MODE']; } if($q[$z]["FIELDS"]){ $searcher = searcher_factory::get_searcher($q[$z]['TYPE'], $mode,$field[$j],$q[$z]["FIELDS"]); }else{ $searcher = searcher_factory::get_searcher($q[$z]['TYPE'], $mode, $field[$j]); } }else{ //recherche par terme... if($q[$z]["FIELDS"]){ $searcher = new $q[$z]['CLASS']($field[$j],$q[$z]["FIELDS"]); }else{ $searcher = new $q[$z]['CLASS']($field[$j]); } } if (!empty($var_table)) { $searcher->add_var_table($var_table); } if(isset($q[$z]['FIELDSRESTRICT']) && is_array($q[$z]['FIELDSRESTRICT'])) { $searcher->add_fields_restrict($q[$z]['FIELDSRESTRICT']); } $main = $searcher->get_full_query(); }else{ $field[$j]=str_replace('*', '%', $field[$j]); $main=str_replace("!!p!!",addslashes($field[$j]),$main); $main=str_replace("!!p1!!",(isset($field1[$j]) ? addslashes($field1[$j]) : ''),$main); } //Y-a-t-il une close repeat ? if (isset($q[$z]["REPEAT"]) && $q[$z]["REPEAT"]) { //Si oui, on repete !! $onvals=$q[$z]["REPEAT"]["ON"]; global ${$onvals}; $onvalst=explode($q[$z]["REPEAT"]["SEPARATOR"],${$onvals}); $mains=array(); if ((count($onvalst)!=1)||($onvalst[0])) { for ($ir=0; $irget_multi_search_operator()?$this->get_multi_search_operator():"or"); } if (count($field)>1) { $suffixe = $i."_".$j; if($operator == "or"){ //Ou logique si plusieurs valeurs if ($prefixe) { $this->gen_temporary_table($prefixe."mf_".$suffixe, $main); } else { $this->gen_temporary_table("mf_".$suffixe, $main); } if ($last_main_table) { if ($prefixe) { $requete="insert ignore into ".$prefixe."mf_".$suffixe." select ".$last_main_table.".* from ".$last_main_table; } else { $requete="insert ignore into mf_".$suffixe." select ".$last_main_table.".* from ".$last_main_table; } pmb_mysql_query($requete,$dbh); //pmb_mysql_query("drop table if exists mf_".$suffixe,$dbh); pmb_mysql_query("drop table if exists ".$last_main_table,$dbh); } //else pmb_mysql_query("drop table if exists mf_".$suffixe,$dbh); if ($prefixe) { $last_main_table=$prefixe."mf_".$suffixe; } else { $last_main_table="mf_".$suffixe; } } elseif($operator == "and"){ //ET logique si plusieurs valeurs if ($prefixe) { $this->gen_temporary_table($prefixe."mf_".$suffixe, $main); } else { $this->gen_temporary_table("mf_".$suffixe, $main); } if ($last_main_table) { if($j>1){ $search_table=$last_main_table; }else{ $search_table=$last_tables; } if ($prefixe) { $requete = $this->generate_query_op_and($prefixe, $suffixe, $search_table); } else { $requete = $this->generate_query_op_and("", $suffixe, $search_table); } pmb_mysql_query($requete,$dbh); pmb_mysql_query("drop table if exists ".$last_tables,$dbh); } if ($prefixe) { $last_tables=$prefixe."mf_".$suffixe; } else { $last_tables="mf_".$suffixe; } if ($prefixe) { $last_main_table = $prefixe."and_result_".$suffixe; } else { $last_main_table = "and_result_".$suffixe; } } } //else print $main; } } if ($last_main_table){ $main="select * from ".$last_main_table; } } elseif (array_key_exists($s[0],$this->pp)) { $datatype=$this->pp[$s[0]]->t_fields[$s[1]]["DATATYPE"]; $df=$this->dynamicfields[$s[0]]["FIELD"][$this->get_id_from_datatype($datatype,$s[0])]; $q_index=$df["QUERIES_INDEX"]; $q=$df["QUERIES"][$q_index[${$op}]]; //Choix du moteur if ($this->memory_engine_allowed && !$df['MEMORYENGINEFORBIDDEN'] ) { $this->current_engine = 'MEMORY'; } else { $this->current_engine = 'MyISAM'; } //Pour chaque valeur du champ $last_main_table=""; if (count($field)==0) $field[0]=""; for ($j=0; $jpp[$s[0]]->t_fields[$s[1]]['TYPE'].".class.php")) { require_once($include_path."/search_queries/dynamics/dynamic_search_".$this->pp[$s[0]]->t_fields[$s[1]]['TYPE'].".class.php"); $dynamic_class_name = "dynamic_search_".$this->pp[$s[0]]->t_fields[$s[1]]['TYPE']; $dynamic_class = new $dynamic_class_name($s[1],$s[0], $i,$df,$this); $main = $dynamic_class->get_query($field[$j], $field1[$j]); } else { if($q["KEEP_EMPTYWORD"]) $field[$j]=strip_empty_chars($field[$j]); elseif ($q["REGDIACRIT"]) $field[$j]=strip_empty_words($field[$j]); $main=$q["MAIN"]; //Si il y a plusieurs termes possibles if ($q["MULTIPLE_WORDS"]) { $terms=explode(" ",$field[$j]); //Pour chaque terme $multiple_terms=array(); for ($k=0; $kadd_fields_restrict($q['FIELDSRESTRICT']); } $main = $searcher->get_full_query(); } else { $field[$j]=str_replace('*', '%', $field[$j]); $main=str_replace("!!p!!",addslashes($field[$j]),$main); $main=str_replace("!!p1!!",(isset($field1[$j]) ? addslashes($field1[$j]) : ''),$main); } $main=str_replace("!!field!!",$s[1],$main); } //Choix de l'operateur dans la liste if(isset($q["DEFAULT_OPERATOR"])){ $operator=$q["DEFAULT_OPERATOR"]; } else { $operator = ($this->get_multi_search_operator()?$this->get_multi_search_operator():"or"); } if (count($field)>1) { $suffixe = $i."_".$j; if($operator == "or"){ //Ou logique si plusieurs valeurs if ($prefixe) { $this->gen_temporary_table($prefixe."mf_".$suffixe, $main); } else { $this->gen_temporary_table("mf_".$suffixe, $main); } if ($last_main_table) { if ($prefixe) { $requete="insert ignore into ".$prefixe."mf_".$suffixe." select ".$last_main_table.".* from ".$last_main_table; } else { $requete="insert ignore into mf_".$suffixe." select ".$last_main_table.".* from ".$last_main_table; } pmb_mysql_query($requete,$dbh); //pmb_mysql_query("drop table if exists mf_".$suffixe,$dbh); pmb_mysql_query("drop table if exists ".$last_main_table,$dbh); } //else pmb_mysql_query("drop table if exists mf_".$suffixe,$dbh); if ($prefixe) { $last_main_table=$prefixe."mf_".$suffixe; } else { $last_main_table="mf_".$suffixe; } } elseif($operator == "and"){ //ET logique si plusieurs valeurs if ($prefixe) { $this->gen_temporary_table($prefixe."mf_".$suffixe, $main); } else { $this->gen_temporary_table("mf_".$suffixe, $main); } if ($last_main_table) { if($j>1){ $search_table=$last_main_table; }else{ $search_table=$last_tables; } if ($prefixe) { $requete = $this->generate_query_op_and($prefixe, $suffixe, $search_table); } else { $requete = $this->generate_query_op_and("", $suffixe, $search_table); } pmb_mysql_query($requete,$dbh); pmb_mysql_query("drop table if exists ".$last_tables,$dbh); } if ($prefixe) { $last_tables=$prefixe."mf_".$suffixe; } else { $last_tables="mf_".$suffixe; } if ($prefixe) { $last_main_table = $prefixe."and_result_".$suffixe; } else { $last_main_table = "and_result_".$suffixe; } } } //else print $main; } if ($last_main_table) { $main="select * from ".$last_main_table; } } elseif ($s[0]=="s") { //instancier la classe de traitement du champ special $type=$this->specialfields[$s[1]]["TYPE"]; if ($type=="facette") { //Traitement final if (!empty($search_previous_table)) { $requete="insert ignore into $last_table (notice_id,idiot,pert) select notice_id,1,pert from $search_previous_table"; pmb_mysql_query($requete); $search_previous_table=""; //print pmb_mysql_error(); } } if (!empty($this->tableau_speciaux['TYPE'])) { for ($is=0; $istableau_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],$i,$sf,$this); if(method_exists($specialclass, 'set_xml_file')){ $specialclass->set_xml_file($this->fichier_xml); } $last_main_table=$specialclass->make_search(); break; } } } if (!empty($last_main_table)) { $main="select * from ".$last_main_table; } } elseif ($s[0]=="authperso") { //on est sur le cas de la recherche "Tous les champs" de l'autorité perso //$s["1"] vaut l'identifiant du type d'autorité perso $df=$this->dynamicfields["a"]["FIELD"]["10"]; $q_index=$df["QUERIES_INDEX"]; $q=$df["QUERIES"][$q_index[${$op}]]; //Choix du moteur if ($this->memory_engine_allowed && !$df['MEMORYENGINEFORBIDDEN'] ) { $this->current_engine = 'MEMORY'; } else { $this->current_engine = 'MyISAM'; } //Pour chaque valeur du champ $last_main_table=""; if (count($field)==0) $field[0]=""; for ($j=0; $jget_full_query(); }else{ if ($q["MULTIPLE_WORDS"]) { $terms=explode(" ",$field[$j]); //Pour chaque terme $multiple_terms=array(); for ($k=0; $kget_multi_search_operator()?$this->get_multi_search_operator():"or"); } if (count($field)>1) { $suffixe = $i."_".$j; if($operator == "or"){ //Ou logique si plusieurs valeurs if ($prefixe) { $this->gen_temporary_table($prefixe."mf_".$suffixe, $main); } else { $this->gen_temporary_table("mf_".$suffixe, $main); } if ($last_main_table) { if ($prefixe) { $requete="insert ignore into ".$prefixe."mf_".$suffixe." select ".$last_main_table.".* from ".$last_main_table; } else { $requete="insert ignore into mf_".$suffixe." select ".$last_main_table.".* from ".$last_main_table; } pmb_mysql_query($requete,$dbh); //pmb_mysql_query("drop table if exists mf_".$suffixe,$dbh); pmb_mysql_query("drop table if exists ".$last_main_table,$dbh); } //else pmb_mysql_query("drop table if exists mf_".$suffixe,$dbh); if ($prefixe) { $last_main_table=$prefixe."mf_".$suffixe; } else { $last_main_table="mf_".$suffixe; } } elseif($operator == "and"){ //ET logique si plusieurs valeurs if ($prefixe) { $this->gen_temporary_table($prefixe."mf_".$suffixe, $main); } else { $this->gen_temporary_table("mf_".$suffixe, $main); } if ($last_main_table) { if($j>1){ $search_table=$last_main_table; }else{ $search_table=$last_tables; } if ($prefixe) { $requete = $this->generate_query_op_and($prefixe, $suffixe, $search_table); } else { $requete = $this->generate_query_op_and("", $suffixe, $search_table); } pmb_mysql_query($requete,$dbh); pmb_mysql_query("drop table if exists ".$last_tables,$dbh); } if ($prefixe) { $last_tables=$prefixe."mf_".$suffixe; } else { $last_tables="mf_".$suffixe; } if ($prefixe) { $last_main_table = $prefixe."and_result_".$suffixe; } else { $last_main_table = "and_result_".$suffixe; } } } //else print $main; } if ($last_main_table) { $main="select * from ".$last_main_table; } } if ($prefixe) { $table=$prefixe."t_".$i."_".$search[$i]; $this->gen_temporary_table($table, $main, true); } else { $table="t_".$i."_".$search[$i]; $this->gen_temporary_table($table, $main, true); } if (!empty($last_main_table)) { $requete="drop table if exists ".$last_main_table; pmb_mysql_query($requete); } //On supprime la table temporaire si elle existe (exemple : DSI multiples via le planificateur) if ($prefixe) { pmb_mysql_query("drop table if exists ".$prefixe."t".$i); } else { pmb_mysql_query("drop table if exists t".$i); } if ($prefixe) { $requete="create temporary table ".$prefixe."t".$i." ENGINE=".$this->current_engine." "; } else { $requete="create temporary table t".$i." ENGINE=".$this->current_engine." "; } $isfirst_criteria=false; switch (${$inter}) { case "and": $requete.="select "; $req_col="SHOW columns FROM ".$table; $res_col=pmb_mysql_query($req_col,$dbh); while ($col = pmb_mysql_fetch_object($res_col)){ if($col->Field == "pert"){ $requete.="SUM(".$table.".pert + ".$last_table.".pert) AS pert,"; }else{ $requete.=$table.".".$col->Field.","; } } $requete=substr($requete,0,-1); $requete.=" from $last_table,$table where ".$table.".".$field_keyName."=".$last_table.".".$field_keyName." group by ".$field_keyName; @pmb_mysql_query($requete,$dbh); break; case "or": //Si la table précédente est vide, c'est comme au premier jour ! $requete_c="select count(*) from ".$last_table; if (!@pmb_mysql_result(pmb_mysql_query($requete_c),0,0)) { $isfirst_criteria=true; } else { $requete.="select * from ".$table; @pmb_mysql_query($requete,$dbh); if ($prefixe) { $requete="alter table ".$prefixe."t".$i." add idiot int(1)"; @pmb_mysql_query($requete); $requete="alter table ".$prefixe."t".$i." add unique($field_keyName)"; @pmb_mysql_query($requete); $requete="alter table ".$prefixe."t".$i." add pert decimal(16,1) default 1"; @pmb_mysql_query($requete); } else { $requete="alter table t".$i." add idiot int(1)"; @pmb_mysql_query($requete); $requete="alter table t".$i." add unique($field_keyName)"; @pmb_mysql_query($requete); $requete="alter table t".$i." add pert decimal(16,1) default 1"; @pmb_mysql_query($requete); } if ($prefixe) { $requete="insert into ".$prefixe."t".$i." ($field_keyName,idiot,pert) select distinct ".$last_table.".".$field_keyName.",".$last_table.".idiot, ".$last_table.".pert AS pert from ".$last_table." left join ".$table." on ".$last_table.".$field_keyName=".$table.".$field_keyName where ".$table.".$field_keyName is null"; } else { $requete="insert into t".$i." ($field_keyName,idiot,pert) select distinct ".$last_table.".".$field_keyName.",".$last_table.".idiot, ".$last_table.".pert AS pert from ".$last_table." left join ".$table." on ".$last_table.".$field_keyName=".$table.".$field_keyName where ".$table.".$field_keyName is null"; //print $requete; } @pmb_mysql_query($requete,$dbh); } break; case "ex": //$requete_not="create temporary table ".$table."_b select notices.notice_id from notices left join ".$table." on notices.notice_id=".$table.".notice_id where ".$table.".notice_id is null"; //@pmb_mysql_query($requete_not); //$requete_not="alter table ".$table."_b add idiot int(1), add unique(notice_id)"; //@pmb_mysql_query($requete_not); $requete.="select ".$last_table.".* from $last_table left join ".$table." on ".$table.".$field_keyName=".$last_table.".$field_keyName where ".$table.".$field_keyName is null"; @pmb_mysql_query($requete); //$requete="drop table if exists ".$table."_b"; //@pmb_mysql_query($requete); if ($prefixe) { $requete="alter table ".$prefixe."t".$i." add idiot int(1)"; @pmb_mysql_query($requete); $requete="alter table ".$prefixe."t".$i." add unique(".$field_keyName.")"; @pmb_mysql_query($requete); $requete="alter table ".$prefixe."t".$i." add pert decimal(16,1) default 1"; @pmb_mysql_query($requete); } else { $requete="alter table t".$i." add idiot int(1)"; @pmb_mysql_query($requete); $requete="alter table t".$i." add unique(".$field_keyName.")"; @pmb_mysql_query($requete); $requete="alter table ".$prefixe."t".$i." add pert decimal(16,1) default 1"; @pmb_mysql_query($requete); } break; default: $isfirst_criteria=true; $requete.="select * from ".$table; @pmb_mysql_query($requete,$dbh); $existing_columns = array(); $result = pmb_mysql_query('show columns from '.$prefixe.'t'.$i); while ($row = pmb_mysql_fetch_object($result)) { $existing_columns[] = $row->Field; } if (!in_array('idiot', $existing_columns)) { $requete="alter table ".$prefixe."t".$i." add idiot int(1)"; @pmb_mysql_query($requete); } $requete="alter table ".$prefixe."t".$i." add unique(".$field_keyName.")"; @pmb_mysql_query($requete); if (!in_array('pert', $existing_columns)) { $requete="alter table ".$prefixe."t".$i." add pert decimal(16,1) default 1"; @pmb_mysql_query($requete); } break; } if (!$isfirst_criteria) { if($last_table){ pmb_mysql_query("drop table if exists ".$last_table,$dbh); } if($table){ pmb_mysql_query("drop table if exists ".$table,$dbh); } if ($prefixe) { $last_table=$prefixe."t".$i; } else { $last_table="t".$i; } } else { if($last_table){ pmb_mysql_query("drop table if exists ".$last_table,$dbh); } $last_table=$table; } } } //Traitement final if (!empty($search_previous_table)) { $requete="insert ignore into $last_table (notice_id,pert) select notice_id,pert from $search_previous_table"; pmb_mysql_query($requete); } $requete_c="select count(*) from ".$last_table; return $last_table; } public function make_hidden_search_form($url,$form_name="search_form",$target="",$close_form=true) { $r="
make_hidden_form_content(); if ($close_form) $r.="
"; return $r; } public function make_hidden_form_content() { global $search; global $charset; global $page; global $count; global $nb_per_page_custom; $r=''; for ($i=0; $iget_global_value($field_); $field1_="field_".$i."_".$search[$i]."_1"; $field1=$this->get_global_value($field1_); $s=explode("_",$search[$i]); $type=''; if ($s[0]=="s") { //instancier la classe de traitement du champ special $type=$this->specialfields[$s[1]]["TYPE"]; } //Recuperation des variables auxiliaires $fieldvar_="fieldvar_".$i."_".$search[$i]; $fieldvar=$this->get_global_value($fieldvar_); if (!is_array($fieldvar)) $fieldvar=array(); // si sélection d'autorité et champ vide : on ne doit pas le prendre en compte if(${$op}=='AUTHORITY'){ $field = $this->clean_completion_empty_values($field); }elseif(${$op}=='EQ'){ $field = $this->clean_empty_values($field); } $r.=""; $r.=""; $r.=""; if ($type=='facette') { $r.="\n"; } elseif(is_array($field) && count($field)) { for ($j=0; $j$value) { $r.=""; } } else { $r.=""; } } } if(is_array($field1)) { for ($j=0; $j$value) { $r.=""; } } else { $r.=""; } } } reset($fieldvar); foreach ($fieldvar as $var_name => $var_value) { for ($j=0; $j$value) { $r.=""; } } else { $r.=""; } } } } if($count){ $r.=""; } $r.=" \n"; return $r; } public function make_hidden_opac_view_form_content() { global $charset; global $search; $r = ''; if (isset($_SESSION['opac_view']) && $_SESSION['opac_view']) { $query = "select opac_view_query from opac_views where opac_view_id = ".$_SESSION['opac_view']; $result = pmb_mysql_query($query); if ($result && pmb_mysql_num_rows($result)) { $row = pmb_mysql_fetch_object($result); $serialized = $row->opac_view_query; if ($serialized) { $nb_search = count($search); $serialized_field = serialize(array( 'serialized_search' => $serialized, 'search_type' => "search_fields" )); $r.=""; $r.=""; $r.=""; $r.=""; } } } return $r; } public function make_human_query() { global $search; global $msg; global $charset; global $include_path; global $lang; global $thesaurus_classement_mode_pmb; $r=""; if(is_array($search) && count($search)){ for ($i=0; $ifixedfields[$s[1]]["TITLE"])) { $title = $this->fixedfields[$s[1]]["TITLE"]; } } elseif(array_key_exists($s[0],$this->pp)){ $title=$this->pp[$s[0]]->t_fields[$s[1]]["TITRE"]; } elseif ($s[0]=="s") { $title=$this->specialfields[$s[1]]["TITLE"]; } elseif ($s[0]=="authperso") { $title=$this->authpersos[$s[1]]['name']; } $op="op_".$i."_".$search[$i]; global ${$op}; if(${$op}) { $operator=$this->operators[${$op}]; } else { $operator=""; } $field=$this->get_global_value("field_".$i."_".$search[$i]); $field1=$this->get_global_value("field_".$i."_".$search[$i]."_1"); //Recuperation des variables auxiliaires $fieldvar_="fieldvar_".$i."_".$search[$i]; global ${$fieldvar_}; $fieldvar=${$fieldvar_}; if (!is_array($fieldvar)) $fieldvar=array(); $field_aff=array(); $fieldvar_aff=array(); $operator_multi = ($this->get_multi_search_operator()?$this->get_multi_search_operator():"or"); if (array_key_exists($s[0],$this->pp)) { $datatype=$this->pp[$s[0]]->t_fields[$s[1]]["DATATYPE"]; $df=$this->dynamicfields[$s[0]]["FIELD"][$this->get_id_from_datatype($datatype,$s[0])]; $q_index=$df["QUERIES_INDEX"]; if(${$op}) { $q=$df["QUERIES"][$q_index[${$op}]]; } else { $q=array(); } if (isset($q["DEFAULT_OPERATOR"])) $operator_multi=$q["DEFAULT_OPERATOR"]; for ($j=0; $jpp[$s[0]]->t_fields[$s[1]]['TYPE'].".class.php")) { require_once($include_path."/search_queries/dynamics/dynamic_search_".$this->pp[$s[0]]->t_fields[$s[1]]['TYPE'].".class.php"); $dynamic_class_name = "dynamic_search_".$this->pp[$s[0]]->t_fields[$s[1]]['TYPE']; $dynamic_class = new $dynamic_class_name($s[1],$s[0], $i,$df,$this); $field_aff[$j] = $dynamic_class->make_human_query($field[$j], $field1[$j]); } else { $field_aff[$j]=$this->pp[$s[0]]->get_formatted_output(array(0=>$field[$j]),$s[1]); if($q['OPERATOR'] == 'BETWEEN' && $field1[$j]) { $field_aff[$j].= ' - '.$this->pp[$s[0]]->get_formatted_output(array(0=>$field1[$j]),$s[1]); } } } } elseif ($s[0]=="f" && !empty($this->fixedfields[$s[1]])) { $ff=$this->fixedfields[$s[1]]; $q_index=$ff["QUERIES_INDEX"]; if(${$op}) { $q=$ff["QUERIES"][$q_index[${$op}]]; } else { $q=array(); } if(isset($fieldvar["operator_between_multiple_authorities"])){ $operator_multi=$fieldvar["operator_between_multiple_authorities"][0]; } else { if (isset($q["DEFAULT_OPERATOR"])) $operator_multi=$q["DEFAULT_OPERATOR"]; } switch ($this->fixedfields[$s[1]]["INPUT_TYPE"]) { case "list": if(${$op} == 'EQ') { $field_aff = self::get_list_display($this->fixedfields[$s[1]], $field); } else { $field_aff = $this->clean_empty_values($field); } break; case "checkbox_list": if(${$op} == 'EQ') { $field_aff = self::get_checkbox_list_display($this->fixedfields[$s[1]], $field); } else { $field_aff = $this->clean_empty_values($field); } break; case "query_list": if(${$op} == 'EQ') { $field_aff = $this->get_query_list_display($this->fixedfields[$s[1]], $field); } else { $field_aff = $this->clean_empty_values($field); } break; case "checkbox_marc_list": case "marc_list": if(${$op} == 'EQ') { $field_aff = self::get_marc_list_display($this->fixedfields[$s[1]], $field); } else { $field_aff = $this->clean_empty_values($field); } break; case "date": switch ($q['OPERATOR']) { case 'LESS_THAN_DAYS': case 'MORE_THAN_DAYS': $field_aff[0]=$field[0]." ".htmlentities($msg['days'], ENT_QUOTES, $charset); break; default: $field_aff[0]=format_date($field[0]); break; } if($q['OPERATOR'] == 'BETWEEN' && $field1[0]) { $field_aff[0].= ' - '.format_date($field1[0]); } break; case "authoritie": if (is_array($field)) { $tmp_size = sizeof($field); for($j=0 ; $j<$tmp_size; $j++){ if((${$op} == "AUTHORITY") && (($field[$j] === "") || ($field[$j] === "0"))){ unset($field[$j]); } else if ($ff['INPUT_OPTIONS']['SELECTOR'] == "instruments" && is_numeric($field[$j])) { $field[$j] = nomenclature_instrument::get_instrument_name_from_id($field[$j]); }elseif(is_numeric($field[$j]) && ((${$op} == "AUTHORITY") || (${$op} == "EQ"))){ $field[$j] = self::get_authoritie_display($field[$j], $ff['INPUT_OPTIONS']['SELECTOR']); if($ff['INPUT_OPTIONS']['SELECTOR'] == "categorie") { if(isset($fieldvar["id_thesaurus"])){ unset($fieldvar["id_thesaurus"]); } } elseif($ff['INPUT_OPTIONS']['SELECTOR'] == "onto") { if(isset($fieldvar["id_scheme"])){ unset($fieldvar["id_scheme"]); } } elseif($ff['INPUT_OPTIONS']['SELECTOR'] == "vedette") { if(isset($fieldvar["grammars"])){ unset($fieldvar["grammars"]); } } } } } $field_aff = $this->clean_empty_values($field); break; default: $field_aff = $this->clean_empty_values($field); break; } //Ajout des variables si necessaire reset($fieldvar); $fieldvar_aff=array(); foreach ($fieldvar as $var_name => $var_value) { //Recherche de la variable par son nom $vvar=$this->fixedfields[$s[1]]["VAR"]; for ($j=0; $jspecialfields[$s[1]]["TYPE"]; if(!empty($this->tableau_speciaux['TYPE'])) { for ($is=0; $istableau_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],$i,$sf,$this); $field_aff=$specialclass->make_human_query(); $field_aff[0]=html_entity_decode(strip_tags($field_aff[0]),ENT_QUOTES,$charset); break; } } } }elseif ($s[0]=="authperso") { if(isset($fieldvar["operator_between_multiple_authorities"])){ $operator_multi=$fieldvar["operator_between_multiple_authorities"][0]; } else { if (isset($q["DEFAULT_OPERATOR"])) $operator_multi=$q["DEFAULT_OPERATOR"]; } if (is_array($field)) { $tmpsize = sizeof($field); for($j=0 ; $j<$tmpsize; $j++){ if((${$op} == "AUTHORITY") && (($field[$j] === "") || ($field[$j] === "0"))){ unset($field[$j]); }elseif(is_numeric($field[$j]) && (${$op} == "AUTHORITY")){ $field[$j] = authperso::get_isbd($field[$j]); } } } $field_aff= $field; } switch ($operator_multi) { case "and": $op_list=$msg["search_and"]; break; case "or": $op_list=$msg["search_or"]; break; default: $op_list=$msg["search_or"]; break; } if(is_array($field_aff)){ $texte=implode(" ".$op_list." ",$field_aff); }else{ $texte=""; } if (count($fieldvar_aff)) $texte.=" [".implode(" ; ",$fieldvar_aff)."]"; $inter="inter_".$i."_".$search[$i]; global ${$inter}; switch (${$inter}) { case "and": $inter_op=$msg["search_and"]; break; case "or": $inter_op=$msg["search_or"]; break; case "ex": $inter_op=$msg["search_exept"]; break; default: $inter_op=""; break; } if ($inter_op) $inter_op="".htmlentities($inter_op,ENT_QUOTES,$charset).""; if ((isset($ff['INPUT_OPTIONS']['SELECTOR']) && $ff['INPUT_OPTIONS']['SELECTOR'] == 'instruments') && (!empty($fieldvar))) { $r.= $inter_op." ".htmlentities($title,ENT_QUOTES,$charset)." (".nomenclature_instrument::get_instrument_name_from_id($field[0]) . ' ' .$operator.' '.$fieldvar['number_instruments'][0] . ') '; } else if ((isset($ff['INPUT_OPTIONS']['SELECTOR']) && $ff['INPUT_OPTIONS']['SELECTOR'] == 'voices') && (!empty($fieldvar))) { $r.= $inter_op." ".htmlentities($title,ENT_QUOTES,$charset)." (".nomenclature_voice::get_voice_name_from_id($field[0]) . ' ' .$operator.' '.$fieldvar['number_voices'][0] . ') '; } else { $r.=$inter_op." ".htmlentities($title,ENT_QUOTES,$charset)." ".htmlentities($operator,ENT_QUOTES,$charset)." (".htmlentities($texte,ENT_QUOTES,$charset).") "; } } } if ($r){ $r="".$r.""; } return $r; } public function make_serialized_human_query($serialized) { global $search; global $msg; global $charset; global $include_path; global $lang; $to_unserialize=unserialize($serialized); $search=$to_unserialize["SEARCH"]; if(!is_array($search)) { $search = array(); } for ($i=0; $ifixedfields[$s[1]]["TITLE"]; } elseif (array_key_exists($s[0],$this->pp)) { $title=$this->pp[$s[0]]->t_fields[$s[1]]["TITRE"]; } elseif ($s[0]=="s") { $title=$this->specialfields[$s[1]]["TITLE"]; } elseif ($s[0]=="authperso") { $title=$this->authpersos[$s[1]]['name']; } $op="op_".$i."_".$search[$i]; global ${$op}; if(${$op}) { $operator=$this->operators[${$op}]; } else { $operator=''; } $field_="field_".$i."_".$search[$i]; global ${$field_}; $field=${$field_}; $field1_="field_".$i."_".$search[$i]."_1"; global ${$field1_}; $field1=${$field1_}; //Recuperation des variables auxiliaires $fieldvar_="fieldvar_".$i."_".$search[$i]; global ${$fieldvar_}; $fieldvar=${$fieldvar_}; if (!is_array($fieldvar)) $fieldvar=array(); $operator_multi = ''; $field_aff=array(); if (array_key_exists($s[0],$this->pp)) { $datatype=$this->pp[$s[0]]->t_fields[$s[1]]["DATATYPE"]; $df=$this->dynamicfields[$s[0]]["FIELD"][$this->get_id_from_datatype($datatype,$s[0])]; $q_index=$df["QUERIES_INDEX"]; if(${$op}) { $q=$df["QUERIES"][$q_index[${$op}]]; } else { $q=array(); } if (isset($q["DEFAULT_OPERATOR"])) $operator_multi=$q["DEFAULT_OPERATOR"]; for ($j=0; $jpp[$s[0]]->get_formatted_output(array(0=>$field[$j]),$s[1]); } } elseif($s[0]=="f") { $ff=$this->fixedfields[$s[1]]; $q_index=$ff["QUERIES_INDEX"]; if(${$op}) { $q=$ff["QUERIES"][$q_index[${$op}]]; } else { $q=array(); } if(isset($fieldvar["operator_between_multiple_authorities"])){ $operator_multi=$fieldvar["operator_between_multiple_authorities"][0]; } else { if (isset($q["DEFAULT_OPERATOR"])) $operator_multi=$q["DEFAULT_OPERATOR"]; } switch ($this->fixedfields[$s[1]]["INPUT_TYPE"]) { case "list": if(${$op} == 'EQ') { $field_aff = self::get_list_display($this->fixedfields[$s[1]], $field); } else { $field_aff = $this->clean_empty_values($field); } break; case "checkbox_list": if(${$op} == 'EQ') { $field_aff = self::get_checkbox_list_display($this->fixedfields[$s[1]], $field); } else { $field_aff = $this->clean_empty_values($field); } break; case "query_list": if(${$op} == 'EQ') { $field_aff = $this->get_query_list_display($this->fixedfields[$s[1]], $field); } else { $field_aff = $this->clean_empty_values($field); } break; case "checkbox_marc_list": case "marc_list": if(${$op} == 'EQ') { $field_aff = self::get_marc_list_display($this->fixedfields[$s[1]], $field); } else { $field_aff = $this->clean_empty_values($field); } break; case "date": switch ($q['OPERATOR']) { case 'LESS_THAN_DAYS': case 'MORE_THAN_DAYS': $field_aff[0]=$field[0]." ".htmlentities($msg['days'], ENT_QUOTES, $charset); break; default: $field_aff[0]=format_date($field[0]); break; } if($q['OPERATOR'] == 'BETWEEN' && $field1[0]) { $field_aff[0].= ' - '.format_date($field1[0]); } break; case "authoritie": if (is_array($field)) { for($j=0 ; $jclean_completion_empty_values($field); break; default: $field_aff = $this->clean_empty_values($field); break; } } elseif ($s[0]=="s") { //appel de la fonction make_human_query de la classe du champ special //Recherche du type $type=$this->specialfields[$s[1]]["TYPE"]; for ($is=0; $istableau_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],$i,$sf,$this); $field_aff=$specialclass->make_human_query(); $field_aff[0]=html_entity_decode(strip_tags($field_aff[0]),ENT_QUOTES,$charset); break; } } } elseif ($s[0]=="authperso") { $field_aff[0]=$field[0]; } //Ajout des variables si necessaire reset($fieldvar); $fieldvar_aff=array(); foreach ($fieldvar as $var_name => $var_value) { //Recherche de la variable par son nom $vvar=$this->fixedfields[$s[1]]["VAR"]; for ($j=0; $j "")); if ($vis["NAME"]) { $vis_name=$vis["NAME"]; global ${$vis_name}; if ($vis["VISIBILITY"]=="no") $visibility=0; for ($k=0; $k"; $r.=$inter_op." ".htmlentities($title,ENT_QUOTES,$charset)." ".htmlentities($operator,ENT_QUOTES,$charset)." (".htmlentities($texte,ENT_QUOTES,$charset).") "; } return $r; } public function make_unimarc_query() { global $search; global $msg; global $charset; global $include_path; $mt=array(); //Récupération du type de recherche $sc_type = $this->fichier_xml; $sc_type = substr($sc_type,0,strlen($sc_type)-8); for ($i=0; $ifixedfields[$s[1]]["UNIMARCFIELD"]; } elseif (array_key_exists($s[0],$this->pp)){ $id=$search[$i]; $title=$this->pp[$s[0]]->t_fields[$s[1]]["UNIMARCFIELD"]; } elseif ($s[0]=="s") { $id=$search[$i]; $title=$this->specialfields[$s[1]]["UNIMARCFIELD"]; } $op="op_".$i."_".$search[$i]; global ${$op}; //$operator=$this->operators[${$op}]; $field=$this->get_global_value("field_".$i."_".$search[$i]); $field1=$this->get_global_value("field_".$i."_".$search[$i]."_1"); //Recuperation des variables auxiliaires $fieldvar_="fieldvar_".$i."_".$search[$i]; global ${$fieldvar_}; $fieldvar=${$fieldvar_}; if (!is_array($fieldvar)) $fieldvar=array(); $field_aff=array(); $fieldvar_aff=array(); if(array_key_exists($s[0],$this->pp)){ for ($j=0; $jpp[$s[0]]->get_formatted_output(array(0=>$field[$j]),$s[1]); } } elseif ($s[0]=="f") { switch ($this->fixedfields[$s[1]]["INPUT_TYPE"]) { case "list": if(${$op} == 'EQ') { $field_aff = self::get_list_display($this->fixedfields[$s[1]], $field); } else { $field_aff = $this->clean_empty_values($field); } break; case "checkbox_list": if(${$op} == 'EQ') { $field_aff = self::get_checkbox_list_display($this->fixedfields[$s[1]], $field); } else { $field_aff = $this->clean_empty_values($field); } break; case "query_list": if(${$op} == 'EQ') { $field_aff = $this->get_query_list_display($this->fixedfields[$s[1]], $field); } else { $field_aff = $this->clean_empty_values($field); } break; case "checkbox_marc_list": case "marc_list": if(${$op} == 'EQ') { $field_aff = self::get_marc_list_display($this->fixedfields[$s[1]], $field); } else { $field_aff = $this->clean_empty_values($field); } break; case "date": switch ($q['OPERATOR']) { case 'LESS_THAN_DAYS': case 'MORE_THAN_DAYS': $field_aff[0]=$field[0]." ".htmlentities($msg['days'], ENT_QUOTES, $charset); break; default: $field_aff[0]=format_date($field[0]); break; } if($q['OPERATOR'] == 'BETWEEN' && $field1[0]) { $field_aff[0].= ' - '.format_date($field1[0]); } break; default: $field_aff=$this->clean_empty_values($field); break; } //Ajout des variables si necessaire reset($fieldvar); foreach ($fieldvar as $var_name => $var_value) { //Recherche de la variable par son nom $vvar=$this->fixedfields[$s[1]]["VAR"]; for ($j=0; $jspecialfields[$s[1]]["TYPE"]; if ($type!="facette") { for ($is=0; $istableau_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],$i,$sf,$this); $sub=$specialclass->make_unimarc_query(); break; } } } else $flag_insert=false; } if ($flag_insert) { $inter="inter_".$i."_".$search[$i]; global ${$inter}; $mterm=new mterm($title,${$op},$field_aff,$fieldvar_aff,${$inter},$id,$fieldvar); if ($i==1) $mterm->sc_type=$sc_type; if ((is_array($sub))&&(count($sub))) { $mterm->set_sub($sub); } else if (is_array($sub)) { unset($mterm); } if (isset($mterm)) { $mt[]=$mterm; } } } return $mt; } // fonction de calcul de visibilite d'un champ de recherche selon les droits d'accès public function access_rights() { global $gestion_acces_active,$gestion_acces_empr_notice; if(!isset($this->tableau_access_rights)) { //droits d'acces emprunteur/notice if ($gestion_acces_active==1 && $gestion_acces_empr_notice==1) { $ac= new acces(); $dom_2= $ac->setDomain(2); $rights= $dom_2->getRights($_SESSION['id_empr_session'], $id); } if (is_null($dom_2)) { $this->tableau_access_rights["acces_j"] = ''; $this->tableau_access_rights["statut_j"] = ',notice_statut'; $this->tableau_access_rights["statut_r"] = "and statut=id_notice_statut and ((notice_visible_opac=1 and notice_visible_opac_abon=0)".($_SESSION["user_code"]?" or (notice_visible_opac_abon=1 and notice_visible_opac=1)":"").")"; } else { $this->tableau_access_rights["acces_j"] = $dom_2->getJoin($_SESSION['id_empr_session'],4,'notice_id'); $this->tableau_access_rights["statut_j"] = ""; $this->tableau_access_rights["statut_r"] = ""; } } } // fonction de calcul de la visibilite d'un champ de recherche public function visibility($ff) { if (!isset($ff["VARVIS"]) || !count($ff["VARVIS"])) return $ff["VISIBILITY"]; for ($i=0; $igroups as $group_id => $group){ $group_name = $this->groups[$group_id]['label']; if(isset($this->list_criteria[$group_name])){ //On a des champs définis pour le groupe courant if(!count($this->filtered_objects_types) || in_array($group['objects_type'], $this->filtered_objects_types)) { $sort_list_criteria_by_groups[$group_name] = $this->list_criteria[$group_name]; } } } $this->list_criteria = $sort_list_criteria_by_groups; } protected function add_criteria($group_name, $id, $label) { $this->list_criteria[$group_name][] = array('id' => $id, 'label' => $label); } public function get_list_criteria() { global $msg, $charset; global $include_path; if(!empty($this->list_criteria)) { return $this->list_criteria; } $this->list_criteria = array(); $group_name = ''; /** * if else, si il n'y a pas de groupe défini, on conserve le traitement de base * Sinon, ordonnancement via les IDs de groupes */ if(!$this->groups_used){ //Champs fixes reset($this->fixedfields); foreach ($this->fixedfields as $id => $ff) { if ($ff["SEPARATOR"]) { $group_name = $ff["SEPARATOR"]; } if ($this->visibility($ff)) { $this->add_criteria($group_name, "f_".$id, $ff["TITLE"]); } } //Champs dynamiques if(!$this->dynamics_not_visible){ foreach ( $this->dynamicfields as $key => $value ) { if(!$this->pp[$key]->no_special_fields && count($this->pp[$key]->t_fields) && ($key != 'a')){ $group_name = $msg["search_custom_".$value["TYPE"]]; reset($this->pp[$key]->t_fields); $array_dyn_tmp=array(); //liste des champs persos à cacher par type $hide_customfields_array = array(); if ($this->dynamicfields_hidebycustomname[$value["TYPE"]]) { $hide_customfields_array = explode(",",$this->dynamicfields_hidebycustomname[$value["TYPE"]]); } foreach ($this->pp[$key]->t_fields as $id => $df) { if ($df["OPAC_SHOW"]) { //On n'affiche pas les champs persos cités par nom dans le fichier xml if ((!count($hide_customfields_array)) || (!in_array($df["NAME"],$hide_customfields_array))) { $array_dyn_tmp[strtolower($df["TITRE"])] = array('id' => $key."_".$id, 'label' => $df["TITRE"]); } } } if (count($array_dyn_tmp)) { if ($this->dynamicfields_order=="alpha") { ksort($array_dyn_tmp); } foreach($array_dyn_tmp as $dynamic_option){ $this->add_criteria($group_name, $dynamic_option['id'], $dynamic_option['label']); } } } } } //Champs autorités perso foreach($this->authpersos as $authperso){ if(!$authperso['opac_multi_search'])continue; $group_name = $msg["authperso_multi_search_by_field_title"]." : ".$authperso['name']; $this->add_criteria($group_name, "authperso_".$authperso['id'], $msg["authperso_multi_search_tous_champs_title"]); foreach($authperso['fields'] as $field){ // On vérifie la visibilité en OPAC grâce à la propriété if ($field['multiple']) { $this->add_criteria($group_name, "a_".$field['id'], $field['label']); } } } //Champs speciaux if (!$this->specials_not_visible && $this->specialfields) { foreach ($this->specialfields as $id => $sf) { for($i=0 ; $itableau_speciaux['TYPE']) ; $i++){ if ($this->tableau_speciaux["TYPE"][$i]["NAME"] == $sf['TYPE']) { require_once($include_path."/search_queries/specials/".$this->tableau_speciaux["TYPE"][$i]["PATH"]."/search.class.php"); $classname = $this->tableau_speciaux["TYPE"][$i]["CLASS"]; if((isset($sf['OPACVISIBILITY']) && $sf['OPACVISIBILITY'] && !method_exists($classname, 'check_visibility')) || (method_exists($classname, 'check_visibility') && $classname::check_visibility() == true)){ if ($sf["SEPARATOR"]) { $group_name = $sf["SEPARATOR"]; } $this->add_criteria($group_name, "s_".$id, $sf["TITLE"]); } break; } } } } } else { //Traitement des champs fixes reset($this->fixedfields); foreach ($this->fixedfields as $id => $ff) { if ($this->visibility($ff)) { if (isset($ff["GROUP"])) { $this->add_criteria($this->groups[$ff["GROUP"]]['label'], "f_".$id, $ff["TITLE"]); } else { $this->add_criteria($msg["search_extended_lonely_fields"], "f_".$id, $ff["TITLE"]); } } } //Traitement des champs dynamiques (champs persos) if(!$this->dynamics_not_visible){ foreach ( $this->dynamicfields as $key => $value ) { if(!$this->pp[$key]->no_special_fields && count($this->pp[$key]->t_fields) && ($key != 'a')){ reset($this->pp[$key]->t_fields); $array_dyn_tmp=array(); //liste des champs persos à cacher par type $hide_customfields_array = array(); if (isset($this->dynamicfields_hidebycustomname[$value["TYPE"]]) && $this->dynamicfields_hidebycustomname[$value["TYPE"]]) { $hide_customfields_array = explode(",",$this->dynamicfields_hidebycustomname[$value["TYPE"]]); } foreach ($this->pp[$key]->t_fields as $id => $df) { if ($df["OPAC_SHOW"]) { //On n'affiche pas les champs persos cités par nom dans le fichier xml if ((!count($hide_customfields_array)) || (!in_array($df["NAME"],$hide_customfields_array))) { $array_dyn_tmp[strtolower($df["TITRE"])]= array('id' => $key."_".$id, 'label' => $df["TITRE"]); } } } if (count($array_dyn_tmp)) { if ($this->dynamicfields_order=="alpha") { ksort($array_dyn_tmp); } $reorganized_array = array(); foreach($array_dyn_tmp as $dynamic_option){ $reorganized_array[] = $dynamic_option; } if(isset($value["GROUP"])){ $group_name = $this->groups[$value["GROUP"]]['label']; if(!isset($this->list_criteria[$group_name]) || !is_array($this->list_criteria[$group_name])) { $this->list_criteria[$group_name] = array(); } $this->list_criteria[$group_name] = array_merge($this->list_criteria[$group_name], $reorganized_array); }else{ $lonely_fields = array_merge($this->list_criteria[$msg["search_extended_lonely_fields"]], $reorganized_array); } } } } } //Traitement des champs spéciaux if (!$this->specials_not_visible && $this->specialfields) { foreach ($this->specialfields as $id => $sf) { for($i=0 ; $itableau_speciaux['TYPE']) ; $i++){ if ($this->tableau_speciaux["TYPE"][$i]["NAME"] == $sf['TYPE']) { require_once($include_path."/search_queries/specials/".$this->tableau_speciaux["TYPE"][$i]["PATH"]."/search.class.php"); $classname = $this->tableau_speciaux["TYPE"][$i]["CLASS"]; if((isset($sf['OPACVISIBILITY']) && $sf['OPACVISIBILITY'] && !method_exists($classname, 'check_visibility')) || (method_exists($classname, 'check_visibility') && $classname::check_visibility() == true)){ if(isset($sf["GROUP"]) && $sf["GROUP"]){ $this->add_criteria($this->groups[$sf["GROUP"]]['label'], "s_".$id, $sf["TITLE"]); }else{ $this->add_criteria($msg["search_extended_lonely_fields"], "s_".$id, $sf["TITLE"]); } } } } } } /** * On parcourt la propriété groups contenant les * groupes ordonnés selon l'ordre défini dans le XML */ $this->sort_list_criteria(); //Traitement des autorités persos (le champs doit être généré dynamiquement $r_authperso=""; foreach($this->authpersos as $authperso){ if(!count($this->filtered_objects_types) || (in_array("authperso", $this->filtered_objects_types) && $authperso_id == $authperso['id'])) { if(!$authperso['opac_multi_search'])continue; $this->add_criteria($msg["authperso_multi_search_by_field_title"]." : ".$authperso['name'], "authperso_".$authperso['id'], $msg["authperso_multi_search_tous_champs_title"]); if ($authperso['responsability_authperso']) { $this->add_criteria($msg["authperso_multi_search_by_field_title"]." : ".$authperso['name'], "f_2000", $msg['aut_responsability_form_responsability_authperso'], $authperso['id']); } foreach($authperso['fields'] as $field){ // On vérifie la visibilité en OPAC grâce à la propriété if ($field['multiple']) { $this->add_criteria($msg["authperso_multi_search_by_field_title"]." : ".$authperso['name'], "a_".$field['id'], $field['label']); } } } } } return $this->list_criteria; } /** * Templates des listes d'operateurs * @param string $url * @param string $result_url * @param string $result_target */ public function show_form($url,$result_url,$result_target='') { global $charset; global $search; global $add_field; global $delete_field; global $launch_search; global $page; // global $search_form; global $msg; global $include_path; global $opac_extended_search_auto; global $opac_extended_search_dnd_interface; global $base_path; global $module; if (($add_field)&&(($delete_field==="")&&(!$launch_search))) { if(empty($search)) { $search = array(); } $search[]=$add_field; } //On sécurise l'input PAGE $page = intval($page); $search_form = search_view::get_display_extended_search_form(); $search_form=str_replace("!!url!!",$url,$search_form); //Generation de la liste des champs possibles if ($opac_extended_search_auto) $r="\n"; $r.="\n"; $this->list_criteria = $this->get_misc_search_fields()->apply_substitution($this->get_list_criteria()); foreach ($this->list_criteria as $group=>$criteria) { $r .= "\n"; foreach ($criteria as $field) { $r.="\n"; } $r.="\n"; } $r.=""; $search_form=str_replace("!!field_list!!",$r,$search_form); $search_form=str_replace("!!already_selected_fields!!", $this->get_already_selected_fields($url), $search_form); $search_form .= "\n\n "; $search_form=str_replace("!!page!!",$page,$search_form); $search_form=str_replace("!!result_url!!",$result_url,$search_form); if ($result_target) $r="document.search_form.target='$result_target';"; else $r=""; $search_form=str_replace("!!target_js!!",$r,$search_form); if ($opac_extended_search_dnd_interface || $module == "selectors") { $search_perso= new search_persopac(); $search_form.=''; $search_form .= $this->show_dnd_form(); } return $search_form; } public function get_already_selected_fields($url='') { global $add_field; global $delete_field; global $search; global $launch_search; global $charset; global $msg; global $include_path; global $search_type; global $limitsearch; //Affichage des champs deja saisis $r=""; $n=0; $this->script_window_onload=''; $r.=""; if(is_array($search) && count($search)){ for ($i=0; $ifixedfields[$f[1]]["NOTDISPLAYCOL"]){ $notdisplaycol=explode(",",$this->fixedfields[$f[1]]["NOTDISPLAYCOL"]); } } elseif ($f[0]=="s") { if($this->specialfields[$f[1]]["NOTDISPLAYCOL"]){ $notdisplaycol=explode(",",$this->specialfields[$f[1]]["NOTDISPLAYCOL"]); } } elseif (array_key_exists($f[0],$this->pp)) { if (array_key_exists($f[0],$this->dynamicfields)) { if ($this->dynamicfields[$f[0]]["TYPE"]==$this->pp[$f[0]]->prefix) { foreach($this->dynamicfields[$f[0]]["FIELD"] as $fieldTmp){ if ($fieldTmp["DATATYPE"]==$this->pp[$f[0]]->t_fields[$f[1]]["DATATYPE"]) { if ($fieldTmp["NOTDISPLAYCOL"]) { $notdisplaycol=explode(",",$fieldTmp["NOTDISPLAYCOL"]); } break; } } } } } $r.=""; $r.=""; $r.=""; $r.=""; //Recherche des operateurs possibles $r.=""; //Affichage du champ de saisie $r.=""; $delnotallowed=false; if ($f[0]=="f") { $delnotallowed=(isset($this->fixedfields[$f[1]]["DELNOTALLOWED"]) ? $this->fixedfields[$f[1]]["DELNOTALLOWED"] : ''); } elseif ($f[0]=="s") { $delnotallowed=(isset($this->specialfields[$f[1]]["DELNOTALLOWED"]) ? $this->specialfields[$f[1]]["DELNOTALLOWED"] : ''); } if(!$limitsearch){ $r.=""; } $r.="\n"; //Si c'est le dernier, on afficher le bouton rechercher... if (($i==(count($search)-1))||(($delete_field==(count($search)-1))&&($i==(count($search)-2)))) $r.="\n"; $n++; } } } //Recherche explicite $r.="
";//Colonne 1 $r.=""; $r.="";//Colonne 2 if ($n>0) { $inter="inter_".$i."_".$search[$i]; global ${$inter}; $r.=""; } else $r.=" "; $r.="";//Colonne 3 if ($f[0]=="f") { $r.=htmlentities($this->fixedfields[$f[1]]["TITLE"],ENT_QUOTES,$charset); } elseif ($f[0]=="s") { $r.=htmlentities($this->specialfields[$f[1]]["TITLE"],ENT_QUOTES,$charset); } elseif (array_key_exists($f[0],$this->pp)) { $r.=htmlentities($this->pp[$f[0]]->t_fields[$f[1]]["TITRE"],ENT_QUOTES,$charset); }elseif ($f[0]=="authperso") { $r.=htmlentities($this->authpersos[$f[1]]['name'],ENT_QUOTES,$charset); } $r.="";//Colonne 4 $op="op_".$i."_".$search[$i]; global ${$op}; if ($f[0]=="f") { $r.=""; $this->script_window_onload.=" operatorChanged('".$n."_".$search[$i]."', document.getElementById('op_".$n."_".$search[$i]."').value,'".$this->fixedfields[$f[1]]['INPUT_TYPE']."'); "; } elseif (array_key_exists($f[0],$this->pp)) { $datatype=$this->pp[$f[0]]->t_fields[$f[1]]["DATATYPE"]; $type=$this->pp[$f[0]]->t_fields[$f[1]]["TYPE"]; $df=$this->get_id_from_datatype($datatype, $f[0]); $onchange =" onchange=\"operatorChanged('".$n."_".$search[$i]."', this.value,'".$datatype."');\" "; $r.=" "; $this->script_window_onload.=" operatorChanged('".$n."_".$search[$i]."', document.getElementById('op_".$n."_".$search[$i]."').value,'".$datatype."'); "; } elseif ($f[0]=="s") { //appel de la fonction get_input_box de la classe du champ special $type=$this->specialfields[$f[1]]["TYPE"]; for ($is=0; $istableau_speciaux["TYPE"]); $is++) { if ($this->tableau_speciaux["TYPE"][$is]["NAME"]==$type) { $sf=$this->specialfields[$f[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"]($f[1],$sf,$n,$this); $q=$specialclass->get_op(); if (count($q)) { $r.=""; } else $r.= " "; break; } } } elseif ($f[0]=="authperso") { //on est sur le cas de la recherche "Tous les champs" de l'autorité perso //$f["1"] vaut l'identifiant du type d'autorité perso $df=10; $r.=""; } $r.="";//Colonne 5 $r.=$this->get_field($i,$n,$search[$i],$this->pp); $r.="".(!$delnotallowed?"":" ")."";//Colonne 6 $r.="
\n
\n"; $r.="\n"; $r.="\n"; return $r; } /** * Génération du formulaire en drag'n'drop */ public function show_dnd_form() { global $javascript_path, $extended_search_dnd_tpl; return $extended_search_dnd_tpl; } public function make_encoding_array($value){ global $charset; //htmlentities récursif car les facette sont des tableaux de tableaux if (is_array($value)) { foreach ($value as $k=>$v) { $value[$k] = $this->make_encoding_array($value[$k]); } return $value; } else { return htmlentities($value,ENT_COMPAT,$charset); //return htmlspecialchars($value, ENT_NOQUOTES, $charset); } } // pour la gestion avec la DSI, recopiee de la partie gestion public function serialize_search($recurse_history=false, $need_htmlentities=false) { global $search; $to_serialize=array(); $to_serialize["SEARCH"]=$search; if(is_array($search) && count($search)){ for ($i=0; $iget_global_value("op_".$i."_".$search[$i]); $to_serialize[$i]["FIELD"]=$this->get_global_value("field_".$i."_".$search[$i]); $to_serialize[$i]["FIELD1"]=$this->get_global_value("field_".$i."_".$search[$i]."_1"); $to_serialize[$i]["INTER"]=$this->get_global_value("inter_".$i."_".$search[$i]); $to_serialize[$i]["FIELDVAR"]=$this->get_global_value("fieldvar_".$i."_".$search[$i]); if($recurse_history && $search[$i] == "s_1"){ $hc = new combine_search("1", $i, array(), $this); $to_serialize[$i]["FIELD"][0] = $hc->get_recursive(); } } } if($need_htmlentities){ $to_serialize = $this->make_encoding_array($to_serialize); } return serialize($to_serialize); } public function make_decode_array($value){ global $charset; //html_entity_decode récursif car les facette sont des tableaux de tableaux if (is_array($value)) { foreach ($value as $k=>$v) { $value[$k] = $this->make_decode_array($value[$k]); } return $value; } else { if (is_string($value)) { return html_entity_decode($value, ENT_COMPAT, $charset); } else { return $value; } } } public function unserialize_search($serialized) { global $search; $to_unserialize=unserialize($serialized); $to_unserialize = $this->make_decode_array($to_unserialize); $search=$to_unserialize["SEARCH"]; if(is_array($search) && count($search)){ for ($i=0; $iset_global_value("op_".$i."_".$search[$i], $to_unserialize[$i]["OP"]); $this->set_global_value("field_".$i."_".$search[$i], $to_unserialize[$i]["FIELD"]); if(isset($to_unserialize[$i]["FIELD1"])) { $this->set_global_value("field_".$i."_".$search[$i]."_1", $to_unserialize[$i]["FIELD1"]); } else { $this->set_global_value("field_".$i."_".$search[$i]."_1"); } $this->set_global_value("inter_".$i."_".$search[$i], $to_unserialize[$i]["INTER"]); $this->set_global_value("fieldvar_".$i."_".$search[$i], $to_unserialize[$i]["FIELDVAR"]); } } } public function push() { global $search; global $pile_search; $pile_search[]=$this->serialize_search(); if(is_array($search) && count($search)){ for ($i=0; $iset_global_value("op_".$i."_".$search[$i]); $this->set_global_value("field_".$i."_".$search[$i]); $this->set_global_value("field_".$i."_".$search[$i]."_1"); $this->set_global_value("inter_".$i."_".$search[$i]); $this->set_global_value("fieldvar_".$i."_".$search[$i]); } } $search=array(); } public function pull() { global $pile_search; $this->unserialize_search($pile_search[count($pile_search)-1]); $t=array(); for ($i=0; $iop_empty[${$op}])) { $tt[$it]=$i; $it++; } break; default: if (((isset($field[0]) && (string)$field[0]!="") || (isset($field1[0]) && (string)$field1[0]!="")) || ($this->op_empty[${$op}])) { $tt[$it]=$i; $it++; } break; } } //Décalage des critères //1) copie des critères valides for ($i=0; $iget_global_value("op_".$it."_".$search[$it]); $fieldt[$i]["field"]=$this->get_global_value("field_".$it."_".$search[$it]); $fieldt[$i]["field1"]=$this->get_global_value("field_".$it."_".$search[$it]."_1"); $fieldt[$i]["fieldvar"]=$this->get_global_value("fieldvar_".$it."_".$search[$it]); $fieldt[$i]["inter"]=$this->get_global_value("inter_".$it."_".$search[$it]); $fieldt[$i]["search"]=$search[$it]; } //On nettoie et on reconstruit $this->destroy_global_env(); $search=array(); for ($i=0; $iset_global_value("op_".$i."_".$search[$i], $fieldt[$i]["op"]); $this->set_global_value("field_".$i."_".$search[$i], $fieldt[$i]["field"]); $this->set_global_value("field_".$i."_".$search[$i]."_1", $fieldt[$i]["field1"]); $this->set_global_value("inter_".$i."_".$search[$i], $fieldt[$i]["inter"]); $this->set_global_value("fieldvar_".$i."_".$search[$i], $fieldt[$i]["fieldvar"]); } } //suppression des champs de recherche marqués FORBIDDEN pour recherche externe public function remove_forbidden_fields() { global $search; $old_search=array(); $old_search['search']=$search; for ($i=0; $iget_global_value($inter); $op="op_".$i."_".$search[$i]; $old_search[$op]=$this->get_global_value($op); $field="field_".$i."_".$search[$i]; $old_search[$field]=$this->get_global_value($field); $fieldvar="fieldvar_".$i."_".$search[$i]; $old_search[$fieldvar]=$this->get_global_value($fieldvar); } $saved_search=array(); if(count($search)){ foreach($search as $k=>$s) { if ($s[0]=="f") { if ($this->fixedfields[substr($s,2)] && ($this->fixedfields[substr($s,2)]['UNIMARCFIELD']!='FORBIDDEN')) { $saved_search[$k]=$s; } } elseif(array_key_exists($s[0],$this->pp)){ //Pas de recherche affiliée dans des champs personnalisés. } elseif ($s[0]=="s") { if ($this->specialfields[substr($s,2)] && ($this->specialfields[substr($s,2)]['UNIMARCFIELD']!='FORBIDDEN')) { $saved_search[$k]=$s; } }elseif (substr($s,0,9)=="authperso") { $saved_search[$k]=$s; } } } $new_search=array(); $i=0; foreach($saved_search as $k=>$v) { $new_search['search'][$i]=$v; $old_inter="inter_".$k."_".$v; $new_inter="inter_".$i."_".$v; $new_search[$new_inter]=$this->get_global_value($old_inter); $old_op="op_".$k."_".$v; $new_op="op_".$i."_".$v; $new_search[$new_op]=$this->get_global_value($old_op); $old_field="field_".$k."_".$v; $new_field="field_".$i."_".$v; $new_search[$new_field]=$this->get_global_value($old_field); $old_fieldvar="fieldvar_".$k."_".$v; $new_fieldvar="fieldvar_".$i."_".$v; $new_search[$new_fieldvar]=$this->get_global_value($old_fieldvar); $i++; } $this->destroy_global_env(); foreach($new_search as $k=>$va) { global ${$k}; ${$k}=$va; } } protected function get_global_value($name) { global ${$name}; return ${$name}; } protected function set_global_value($name, $value='') { global ${$name}; ${$name} = $value; } protected function clean_completion_empty_values($values) { $suppr = false; if(is_array($values)) { foreach($values as $k=>$v){ if(!$v){ unset($values[$k]); $suppr=true; } } if($suppr){ $values = array_values($values); } } return $values; } protected function clean_empty_values($values) { $suppr = false; if(is_array($values)) { foreach($values as $k=>$v){ if($v===""){ unset($values[$k]); $suppr=true; } } if($suppr){ $values = array_values($values); } } return $values; } protected function sort_groups($a, $b){ if($a['order'] == $b['order']){ return 0; } return ($a['order'] > $b['order'] ? 1 : -1); } public static function get_authoritie_display($id, $type) { global $thesaurus_classement_mode_pmb; global $lang; $libelle = ''; switch ($type){ case "auteur": $aut=new auteur($id); $libelle = $aut->get_isbd(); break; case "categorie": $libelle = categories::getlibelle($id,$lang); break; case "editeur": $ed = new publisher($id); $libelle.= $ed->get_isbd(); break; case "collection" : $coll = new collection($id); $libelle = $coll->get_isbd(); break; case "subcollection" : $coll = new subcollection($id); $libelle = $coll->get_isbd(); break; case "serie" : $serie = new serie($id); $libelle = $serie->get_isbd(); break; case "indexint" : $indexint = new indexint($id); $libelle = $indexint->get_isbd(); break; case "titre_uniforme" : $tu = new titre_uniforme($id); $libelle = $tu->get_isbd(); break; case "notice" : $libelle = notice::get_notice_title($id); break; case "vedette" : $vedette_composee = new vedette_composee($id); $libelle = $vedette_composee->get_label(); break; case "authperso" : $libelle = authperso::get_isbd($id); break; case "ontology" : if ($id && !is_numeric($id)) { $id = onto_common_uri::get_id($id); } $query ="select value from skos_fields_global_index where id_item = '".$id."'"; $result = pmb_mysql_query($query); if(pmb_mysql_num_rows($result)) { $row = pmb_mysql_fetch_object($result); $libelle = $row->value; } else { $libelle = ""; } break; default : $libelle = $id; break; } return $libelle; } public function get_selector_display($id, $type, $search) { global $msg; $display = ''; $p = explode('_', $search); switch ($type){ case 'list': $options=$this->fixedfields[$p[1]]["INPUT_OPTIONS"]["OPTIONS"][0]; foreach ($options["OPTION"] as $option) { if($option['VALUE'] == $id) { $display .= get_msg_to_display($option["value"]); break; } } break; case 'query_list': if($p[0] == 'f') { $requete=$this->fixedfields[$p[1]]["INPUT_OPTIONS"]["QUERY"][0]["value"]; if (isset($this->fixedfields[$p[1]]["INPUT_OPTIONS"]["FILTERING"])) { if ($this->fixedfields[$p[1]]["INPUT_OPTIONS"]["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=pmb_mysql_query($requete); while ($r_=@pmb_mysql_fetch_row($resultat)) { if($r_[0] == $id) { $display .= $r_[1]; break; } } } break; case 'marc_list': $opt = marc_list_collection::get_instance($this->fixedfields[$p[1]]["INPUT_OPTIONS"]["NAME"][0]["value"]); $tmp = array(); if (count($opt->inverse_of)) { // sous tableau genre ascendant descendant... foreach ($opt->table as $table) { $tmp = array_merge($tmp, $table); } } else { $tmp = $opt->table; } $display.= $tmp->table[$id]; break; } return $display; } public static function get_list_display($fixedfield, $field) { global $msg; $field_aff = array(); $options=$fixedfield["INPUT_OPTIONS"]["OPTIONS"][0]; $opt=array(); for ($j=0; $jaccess_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); } } if (isset($fixedfield["INPUT_OPTIONS"]["QUERY"][0]["USE_GLOBAL"]) && $fixedfield["INPUT_OPTIONS"]["QUERY"][0]["USE_GLOBAL"]) { $use_global = explode(",", $fixedfield["INPUT_OPTIONS"]["QUERY"][0]["USE_GLOBAL"]); for($j=0; $jinverse_of)) { // sous tableau genre ascendant descendant... foreach ($opt->table as $table) { $tmp = array_merge($tmp, $table); } } else { $tmp = $opt->table; } for ($j=0; $jset_mode($current_search); $size=explode("*",$opac_map_size_search_result); if(count($size)!=2) { $map_size="width:800px; height:480px;"; } else { if (is_numeric($size[0])) $size[0].= 'px'; if (is_numeric($size[1])) $size[1].= 'px'; $map_size= "width:".$size[0]."; height:".$size[1].";"; } $map_search_controler->ajax = true; $map = " "; } return $map; } public function get_unimarc_fields() { $r=array(); foreach($this->fixedfields as $id=>$values) { if ($values["UNIMARCFIELD"]) { $r[$values["UNIMARCFIELD"]]["TITLE"][]=$values["TITLE"]; foreach($values["QUERIES_INDEX"] as $op=>$top) { $r[$values["UNIMARCFIELD"]]["OPERATORS"][$op]=$this->operators[$op]; } } } return $r; } protected function gen_temporary_table($table_name, $main='', $with_pert=false) { if(!$main) { $this->is_created_temporary_table = false; return; } $query = "create temporary table ".$table_name." ENGINE=".$this->current_engine." ".$main; $result = pmb_mysql_query($query); if($result) { if (!pmb_mysql_num_rows(pmb_mysql_query("show columns from ".$table_name." like 'idiot'"))) { $query = "alter table ".$table_name." add idiot int(1)"; pmb_mysql_query($query); } $query = "alter table ".$table_name." add unique(".$this->keyName.")"; pmb_mysql_query($query); if($with_pert) { if (!pmb_mysql_num_rows(pmb_mysql_query("show columns from ".$table_name." like 'pert'"))) { $query="alter table ".$table_name." add pert decimal(16,1) default 1"; pmb_mysql_query($query); } } $this->is_created_temporary_table = true; } } public function is_created_temporary_table($table_name) { return $this->is_created_temporary_table; } protected function is_empty($field, $field_name) { if ((!count($field))||((count($field)==1)&&((string)$field[0]==""))) { return true; } if(count($field) > 1) { if((string)$field[0]=="") { $field = array_filter($field, function($var){ return (!($var == '' || is_null($var))); }); $field = array_values($field); global ${$field_name}; ${$field_name} = $field; if(!count($field)) { return true; } } } return false; } public function show_results($url,$url_to_search_form,$hidden_form=true,$search_target="") { global $dbh; global $begin_result_liste; global $opac_search_results_per_page; $nb_per_page_search = $opac_search_results_per_page; global $page; global $charset; global $search; global $msg, $opac_notices_depliable ; global $debug; $start_page=$nb_per_page_search*$page; //Y-a-t-il des champs ? if (count($search)==0) { error_message_history($msg["search_empty_field"], $msg["search_no_fields"], 1); exit(); } //Verification des champs vides for ($i=0; $iget_global_value("op_".$i."_".$search[$i]); $field=$this->get_global_value("field_".$i."_".$search[$i]); $field1=$this->get_global_value("field_".$i."_".$search[$i]."_1"); $s=explode("_",$search[$i]); $bool=false; if ($s[0]=="f") { $champ=$this->fixedfields[$s[1]]["TITLE"]; if ($this->is_empty($field, "field_".$i."_".$search[$i]) && $this->is_empty($field1, "field_".$i."_".$search[$i]."_1")) { $bool=true; } } elseif(array_key_exists($s[0],$this->pp)) { $champ=$this->pp[$s[0]]->t_fields[$s[1]]["TITRE"]; if ($this->is_empty($field, "field_".$i."_".$search[$i]) && $this->is_empty($field1, "field_".$i."_".$search[$i]."_1")) { $bool=true; } } elseif($s[0]=="s") { $champ=$this->specialfields[$s[1]]["TITLE"]; $type=$this->specialfields[$s[1]]["TYPE"]; for ($is=0; $istableau_speciaux["TYPE"]); $is++) { if ($this->tableau_speciaux["TYPE"][$is]["NAME"]==$type) { $sf=$this->specialfields[$s[1]]; global $include_path; 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],$sf,$i,$this); $bool=$specialclass->is_empty($field); break; } } }elseif (substr($s,0,9)=="authperso") { } if (($bool)&&(!$this->op_empty[$op])) { error_message_history($msg["search_empty_field"], sprintf($msg["search_empty_error_message"],$champ), 1); exit(); } } $table=$this->make_search(); //Y-a-t-il une erreur lors de la recherche ? if ($this->error_message) { error_message_history("", $this->error_message, 1); exit(); } if ($hidden_form) print $this->make_hidden_search_form($url); $requete="select count(1) from $table"; $nb_results=pmb_mysql_result(pmb_mysql_query($requete),0,0); print pmb_bidi("".$msg["search_search_extended"]." : ".$this->make_human_query()); if ($nb_results) { print " => ".$nb_results." ".$msg["1916"]."
\n"; if ($opac_notices_depliable) print $begin_result_liste; } else print "
".$msg["no_result"]." "; print ""; //Gestion de la pagination if ($nb_results) { print $this->get_current_search_map(); $n_max_page=ceil($nb_results/$nb_per_page_search); echo "
"; if ($page>0) { echo ""; echo "[".$msg["prec_page"]."]"; echo ""; } echo "page ".($page+1)."/".$n_max_page.""; if (($page+1)<$n_max_page) { echo ""; echo "[".$msg["next_page"]."]"; echo ""; } echo "
"; } } public function show_results_unimarc($url,$url_to_search_form,$hidden_form=true,$search_target="") { global $dbh; global $begin_result_liste; global $opac_notices_depliable; global $opac_search_results_per_page; $nb_per_page_search = $opac_search_results_per_page; global $page; global $charset; global $search; global $msg; global $count; global $add_cart_link; global $filtre_compare, $reinit_compare; global $sort; $start_page=$nb_per_page_search*($page-1); //Y-a-t-il des champs ? if (count($search)==0) { return; } $_SESSION['last_unimarc_search'] = $this->json_encode_search(); $table=$this->make_search(); $requete="select count(1) from $table"; $nb_results=pmb_mysql_result(pmb_mysql_query($requete),0,0); $count=$nb_results; $requete = "select * from $table"; $objects = ""; $resultat=pmb_mysql_query($requete,$dbh); while($row = pmb_mysql_fetch_object($resultat)){ if($objects){ $objects.=","; } $objects.= $row->notice_id; } $_SESSION['tab_result_external'] = $objects; //tri if (!isset($_SESSION['last_sortexternal'])) { $_SESSION['last_sortexternal'] = "default"; } if (isset($sort)) { $_SESSION['last_sortexternal'] = $sort; } $sort_external = new sort_external("external","session"); $requete = $sort_external->appliquer_tri($_SESSION['last_sortexternal'],$requete,"notice_id"); $requete .= " limit ".$start_page.",".$nb_per_page_search; $resultat=pmb_mysql_query($requete,$dbh); print "

$msg[resultat_recherche]

\n
"; print pmb_bidi("

$nb_results $msg[titles_found] ".$this->make_human_query()."

"); print suggest::get_add_link(); flush(); $entrepots_localisations = array(); $entrepots_localisations_sql = "SELECT * FROM entrepots_localisations ORDER BY loc_visible DESC"; $res = pmb_mysql_query($entrepots_localisations_sql); while ($row = pmb_mysql_fetch_array($res)) { $entrepots_localisations[$row["loc_code"]] = array("libelle" => $row["loc_libelle"], "visible" => $row["loc_visible"]); } if ($opac_notices_depliable) { if($filtre_compare=='compare'){ print facettes_external_search_compare::get_begin_result_list(); }else{ print $begin_result_liste; } } print $add_cart_link; print "
".sort::show_tris_in_result_list($nb_results, "external"); print "
\n
"; //on suis le flag filtre/compare facettes_external::session_filtre_compare(); print "
"; if($filtre_compare=='compare'){ //on valide la variable session qui comprend les critères de comparaisons facettes_external_search_compare::session_facette_compare(); //affichage comparateur $facette_compare= new facettes_external_search_compare(); $compare=$facette_compare->compare_from_objects($objects); if($compare===true){ print $facette_compare->display_compare(); }else{ print $msg[$compare]; } } else { //si demande de réinitialisation if($reinit_compare==1){ facettes_external_search_compare::session_facette_compare(null,$reinit_compare); } while ($r=pmb_mysql_fetch_object($resultat)) { print aff_notice_unimarc($r->notice_id, 0, $entrepots_localisations); } } print "
"; print "
\n
"; } //Permet de savoir si la recherche utilise des champs qui ne sont pas autorisé dans les recherches externes ou affiliée public function has_forbidden_fields() { global $search; $saved_search=array(); foreach($search as $k=>$s) { if ($s[0]=="f") { if (!empty($this->fixedfields[substr($s,2)]) && $this->fixedfields[substr($s,2)] && ($this->fixedfields[substr($s,2)]['UNIMARCFIELD']!='FORBIDDEN')) { $saved_search[$k]=$s; } } elseif(array_key_exists($s[0],$this->pp)){ //Pas de recherche affiliée dans des champs personnalisés. } elseif ($s[0]=="s") { if (!empty($this->specialfields[substr($s,2)]) && ($this->specialfields[substr($s,2)]['UNIMARCFIELD']!='FORBIDDEN')) { $saved_search[$k]=$s; } }elseif (substr($s,0,9)=="authperso") { $saved_search[$k]=$s; } } if(count($search) != count($saved_search)){ return true; }else{ return false; } } public function unhistorize_search(){ global $include_path,$search; $search_type = 'extended'; $es=new search(); $trouveHistoriqueDansCriteres=true; while($trouveHistoriqueDansCriteres){ $trouveHistoriqueDansCriteres=false; for ($i=0; $ispecialfields[$s[1]]; if ($s[0]=="s" && $sf["TYPE"]=="combine") { $trouveHistoriqueDansCriteres=true; require_once($include_path."/search_queries/specials/combine/search.class.php"); $sf=$es->specialfields[$s[1]]; //on est sur un historique, on vérifie le type de recherche $valeur_="field_".$i."_s_".$s[1]; global ${$valeur_}; $valeur=${$valeur_}; $search_type = $_SESSION["search_type".$valeur[0]]; //on instancie la classe historique $specialclass = new combine_search($s[1], $i, $sf, $es); $specialclass_serialized_search = $specialclass->serialize_search(); $specialSearch = unserialize($specialclass_serialized_search); if ($search_type == 'simple_search') { //on transforme la recherche simple historisée en recherche spéciale s_4 (recherche simple) $search[$i] = "s_4"; $field="field_".$i."_s_4"; $op="op_".$i."_s_4"; $fieldvar="fieldvar_".$i."_s_4"; $inter="inter_".$i."_s_4"; global ${$field},${$op},${$fieldvar},${$inter}; ${$field}=array( serialize( array( 'serialized_search'=>$specialclass_serialized_search, 'search_type'=>"search_simple_fields" ) ) ); ${$op}="EQ"; ${$fieldvar}=""; if ($i==0) { ${$inter}=""; } else { ${$inter}="and"; } } else { $maxX=count($specialSearch["SEARCH"])-1; for($x=$maxX;$x>=0;$x--){ if($x!=$maxX){ $maxY=count($search)-1; for($y=$maxY;$y>=$i;$y--){ $search[($y+1)]=$search[$y]; $newField="field_".($y+1)."_".$search[$i]; $oldField="field_".$y."_".$search[$i]; $newOp="op_".($y+1)."_".$search[$i]; $oldOp="op_".$y."_".$search[$i]; $newFieldvar="fieldvar_".($y+1)."_".$search[$i]; $oldFieldvar="fieldvar_".$y."_".$search[$i]; $newInter="inter_".($y+1)."_".$search[$i]; $oldInter="inter_".$y."_".$search[$i]; global ${$oldField},${$oldOp},${$oldFieldvar},${$oldInter}; global ${$newField},${$newOp},${$newFieldvar},${$newInter}; ${$newField}=${$oldField}; ${$newOp}=${$oldOp}; ${$newFieldvar}=${$oldFieldvar}; ${$newInter}=${$oldInter}; } } $search[$i]=$specialSearch["SEARCH"][$x]; $field="field_".$i."_".$specialSearch["SEARCH"][$x]; $op="op_".$i."_".$specialSearch["SEARCH"][$x]; $var="var_".$i."_".$specialSearch["SEARCH"][$x]; $inter="inter_".$i."_".$specialSearch["SEARCH"][$x]; global ${$field},${$op},${$var},${$inter}; ${$field}=$specialSearch[$x]["FIELD"]; $s=explode("_",$search[$i]); $sf=$es->specialfields[$s[1]]; if ($s[0]=="s" && $sf["TYPE"]=="facette") { ${$field}=array(serialize(${$field})); } ${$op}=$specialSearch[$x]["OP"]; ${$fieldvar}=$specialSearch[$x]["FIELDVAR"]; ${$inter}=$specialSearch[$x]["INTER"]; } } break; } } } return $search_type; } public static function get_join_and_clause_from_equation($type = 0, $equation) { $notice_clause = ''; $notice_ids = array(); if($equation) { $my_search = new search('search_fields'); $my_search->unserialize_search(stripslashes($equation)); $res = $my_search->make_search(); $req="select * from ".$res ; $resultat=pmb_mysql_query($req); while($r=pmb_mysql_fetch_object($resultat)) { $notice_ids[]=$r->notice_id; } if (count($notice_ids)) { $notice_clause = ' and notices.notice_id IN ('.implode(',',$notice_ids).') '; }else { $notice_clause = ' and notices.notice_id IN (0) '; } } return array( 'clause' => $notice_clause ); } public function get_script_window_onload() { return $this->script_window_onload; } public function get_multi_search_operator() { global $opac_multi_search_operator; return $opac_multi_search_operator; } public function set_filtered_objects_types($filtered_objects_types=array()) { $this->filtered_objects_types = $filtered_objects_types; } public function json_encode_search() { global $search; $to_json=array(); $to_json["SEARCH"]=$search; for ($i=0; $iget_global_value("op_".$i."_".$search[$i]); $to_json[$i]["FIELD"]=$this->get_global_value("field_".$i."_".$search[$i]); // On addslash les valeurs pour formater le JSON correctement $to_json[$i]["FIELD"] = $this->addslashes_field($to_json[$i]["FIELD"]); $to_json[$i]["FIELD1"]=$this->get_global_value("field_".$i."_".$search[$i]."_1"); $to_json[$i]["INTER"]=$this->get_global_value("inter_".$i."_".$search[$i]); $to_json[$i]["FIELDVAR"]=$this->get_global_value("fieldvar_".$i."_".$search[$i]); } return encoding_normalize::json_encode($to_json); } private function addslashes_field($field) { for ($j = 0; $j < count($field); $j++) { if (is_string($field[$j])){ if ((strpos($field[$j], '"') !== false || strpos($field[$j], "'") !== false) && $field[$j] == stripslashes($field[$j])) { $field[$j] = addslashes($field[$j]); } } if(is_array($field[$j])){ $field[$j] = $this->addslashes_field($field[$j]); } } return $field; } public function json_decode_search($json_encoded) { global $search; $from_json = encoding_normalize::json_decode($json_encoded, true); if (is_array($from_json)) { $search = $from_json["SEARCH"]; for ($i=0; $iset_global_value("op_".$i."_".$search[$i], $from_json[$i]["OP"]); $this->set_global_value("field_".$i."_".$search[$i], $from_json[$i]["FIELD"]); if(isset($from_json[$i]["FIELD1"])) { $this->set_global_value("field_".$i."_".$search[$i]."_1", $from_json[$i]["FIELD1"]); } else { $this->set_global_value("field_".$i."_".$search[$i]."_1"); } $this->set_global_value("inter_".$i."_".$search[$i], $from_json[$i]["INTER"]); $this->set_global_value("fieldvar_".$i."_".$search[$i], $from_json[$i]["FIELDVAR"]); } } } public function make_segment_search_form($url,$form_name="search_form",$target="",$close_form=true, $undisplayed_index = []) { $r="
make_segment_form_content($undisplayed_index); if ($close_form) $r.="
"; return $r; } public function make_segment_form_content($undisplayed_index = []) { global $search; global $charset; global $page; global $nb_per_page_custom; global $msg; global $search_index; $r = "

".htmlentities($msg['facette_active'],ENT_QUOTES,$charset)."

"; $r.= "
"; for ($i=0; $iget_global_value($field_); $field1_="field_".$i."_".$search[$i]."_1"; $field1=$this->get_global_value($field1_); $s=explode("_",$search[$i]); $type=''; if ($s[0]=="s") { //instancier la classe de traitement du champ special $type=$this->specialfields[$s[1]]["TYPE"]; } //Recuperation des variables auxiliaires $fieldvar_="fieldvar_".$i."_".$search[$i]; $fieldvar=$this->get_global_value($fieldvar_); if (!is_array($fieldvar)) $fieldvar=array(); // si sélection d'autorité et champ vide : on ne doit pas le prendre en compte if(${$op}=='AUTHORITY'){ $field = $this->clean_completion_empty_values($field); }elseif(${$op}=='EQ'){ $field = $this->clean_empty_values($field); } $r.="
"; //on stocke l'indice de la recherche if ($search[$i] != 's_2' && $search[$i] != 's_10' && !in_array($i, $undisplayed_index)) { $r.= " "; $r.= " ".$this->make_segment_human_field($i)." X"; } $r.= "
"; } $r.= " "; $r.= " "; $r.= " "; $r.= "
"; // On reset la page pour l'utilisation des facettes $r.=" \n"; return $r; } public function make_segment_human_field($n) { global $search; global $charset; global $msg; if (isset($search[$n])) { $s=explode("_",$search[$n]); if ($s[0]=="f") { $title=$this->fixedfields[$s[1]]["TITLE"]; } elseif(array_key_exists($s[0],$this->pp)){ $title=$this->pp[$s[0]]->t_fields[$s[1]]["TITRE"]; } elseif ($s[0]=="s") { $title=$this->specialfields[$s[1]]["TITLE"]; } elseif ($s[0]=="authperso") { $title=$this->authpersos[$s[1]]['name']; } $op="op_".$n."_".$search[$n]; global ${$op}; if(${$op}) { $operator=$this->operators[${$op}]; } else { $operator=""; } $field_ = "field_".$n."_".$search[$n]; $field = $this->get_global_value($field_); //cas particulier pour les facettes if ($search[$n] == 's_3' || $search[$n] == 's_5') { $texte = $field[0][0].' = '; $facets_label = ""; foreach ($field[0][1] as $facet_label) { if ($facets_label) { $facets_label .= ' '.$msg['search_or'].' '; } $facets_label .= $facet_label; } $texte.= $facets_label; $operator = ""; } else { $texte = (is_array($field) ? implode(' / ', $field) : ""); } return "".htmlentities($title,ENT_QUOTES,$charset)." ".htmlentities($operator,ENT_QUOTES,$charset)." (".htmlentities($texte,ENT_QUOTES,$charset).")"; } return ""; } public function delete_search($i){ global $search; if (isset($i) && $search[$i]) { $field ="field_".$i."_".$search[$i]; global ${$field}; ${$field} = array(); $this->reduct_search(); } } public function get_elements_list_ui_class_name() { if(!isset($this->elements_list_ui_class_name)) { $this->elements_list_ui_class_name = "elements_records_list_ui"; } return $this->elements_list_ui_class_name; } public function set_elements_list_ui_class_name($class_name) { $this->elements_list_ui_class_name = $class_name; } public function get_navbar($nb_results, $hidden_form){ global $nb_per_page, $page, $msg; if ($nb_results) { $n_max_page = $nb_results; if (!empty($nb_per_page)) { $n_max_page = ceil($nb_results/$nb_per_page); } $etendue=10; if (!$page) $page_en_cours=0 ; else $page_en_cours=$page ; $nav_bar = ''; //Première if(($page_en_cours+1)-$etendue > 1) { $nav_bar .= "get_hidden_form_name().".page.value=0;"; if (!$hidden_form) $nav_bar .= "document.".$this->get_hidden_form_name().".launch_search.value=1; "; $nav_bar .= "document.".$this->get_hidden_form_name().".submit(); return false;\">".$msg["; } // affichage du lien precedent si necessaire if ($page>0) { $nav_bar .= ""; $nav_bar .= "[".$msg["; $nav_bar .= ""; } $deb = $page_en_cours - 10 ; if ($deb<0) $deb=0; for($i = $deb; ($i < $n_max_page) && ($i<$page_en_cours+10); $i++) { if($i==$page_en_cours) $nav_bar .= "".($i+1).""; else { $nav_bar .= "get_hidden_form_name().".page.value))||(document.".$this->get_hidden_form_name().".page.value=='')) document.".$this->get_hidden_form_name().".page.value=1; else document.".$this->get_hidden_form_name().".page.value=".($i)."; "; if (!$hidden_form) $nav_bar .= "document.".$this->get_hidden_form_name().".launch_search.value=1; "; $nav_bar .= "document.".$this->get_hidden_form_name().".submit(); return false;\">"; $nav_bar .= ($i+1); $nav_bar .= ""; } if($i<$n_max_page) $nav_bar .= " "; } if(($page+1)<$n_max_page) { $nav_bar .= "get_hidden_form_name().".page.value))||(document.".$this->get_hidden_form_name().".page.value=='')) document.".$this->get_hidden_form_name().".page.value=1; else document.".$this->get_hidden_form_name().".page.value=parseInt(document.".$this->get_hidden_form_name().".page.value)+parseInt(1); "; if (!$hidden_form) $nav_bar .= "document.".$this->get_hidden_form_name().".launch_search.value=1; "; $nav_bar .= "document.".$this->get_hidden_form_name().".submit(); return false;\">"; $nav_bar .= "[".$msg["; $nav_bar .= ""; } else $nav_bar .= ""; //Dernière if((($page_en_cours+1)+$etendue)<$n_max_page){ $nav_bar .= "get_hidden_form_name().".page.value=".($n_max_page-1).";"; if (!$hidden_form) $nav_bar .= "document.".$this->get_hidden_form_name().".launch_search.value=1; "; $nav_bar .= "document.".$this->get_hidden_form_name().".submit(); return false;\">".$msg["; } $nav_bar = "
$nav_bar
"; echo $nav_bar ; } } public function get_context_parameters() { return $this->context_parameters; } public function set_context_parameters($context_parameters=array()) { $this->context_parameters = $context_parameters; } public function add_context_parameter($key, $value) { $this->context_parameters[$key] = $value; } public function delete_context_parameter($key) { unset($this->context_parameters[$key]); } public function get_misc_search_fields() { global $include_path; if(!isset($this->misc_file_search_fields)) { if(!$this->full_path) { $full_path = $include_path."/search_queries"; } else { $full_path = substr($this->full_path, strlen($this->full_path)-1); } $this->misc_file_search_fields = new misc_file_search_fields($full_path, $this->fichier_xml.".xml"); } return $this->misc_file_search_fields; } public function generate_query_op_and($prefixe = "", $suffixe, $search_table) { if ($prefixe) { return "create temporary table ".$prefixe."and_result_".$suffixe." ENGINE=".$this->current_engine." select ".$search_table.".* from ".$search_table." where exists ( select ".$prefixe."mf_".$suffixe.".* from ".$prefixe."mf_".$suffixe." where ".$search_table.".notice_id=".$prefixe."mf_".$suffixe.".notice_id)"; } else { return "create temporary table and_result_".$suffixe." ENGINE=".$this->current_engine." select ".$search_table.".* from ".$search_table." where exists ( select mf_".$suffixe.".* from mf_".$suffixe." where ".$search_table.".notice_id=mf_".$suffixe.".notice_id)"; } } } ?>