search_class=new search(false); $this->id = $id; $this->id_empr = $id_empr; $this->fetch_data(); return $this->id; } // récupération des infos en base function fetch_data() { global $dbh; if($this->id){ $myQuery = mysql_query("SELECT * FROM opac_views WHERE opac_view_id='".$this->id."' LIMIT 1", $dbh); $myreq= mysql_fetch_object($myQuery); $this->name=$myreq->opac_view_name; $this->requete=$myreq->opac_view_query; if ($this->requete) { $this->opac_view_wo_query = 0; $this->human_query = $this->search_class->make_serialized_human_query($this->requete) ; } else { $this->opac_view_wo_query = 1; $this->human_query = ''; } $this->comment=$myreq->opac_view_comment; $this->visible=$myreq->opac_view_visible; $this->last_gen=$myreq->opac_view_last_gen; $this->ttl=$myreq->opac_view_ttl; $this->param_subst=new param_subst("opac", "opac_view",$this->id); $this->opac_filters=new opac_filters($this->id); } $this->view_list_empr=array(); $this->view_list_empr_default=0; if($this->id_empr){ // vues selectionnées pour empr $myQuery = mysql_query("SELECT * FROM opac_views_empr WHERE emprview_empr_num='".$this->id_empr."' ", $dbh); if(mysql_num_rows($myQuery)){ while(($r=mysql_fetch_object($myQuery))) { if($r->emprview_default) $this->view_list_empr_default=$r->emprview_view_num; $this->view_list_empr[]=$r->emprview_view_num; } } } $this->get_list(); } function get_list($name='', $value_selected=0) { global $dbh,$charset; $myQuery = mysql_query("SELECT * FROM opac_views order by opac_view_name ", $dbh); $this->opac_views_list=array(); $selector = "'; $this->selector=$selector; return true; } // fonction de mise à jour ou de création function update($value) { global $dbh,$msg; $fields=""; foreach($value as $key => $val) { if($fields) $fields.=","; $fields.=" $key='$val' "; } if($this->id) { // modif $erreur=mysql_query("UPDATE opac_views SET $fields WHERE opac_view_id=".$this->id, $dbh); if(!$erreur) { error_message($msg["opac_view_form_edit"], $msg["opac_view_form_add_error"],1); exit; } } else { // create $erreur=mysql_query("INSERT INTO opac_views SET $fields ", $dbh); $this->id = mysql_insert_id($dbh); if(!$erreur) { error_message($msg["opac_view_form_edit"], $msg["opac_view_form_add_error"],1); exit; } } // Création/suppression table associée si besoin if ($this->opac_view_wo_query) { $q = "drop table if exists opac_view_notices_".$this->id; mysql_query($q, $dbh); } else { $req_create="create table if not exists opac_view_notices_".$this->id." ( opac_view_num_notice int(20) not null default 0, KEY opac_view_num_notice (opac_view_num_notice) )"; mysql_query($req_create,$dbh); } // rafraichissement des données $this->fetch_data(); return $this->id; } function update_form() { global $name,$requete,$comment,$opac_view_form_visible,$ttl,$opac_view_wo_query; $value = new stdClass(); $value->opac_view_name=$name; if ($opac_view_wo_query || !isset($requete)) { $this->opac_view_wo_query = 1; $value->opac_view_query=''; } else { $this->opac_view_wo_query = 0; $value->opac_view_query=$requete; } if (isset($comment)) { $value->opac_view_comment=$comment; } else { $value->opac_view_comment=''; } if(isset($opac_view_form_visible)) { $value->opac_view_visible=$opac_view_form_visible; } else { $value->opac_view_visible=$this->visible; } if(isset($ttl)) { $value->opac_view_ttl = $ttl; } else { $value->opac_view_ttl=$this->ttl; } $this->update($value); $this->opac_filters->save_all_form(); } function gen() { global $dbh,$msg; for($i=0;$iopac_views_list);$i++) { $req="TRUNCATE TABLE opac_view_notices_".$this->opac_views_list[$i]->id; @mysql_query($req, $dbh); if($this->opac_views_list[$i]->query) { $this->search_class->unserialize_search($this->opac_views_list[$i]->query); $table=$this->search_class->make_search() ; $req="INSERT INTO opac_view_notices_".$this->opac_views_list[$i]->id." ( opac_view_num_notice) select notice_id from $table "; mysql_query($req, $dbh); mysql_query("drop table $table"); } } $req="update opac_views set opac_view_last_gen=now()"; mysql_query($req, $dbh); } // fonction générant le form de saisie function do_form() { global $msg,$tpl_opac_view_form, $tpl_opac_view_create_form, $charset,$newsearch; // titre formulaire if($this->id) { global $suite,$requete; if($suite== 'transform_equ') { $this->requete=stripslashes($requete); $this->human_query =$this->search_class->make_serialized_human_query($this->requete) ; } $libelle=$msg["opac_view_modifier"]; $link_delete=""; $button_modif_requete = "onClick=\"document.modif_requete_form.submit();\" "; $form_modif_requete = $this->make_hidden_search_form(); $tpl=$tpl_opac_view_form; } else { $tpl=$tpl_opac_view_create_form; $libelle=$msg["opac_view_add"]; $link_delete=""; } // Champ $opac_visible_selected= "!!opac_visible_selected_".$this->visible."!!"; $tpl = str_replace($opac_visible_selected, "selected=selected", $tpl); $tpl = str_replace('!!name!!', htmlentities($this->name,ENT_QUOTES,$charset), $tpl); $tpl = str_replace('!!libelle!!',htmlentities($libelle,ENT_QUOTES,$charset) , $tpl); $tpl = str_replace('!!comment!!',htmlentities($this->comment,ENT_QUOTES,$charset) , $tpl); $tpl = str_replace('!!last_gen!!',(($this->last_gen!=NULL)?htmlentities(formatdate($this->last_gen,ENT_QUOTES,$charset)):'') , $tpl); $tpl = str_replace('!!ttl!!',htmlentities($this->ttl,ENT_QUOTES,$charset) , $tpl); // recherche multicritères if (!$suite== 'transform_equ' && $this->opac_view_wo_query) { $tpl = str_replace('!!opac_view_w_query_checked!!','',$tpl); $tpl = str_replace('!!opac_view_wo_query_checked!!',"checked='checked'",$tpl); } else { $tpl = str_replace('!!opac_view_wo_query_checked!!','',$tpl); $tpl = str_replace('!!opac_view_w_query_checked!!',"checked='checked'",$tpl); } $tpl = str_replace('!!opac_view_id!!', $this->id, $tpl); $tpl = str_replace('!!form_modif_requete!!', $form_modif_requete, $tpl); $tpl = str_replace('!!search_build!!', $button_modif_requete, $tpl); $tpl = str_replace('!!requete_human!!', $this->human_query, $tpl); $tpl = str_replace('!!requete!!', $this->requete, $tpl); // param subst if($this->param_subst)$tpl = str_replace('!!parameters!!', $this->param_subst->get_form_list("./admin.php?categ=opac&sub=opac_view§ion=list&opac_view_id=".$this->id."&action=param"), $tpl); else $tpl=str_replace('!!parameters!!',"", $tpl); // elements visibles: filtres if($this->opac_filters)$tpl = str_replace('!!filters!!', $this->opac_filters->show_all_form(), $tpl); else $tpl=str_replace('!!filters!!',"", $tpl); $action="./admin.php?categ=opac&sub=opac_view§ion=list&opac_view_id=".$this->id."&action=save"; $tpl = str_replace('!!action!!', $action, $tpl); $tpl = str_replace('!!delete!!', $link_delete, $tpl); $tpl = str_replace('!!annul!!', "onClick=\"document.location='./admin.php?categ=opac&sub=opac_view§ion=list'\" ", $tpl); return $tpl; } function get_form_param() { return $this->param_subst->exec_param_form("./admin.php?categ=opac&sub=opac_view§ion=list&opac_view_id=".$this->id."&action=param"); } // fonction générant le form de saisie function do_list() { global $tpl_opac_view_list_tableau,$tpl_opac_view_list_tableau_ligne; $liste=""; // pour toutes les vues for($i=0;$iopac_views_list);$i++) { if ($i % 2) $pair_impair = "even"; else $pair_impair = "odd"; $td_javascript=" onmousedown=\"document.location='./admin.php?categ=opac&sub=opac_view§ion=list&action=form&opac_view_id=!!opac_view_id!!'\" "; $tr_surbrillance = "onmouseover=\"this.className='surbrillance'\" onmouseout=\"this.className='".$pair_impair."'\" "; $line = str_replace('!!td_javascript!!',$td_javascript , $tpl_opac_view_list_tableau_ligne); $line = str_replace('!!tr_surbrillance!!',$tr_surbrillance , $line); $line = str_replace('!!pair_impair!!',$pair_impair , $line); $line =str_replace('!!opac_view_id!!', $this->opac_views_list[$i]->id, $line); $line = str_replace('!!name!!', $this->opac_views_list[$i]->name, $line); $line = str_replace('!!comment!!', $this->opac_views_list[$i]->comment, $line); $liste.=$line; } return str_replace('!!lignes_tableau!!',$liste , $tpl_opac_view_list_tableau); } function do_sel_list() { global $tpl_opac_view_list_sel_tableau,$tpl_opac_view_list_sel_tableau_ligne; global $pmb_opac_view_class; global $base_path,$include_path,$lang,$msg; global $charset; // on reprend... global $pmb_opac_view_activate; $j=0; $list = $disabled = ""; //on a une classe spécifique pour la gestion des vues... //on ne peut pas proposer le forcage, mais on peut peut etre afficher les valeurs if($pmb_opac_view_class){ $tpl = "
".htmlentities($msg['opac_view_class_exists'],ENT_QUOTES,$charset)."
"; }else{ if($pmb_opac_view_activate==2){ //définition en administration, on va chercher les valeurs... $qt = new quota("OPAC_VIEW",$include_path."/quotas/own/".$lang."/opac_views.xml"); //Tableau de passage des paramètres if($this->id_empr){ $struct["READER"] = ($this->id_empr ? $this->id_empr : 0) ; $values = $qt->get_quota_value_with_id($struct); }else{ $values = $qt->apply_conflict(array("")); } if($values['VALUE']){ $allowed = unserialize($values['VALUE']); } //on a peut etre déjà forcer if(count($this->view_list_empr)==0){ $disabled = "disabled='disabled'"; } } //OPAC Classique $line = str_replace('!!class!!',"even", $tpl_opac_view_list_sel_tableau_ligne); $line = str_replace('!!name!!', $msg['opac_view_classic_opac'], $line); $line = str_replace('!!comment!!', $msg['opac_view_classic_opac_comment'], $line); $line = str_replace('!!opac_view_id!!', 0, $line); $tr_surbrillance = "onmouseover=\"this.className='surbrillance'\" onmouseout=\"this.className='even'\" "; $line = str_replace('!!tr_surbrillance!!',$tr_surbrillance , $line); if($disabled == ""){ if(in_array (0,$this->view_list_empr) || !count($this->view_list_empr)){ $checked = "checked='checked'"; }else $checked = ""; $line = str_replace("!!checked!!",$checked,$line); if($this->view_list_empr_default == 0){ $checked_default = "checked='checked'"; }else{ $checked_default = ""; } $line = str_replace("!!radio_checked!!",$checked_default,$line); $line = str_replace("!!disabled!!",$disabled,$line); }else{ if(in_array (0,$allowed['allowed'])){ $checked = "checked='checked'"; }else $checked = ""; $line = str_replace("!!checked!!",$checked,$line); if($allowed['default'] == 0){ $checked_default = "checked='checked'"; }else{ $checked_default = ""; } $line = str_replace("!!radio_checked!!",$checked_default,$line); } $line = str_replace("!!disabled!!",$disabled,$line); $liste.=$line; //Pour les vues for($i=0;$iopac_views_list);$i++) { if($this->opac_views_list[$i]->visible==0) continue; if($this->opac_views_list[$i]->visible>0) { $j++; } $line = str_replace('!!class!!',($j%2 ? "odd" : "even"), $tpl_opac_view_list_sel_tableau_ligne); $line = str_replace('!!name!!', $this->opac_views_list[$i]->name, $line); $line = str_replace('!!comment!!', $this->opac_views_list[$i]->comment, $line); $line = str_replace('!!opac_view_id!!', $this->opac_views_list[$i]->id, $line); $tr_surbrillance = "onmouseover=\"this.className='surbrillance'\" onmouseout=\"this.className='".($j%2 ? "odd" : "even")."'\" "; $line = str_replace('!!tr_surbrillance!!',$tr_surbrillance , $line); //gestion simple ou forçage pour l'utilisateur... if($disabled == ""){ if(in_array ($this->opac_views_list[$i]->id,$this->view_list_empr)){ $checked = "checked='checked'"; }else $checked = ""; $line = str_replace("!!checked!!",$checked,$line); if($this->view_list_empr_default == $this->opac_views_list[$i]->id){ $checked_default = "checked='checked'"; }else{ $checked_default = ""; } $line = str_replace("!!radio_checked!!",$checked_default,$line); }else{ if(in_array ($this->opac_views_list[$i]->id,$allowed['allowed'])){ $checked = "checked='checked'"; }else $checked = ""; $line = str_replace("!!checked!!",$checked,$line); if($allowed['default'] == $this->opac_views_list[$i]->id){ $checked_default = "checked='checked'"; }else{ $checked_default = ""; } $line = str_replace("!!radio_checked!!",$checked_default,$line); } $line = str_replace("!!disabled!!",$disabled,$line); $liste.=$line; } $tpl = str_replace('!!lignes_tableau!!',$liste , $tpl_opac_view_list_sel_tableau); if($pmb_opac_view_activate == 2 && !$pmb_opac_view_class){ $forcage = "    ".$msg['40']."  ".$msg['39']." "; }else{ $forcage = ""; } $tpl = str_replace("!!forcage!!",$forcage,$tpl); } return $tpl; } function update_sel_list() { global $dbh; global $form_empr_opac_view; // issu du formulaire global $form_empr_opac_view_default; // issu du formulaire if($this->id_empr) mysql_query("DELETE from opac_views_empr WHERE emprview_empr_num=".$this->id_empr, $dbh); if(is_array($form_empr_opac_view) && $this->id_empr){ foreach($form_empr_opac_view as $view_num){ $found=0; for($i=0;$iopac_views_list);$i++) { if( $this->opac_views_list[$i]->id == $view_num){$found=1;break;} } if($found || $view_num == 0){ if($view_num==$form_empr_opac_view_default)$default=1; else $default=0; $req="INSERT INTO opac_views_empr SET emprview_view_num=$view_num, emprview_empr_num=".$this->id_empr.", emprview_default=$default "; mysql_query($req, $dbh); } } } } function delete() { global $dbh; if($this->id) { // relation vues / empr mysql_query("DELETE from opac_views_empr WHERE emprview_view_num=".$this->id, $dbh); // table de la liste des notices de la vue $req="DROP TABLE opac_view_notices_".$this->id; mysql_query($req); // la vue mysql_query("DELETE from opac_views WHERE opac_view_id='".$this->id."' ", $dbh); $this->id=0; } $this->fetch_data(); } function make_hidden_search_form() { global $search; global $charset; global $page; $url = "./catalog.php?categ=search&mode=6" ; // remplir $search $this->search_class->unserialize_search($this->requete); $r="
"; for ($i=0; $i"; $r.=""; $r.=""; for ($j=0; $j"; } reset($fieldvar); while (list($var_name,$var_value)=each($fieldvar)) { for ($j=0; $j"; } } } // Champs à mémoriser $r.=""; $r.=""; return $r; } } // fin définition classe