opac_views_list);$i++) {
$query="SHOW TABLES LIKE 'opac_view_notices_".$this->opac_views_list[$i]->id."'";
$result = pmb_mysql_query($query);
if(pmb_mysql_num_rows($result)) {
$req="TRUNCATE TABLE opac_view_notices_".$this->opac_views_list[$i]->id;
@pmb_mysql_query($req);
}
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 ignore INTO opac_view_notices_".$this->opac_views_list[$i]->id." ( opac_view_num_notice) select notice_id from $table ";
pmb_mysql_query($req);
pmb_mysql_query("drop table $table");
}
}
$req="update opac_views set opac_view_last_gen=now()";
pmb_mysql_query($req);
}
// fonction générant le form de saisie
public function get_form() {
global $msg,$tpl_opac_view_form, $tpl_opac_view_create_form, $charset,$newsearch,$suite;
// 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="";
$button_modif_requete ="";
$form_modif_requete ="";
}
// 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!!', htmlentities($this->requete,ENT_QUOTES, $charset), $tpl);
// param subst
if(isset($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(isset($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;
}
public 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");
}
public function do_sel_list() {
global $tpl_opac_view_list_sel_tableau,$tpl_opac_view_list_sel_tableau_ligne;
global $pmb_opac_view_class;
global $include_path,$lang,$msg;
global $charset;
// on reprend...
global $pmb_opac_view_activate;
$j=0;
$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=array();
$struct["READER"] = $this->id_empr;
$values = $qt->get_quota_value_with_id($struct);
}else{
$values = $qt->apply_conflict(array(""));
}
$allowed = array();
if($values['VALUE'] && $values['VALUE'] != -1){
$allowed = unserialize($values['VALUE']);
}
//on a peut etre déjà forcer
if(count($this->view_list_empr)==0){
$disabled = "disabled='disabled'";
}
}
if (!isset($allowed['default'])) {
$allowed['default'] = 0;
}
//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(isset($allowed['allowed']) && is_array($allowed['allowed']) && 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(isset($allowed['allowed']) && is_array($allowed['allowed']) && 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;
}
public function update_sel_list() {
global $form_empr_opac_view; // issu du formulaire
global $form_empr_opac_view_default; // issu du formulaire
if($this->id_empr) pmb_mysql_query("DELETE from opac_views_empr WHERE emprview_empr_num=".$this->id_empr);
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 ";
pmb_mysql_query($req);
}
}
}
}
public static function delete($id) {
$id = intval($id);
if($id) {
// relation vues / empr
pmb_mysql_query("DELETE from opac_views_empr WHERE emprview_view_num=".$id);
// table de la liste des notices de la vue
$req="DROP TABLE opac_view_notices_".$id;
pmb_mysql_query($req);
// la vue
pmb_mysql_query("DELETE from opac_views WHERE opac_view_id='".$id."' ");
}
}
public 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="";
return $r;
}
} // fin définition classe