Esempio n. 1
0
 function show_results($url, $url_to_search_form, $hidden_form = true, $search_target = "", $acces = false)
 {
     global $dbh;
     global $begin_result_liste;
     global $nb_per_page_search;
     global $page;
     global $charset;
     global $search;
     global $msg;
     global $pmb_nb_max_tri;
     global $affich_tris_result_liste;
     global $pmb_allow_external_search;
     global $debug;
     global $gestion_acces_active, $gestion_acces_user_notice, $PMBuserid, $pmb_allow_external_search;
     global $link_bulletin;
     global $opac_view_id;
     $start_page = $nb_per_page_search * $page;
     //Y-a-t-il des champs ?
     if (count($search) == 0) {
         array_pop($_SESSION["session_history"]);
         error_message_history($msg["search_empty_field"], $msg["search_no_fields"], 1);
         exit;
     }
     $recherche_externe = true;
     //Savoir si l'on peut faire une recherche externe à partir des critères choisis
     //Verification des champs vides
     for ($i = 0; $i < count($search); $i++) {
         $op = "op_" . $i . "_" . $search[$i];
         global ${$op};
         $field_ = "field_" . $i . "_" . $search[$i];
         global ${$field_};
         $field = ${$field_};
         $s = explode("_", $search[$i]);
         $bool = false;
         if ($s[0] == "f") {
             $champ = $this->fixedfields[$s[1]]["TITLE"];
             if ((string) $field[0] == "") {
                 $bool = true;
             }
         } elseif (array_key_exists($s[0], $this->pp)) {
             $recherche_externe = false;
             $champ = $this->pp[$s[0]]->t_fields[$s[1]]["TITRE"];
             if ((string) $field[0] == "") {
                 $bool = true;
             }
         } elseif ($s[0] == "s") {
             $recherche_externe = false;
             $champ = $this->specialfields[$s[1]]["TITLE"];
             $type = $this->specialfields[$s[1]]["TYPE"];
             for ($is = 0; $is < count($this->tableau_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;
                 }
             }
         }
         if ($bool && !$this->op_empty[${$op}]) {
             array_pop($_SESSION["session_history"]);
             error_message_history($msg["search_empty_field"], sprintf($msg["search_empty_error_message"], $champ), 1);
             exit;
         }
     }
     $table = $this->make_search();
     if ($acces == true && $gestion_acces_active == 1 && $gestion_acces_user_notice == 1) {
         $this->filter_searchtable_from_accessrights($table, $PMBuserid);
     }
     $requete = "select count(1) from {$table}";
     if ($res = pmb_mysql_query($requete)) {
         $nb_results = pmb_mysql_result($res, 0, 0);
     } else {
         array_pop($_SESSION["session_history"]);
         error_message_history("", $msg["search_impossible"], 1);
         exit;
     }
     //gestion du tri
     $has_sort = false;
     if ($nb_results <= $pmb_nb_max_tri) {
         if ($_SESSION["tri"]) {
             $sort = new sort('notices', 'base');
             $requete = $sort->appliquer_tri($_SESSION["tri"], "SELECT * FROM " . $table, "notice_id", $start_page, $nb_per_page_search);
             $table = $sort->table_tri_tempo;
             $has_sort = true;
         }
     }
     // fin gestion tri
     //Y-a-t-il une erreur lors de la recherche ?
     if ($this->error_message) {
         array_pop($_SESSION["session_history"]);
         error_message_history("", $this->error_message, 1);
         exit;
     }
     if ($hidden_form) {
         print $this->make_hidden_search_form($url);
     }
     $requete = "select {$table}.*,notices.niveau_biblio from " . $table . ",notices where notices.notice_id={$table}.notice_id";
     if (count($search) > 1 && !$has_sort) {
         $requete .= " order by index_serie, tnvol, index_sew";
     }
     $requete .= " limit " . $start_page . "," . $nb_per_page_search;
     $resultat = pmb_mysql_query($requete, $dbh);
     $human_requete = $this->make_human_query();
     print "<strong>" . $msg["search_search_extended"] . "</strong> : " . $human_requete;
     if ($debug) {
         print "<br />" . $this->serialize_search();
     }
     if ($nb_results) {
         print " => " . $nb_results . " " . $msg["1916"] . "<br />\n";
         print $begin_result_liste;
         if ($this->rec_history) {
             //Affichage des liens paniers et impression
             $current = $_SESSION["CURRENT"];
             if ($current !== false) {
                 $tri_id_info = $_SESSION["tri"] ? "&sort_id=" . $_SESSION["tri"] : "";
                 print "&nbsp;<a href='#' onClick=\"openPopUp('./print_cart.php?current_print={$current}&action=print_prepare{$tri_id_info}','print',600,700,-2,-2,'scrollbars=yes,menubar=0,resizable=yes'); return false;\"><img src='./images/basket_small_20x20.gif' border='0' align='center' alt=\"" . $msg["histo_add_to_cart"] . "\" title=\"" . $msg["histo_add_to_cart"] . "\"></a>&nbsp;<a href='#' onClick=\"openPopUp('./print.php?current_print={$current}&action_print=print_prepare{$tri_id_info}','print',500,600,-2,-2,'scrollbars=yes,menubar=0'); w.focus(); return false;\"><img src='./images/print.gif' border='0' align='center' alt=\"" . $msg["histo_print"] . "\" title=\"" . $msg["histo_print"] . "\"/></a>";
                 print "&nbsp;<a href='#' onClick=\"openPopUp('./download.php?current_download={$current}&action_download=download_prepare" . $tri_id_info . "','download',500,600,-2,-2,'scrollbars=yes,menubar=0'); return false;\"><img src='./images/upload.gif' border='0' align='center' alt=\"" . $msg["docnum_download"] . "\" title=\"" . $msg["docnum_download"] . "\"/></a>";
                 if ($pmb_allow_external_search) {
                     if ($recherche_externe) {
                         $tag_a = "href='catalog.php?categ=search&mode=7&from_mode=6&external_type=multi'";
                     } else {
                         $tag_a = "onClick=\"alert('" . $msg["search_interdite_externe"] . "')\"";
                     }
                     print "&nbsp;<a " . $tag_a . "  title='" . $msg["connecteurs_external_search_sources"] . "'><img src='./images/external_search.png' border='0' align='center' alt=\"" . $msg["connecteurs_external_search_sources"] . "\"/></a>";
                 }
                 if ($nb_results <= $pmb_nb_max_tri) {
                     print $affich_tris_result_liste;
                 }
             }
         }
     } else {
         print "<br />" . $msg["1915"] . " ";
     }
     print "<input type='button' class='bouton' onClick=\"document.search_form.action='{$url_to_search_form}'; document.search_form.target='{$search_target}'; document.search_form.submit(); return false;\" value=\"" . $msg["search_back"] . "\"/>";
     global $dsi_active;
     if ($dsi_active && !$opac_view_id) {
         global $id_equation, $priv_pro, $id_empr;
         if ($id_equation) {
             $mess_bouton = $msg['dsi_sauvegarder_equation'];
         } else {
             $mess_bouton = $msg["dsi_transformer_equation"];
         }
         print "&nbsp;<input  type='button' class='bouton' onClick=\"document.forms['transform_dsi'].submit(); \" value=\"" . $mess_bouton . "\"/>\n\t\t\t\t\t\t<form name='transform_dsi' style='display:none;' method='post' action='./dsi.php'>";
         if ($priv_pro == "PRI") {
             print "\n\t\t\t\t\t\t<input type=hidden name='categ' value='bannettes' />\n\t\t\t\t\t\t<input type=hidden name='sub' value='abo' />\n\t\t\t\t\t\t<input type=hidden name='suite' value='transform_equ' />\n\t\t\t\t\t\t<input type=hidden name='id_equation' value='{$id_equation}' />\n\t\t\t\t\t\t<input type=hidden name='id_empr' value='{$id_empr}' />\n\t\t\t\t\t\t<input type=hidden name='requete' value='" . htmlentities($this->serialize_search(), ENT_QUOTES, $charset) . "' />\n\t\t\t\t\t\t</form>";
         } else {
             print "\n\t\t\t\t\t\t<input type=hidden name='categ' value='equations' />\n\t\t\t\t\t\t<input type=hidden name='sub' value='gestion' />\n\t\t\t\t\t\t<input type=hidden name='suite' value='transform' />\n\t\t\t\t\t\t<input type=hidden name='id_equation' value='{$id_equation}' />\n\t\t\t\t\t\t<input type=hidden name='requete' value='" . htmlentities($this->serialize_search(), ENT_QUOTES, $charset) . "' />\n\t\t\t\t\t\t</form>";
         }
     }
     global $pmb_opac_view_activate;
     if ($pmb_opac_view_activate) {
         if ($opac_view_id) {
             $mess_bouton = $msg['opac_view_sauvegarder_equation'];
             print "\n\t\t\t\t\t&nbsp;<input  type='button' class='bouton' onClick=\"document.forms['transform_opac_view'].submit(); \" value=\"" . $mess_bouton . "\"/>\n\t\t\t\t\t<form name='transform_opac_view' style='display:none;' method='post' action='./admin.php?categ=opac&sub=opac_view&section=list&action=form&opac_view_id={$opac_view_id}'>\t\t\t\t\t\t\n\t\t\t\t\t\t\t<input type=hidden name='suite' value='transform_equ' />\n\t\t\t\t\t\t\t<input type=hidden name='opac_view_id' value='{$opac_view_id}' />\n\t\t\t\t\t\t\t<input type=hidden name='requete' value='" . htmlentities($this->serialize_search(), ENT_QUOTES, $charset) . "' />\n\t\t\t\t\t</form>";
         }
     }
     // transformation de la recherche en multicriteres: on reposte tout avec mode=8
     if (!$opac_view_id) {
         print "&nbsp;<input  type='button' class='bouton' onClick='document.search_transform.submit(); return false;' value=\"" . $msg["search_notice_to_expl_transformation"] . "\"/>";
         print "<form name='search_transform' action='./catalog.php?categ=search&mode=8&sub=launch' style=\"display:none\" method='post'>";
         $memo_search = "";
         foreach ($_POST as $key => $val) {
             if ($val) {
                 if (is_array($val)) {
                     foreach ($val as $cle => $val_array) {
                         if (is_array($val_array)) {
                             foreach ($val_array as $valeur) {
                                 $memo_search .= "<input type='hidden' name=\"" . $key . "[" . $cle . "][]\" value='" . htmlentities($valeur, ENT_QUOTES, $charset) . "'/>";
                             }
                         } else {
                             $memo_search .= "<input type='hidden' name='" . $key . "[]' value='" . htmlentities($val_array, ENT_QUOTES, $charset) . "'/>";
                         }
                     }
                 } else {
                     $memo_search .= "<input type='hidden' name='{$key}' value='{$val}'/>";
                 }
             }
         }
         print "{$memo_search}</form>";
     }
     //transformation en set pour connecteur externe
     global $id_connector_set;
     $id_connector_set += 0;
     //Il faut que l'on soit passé par le formulaire d'édition de set pour avoir $id_connector_set pour ne pas avoir le bouton tout le temps vu qu'il sert rarement
     if ($pmb_allow_external_search && SESSrights & ADMINISTRATION_AUTH && $id_connector_set) {
         //Il faut qu'il y ait des sets multi critères si on veut pouvoir associer la recherche à quelque chose
         if (connector_out_sets::get_typed_set_count(2)) {
             print '<form name="export_to_outset" style="display:none;" method="post" action="./admin.php?categ=connecteurs&sub=out_sets&action=import_notice_search_into_set&candidate_id=' . $id_connector_set . '"><input type="hidden" name="toset_search" value="' . htmlentities($this->serialize_search(), ENT_QUOTES, $charset) . '" /></form>';
             print '&nbsp;<input type="button" onClick="document.forms[\'export_to_outset\'].submit(); " class="bouton" value="' . htmlentities($msg["search_notice_to_connector_out_set"], ENT_QUOTES, $charset) . '">';
         }
     }
     print $this->get_current_search_map();
     while ($r = pmb_mysql_fetch_object($resultat)) {
         if ($nb++ > 5) {
             $recherche_ajax_mode = 1;
         }
         switch ($r->niveau_biblio) {
             case 'm':
                 // notice de monographie
                 $nt = new mono_display($r->notice_id, 6, $this->link, 1, $this->link_expl, '', $this->link_explnum, 1, 0, 1, 1, "", 1, false, true, $recherche_ajax_mode, 1);
                 break;
             case 's':
                 // on a affaire a un periodique
                 // function serial_display ($id, $level='1', $action_serial='', $action_analysis='', $action_bulletin='', $lien_suppr_cart="", $lien_explnum="", $bouton_explnum=1,$print=0,$show_explnum=1, $show_statut=0, $show_opac_hidden_fields=true, $draggable=0 ) {
                 $nt = new serial_display($r->notice_id, 6, $this->link_serial, $this->link_analysis, $this->link_bulletin, "", $this->link_explnum_serial, 0, 0, 1, 1, true, 1, $recherche_ajax_mode);
                 break;
             case 'a':
                 // on a affaire a un article
                 // function serial_display ($id, $level='1', $action_serial='', $action_analysis='', $action_bulletin='', $lien_suppr_cart="", $lien_explnum="", $bouton_explnum=1,$print=0,$show_explnum=1, $show_statut=0, $show_opac_hidden_fields=true, $draggable=0 ) {
                 $nt = new serial_display($r->notice_id, 6, $this->link_serial, $this->link_analysis, $this->link_bulletin, "", $this->link_explnum_analysis, 0, 0, 1, 1, true, 1, $recherche_ajax_mode);
                 break;
             case 'b':
                 // on a affaire a un bulletin
                 $rqt_bull_info = "SELECT s.notice_id as id_notice_mere, bulletin_id as id_du_bulletin, b.notice_id as id_notice_bulletin FROM notices as s, notices as b, bulletins WHERE b.notice_id={$r->notice_id} and s.notice_id=bulletin_notice and num_notice=b.notice_id";
                 $bull_ids = @pmb_mysql_fetch_object(pmb_mysql_query($rqt_bull_info));
                 if (!$link_bulletin) {
                     $link_bulletin = './catalog.php?categ=serials&sub=bulletinage&action=view&bul_id=' . $bull_ids->id_du_bulletin;
                 } else {
                     $link_bulletin = str_replace("!!id!!", $bull_ids->id_du_bulletin, $link_bulletin);
                 }
                 if ($this->link_explnum_bulletin) {
                     $link_explnum_bulletin = str_replace("!!bul_id!!", $bull_ids->id_du_bulletin, $this->link_explnum_bulletin);
                 } else {
                     $link_explnum_bulletin = "";
                 }
                 $nt = new mono_display($r->notice_id, 6, $link_bulletin, 1, $this->link_expl, '', $link_explnum_bulletin, 1, 0, 1, 1, "", 1, false, true, $recherche_ajax_mode);
                 $link_bulletin = '';
                 break;
         }
         echo "<div class='row'>" . $nt->result . "</div>";
     }
     //Gestion de la pagination
     if ($nb_results) {
         $n_max_page = ceil($nb_results / $nb_per_page_search);
         if (!$page) {
             $page_en_cours = 0;
         } else {
             $page_en_cours = $page;
         }
         // affichage du lien precedent si necessaire
         if ($page > 0) {
             $nav_bar .= "<a href='#' onClick='document.search_form.page.value-=1; ";
             if (!$hidden_form) {
                 $nav_bar .= "document.search_form.launch_search.value=1; ";
             }
             $nav_bar .= "document.search_form.submit(); return false;'>";
             $nav_bar .= "<img src='./images/left.gif' border='0'  title='" . $msg[48] . "' alt='[" . $msg[48] . "]' hspace='3' align='middle'/>";
             $nav_bar .= "</a>";
         }
         $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 .= "<strong>" . ($i + 1) . "</strong>";
             } else {
                 $nav_bar .= "<a href='#' onClick=\"if ((isNaN(document.search_form.page.value))||(document.search_form.page.value=='')) document.search_form.page.value=1; else document.search_form.page.value=" . $i . "; ";
                 if (!$hidden_form) {
                     $nav_bar .= "document.search_form.launch_search.value=1; ";
                 }
                 $nav_bar .= "document.search_form.submit(); return false;\">";
                 $nav_bar .= $i + 1;
                 $nav_bar .= "</a>";
             }
             if ($i < $n_max_page) {
                 $nav_bar .= " ";
             }
         }
         if ($page + 1 < $n_max_page) {
             $nav_bar .= "<a href='#' onClick=\"if ((isNaN(document.search_form.page.value))||(document.search_form.page.value=='')) document.search_form.page.value=1; else document.search_form.page.value=parseInt(document.search_form.page.value)+parseInt(1); ";
             if (!$hidden_form) {
                 $nav_bar .= "document.search_form.launch_search.value=1; ";
             }
             $nav_bar .= "document.search_form.submit(); return false;\">";
             $nav_bar .= "<img src='./images/right.gif' border='0' title='" . $msg[49] . "' alt='[" . $msg[49] . "]' hspace='3' align='middle'>";
             $nav_bar .= "</a>";
         } else {
             $nav_bar .= "";
         }
         $nav_bar = "<div align='center'>{$nav_bar}</div>";
         echo $nav_bar;
     }
 }
Esempio n. 2
0
 protected function get_display_actions()
 {
     global $msg, $charset;
     global $opac_view_id;
     global $dsi_active;
     global $id_equation, $priv_pro, $id_empr;
     global $pmb_opac_view_activate;
     global $id_connector_set;
     global $pmb_allow_external_search;
     $display_actions = "";
     if ($dsi_active && !$opac_view_id) {
         if ($id_equation) {
             $mess_bouton = $msg['dsi_sauvegarder_equation'];
         } else {
             $mess_bouton = $msg["dsi_transformer_equation"];
         }
         $display_actions .= "&nbsp;<input  type='button' class='bouton' onClick=\"document.forms['transform_dsi'].submit(); \" value=\"" . $mess_bouton . "\"/>\n\t\t\t\t\t\t<form name='transform_dsi' style='display:none;' method='post' action='./dsi.php'>";
         if ($priv_pro == "PRI") {
             $display_actions .= "\n\t\t\t\t<input type=hidden name='categ' value='bannettes' />\n\t\t\t\t<input type=hidden name='sub' value='abo' />\n\t\t\t\t<input type=hidden name='suite' value='transform_equ' />\n\t\t\t\t<input type=hidden name='id_equation' value='{$id_equation}' />\n\t\t\t\t<input type=hidden name='id_empr' value='{$id_empr}' />\n\t\t\t\t<input type=hidden name='requete' value='" . htmlentities($this->serialize_search(), ENT_QUOTES, $charset) . "' />";
         } else {
             $display_actions .= "\n\t\t\t\t<input type=hidden name='categ' value='equations' />\n\t\t\t\t<input type=hidden name='sub' value='gestion' />\n\t\t\t\t<input type=hidden name='suite' value='transform' />\n\t\t\t\t<input type=hidden name='id_equation' value='{$id_equation}' />\n\t\t\t\t<input type=hidden name='requete' value='" . htmlentities($this->serialize_search(), ENT_QUOTES, $charset) . "' />";
         }
         $display_actions .= "</form>";
     }
     if ($pmb_opac_view_activate) {
         if ($opac_view_id) {
             $mess_bouton = $msg['opac_view_sauvegarder_equation'];
             $display_actions .= "\n\t\t\t\t\t&nbsp;<input  type='button' class='bouton' onClick=\"document.forms['transform_opac_view'].submit(); \" value=\"" . $mess_bouton . "\"/>\n\t\t\t\t\t<form name='transform_opac_view' style='display:none;' method='post' action='./admin.php?categ=opac&sub=opac_view&section=list&action=form&opac_view_id={$opac_view_id}'>\n\t\t\t\t\t\t<input type=hidden name='suite' value='transform_equ' />\n\t\t\t\t\t\t<input type=hidden name='opac_view_id' value='{$opac_view_id}' />\n\t\t\t\t\t\t<input type=hidden name='requete' value='" . htmlentities($this->serialize_search(), ENT_QUOTES, $charset) . "' />\n\t\t\t\t\t</form>";
         }
     }
     // transformation de la recherche en multicriteres: on reposte tout avec mode=8
     if (!$opac_view_id) {
         $display_actions .= "&nbsp;<input  type='button' class='bouton' onClick='document.search_transform.submit(); return false;' value=\"" . $msg["search_notice_to_expl_transformation"] . "\"/>";
         $display_actions .= "<form name='search_transform' action='./catalog.php?categ=search&mode=8&sub=launch' style=\"display:none\" method='post'>";
         $memo_search = "";
         foreach ($_POST as $key => $val) {
             if ($val) {
                 if (is_array($val)) {
                     foreach ($val as $cle => $val_array) {
                         if (is_array($val_array)) {
                             foreach ($val_array as $valeur) {
                                 $memo_search .= "<input type='hidden' name=\"" . $key . "[" . $cle . "][]\" value='" . htmlentities($valeur, ENT_QUOTES, $charset) . "'/>";
                             }
                         } else {
                             $memo_search .= "<input type='hidden' name='" . $key . "[]' value='" . htmlentities($val_array, ENT_QUOTES, $charset) . "'/>";
                         }
                     }
                 } else {
                     $memo_search .= "<input type='hidden' name='{$key}' value='{$val}'/>";
                 }
             }
         }
         $display_actions .= "{$memo_search}</form>";
     }
     //transformation en set pour connecteur externe
     $id_connector_set += 0;
     //Il faut que l'on soit passé par le formulaire d'édition de set pour avoir $id_connector_set pour ne pas avoir le bouton tout le temps vu qu'il sert rarement
     if ($pmb_allow_external_search && SESSrights & ADMINISTRATION_AUTH && $id_connector_set) {
         //Il faut qu'il y ait des sets multi critères si on veut pouvoir associer la recherche à quelque chose
         if (connector_out_sets::get_typed_set_count(2)) {
             $display_actions .= '<form name="export_to_outset" style="display:none;" method="post" action="./admin.php?categ=connecteurs&sub=out_sets&action=import_notice_search_into_set&candidate_id=' . $id_connector_set . '"><input type="hidden" name="toset_search" value="' . htmlentities($this->serialize_search(), ENT_QUOTES, $charset) . '" /></form>';
             $display_actions .= '&nbsp;<input type="button" onClick="document.forms[\'export_to_outset\'].submit(); " class="bouton" value="' . htmlentities($msg["search_notice_to_connector_out_set"], ENT_QUOTES, $charset) . '">';
         }
     }
     return $display_actions;
 }