id=$id; $this->n_ligne=$n_ligne; $this->params=$params; $this->search=&$search; } //fonction de récupération des opérateurs disponibles pour ce champ spécial (renvoie un tableau d'opérateurs) function get_op() { $operators = array(); $operators["EQ"]="="; return $operators; } //fonction de récupération de l'affichage de la saisie du critère function get_input_box() { global $msg; global $charset; global $get_input_box_id; global $base_path; //$this->s = new search(false,"search_simple_fields.xml"); //Récupération de la valeur de saisie $valeur_="field_".$this->n_ligne."_s_".$this->id; global $$valeur_; $valeur=$$valeur_; $r.="
"; return $r; } function get_ajax_params(){ global $selected_sources; global $field_form; global $charset; global $serial_title; global $onchange; global $msg; $response = array(); $queries = array(); $response['field'] = $field_form; $response['onchange'] = ($onchange ? true : false); $elem = explode("_",$field_form); switch($elem[0]){ case "issues" : if($serial_title){ foreach($selected_sources as $source){ $queries[] = "select distinct concat(num_issue.value,if(num_issue.value = '','',if(date_issue.value='','',' - ')),date_format(date_issue.value,'".$msg['format_date']."')) as val,date_issue.value as date, num_issue.value as num from entrepot_source_".$source." as serial join entrepot_source_".$source." as num_issue on serial.recid = num_issue.recid join entrepot_source_".$source." as date_issue on serial.recid = date_issue.recid where serial.ufield='461' and serial.usubfield='t' and serial.value='".$serial_title."' and num_issue.ufield = '463' and num_issue.usubfield='v' and date_issue.ufield = '463' and date_issue.usubfield='d' "; } } if(count($queries)>1){ $query = "select * from (".implode(" union ",$queries).") as uni order by date,num,val"; }else if(count($queries)==1){ $query = $queries[0]. "order by date,num,val"; } if($query){ $result = mysql_query($query); $list=array(); if(mysql_num_rows($result)){ while($row = mysql_fetch_object($result)){ if($charset!="utf-8"){ $list[] = array( 'value' => utf8_encode($row->num."|||".$row->date), 'text' => utf8_encode($row->val) ); }else $list[] = array( 'value' => $row->num."|||".$row->date, 'text' => $row->val ); } } $response['list'] = $list; }else{ $response['list'] = array(); } break; default : if($selected_sources){ foreach($selected_sources as $source){ $queries[] = "select distinct entrepot.value as val from entrepot_source_".$source." as entrepot join entrepot_source_".$source." on entrepot.recid = entrepot_source_".$source.".recid where entrepot_source_".$source.".ufield = 'bl' and entrepot_source_".$source.".value!='m' and entrepot.ufield='461' and entrepot.usubfield='t'"; } } if(count($queries)>1){ $query = "select * from (".implode(" union ",$queries).") as uni order by val"; }else if(count($queries)==1){ $query = $queries[0]. "order by val"; } if($query){ $result = mysql_query($query); $list=array(); if(mysql_num_rows($result)){ while($row = mysql_fetch_object($result)){ if($charset!="utf-8"){ $list[] = utf8_encode($row->val); }else $list[] = $row->val; } } $response['list'] = $list; }else{ $response['list'] = array(); } break; } ajax_http_send_response($response,'application/json'); } //fonction de conversion de la saisie en quelque chose de compatible avec l'environnement function transform_input() { } //fonction de création de la requête (retourne une table temporaire) function make_search() { global $search; global $source; //Récupération de la valeur de saisie $serial_="field_".$this->n_ligne."_s_".$this->id; $issues_="fieldvar_".$this->n_ligne."_s_".$this->id; global $$serial_; global $$issues_; $serial=$$serial_; $issues = $$issues_; //$issues=$issues[0]; global $field_0_s_2; if (count($field_0_s_2) && !$source){ $selected_sources =$field_0_s_2; }else $selected_sources = $source; if(!$this->is_empty($serial)){ $issues_infos = array(); foreach($issues as $issue){ $issues_infos[] = explode('|||',$issue[0]); } if($selected_sources){ foreach($selected_sources as $s){ $query= "select distinct analysis.recid as notice_id from entrepot_source_".$s." as serial join entrepot_source_".$s." as num_issue on serial.recid = num_issue.recid join entrepot_source_".$s." as date_issue on serial.recid = date_issue.recid join entrepot_source_".$s." as analysis on serial.recid = analysis.recid where analysis.ufield ='bl' and analysis.value!='m' and serial.ufield='461' and serial.usubfield='t' and serial.value='".addslashes($serial[0])."' "; $restricted_issues = array(); foreach($issues_infos as $issue){ $restricted_issues[] = "(num_issue.value='".$issue[0]."' and date_issue.value='".$issue[1]."')"; } $query.=" and (".implode(" or ",$restricted_issues).")"; $queries[] = $query; } $t_table= "table_".$this->n_ligne."_s_".$this->id; $query = "create temporary table ".$t_table." select * from(".implode(" union ",$queries).") as uni"; mysql_query($query); return $t_table; } } } function make_unimarc_query() { global $search; global $source; //Récupération de la valeur de saisie $serial_="field_".$this->n_ligne."_s_".$this->id; $issues_="fieldvar_".$this->n_ligne."_s_".$this->id; global $$serial_; global $$issues_; $serial=$$serial_; $issues = $$issues_; //$issues=$issues[0]; global $field_0_s_2; if (count($field_0_s_2) && !$source){ $selected_sources =$field_0_s_2; }else $selected_sources = $source; if(!$this->is_empty($serial)){ $issues_infos = array(); foreach($issues as $issue){ $issues_infos[] = explode('|||',$issue[0]); } if($selected_sources){ foreach($selected_sources as $s){ $query= "select distinct analysis.recid as notice_id from entrepot_source_".$s." as serial join entrepot_source_".$s." as num_issue on serial.recid = num_issue.recid join entrepot_source_".$s." as date_issue on serial.recid = date_issue.recid join entrepot_source_".$s." as analysis on serial.recid = analysis.recid where analysis.ufield ='bl' and analysis.value!='m' and serial.ufield='461' and serial.usubfield='t' and serial.value='".addslashes($serial[0])."' "; $restricted_issues = array(); foreach($issues_infos as $issue){ $restricted_issues[] = "(num_issue.value='".$issue[0]."' and date_issue.value='".$issue[1]."')"; } $query.=" and (".implode(" or ",$restricted_issues).")"; $queries[] = $query; } $t_table= "table_".$this->n_ligne."_s_".$this->id; $query = "create temporary table ".$t_table." select * from(".implode(" union ",$queries).") as uni"; mysql_query($query); return $t_table; } } } //fonction de traduction littérale de la requête effectuée (renvoie un tableau des termes saisis) function make_human_query() { global $search; global $source; //Récupération de la valeur de saisie $serial_="field_".$this->n_ligne."_s_".$this->id; $issues_="fieldvar_".$this->n_ligne."_s_".$this->id; global $$serial_; global $$issues_; $serial=$$serial_; $issues = $$issues_; //$issues=$issues[0]; if(!$this->is_empty($serial)){ $issues_infos = array(); foreach($issues as $issue){ $elem = explode('|||',$issue[0]); $issues_infos[] = $elem[0].($elem[0] && $elem[1] ? " - ":"").format_date($elem[1]); } $label = $serial[0]." (".implode(" / ",$issues_infos).")"; $litteral=array($label); return $litteral; } } //fonction de vérification du champ saisi ou sélectionné function is_empty($valeur) { if($valeur[0]!= ""){ $issues_="fieldvar_".$this->n_ligne."_s_".$this->id; global $$issues_; if(count($$issues_)>0){ return false; } } return true; } //fonction de découpage d'une chaine trop longue function cutlongwords($valeur,$size=50) { if (strlen($valeur)>=$size) { $pos=strrpos(substr($valeur,0,$size)," "); if ($pos) { $valeur=substr($valeur,0,$pos+1)."..."; } } return $valeur; } } ?>