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)
public function get_op() {
global $msg;
$operators = array(
'AUTHORITY' => $msg['authority_query']
);
return $operators;
}
protected function get_variable($type, $inc) {
global $msg;
switch ($type) {
case 'function' :
$label = $msg['245'];
$ajax = 'fonction';
$selector = 'function';
$p1 = 'p1';
$p2 = 'p2';
$linkfield = '';
break;
case 'qualification' :
$label = $msg['notice_vedette_composee_author'];
$ajax = 'vedette';
$selector = 'vedette';
$p1 = 'p1';
$p2 = 'p2';
$linkfield = "fieldvar_".$this->n_ligne."_s_".$this->id."[".$inc."][".$type."][grammars]";
break;
case 'author' :
default :
$label = $msg['tu_authors_list'];
$ajax = 'authors';
$selector = 'auteur';
$p1 = 'param1';
$p2 = 'param2';
$linkfield = '';
break;
}
return array(
"label" => $label,
"fnamesans" => "field_".$this->n_ligne."_s_".$this->id."_".$type,
"fname" => "field_".$this->n_ligne."_s_".$this->id."[".$inc."][".$type."]",
"fname_id" => "field_".$this->n_ligne."_s_".$this->id."_".$type."_id",
"fnamesanslib" => "field_".$this->n_ligne."_s_".$this->id."_".$type."_lib",
"fnamelib" => "field_".$this->n_ligne."_s_".$this->id."_lib[".$inc."][".$type."]",
"fname_name_aut_id" => "fieldvar_".$this->n_ligne."_s_".$this->id."[".$inc."][".$type."][authority_id]",
"fname_aut_id" => "fieldvar_".$this->n_ligne."_s_".$this->id."_".$type."_authority_id",
"fnamevar_id" => "",
"fnamevar_id_js" => "",
"ajax" => $ajax,
"selector" => $selector,
"p1" => $p1,
"p2" => $p2,
"linkfield" => $linkfield
);
}
//fonction de récupération de l'affichage de la saisie du critère
public function get_input_box() {
global $msg;
global $charset;
global $fonction_auteur;
global $pmb_authors_qualification;
// récupération des codes de fonction
if (!count($fonction_auteur)) {
$fonction_auteur = new marc_list('function');
$fonction_auteur = $fonction_auteur->table;
}
$display = '';
//Récupération des valeurs saisies
$values_="field_".$this->n_ligne."_s_".$this->id;
global ${$values_};
$values=${$values_};
//Recuperation des variables auxiliaires
$fieldvar_="fieldvar_".$this->n_ligne."_s_".$this->id;
global ${$fieldvar_};
$fieldvar=${$fieldvar_};
$nb_values=count($values);
if(!$nb_values){
//Création de la ligne
$nb_values=1;
}
$nb_max_aut=$nb_values-1;
$display = "";
$display .= "";
$display .= "
";
for($inc=0;$inc<$nb_values;$inc++){
$fields = array();
$fields['author'] = $this->get_variable('author', $inc);
$fields['function'] = $this->get_variable('function', $inc);
if($pmb_authors_qualification) {
$fields['qualification'] = $this->get_variable('qualification', $inc);
}
$display .="
";
}
$display .= "
";
$display .= "
";
$display .="";
$display .= htmlentities($msg["operator_between_multiple_authorities"],ENT_QUOTES,$charset);
$display .= " ".htmlentities($msg["operator_between_multiple_authorities_or"],ENT_QUOTES,$charset);
$display .= " ".htmlentities($msg["operator_between_multiple_authorities_and"],ENT_QUOTES,$charset);
$display .="
";
if($nb_values>1){
$display .="
";
}
return $display;
}
//fonction de conversion de la saisie en quelque chose de compatible avec l'environnement
public function transform_input() {
}
//fonction de création de la requête (retourne une table temporaire)
public function make_search() {
//Récupération des valeurs saisies
$values_="field_".$this->n_ligne."_s_".$this->id;
global ${$values_};
$values=${$values_};
//Recuperation des variables auxiliaires
$fieldvar_="fieldvar_".$this->n_ligne."_s_".$this->id;
global ${$fieldvar_};
$fieldvar=${$fieldvar_};
if (!$this->is_empty($values)) {
$notices = array();
$query = "select distinct id_authority from authorities
join responsability_tu on responsability_tu.responsability_tu_num=authorities.num_object and authorities.type_object = 7 ";
if($this->params['TYPE'] == 'tu_qualified_interpreter') {
$query .= "and responsability_tu.responsability_tu_type=1";
} else {
$query .= "and responsability_tu.responsability_tu_type=0";
}
$restricts = array();
foreach ($values as $value) {
$restrict = array();
if(isset($value['author']) && $value['author']*1) {
$restrict[] = "responsability_tu.responsability_tu_author_num=".$value['author'];
}
if(isset($value['function']) && $value['function']) {
$restrict[] = "responsability_tu.responsability_tu_fonction='".$value['function']."'";
}
if(isset($value['qualification']) && $value['qualification']) {
$restrict[] = "id_responsability_tu in (select vedette_link.num_object from vedette_link where vedette_link.num_vedette = ".$value['qualification'].")";
}
if(count($restrict)) {
$restricts[] = "(".implode(' and ', $restrict).")";
}
}
if(count($restricts)) {
$query .= " where (".implode(') '.$fieldvar['operator_between_multiple_authorities'][0].' (', $restricts).")";
}
if($this->search->tableName == "notices"){
$query = "select ntu_num_notice as notice_id from notices_titres_uniformes where ntu_num_tu in (
select authorities.num_object as ntu_num_tu from authorities
join (".$query.") as t1 on t1.id_authority = authorities.id_authority and authorities.type_object = 7)";
}
pmb_mysql_query("create temporary table t_s_tu_qualified_author (".$this->search->keyName." integer unsigned not null) as ".$query);
pmb_mysql_query("alter table t_s_tu_qualified_author add primary key(".$this->search->keyName.")");
}
return "t_s_tu_qualified_author";
}
//fonction de traduction littérale de la requête effectuée (renvoie un tableau des termes saisis)
public function make_human_query() {
global $msg;
global $include_path;
global $fonction_auteur;
// récupération des codes de fonction
if (!count($fonction_auteur)) {
$fonction_auteur = new marc_list('function');
$fonction_auteur = $fonction_auteur->table;
}
//Récupération des valeurs saisies
$values_="field_".$this->n_ligne."_s_".$this->id;
global ${$values_};
$values=${$values_};
//Recuperation des variables auxiliaires
$fieldvar_="fieldvar_".$this->n_ligne."_s_".$this->id;
global ${$fieldvar_};
$fieldvar=${$fieldvar_};
$human_query = array();
if (!$this->is_empty($values)) {
$humans=array();
foreach ($values as $value) {
$human = array();
if(isset($value['author']) && $value['author']*1) {
$human[] = $msg['tu_authors_list'].' : '.search::get_authoritie_display($value['author'], 'auteur');
}
if(isset($value['function']) && $value['function']) {
$human[] = $msg['245'].' : '.$fonction_auteur[$value['function']];
}
if(isset($value['qualification']) && $value['qualification']) {
$human[] = $msg['notice_vedette_composee_author'].' : '.search::get_authoritie_display($value['qualification'], 'vedette');;
}
if(count($human)) {
$humans[] = ' [ '.implode(', ', $human).' ] ';
}
}
switch($fieldvar['operator_between_multiple_authorities'][0]) {
case 'and' :
$human_query[] = implode(' '.$msg["operator_between_multiple_authorities_and"].' ',$humans);
break;
case 'or' :
default :
$human_query[] = implode(' '.$msg["operator_between_multiple_authorities_or"].' ',$humans);
break;
}
}
return $human_query;
}
public function make_unimarc_query() {
//Récupération des valeurs saisies
$values_="field_".$this->n_ligne."_s_".$this->id;
global ${$values_};
$values=${$values_};
return "";
}
//fonction de vérification du champ saisi ou sélectionné
public function is_empty($values) {
//Récupération des valeurs saisies
$values_="field_".$this->n_ligne."_s_".$this->id;
global ${$values_};
$values=${$values_};
if (count($values)) {
if (($values[0]['author']=="") && ($values[0]['function']=="") && ($values[0]['qualification']=="")) return true;
else return false;
} else {
return true;
}
}
}