function show_results($dbh, $user_input, $nbr_lignes = 0, $page = 0, $id = 0) { global $nb_per_page; global $base_url; global $caller; global $msg; global $no_display; global $charset; // on récupére le nombre de lignes qui vont bien if ($user_input == "") { $requete = "SELECT COUNT(1) FROM notices where notice_id!='" . $no_display . "' and niveau_biblio='s' and niveau_hierar='1' "; } else { $aq = new analyse_query(stripslashes($user_input)); if ($aq->error) { error_message($msg["searcher_syntax_error"], sprintf($msg["searcher_syntax_error_desc"], $aq->current_car, $aq->input_html, $aq->error_message)); exit; } $members = $aq->get_query_members("notices", "index_wew", "index_sew", "notice_id"); $requete = "select count(notice_id) from notices where (" . $members["where"] . " or code like '" . stripslashes($user_input) . "') and notice_id!='" . $no_display . "' and niveau_biblio='s' and niveau_hierar='1'"; } $res = pmb_mysql_query($requete, $dbh); $nbr_lignes = @pmb_mysql_result($res, 0, 0); if (!$page) { $page = 1; } $debut = ($page - 1) * $nb_per_page; if ($nbr_lignes) { // on lance la vraie requête if ($user_input == "") { $requete = "SELECT notice_id, tit1, code FROM notices where notice_id!='" . $no_display . "' and niveau_biblio='s' and niveau_hierar='1' ORDER BY tit1, code LIMIT {$debut},{$nb_per_page} "; } else { $requete = "select notice_id, tit1, code, " . $members["select"] . " as pert from notices where (" . $members["where"] . " or code like '" . stripslashes($user_input) . "') and notice_id!='" . $no_display . "' and niveau_biblio='s' and niveau_hierar='1' group by notice_id order by pert desc, index_serie, tnvol, index_sew, code limit {$debut},{$nb_per_page}"; } $res = @pmb_mysql_query($requete, $dbh); print "<table><tr>"; while ($notice = pmb_mysql_fetch_object($res)) { $notice_entry = $notice->tit1 . " " . $notice->code; print "\n\t\t\t\t<tr>\n\t\t\t\t\t<td>\n\t\t\t\t\t\t<a href='#' onclick=\"set_parent('{$caller}', '{$notice->notice_id}', '" . htmlentities(addslashes($notice->tit1), ENT_QUOTES, $charset) . " ({$notice->code})')\">" . htmlentities($notice->tit1, ENT_QUOTES, $charset) . "</a></td>\n\t\t\t\t\t<td>{$notice->code}</td>"; print "</tr>"; } print "</table>"; pmb_mysql_free_result($res); // constitution des liens $nbepages = ceil($nbr_lignes / $nb_per_page); $suivante = $page + 1; $precedente = $page - 1; } // affichage de la pagination print "<div class='row'> <hr /></div><div align='center'>"; $url_base = $base_url . "&user_input=" . rawurlencode(stripslashes($user_input)); $nav_bar = aff_pagination($url_base, $nbr_lignes, $nb_per_page, $page, 10, false, true); print $nav_bar; print "</div>"; }
function make_first_search() { global $msg, $dbh; global $elt_query; global $location_query, $date_ech_query; global $nb_per_page, $nb_per_page_select; global $results_show_all; if (!$nb_per_page) { $nb_per_page = $nb_per_page_select; } $restrict = "1 "; if ($location_query != '-1') { $restrict .= "and location_id='" . $location_query . "' "; } $restrict .= "and notice_id=num_notice "; if ($date_ech_query != '-1') { $restrict .= "and date_fin < '" . $date_ech_query . "' "; } $suite_rqt = "or code='" . $elt_query . "' "; $issn_verif = traite_code_ISSN(stripslashes($elt_query)); if (isISSN(stripslashes($elt_query))) { $suite_rqt .= " or code='" . $issn_verif . "' "; $q_count = "select count(abt_id) from notices, abts_abts where " . $restrict . " and (0 " . $suite_rqt . ")"; $r_count = pmb_mysql_query($q_count); $n_count = pmb_mysql_result($r_count, 0, 0); $this->nbresults = $n_count; $q_list = "select tit1, abt_id, abt_name from notices, abts_abts where " . $restrict . " and (0 " . $suite_rqt . ") ORDER BY 1,3"; if (!$results_show_all) { $q_list .= " limit " . $this->page * $nb_per_page . ", " . $nb_per_page . " "; } $r_list = pmb_mysql_query($q_list, $dbh); $this->t_query = $r_list; if (!$results_show_all) { $this->nbepage = ceil($this->nbresults / $nb_per_page); } else { $this->nbepage = 1; } } else { $aq = new analyse_query(stripslashes($elt_query)); if ($aq->error) { $this->show_form(); error_message($msg["searcher_syntax_error"], sprintf($msg["searcher_syntax_error_desc"], $aq->current_car, $aq->input_html, $aq->error_message)); return; } else { $q_members = $aq->get_query_members("notices", "index_wew", "index_sew", "abt_id"); $q_count = "select count(abt_id) from notices, abts_abts where " . $restrict . " and (" . $q_members["where"] . " " . $suite_rqt . ")"; $r_count = pmb_mysql_query($q_count); $n_count = pmb_mysql_result($r_count, 0, 0); $this->nbresults = $n_count; $q_list = "select abt_id, " . $q_members['select'] . " as pert from notices, abts_abts where " . $restrict . " and (" . $q_members["where"] . " " . $suite_rqt . ") " . $q_members['post']; if (!$results_show_all) { $q_list .= " limit " . $this->page * $nb_per_page . ", " . $nb_per_page . " "; } //on surcharge la requête d'origine pour ajouter trier sur titre de périodique $new_q_list = "\n\t\t\t\t\t\tSELECT tit1, a.abt_id, a.abt_name, pert \n\t\t\t\t\t\tFROM notices n, abts_abts a, (" . $q_list . ") as q \n\t\t\t\t\t\tWHERE q.abt_id=a.abt_id AND a.num_notice=n.notice_id \n\t\t\t\t\t\tORDER BY 1 ASC,3 DESC"; $r_list = pmb_mysql_query($new_q_list, $dbh); $this->t_query = $r_list; if (!$results_show_all) { $this->nbepage = ceil($this->nbresults / $nb_per_page); } else { $this->nbepage = 1; } } } return ELT_LIST; }
print $serial_edit_access; // nombre de références par pages if ($nb_per_page_empr != "") { $nb_per_page = $nb_per_page_empr; } else { $nb_per_page = 10; } // comptage du nombre de résultats $where = ""; if ($user_query) { $aq = new analyse_query(stripslashes($user_query)); if ($aq->error) { error_message($msg["searcher_syntax_error"], sprintf($msg["searcher_syntax_error_desc"], $aq->current_car, $aq->input_html, $aq->error_message)); exit; } $members = $aq->get_query_members("notices", "index_wew", "index_sew", "notice_id"); $where .= $members["where"] . " and "; } $where .= "niveau_biblio='s' AND niveau_hierar='1'"; $count_query = pmb_mysql_query("SELECT count(distinct notice_id) FROM notices WHERE {$where}", $dbh); $nbr_lignes = pmb_mysql_result($count_query, 0, 0); if (!$page) { $page = 1; } $debut = ($page - 1) * $nb_per_page; if ($nbr_lignes) { $myQuery = pmb_mysql_query("SELECT *," . $members["select"] . " as pert FROM notices WHERE " . $where . " group by notice_id ORDER BY pert desc,index_sew LIMIT {$debut},{$nb_per_page_a_search}", $dbh); $affichage_final = "<br /><table class='hidelink'>"; while ($myPerio = pmb_mysql_fetch_object($myQuery)) { $class_entete = "even"; $tr_javascript = " onmouseover=\"this.className='surbrillance'\" onmouseout=\"this.className='{$class_entete}'\" ";
function show_results($dbh, $user_input, $nbr_lignes = 0, $page = 0, $id = 0) { global $dbh, $msg, $charset; global $nb_per_page; global $base_url; global $caller; global $no_display; global $exact; global $thesaurus_classement_mode_pmb; global $id_pclass, $typdoc; $pclass_and_req = " num_pclass='{$id_pclass}' and id_pclass = num_pclass "; // on récupère le nombre de lignes qui vont bien if (!$id) { if ($user_input == '') { $requete = "SELECT COUNT(1) FROM indexint,pclassement where {$pclass_and_req} "; } else { if (!$exact) { $aq = new analyse_query(stripslashes($user_input)); if ($aq->error) { print '<br /><div class="row">' . htmlentities($msg['no_result'], ENT_QUOTES, $charset) . '</div>'; exit; } $requete = $aq->get_query_count("indexint, pclassement", "concat(indexint_name,' ',indexint_comment)", "index_indexint", "indexint_id", "{$pclass_and_req}"); } else { $requete = "select count(distinct indexint_id) from indexint,pclassement where indexint_name like '" . str_replace("*", "%", $user_input) . "' and {$pclass_and_req}"; } } $res = mysql_query($requete, $dbh); $nbr_lignes = @mysql_result($res, 0, 0); } else { $nbr_lignes = 1; } if (!$page) { $page = 1; } $debut = ($page - 1) * $nb_per_page; if ($nbr_lignes) { // on lance la vraie requête if (!$id) { if ($user_input == "") { $requete = "SELECT * FROM indexint,pclassement where {$pclass_and_req} "; $requete .= "ORDER BY indexint_name LIMIT {$debut},{$nb_per_page} "; } else { if (!$exact) { $members = $aq->get_query_members("indexint", "concat(indexint_name,' ',indexint_comment)", "index_indexint", "indexint_id"); $requete = "select *," . $members["select"] . " as pert from indexint,pclassement where " . $members["where"] . " and {$pclass_and_req} group by indexint_id order by pert desc, index_indexint limit {$debut},{$nb_per_page}"; } else { $requete = "select * from indexint,pclassement where indexint_name like '" . str_replace("*", "%", $user_input) . "' and {$pclass_and_req} group by indexint_id order by indexint_name limit {$debut},{$nb_per_page}"; } } } else { $requete = "select * from indexint,pclassement where indexint_id='" . $id . "' {$pclass_and_req}"; } $res = @mysql_query($requete, $dbh); while ($indexint = mysql_fetch_object($res)) { if ($indexint->indexint_comment) { $entry = $indexint->indexint_name . " : " . $indexint->indexint_comment; $entry_ret = $indexint->indexint_name . " " . $indexint->indexint_comment; } else { $entry = $indexint->indexint_name; $entry_ret = $entry; } print "<a href='#' onclick=\"set_parent('{$caller}', '{$indexint->indexint_id}', '" . htmlentities(addslashes(str_replace("\r", " ", str_replace("\n", " ", $entry_ret))), ENT_QUOTES, $charset) . "')\">\n\t\t\t\t{$entry}</a>"; print "<br />"; } mysql_free_result($res); // constitution des liens $nbepages = ceil($nbr_lignes / $nb_per_page); $suivante = $page + 1; $precedente = $page - 1; // affichage pagination print '<hr /><div align="center">'; if ($precedente > 0) { print "<a href='{$base_url}&page={$precedente}&nbr_lignes={$nbr_lignes}" . $pclass_url . "&user_input=" . rawurlencode(stripslashes($user_input)) . "&exact={$exact}'><img src='./images/left.gif' border='0' title='{$msg['48']}' alt='[{$msg['48']}]' hspace='3' align='middle' /></a>"; } for ($i = 1; $i <= $nbepages; $i++) { if ($i == $page) { print "<b>{$i}/{$nbepages}</b>"; } } if ($suivante <= $nbepages) { print "<a href='{$base_url}&page={$suivante}&nbr_lignes={$nbr_lignes}" . $pclass_url . "&user_input=" . rawurlencode(stripslashes($user_input)) . "&exact={$exact}'><img src='./images/right.gif' border='0' title='{$msg['49']}' alt='[{$msg['49']}]' hspace='3' align='middle' /></a>"; } print '</div>'; } }
if ($aq->error) { categ_browser::search_form($parent); error_message($msg["searcher_syntax_error"], sprintf($msg["searcher_syntax_error_desc"], $aq->current_car, $aq->input_html, $aq->error_message)); exit; } } if ($lg_search == 1 || $id_thes != -1 && $thes->langue_defaut == $lang) { //On recherche dans toutes les langues ou dans celle par défaut du thésaurus // $user_input -> Permet de savoir si l'on a préciser une recheche //$id_thes -> Si l'on est ici c'est que l'on a qu'un thésaurus et la langue de l'interface est celle du thésaurus $requete .= "categories.langue AS langue, "; $requete .= "categories.libelle_categorie AS categ_libelle, "; $requete .= "categories.note_application AS categ_comment, "; $requete .= "categories.index_categorie AS index_categorie "; if ($user_input) { $members = $aq->get_query_members("categories", "libelle_categorie", "index_categorie", "num_noeud"); $requete .= ", " . $members["select"] . " AS pert "; } $requete .= "FROM noeuds JOIN categories ON noeuds.id_noeud = categories.num_noeud "; if ($lg_search != 1) { $requete .= " AND categories.langue='" . addslashes($lang) . "' "; } $requete .= "WHERE 1 "; if ($user_input) { $requete .= "AND (" . $members["where"] . ") "; } if ($id_thes != -1) { $requete .= "AND noeuds.num_thesaurus = '" . $id_thes . "' "; } } else { //J'ai qu'un thésaurus mais la langue du thésaurus est différente de l'interface
function make_first_search() { global $msg, $charset, $lang, $dbh; global $all_query, $typdoc_query, $statut_query, $etat, $docnum_query; global $categ_query, $thesaurus_auto_postage_search, $auto_postage_query; global $nb_per_page_a_search; global $class_path; global $pmb_default_operator; global $acces_j; global $thesaurus_concepts_active, $concept_query; global $map_echelle_query, $map_projection_query, $map_ref_query, $map_equinoxe_query, $map_emprises_query; global $dbh; if ($nb_per_page_a_search) { $this->nb_per_page = $nb_per_page_a_search; } else { $this->nb_per_page = 3; } $restrict = ''; //Ou les notices qui ont une catégories qui a une emprise $restriction_emprise .= "and (notices.notice_id IN (select distinct map_emprise_obj_num FROM map_emprises where map_emprise_type=11) or (notices.notice_id IN (select distinct notcateg_notice from notices_categories join map_emprises on map_emprises.map_emprise_obj_num = notices_categories.num_noeud where map_emprises.map_emprise_type=2)))"; //$restrict.= "and notice_id IN (select distinct map_emprise_obj_num FROM map_emprises)"; $no_results = false; if (!$concept_query && !$categ_query && !$map_equinoxe_query && !$map_ref_query && !$map_projection_query && !$map_emprises_query && !$all_query && !$map_echelle_query) { $all_query = "*"; } //tous les champs if ($all_query) { //TODO Searcher all_fields, pas le temps de le faire là... // Recherche sur tous les champs (index global) uniquement : $aq = new analyse_query(stripslashes($all_query), 0, 0, 1, 1); $aq2 = new analyse_query(stripslashes($all_query)); if (!$aq->error) { $aq1 = new analyse_query(stripslashes($all_query), 0, 0, 1, 1); $members1 = $aq1->get_query_members("notices", "index_wew", "index_sew", "notice_id", $restrict); global $pmb_title_ponderation; $pert1 = "+" . $members1["select"] . "*" . $pmb_title_ponderation; $members = $aq->get_query_members("notices_global_index", "infos_global", "index_infos_global", "num_notice"); $members2 = $aq2->get_query_members("notices_global_index", "infos_global", "index_infos_global", "num_notice"); if ($members2["where"] != "()" && $pmb_default_operator) { $where_term = "(" . $members["where"] . " or " . $members2["where"] . ")"; } else { $where_term = $members["where"]; } if ($docnum_query && $all_query != '*') { //Si on a activé la recherche dans les docs num //On traite les notices $members_num_noti = $aq2->get_query_members("explnum", "explnum_index_wew", "explnum_index_sew", "explnum_notice", "", 0, 0, true); $members_num_bull = $aq2->get_query_members("explnum", "explnum_index_wew", "explnum_index_sew", "explnum_bulletin", "", 0, 0, true); $join = "(\n\t\t\t\t\tselect tc.notice_id, sum(tc.pert) as pert, tc.typdoc from (\n\t\t\t\t\t(\n\t\t\t\t\t\tselect notice_id, " . $members["select"] . "+" . $members1["select"] . " as pert,typdoc\n\t\t\t\t\t\tfrom notices join notices_global_index on num_notice=notice_id {$acces_j}\n\t\t\t\t\t\twhere " . $members["where"] . " {$restrict}\n\t\t\t\t\t)\n\t\t\t\t\tunion\n\t\t\t\t\t(\n\t\t\t\t\tselect notice_id, " . $members_num_noti["select"] . " as pert,typdoc\n\t\t\t\t\tfrom notices join explnum on explnum_notice=notice_id {$acces_j}\n\t\t\t\t\twhere " . $members_num_noti["where"] . " {$restrict}\n\t\t\t\t\t)\n\t\t\t\t\tunion\n\t\t\t\t\t(\n\t\t\t\t\tselect if(num_notice,num_notice,bulletin_notice) as notice_id, " . $members_num_bull["select"] . " as pert,typdoc\n\t\t\t\t\tfrom explnum join bulletins on explnum_bulletin=bulletin_id ,notices {$acces_j}\n\t\t\t\t\twhere bulletin_notice=notice_id and " . $members_num_bull["where"] . " {$restrict}\n\t\t\t\t\t)\n\t\t\t\t\t)as tc group by notice_id\n\t\t\t\t\t)"; $requete_count = "select count(distinct notice_id) from ({$join}) as union_table"; $requete = "select uni.notice_id, sum(pert) as pert from ({$join}) as uni join notices n on n.notice_id=uni.notice_id group by uni.notice_id order by pert desc, index_serie, tnvol, index_sew "; } elseif ($all_query == "*") { $restrict .= " and num_notice = notice_id "; $requete_count = "select count(1) from notices "; $requete_count .= $acces_j; $requete_count .= ", notices_global_index "; $requete_count .= "where " . $where_term . " "; $requete_count .= $restrict; $requete = "select notice_id,100 as pert from notices "; $requete .= $acces_j; $requete .= ", notices_global_index "; $requete .= "where {$where_term} "; $requete .= $restrict . " order by index_serie, tnvol, index_sew "; } else { $restrict .= " and num_notice = notice_id "; $requete_count = "select count(1) from notices "; $requete_count .= $acces_j; $requete_count .= ", notices_global_index "; $requete_count .= "where " . $where_term . " "; $requete_count .= $restrict; $requete = "select notice_id," . $members["select"] . "{$pert1} as pert from notices "; $requete .= $acces_j; $requete .= ", notices_global_index "; $requete .= "where {$where_term} "; $requete .= $restrict . " order by pert desc, index_serie, tnvol, index_sew "; } $queries[] = $requete; } } //pour la suite, avant de déclencher les recherches, on vérifie si la recherche est différente de celle tous les champs (on s'économise quelques requetes qui ne serviront à rien) //les concepts if ($thesaurus_concepts_active && $concept_query && $concept_query != $all_query) { $concept_searcher = new searcher_records_concepts(stripslashes($concept_query)); if ($concept_searcher->get_nb_results()) { $queries[] = $concept_searcher->get_full_query() . " "; } else { $no_results = true; } } //catégorie if ($categ_query && $categ_query != $all_query) { $categ_searcher = new searcher_records_categories(stripslashes($categ_query)); if ($categ_searcher->get_nb_results()) { $queries[] = $categ_searcher->get_full_query() . " "; } else { $no_results = true; } } //echelle if ($map_echelle_query) { //$queries[] = "select notice_id from notices where map_echelle_num=".$map_echelle_query." "; $queries[] = " select notice_id, 100 as pert from notices where map_echelle_num='" . $map_echelle_query . "' "; } //projection if ($map_projection_query) { $queries[] = " select notice_id, 100 as pert from notices where map_projection_num='" . $map_projection_query . "' "; } //ref if ($map_ref_query) { $queries[] = " select notice_id, 100 as pert from notices where map_ref_num='" . $map_ref_query . "' "; } //équinoxe if ($map_equinoxe_query) { $queries[] = " select notice_id, 100 as pert from notices where map_equinoxe='" . $map_equinoxe_query . "' "; } //map if ($map_emprises_query) { /* $map_map_emprises_searcher = new searcher_records_map_emprises($map_emprises_query); if($map_emprises_searcher->get_nb_results()){ $queries[]=$map_map_emprises_searcher->get_full_query()." "; } */ foreach ($map_emprises_query as $map_emprise_query) { //récupération des emprise de notices correspondantes $query_notice = "select map_emprise_obj_num as notice_id, 100 as pert from map_emprises where map_emprise_type=11 and contains(geomfromtext('{$map_emprise_query}'),map_emprise_data) = 1 "; //récupération des emprise d'autorité correspondantes $query_categories = "select notcateg_notice as notice_id, 100 as pert from notices_categories join map_emprises on num_noeud = map_emprises.map_emprise_obj_num where map_emprise_type = 2 and contains(geomfromtext('{$map_emprise_query}'),map_emprise_data) = 1"; //récupérations des notices indexés avec une categorie //$query = "select notcateg_notice as notice_id, 100 as pert from notices_categories join map_emprises on num_noeud = map_emprises.map_emprise_obj_num where map_emprise_type = 2 and contains(geomfromtext('$map_emprise_query'),map_emprise_data) = 1 union select map_emprise_obj_num as notice_id, 100 as pert from map_emprises where map_emprise_type=11 and contains(geomfromtext('$map_emprise_query'),map_emprise_data) = 1"; $queries[] = "select * from (" . $query_notice . " union " . $query_categories . ") as uni"; //TODO-> faire le mapage et mettre le tout dans $queries... } } //on fait un et donc si un élément ne renvoi rien ,on s'embete pas avec les jointures... if ($no_results || !count($queries)) { $this->nbresults = 0; if ($typdoc_query || $statut_query) { if ($typdoc_query && $statut_query) { $restrict = "notices.typdoc=" . $typdoc_query . " and notices.statut=" . $statut_query . " "; } elseif ($typdoc_query) { $restrict = "notices.typdoc=" . $typdoc_query; } elseif ($statut_query) { $restrict = "notices.statut=" . $statut_query; } } else { $restrict = "notice_id = 0"; } $this->text_query = "select notice_id from notices where " . $restrict; } else { //TODO le tri sur la pertinance desc, titre devrait être automatique... $from = ""; $select_pert = ""; for ($i = 0; $i < count($queries); $i++) { if ($i == 0) { $from = "(" . $queries[$i] . ") as t" . $i; $select_pert = "t" . $i . ".pert"; } else { $from .= " inner join (" . $queries[$i] . ") as t" . $i . " on t" . $i . ".notice_id = t" . ($i - 1) . ".notice_id"; $select_pert .= " + t" . $i . ".pert"; } } $restrict = ""; if ($typdoc_query) { $restrict .= " and notices.typdoc='{$typdoc_query}' "; } elseif ($statut_query) { $restrict .= " and notices.statut='{$statut_query}' "; } $this->text_query = "select t0.notice_id, (" . $select_pert . ") as pert from " . $from . " join notices on t0.notice_id = notices.notice_id " . $restriction_emprise . $restrict . " group by t0.notice_id order by pert desc, notices.index_sew "; $result = pmb_mysql_query($this->text_query, $dbh); $this->nbresults = pmb_mysql_num_rows($result); } $this->nbepage = ceil($this->nbresults / $this->nb_per_page); return NOTICE_LIST; }
// +-------------------------------------------------+ // © 2002-2004 PMB Services / www.sigb.net pmb@sigb.net et contributeurs (voir www.sigb.net) // +-------------------------------------------------+ // $Id: subcollection.inc.php,v 1.28 2015-04-03 11:16:22 jpermanne Exp $ if (stristr($_SERVER['REQUEST_URI'], ".inc.php")) { die("no access"); } if ($opac_search_other_function) { require_once $include_path . "/" . $opac_search_other_function; } // on regarde comment la saisie utilisateur se présente $clause = ''; $add_notice = ''; $aq = new analyse_query(stripslashes($user_query)); $members = $aq->get_query_members("sub_collections", "sub_coll_name", "index_sub_coll", "sub_coll_id"); $clause .= "where " . $members["where"]; if ($opac_search_other_function) { $add_notice = search_other_function_clause(); } if ($typdoc || $add_notice) { $clause = ', notices ' . $clause . ' and subcoll_id=sub_coll_id '; } if ($typdoc) { $clause .= " and typdoc='" . $typdoc . "' "; } if ($add_notice) { $clause .= ' and notice_id in (' . $add_notice . ')'; } $tri = 'order by pert desc, index_sub_coll'; $pert = $members["select"] . " as pert";
// +-------------------------------------------------+ // © 2002-2004 PMB Services / www.sigb.net pmb@sigb.net et contributeurs (voir www.sigb.net) // +-------------------------------------------------+ // $Id: publisher.inc.php,v 1.34 2015-04-03 11:16:22 jpermanne Exp $ if (stristr($_SERVER['REQUEST_URI'], ".inc.php")) { die("no access"); } if ($opac_search_other_function) { require_once $include_path . "/" . $opac_search_other_function; } // on regarde comment la saisie utilisateur se présente $clause = ''; $add_notice = ''; $aq = new analyse_query(stripslashes($user_query), 0, 0, 1, 1); $members = $aq->get_query_members("publishers", "ed_name", "index_publisher", "ed_id"); $clause .= "where " . $members["where"]; if ($opac_search_other_function) { $add_notice = search_other_function_clause(); } if ($typdoc || $add_notice) { $clause = ', notices ' . $clause . ' and (ed1_id=ed_id or ed2_id=ed_id) '; } if ($typdoc) { $clause .= " and typdoc='" . $typdoc . "' "; } if ($add_notice) { $clause .= ' and notice_id in (' . $add_notice . ')'; } $tri = 'order by pert desc, index_publisher'; $pert = $members["select"] . " as pert";
function show_results($dbh, $user_input, $nbr_lignes = 0, $page = 0, $id = 0) { global $nb_per_page; global $base_url; global $caller; global $class_path; global $no_display; global $charset; global $msg; global $callback; if (!$id) { // on récupére le nombre de lignes if ($user_input == "") { $requete = "SELECT COUNT(1) FROM titres_uniformes where tu_id!='{$no_display}' "; } else { $aq = new analyse_query(stripslashes($user_input)); if ($aq->error) { error_message($msg["searcher_syntax_error"], sprintf($msg["searcher_syntax_error_desc"], $aq->current_car, $aq->input_html, $aq->error_message)); exit; } $requete = $aq->get_query_count("titres_uniformes", "tu_name,", "index_tu", "tu_id", "tu_id!='{$no_display}'"); } $res = pmb_mysql_query($requete, $dbh); $nbr_lignes = @pmb_mysql_result($res, 0, 0); } else { $nbr_lignes = 1; } if (!$page) { $page = 1; } $debut = ($page - 1) * $nb_per_page; if ($nbr_lignes) { // on lance la vraie requête if (!$id) { if ($user_input == "") { $requete = "SELECT * FROM titres_uniformes where tu_id!='{$no_display}' ORDER BY tu_name LIMIT {$debut},{$nb_per_page} "; } else { $members = $aq->get_query_members("titres_uniformes", "tu_name", "index_tu", "tu_id"); $requete = "select *," . $members["select"] . " as pert from titres_uniformes where " . $members["where"] . " and tu_id!='{$no_display}' group by tu_id order by pert desc,index_tu limit {$debut},{$nb_per_page}"; } } else { $requete = "select * from titres_uniformes where tu_id='" . $id . "'"; } $res = @pmb_mysql_query($requete, $dbh); while ($titre_uniforme = pmb_mysql_fetch_object($res)) { $tu = new titre_uniforme($titre_uniforme->tu_id); $titre_uniforme_entry = $tu->display; print "<div class='row'>"; print pmb_bidi("<a href='#' onclick=\"set_parent('{$caller}', '{$titre_uniforme->tu_id}', '" . htmlentities(addslashes($titre_uniforme_entry), ENT_QUOTES, $charset) . "','{$callback}')\">{$titre_uniforme_entry}</a>"); print "</div>"; } pmb_mysql_free_result($res); // constitution des liens $nbepages = ceil($nbr_lignes / $nb_per_page); $suivante = $page + 1; $precedente = $page - 1; // affichage du lien précédent si nécéssaire print "<div class='row'> <hr /></div><div align='center'>"; $url_base = $base_url . "&rech_regexp={$rech_regexp}&user_input=" . rawurlencode(stripslashes($user_input)); $nav_bar = aff_pagination($url_base, $nbr_lignes, $nb_per_page, $page, 10, false, true); print $nav_bar; print "</div>"; } else { print $msg["aut_titre_uniforme_not_found"]; } }
function search_docnums() { global $typdoc, $dbh, $charset, $gestion_acces_active, $gestion_acces_empr_notice, $opac_search_other_function, $class_path; global $opac_stemming_active; if ($_SESSION["opac_view"] && $_SESSION["opac_view_query"]) { $opac_view_restrict = " notice_id in (select opac_view_num_notice from opac_view_notices_" . $_SESSION["opac_view"] . ") "; } if ($typdoc) { $restrict = "typdoc='" . $typdoc . "'"; } else { $restrict = ""; } //droits d'acces emprunteur/notice $acces_j = ''; if ($gestion_acces_active == 1 && $gestion_acces_empr_notice == 1) { require_once "{$class_path}/acces.class.php"; $ac = new acces(); $dom_2 = $ac->setDomain(2); $acces_j = $dom_2->getJoin($_SESSION['id_empr_session'], 16, 'notice_id'); } // on regarde comment la saisie utilisateur se presente $clause = ''; $clause_bull = ''; $clause_bull_num_notice = ''; $add_notice = ''; $aq = new analyse_query(stripslashes($this->user_query), 0, 0, 1, 0, $opac_stemming_active); if ($acces_j) { $members = $aq->get_query_members("explnum", "explnum_index_wew", "explnum_index_sew", "explnum_notice", " explnum_notice=notice_id and explnum_bulletin=0", 0, 0, true); $clause = "where " . $members["where"] . " and (" . $members["restrict"] . ")"; $members_bull = $aq->get_query_members("explnum", "explnum_index_wew", "explnum_index_sew", "explnum_bulletin", " explnum_bulletin=bulletin_id and explnum_notice=0 and num_notice=0 and bulletin_notice=notice_id", 0, 0, true); $clause_bull = "where " . $members_bull["where"] . " and (" . $members_bull["restrict"] . ")"; $members_bull_num_notice = $aq->get_query_members("explnum", "explnum_index_wew", "explnum_index_sew", "explnum_bulletin", " explnum_bulletin=bulletin_id and num_notice=notice_id", 0, 0, true); $clause_bull_num_notice = "where " . $members_bull_num_notice["where"] . " and (" . $members_bull_num_notice["restrict"] . ")"; $statut_j = ''; } else { $members = $aq->get_query_members("explnum", "explnum_index_wew", "explnum_index_sew", "explnum_notice", " explnum_notice=notice_id and statut=id_notice_statut and (((notice_visible_opac=1 and notice_visible_opac_abon=0) and (explnum_visible_opac=1 and explnum_visible_opac_abon=0)) " . ($_SESSION["user_code"] ? " or ((notice_visible_opac_abon=1 and notice_visible_opac=1) and (explnum_visible_opac=1 and explnum_visible_opac_abon=1)) or ((notice_visible_opac_abon=0 and notice_visible_opac=1) and (explnum_visible_opac=1 and explnum_visible_opac_abon=1))" : "") . ")", 0, 0, true); $clause = "where " . $members["where"] . " and (" . $members["restrict"] . ")"; $members_bull = $aq->get_query_members("explnum", "explnum_index_wew", "explnum_index_sew", "explnum_bulletin", " explnum_bulletin=bulletin_id and bulletin_notice=notice_id and num_notice=0 and statut=id_notice_statut and (((notice_visible_opac=1 and notice_visible_opac_abon=0) and (explnum_visible_opac=1 and explnum_visible_opac_abon=0)) " . ($_SESSION["user_code"] ? " or ((notice_visible_opac_abon=1 and notice_visible_opac=1) and (explnum_visible_opac=1 and explnum_visible_opac_abon=1)) or ((notice_visible_opac_abon=0 and notice_visible_opac=1) and (explnum_visible_opac=1 and explnum_visible_opac_abon=1))" : "") . ")", 0, 0, true); $clause_bull = "where " . $members_bull["where"] . " and (" . $members_bull["restrict"] . ")"; $members_bull_num_notice = $aq->get_query_members("explnum", "explnum_index_wew", "explnum_index_sew", "explnum_bulletin", " explnum_bulletin=bulletin_id and num_notice=notice_id and statut=id_notice_statut and (((notice_visible_opac=1 and notice_visible_opac_abon=0) and (explnum_visible_opac=1 and explnum_visible_opac_abon=0)) " . ($_SESSION["user_code"] ? " or ((notice_visible_opac_abon=1 and notice_visible_opac=1) and (explnum_visible_opac=1 and explnum_visible_opac_abon=1)) or ((notice_visible_opac_abon=0 and notice_visible_opac=1) and (explnum_visible_opac=1 and explnum_visible_opac_abon=1))" : "") . ")", 0, 0, true); $clause_bull_num_notice = "where " . $members_bull_num_notice["where"] . " and (" . $members_bull_num_notice["restrict"] . ")"; $statut_j = ',notice_statut'; } if ($opac_search_other_function) { $add_notice = search_other_function_clause(); if ($add_notice) { $clause .= ' and notice_id in (' . $add_notice . ')'; $clause_bull .= ' and notice_id in (' . $add_notice . ')'; $clause_bull_num_notice .= ' and notice_id in (' . $add_notice . ')'; } } $search_terms = $aq->get_positive_terms($aq->tree); //On enlève le dernier terme car il s'agit de la recherche booléenne complète unset($search_terms[count($search_terms) - 1]); $pert = $members["select"] . " as pert"; $tri = "order by pert desc, index_serie, tnvol, index_sew"; if ($restrict) { $clause .= " and " . $restrict; $clause_bull .= " and " . $restrict; $clause_bull_num_notice .= " and " . $restrict; } if ($opac_view_restrict) { $clause .= " and " . $opac_view_restrict; } if ($clause) { // instanciation de la nouvelle requête $q_docnum_noti = "select explnum_id from explnum, notices {$statut_j} {$acces_j} {$clause}"; $q_docnum_bull = "select explnum_id from bulletins, explnum, notices {$statut_j} {$acces_j} {$clause_bull}"; $q_docnum_bull_notice = "select explnum_id from bulletins, explnum, notices {$statut_j} {$acces_j} {$clause_bull_num_notice}"; $q_docnum = "select count(explnum_id) from ( {$q_docnum_noti} UNION {$q_docnum_bull} UNION {$q_docnum_bull_notice}) as uni\t"; $docnum = pmb_mysql_query($q_docnum, $dbh); $nb_result_docnum = 0; if ($docnum && pmb_mysql_num_rows($docnum)) { $nb_result_docnum = pmb_mysql_result($docnum, 0, 0); } $req_typdoc_noti = "select distinct typdoc from explnum,notices {$statut_j} {$acces_j} {$clause} group by typdoc"; $req_typdoc_bull = "select distinct typdoc from bulletins, explnum,notices {$statut_j} {$acces_j} {$clause_bull} group by typdoc"; $req_typdoc_bull_num_notice = "select distinct typdoc from bulletins, explnum,notices {$statut_j} {$acces_j} {$clause_bull_num_notice} group by typdoc"; $req_typdoc = "({$req_typdoc_noti}) UNION ({$req_typdoc_bull}) UNION ({$req_typdoc_bull_num_notice})"; $res_typdoc = pmb_mysql_query($req_typdoc, $dbh); $t_typdoc = array(); if ($res_typdoc && pmb_mysql_num_rows($res_typdoc)) { while ($tpd = pmb_mysql_fetch_object($res_typdoc)) { $t_typdoc[] = $tpd->typdoc; } } $l_typdoc = implode(",", $t_typdoc); if ($nb_result_docnum) { $form = "<form name=\"search_docnum\" action=\"./index.php?lvl=more_results\" method=\"post\">"; $form .= "<input type=\"hidden\" name=\"user_query\" value=\"" . htmlentities(stripslashes($this->user_query), ENT_QUOTES, $charset) . "\">\n"; if (function_exists("search_other_function_post_values")) { $form .= search_other_function_post_values(); } $form .= "<input type=\"hidden\" name=\"mode\" value=\"docnum\">\n"; $form .= "<input type=\"hidden\" name=\"search_type_asked\" value=\"simple_search\">\n"; $form .= "<input type=\"hidden\" name=\"count\" value=\"" . $nb_result_docnum . "\">\n"; $form .= "<input type=\"hidden\" name=\"clause\" value=\"" . htmlentities($clause, ENT_QUOTES, $charset) . "\">\n"; $form .= "<input type=\"hidden\" name=\"clause_bull\" value=\"" . htmlentities($clause_bull, ENT_QUOTES, $charset) . "\">\n"; $form .= "<input type=\"hidden\" name=\"clause_bull_num_notice\" value=\"" . htmlentities($clause_bull_num_notice, ENT_QUOTES, $charset) . "\">\n"; $form .= "<input type=\"hidden\" name=\"pert\" value=\"" . htmlentities($pert, ENT_QUOTES, $charset) . "\">\n"; $form .= "<input type=\"hidden\" name=\"l_typdoc\" value=\"" . htmlentities($l_typdoc, ENT_QUOTES, $charset) . "\">\n"; $form .= "<input type=\"hidden\" name=\"tri\" value=\"" . htmlentities($tri, ENT_QUOTES, $charset) . "\">\n"; $form .= "<input type=\"hidden\" name=\"search_terms\" value=\"" . htmlentities(serialize($search_terms), ENT_QUOTES, $charset) . "\"></form>\n"; $_SESSION["level1"]["docnum"]["form"] = $form; $_SESSION["level1"]["docnum"]["count"] = $nb_result_docnum; } } }
/** * * * @return void * @access public */ public function get_objects() { global $dbh; global $search; $objects = array(); $current_search = $this->get_mode(); if ($_SESSION["session_history"][$current_search]["NOTI"]["GET"]["mode"] != "") { $mode_search = $_SESSION["session_history"][$current_search]["NOTI"]["GET"]["mode"]; switch ($mode_search) { case 1: case 2: case 9: $requete = substr($_SESSION["session_history"][$current_search]["NOTI"]["TEXT_QUERY"], 0, strpos($_SESSION["session_history"][$current_search]["NOTI"]["TEXT_QUERY"], "limit")); $result = pmb_mysql_query($requete, $dbh); $notices_ids = array(); while ($row = pmb_mysql_fetch_object($result)) { $notices_ids[] = $row->notice_id; } $objects[] = array('layer' => "record", 'ids' => $notices_ids); if (count($notices_ids)) { $requete = "select distinct map_emprise_obj_num from map_emprises join notices_categories on map_emprises.map_emprise_obj_num = notices_categories.num_noeud where map_emprises.map_emprise_type=2 and notices_categories.notcateg_notice in (" . implode(",", $notices_ids) . ")"; $result = pmb_mysql_query($requete, $dbh); if (pmb_mysql_num_rows($result)) { $categ_ids = array(); while ($row = pmb_mysql_fetch_object($result)) { $categ_ids[] = $row->map_emprise_obj_num; } $objects[] = array('layer' => "authority", 'type' => 2, 'ids' => $categ_ids); } } break; case 0: case 11: if ($_SESSION["session_history"][$current_search]["NOTI"]["TEXT_QUERY"]) { $requete = substr($_SESSION["session_history"][$current_search]["NOTI"]["TEXT_QUERY"], 0, strpos($_SESSION["session_history"][$current_search]["NOTI"]["TEXT_QUERY"], "limit")); $result = pmb_mysql_query($requete, $dbh); $notices_ids = array(); while ($row = pmb_mysql_fetch_object($result)) { $notices_ids[] = $row->notice_id; } $objects[] = array('layer' => "record", 'ids' => $notices_ids); if (count($notices_ids)) { $requete = "select distinct map_emprise_obj_num from map_emprises join notices_categories on map_emprises.map_emprise_obj_num = notices_categories.num_noeud where map_emprises.map_emprise_type=2 and notices_categories.notcateg_notice in (" . implode(",", $notices_ids) . ")"; $result = pmb_mysql_query($requete, $dbh); if (pmb_mysql_num_rows($result)) { $categ_ids = array(); while ($row = pmb_mysql_fetch_object($result)) { $categ_ids[] = $row->map_emprise_obj_num; } $objects[] = array('layer' => "authority", 'type' => 2, 'ids' => $categ_ids); } } } break; case 3: $requete = "SELECT object_id FROM caddie_content where caddie_id='" . $_SESSION["session_history"][$current_search]["NOTI"]["GET"]["idcaddie"] . "' "; $res = pmb_mysql_query($requete, $dbh); $result = pmb_mysql_query($requete, $dbh); $notices_ids = array(); while ($row = pmb_mysql_fetch_object($result)) { $notices_ids[] = $row->object_id; } $objects[] = array('layer' => "record", 'ids' => $notices_ids); if (count($notices_ids)) { $requete = "select distinct map_emprise_obj_num from map_emprises join notices_categories on map_emprises.map_emprise_obj_num = notices_categories.num_noeud where map_emprises.map_emprise_type=2 and notices_categories.notcateg_notice in (" . implode(",", $notices_ids) . ")"; $result = pmb_mysql_query($requete, $dbh); if (pmb_mysql_num_rows($result)) { $categ_ids = array(); while ($row = pmb_mysql_fetch_object($result)) { $categ_ids[] = $row->map_emprise_obj_num; } $objects[] = array('layer' => "authority", 'type' => 2, 'ids' => $categ_ids); } } break; case 6: //Récupération et mise en variables globales des valeurs de l'historique if ($_SESSION["session_history"][$current_search]["QUERY"]["POST"]["search"][0]) { $search = $_SESSION["session_history"][$current_search]["QUERY"]["POST"]["search"]; //Pour chaque champ for ($i = 0; $i < count($search); $i++) { //Récupération de l'opérateur $op = "op_" . $i . "_" . $search[$i]; global ${$op}; ${$op} = $_SESSION["session_history"][$current_search]["QUERY"]["POST"][$op]; //Récupération du contenu de la recherche $field_ = "field_" . $i . "_" . $search[$i]; global ${$field_}; ${$field_} = $_SESSION["session_history"][$current_search]["QUERY"]["POST"][$field_]; $field = ${$field_}; //Récupération de l'opérateur inter-champ $inter = "inter_" . $i . "_" . $search[$i]; global ${$inter}; ${$inter} = $_SESSION["session_history"][$current_search]["QUERY"]["POST"][$inter]; //Récupération des variables auxiliaires $fieldvar_ = "fieldvar_" . $i . "_" . $search[$i]; global ${$fieldvar_}; ${$fieldvar_} = $_SESSION["session_history"][$current_search]["QUERY"]["POST"][$fieldvar_]; $fieldvar = ${$fieldvar_}; } } //on instancie la classe search avec le nom de la nouvelle table temporaire if ($_SESSION["session_history"][$current_search]["QUERY"]["POST"]["search"][0]) { $sc = new search(false); } else { $sc = new search(false, "search_simple_fields"); } $table_tempo = $sc->make_search("tempo_" . $current_search); $requete = "select * from " . $table_tempo; $result = pmb_mysql_query($requete, $dbh); $notices_ids = array(); while ($row = pmb_mysql_fetch_object($result)) { $notices_ids[] = $row->notice_id; } $objects[] = array('layer' => "record", 'ids' => $notices_ids); if (count($notices_ids)) { $requete = "select distinct map_emprise_obj_num from map_emprises join notices_categories on map_emprises.map_emprise_obj_num = notices_categories.num_noeud where map_emprises.map_emprise_type=2 and notices_categories.notcateg_notice in (" . implode(",", $notices_ids) . ")"; $result = pmb_mysql_query($requete, $dbh); if (pmb_mysql_num_rows($result)) { $categ_ids = array(); while ($row = pmb_mysql_fetch_object($result)) { $categ_ids[] = $row->map_emprise_obj_num; } $objects[] = array('layer' => "authority", 'type' => 2, 'ids' => $categ_ids); } } break; default: // authpersos if ($mode_search > 1000) { if ($_SESSION["session_history"][$current_search]["NOTI"]["POST"]) { $requete = substr($_SESSION["session_history"][$current_search]["NOTI"]["TEXT_QUERY"], 0, strpos($_SESSION["session_history"][$current_search]["NOTI"]["TEXT_QUERY"], "limit")); $result = pmb_mysql_query($requete, $dbh); $notices_ids = array(); while ($row = pmb_mysql_fetch_object($result)) { $notices_ids[] = $row->notice_id; } $objects[] = array('layer' => "record", 'ids' => $notices_ids); if (count($notices_ids)) { $requete = "select distinct map_emprise_obj_num from map_emprises join notices_categories on map_emprises.map_emprise_obj_num = notices_categories.num_noeud where map_emprises.map_emprise_type=2 and notices_categories.notcateg_notice in (" . implode(",", $notices_ids) . ")"; $result = pmb_mysql_query($requete, $dbh); if (pmb_mysql_num_rows($result)) { $categ_ids = array(); while ($row = pmb_mysql_fetch_object($result)) { $categ_ids[] = $row->map_emprise_obj_num; } $objects[] = array('layer' => "authority", 'type' => 2, 'ids' => $categ_ids); } } } } break; } } elseif ($_SESSION["session_history"][$current_search]["AUT"]["GET"]["mode"] != "") { $mode_search = $_SESSION["session_history"][$current_search]["AUT"]["GET"]["mode"]; switch ($mode_search) { case 0: if ($_SESSION["session_history"][$current_search]["AUT"]["POST"]) { foreach ($_SESSION["session_history"][$current_search]["AUT"]["POST"] as $key => $valeur) { global ${$key}; ${$key} = $valeur; } // Recherche sur l'auteur uniquement : $aq = new analyse_query(stripslashes($author_query), 0, 0, 1, 1); $restrict = ''; if ($typdoc_query) { $restrict = "and typdoc='" . $typdoc_query . "' "; } if ($statut_query) { $restrict .= "and statut='" . $statut_query . "' "; } if ($typdoc_query || $statut_query || $acces_j) { $restrict = "and responsability_author=author_id and responsability_notice=notice_id " . $restrict . " "; $members = $aq->get_query_members("authors", "concat(author_name,', ',author_rejete)", "index_author", "author_id"); $requete_count = "select count(distinct author_id) from authors, responsability, notices "; $requete_count .= $acces_j; $requete_count .= "where " . $members["where"] . " "; $requete_count .= $restrict; $requete = "select author_id," . $members["select"] . " as pert from authors, responsability, notices "; $requete .= $acces_j; $requete .= "where " . $members["where"] . " "; $requete .= $restrict . " group by author_id order by pert desc,author_name, author_rejete,author_numero , author_subdivision "; } else { $requete_count = $aq->get_query_count("authors", "concat(author_name,', ',author_rejete)", "index_author", "author_id"); $t_query = $aq->get_query_members("authors", "concat(author_name,', ',author_rejete)", "index_author", "author_id"); $requete = "select author_id," . $t_query["select"] . " as pert from authors where " . $t_query["where"] . " group by author_id order by pert desc,author_name, author_rejete, author_numero , author_subdivision "; } $t_query = @pmb_mysql_query($requete, $dbh); while ($row = pmb_mysql_fetch_object($t_query)) { $aut_ids[] = $row->author_id; } $objects[] = array('layer' => "authority", 'ids' => $aut_ids); } break; } } return $objects; }
function show_results($dbh, $user_input, $nbr_lignes = 0, $page = 0, $id = 0) { global $nb_per_page; global $base_url; global $caller; global $callback; global $class_path; global $no_display; global $charset; global $msg; global $libelleReq; global $id_type_autorite; if (!$id) { // on récupére le nombre de lignes if ($user_input == "") { $requete = "SELECT COUNT(1) FROM authors where author_id!='{$no_display}' " . $libelleReq; } else { $aq = new analyse_query(stripslashes($user_input)); if ($aq->error) { error_message($msg["searcher_syntax_error"], sprintf($msg["searcher_syntax_error_desc"], $aq->current_car, $aq->input_html, $aq->error_message)); exit; } $requete = $aq->get_query_count("authors", "concat(author_name,', ',author_rejete) ", "index_author", "author_id", "author_id!='{$no_display}'"); $requete .= $libelleReq; } $res = mysql_query($requete, $dbh); $nbr_lignes = @mysql_result($res, 0, 0); } else { $nbr_lignes = 1; } if (!$page) { $page = 1; } $debut = ($page - 1) * $nb_per_page; if ($nbr_lignes) { // on lance la vraie requête if (!$id) { if ($user_input == "") { $requete = "SELECT * FROM authors where author_id!='{$no_display}' {$libelleReq} ORDER BY author_name, author_rejete LIMIT {$debut},{$nb_per_page} "; } else { $members = $aq->get_query_members("authors", "concat(author_name,', ',author_rejete)", "index_author", "author_id"); $requete = "select *," . $members["select"] . " as pert from authors where " . $members["where"] . " and author_id!='{$no_display}' {$libelleReq} group by author_id order by pert desc,index_author limit {$debut},{$nb_per_page}"; } } else { $requete = "select * from authors where author_id='" . $id . "'" . $libelleReq; } $res = @mysql_query($requete, $dbh); while ($author = mysql_fetch_object($res)) { $auteur = new auteur($author->author_id); $author_voir = ""; // gestion des voir : if ($author->author_see) { $auteur_see = new auteur($author->author_see); $author_voir = "<a href='#' onclick=\"set_parent('{$caller}', '{$author->author_see}', '" . htmlentities(addslashes($auteur_see->isbd_entry), ENT_QUOTES, $charset) . "','{$callback}')\">" . htmlentities($auteur_see->isbd_entry, ENT_QUOTES, $charset) . "</a>"; $author_voir = ". - <i>{$msg['210']}</i> : " . $author_voir; } print "<div class='row'>"; print pmb_bidi("<a href='#' onclick=\"set_parent('{$caller}', '{$author->author_id}', '" . htmlentities(addslashes($auteur->isbd_entry), ENT_QUOTES, $charset) . "','{$callback}')\">{$auteur->isbd_entry}</a>"); print pmb_bidi($author_voir); print "</div>"; } mysql_free_result($res); // constitution des liens $nbepages = ceil($nbr_lignes / $nb_per_page); $suivante = $page + 1; $precedente = $page - 1; // affichage du lien précédent si nécéssaire print "<div class='row'> <hr /></div><div align='center'>"; $url_base = $base_url . "&rech_regexp={$rech_regexp}&user_input=" . rawurlencode(stripslashes($user_input)) . "&id_type_autorite=" . $id_type_autorite; $nav_bar = aff_pagination($url_base, $nbr_lignes, $nb_per_page, $page, 10, false, true); print $nav_bar; print "</div>"; } else { print $msg["no_author_found"]; } }
require_once $include_path . "/" . $opac_search_other_function; print pmb_bidi(" " . search_other_function_human_query($_SESSION["last_query"])); } print "</span>"; print activation_surlignage(); print "</h3>"; $restrict_opac_view = ''; if ($_SESSION["opac_view"]) { $restrict_opac_view = " notice_id in (select opac_view_num_notice from opac_view_notices_" . $_SESSION["opac_view"] . ") "; } $restrict_typdoc = ''; if ($typdoc) { $restrict_typdoc = "typdoc='" . addslashes($typdoc) . "'"; } $aq = new analyse_query(stripslashes($user_query), 0, 0, 1, 0, $opac_stemming_active); $members = $aq->get_query_members("explnum", "explnum_index_wew", "explnum_index_sew", "explnum_id", '', 0, 0, true); if ($user_query == '*') { $new_clause = '1'; $pert = "100 as pert"; } else { $new_clause = $members["where"]; } if (!isset($pert)) { $pert = $members["select"] . " as pert"; } //droits d'acces emprunteur/notice $acces_j = ''; if ($gestion_acces_active == 1 && $gestion_acces_empr_notice == 1) { require_once "{$class_path}/acces.class.php"; $ac = new acces(); $dom_2 = $ac->setDomain(2);
function make_first_search() { global $search_subject; global $search_indexint, $search_indexint_id, $aut_type; global $msg; global $charset; global $browser, $search_form_categ, $browser_url; global $lang; global $dbh; global $id_thes; global $thesaurus_mode_pmb; if ($search_indexint_id) { $this->id = $search_indexint_id; $aut_type = "indexint"; return AUT_SEARCH; } $this->nbresults = 0; if ($search_subject) { $aq = new analyse_query(stripslashes($search_subject)); if (!$aq->error) { if ($id_thes != -1) { $thes = new thesaurus($id_thes); } $requete = "SELECT SQL_CALC_FOUND_ROWS noeuds.id_noeud AS categ_id, "; if ($id_thes != -1 && $thes->langue_defaut == $lang) { $members = $aq->get_query_members("categories", "libelle_categorie", "index_categorie", "num_noeud"); $requete .= $members["select"] . " AS pert "; $requete .= "FROM noeuds JOIN categories ON noeuds.id_noeud = categories.num_noeud AND categories.langue='" . addslashes($lang) . "' "; $requete .= "WHERE noeuds.num_thesaurus = '" . $id_thes . "' "; $requete .= "AND (" . $members["where"] . ") "; $requete .= "AND categories.libelle_categorie NOT LIKE '~%' "; $requete .= "ORDER BY pert DESC,categories.index_categorie"; } else { $members_catdef = $aq->get_query_members("catdef", "catdef.libelle_categorie", "catdef.index_categorie", "catdef.num_noeud"); $members_catlg = $aq->get_query_members("catlg", "catlg.libelle_categorie", "catlg.index_categorie", "catlg.num_noeud"); $requete .= "IF (catlg.num_noeud IS NULL, catdef.index_categorie, catlg.index_categorie) as index_categorie, "; $requete .= "IF (catlg.num_noeud IS NULL, " . $members_catdef["select"] . ", " . $members_catlg["select"] . ") as pert "; if ($id_thes != -1) { $requete .= "FROM noeuds JOIN categories AS catdef ON noeuds.id_noeud = catdef.num_noeud AND catdef.langue = '" . $thes->langue_defaut . "' "; $requete .= "LEFT JOIN categories AS catlg ON catdef.num_noeud = catlg.num_noeud AND catlg.langue = '" . $lang . "' "; $requete .= "WHERE noeuds.num_thesaurus = '" . $id_thes . "' "; } else { //Plusieurs thésaurus $requete .= "FROM noeuds JOIN thesaurus ON thesaurus.id_thesaurus = noeuds.num_thesaurus "; $requete .= "JOIN categories AS catdef ON noeuds.id_noeud = catdef.num_noeud AND catdef.langue = thesaurus.langue_defaut "; $requete .= "LEFT JOIN categories AS catlg on catdef.num_noeud = catlg.num_noeud AND catlg.langue = '" . $lang . "' "; $requete .= "WHERE 1 "; } $requete .= "AND catdef.libelle_categorie NOT LIKE '~%' "; $requete .= "AND (IF (catlg.num_noeud IS NULL, " . $members_catdef["where"] . ", " . $members_catlg["where"] . ") ) ORDER BY pert DESC,index_categorie"; } $this->s_query = mysql_query($requete, $dbh); $qry = "SELECT FOUND_ROWS() AS NbRows"; if ($resnum = mysql_query($qry)) { $this->nb_s = mysql_result($resnum, 0, 0); } } else { $this->show_error($aq->current_car, $aq->input_html, $aq->error_message); return; } } if ($search_indexint) { $aq = new analyse_query(stripslashes($search_indexint)); if (!$aq->error) { $this->nb_id = @mysql_result(@mysql_query("select count(distinct indexint_id) from indexint where indexint_name like '" . str_replace("*", "%", $search_indexint) . "'"), 0, 0); if ($this->nb_id) { $this->id_query = @mysql_query("select indexint_id from indexint where indexint_name like '" . str_replace("*", "%", $search_indexint) . "' order by indexint_name*1, indexint_name"); if ($this->nb_id == 1) { $id = @mysql_fetch_object($this->id_query); $this->id = $id->indexint_id; $aut_type = "indexint"; return AUT_SEARCH; } } $this->nb_i = @mysql_result(@mysql_query($aq->get_query_count("indexint", "indexint_comment", "index_indexint", "indexint_id")), 0, 0); if ($this->nb_i) { $this->i_query = @mysql_query($aq->get_query("indexint", "indexint_comment", "index_indexint", "indexint_id")); } } else { $this->show_error($aq->current_car, $aq->input_html, $aq->error_message); return; } } if ($this->nb_s + $this->nb_i + $this->nb_id == 0) { //affichage du selectionneur de thesaurus et du lien vers les thésaurus $liste_thesaurus = thesaurus::getThesaurusList(); $sel_thesaurus = ''; $lien_thesaurus = ''; if ($thesaurus_mode_pmb != 0) { //la liste des thesaurus n'est pas affichée en mode monothesaurus $sel_thesaurus = "<select class='saisie-30em' id='id_thes' name='id_thes' "; $sel_thesaurus .= "onchange = \"document.location = '" . $this->base_url . "&id_thes='+document.getElementById('id_thes').value; \">"; foreach ($liste_thesaurus as $id_thesaurus => $libelle_thesaurus) { $sel_thesaurus .= "<option value='" . $id_thesaurus . "' "; if ($id_thesaurus == $id_thes) { $sel_thesaurus .= " selected"; } $sel_thesaurus .= ">" . htmlentities($libelle_thesaurus, ENT_QUOTES, $charset) . "</option>"; } $sel_thesaurus .= "<option value=-1 "; if ($id_thes == -1) { $sel_thesaurus .= "selected "; } $sel_thesaurus .= ">" . htmlentities($msg['thes_all'], ENT_QUOTES, $charset) . "</option>"; $sel_thesaurus .= "</select> "; } $search_form_categ = str_replace("<!-- sel_thesaurus -->", $sel_thesaurus, $search_form_categ); //affichage du choix de langue pour la recherche // $sel_langue = ''; // $sel_langue = "<div class='row'>"; // $sel_langue.= "<input type='checkbox' name='lg_search' id='lg_search' value='1' /> ".htmlentities($msg['thes_sel_langue'],ENT_QUOTES, $charset); // $sel_langue.= "</div><br />"; // $search_form_categ=str_replace("<!-- sel_langue -->",$sel_langue,$search_form_categ); $search_form_categ = str_replace("!!base_url!!", $this->base_url, $search_form_categ); print pmb_bidi($search_form_categ); error_message($msg["searcher_no_result"], $msg["searcher_no_result_desc"]); $browser = str_replace("!!browser_url!!", $browser_url, $browser); print pmb_bidi($browser); return; } return AUT_LIST; }
$restrict_typdoc = "typdoc='" . addslashes($typdoc) . "'"; } //droits d'acces emprunteur/notice $acces_j = ''; if ($gestion_acces_active == 1 && $gestion_acces_empr_notice == 1) { require_once "{$class_path}/acces.class.php"; $ac = new acces(); $dom_2 = $ac->setDomain(2); $acces_j = $dom_2->getJoin($_SESSION['id_empr_session'], 16, 'notice_id'); } //Pour rester compatible avec l'ancienne version $old_clause = ''; $old_clause_bull = ''; $old_clause_bull_num_notice = ''; $aq = new analyse_query(stripslashes($user_query), 0, 0, 1, 0, $opac_stemming_active); $members = $aq->get_query_members("explnum", "explnum_index_wew", "explnum_index_sew", "explnum_id", '', 0, 0, true); if ($user_query == '*') { $new_clause = '1'; $pert = "100 as pert"; } else { $new_clause = $members["where"]; $pert = $members["select"] . " as pert"; } if ($acces_j) { $q_restrict = "select notice_id from notices " . $acces_j . " where " . ($restrict_typdoc ? $restrict_typdoc : '1 '); $q_restrict .= $restrict_opac_view ? 'and ' . $restrict_opac_view : ''; //Pour rester compatible avec l'ancienne version $old_members = $aq->get_query_members("explnum", "explnum_index_wew", "explnum_index_sew", "explnum_notice", " explnum_notice=notice_id and explnum_bulletin=0", 0, 0, true); $old_clause = "where " . $old_members["where"] . " and (" . $old_members["restrict"] . ")"; $old_members_bull = $aq->get_query_members("explnum", "explnum_index_wew", "explnum_index_sew", "explnum_bulletin", " explnum_bulletin=bulletin_id and explnum_notice=0 and num_notice=0 and bulletin_notice=notice_id", 0, 0, true); $old_clause_bull = "where " . $old_members_bull["where"] . " and (" . $old_members_bull["restrict"] . ")";
function show_results($dbh, $user_input, $nbr_lignes = 0, $page = 0, $id = 0) { global $nb_per_page; global $base_url; global $caller; global $no_display; global $exact; global $charset; global $msg; global $thesaurus_classement_mode_pmb, $thesaurus_classement_defaut, $id_pclass, $typdoc; global $callback; if ($thesaurus_classement_mode_pmb != 0) { //classement indexation décimale autorisé en parametrage $pclass_and_req = " and num_pclass='{$id_pclass}' and id_pclass = num_pclass "; $pclass_url = "&id_pclass={$id_pclass}"; } else { $pclass_and_req = " and num_pclass='{$thesaurus_classement_defaut}' and id_pclass = num_pclass"; $pclass_url = "&id_pclass={$thesaurus_classement_defaut}"; } // on récupére le nombre de lignes qui vont bien if (!$id) { if ($user_input == "") { $requete = "SELECT COUNT(1) FROM indexint,pclassement where indexint_id!='{$no_display}' {$pclass_and_req} "; } else { if (!$exact) { $aq = new analyse_query(stripslashes($user_input)); if ($aq->error) { error_message($msg["searcher_syntax_error"], sprintf($msg["searcher_syntax_error_desc"], $aq->current_car, $aq->input_html, $aq->error_message)); exit; } $requete = $aq->get_query_count("indexint, pclassement", "concat(indexint_name,' ',indexint_comment)", "index_indexint", "indexint_id", "indexint_id!='{$no_display}' {$pclass_and_req}"); } else { $requete = "select count(distinct indexint_id) from indexint,pclassement where indexint_name like '" . str_replace("*", "%", $user_input) . "' and indexint_id!='{$no_display}' {$pclass_and_req}"; } } $res = pmb_mysql_query($requete, $dbh); $nbr_lignes = @pmb_mysql_result($res, 0, 0); } else { $nbr_lignes = 1; } if (!$page) { $page = 1; } $debut = ($page - 1) * $nb_per_page; if ($nbr_lignes) { // on lance la vraie requête if (!$id) { if ($user_input == "") { $requete = "SELECT * FROM indexint,pclassement where indexint_id!='{$no_display}' {$pclass_and_req} "; $requete .= "ORDER BY indexint_name LIMIT {$debut},{$nb_per_page} "; } else { if (!$exact) { $members = $aq->get_query_members("indexint", "concat(indexint_name,' ',indexint_comment)", "index_indexint", "indexint_id"); $requete = "select *," . $members["select"] . " as pert from indexint,pclassement where " . $members["where"] . " and indexint_id!='{$no_display}' {$pclass_and_req} group by indexint_id order by pert desc, index_indexint limit {$debut},{$nb_per_page}"; } else { $requete = "select * from indexint,pclassement where indexint_name like '" . str_replace("*", "%", $user_input) . "' and indexint_id!='{$no_display}' {$pclass_and_req} group by indexint_id order by indexint_name limit {$debut},{$nb_per_page}"; } } } else { $requete = "select * from indexint,pclassement where indexint_id='" . $id . "' {$pclass_and_req}"; } $res = @pmb_mysql_query($requete, $dbh); while ($indexint = pmb_mysql_fetch_object($res)) { if ($indexint->indexint_comment) { $entry = $indexint->indexint_name . " - " . $indexint->indexint_comment; } else { $entry = $indexint->indexint_name; } if ($thesaurus_classement_mode_pmb != 0) { //classement indexation décimale autorisé en parametrage $entry = "[" . $indexint->name_pclass . "] " . $entry; } print pmb_bidi("\n\t\t\t<a href='#' onclick=\"set_parent('{$caller}', '{$indexint->indexint_id}', '" . htmlentities(addslashes(str_replace("\r", " ", str_replace("\n", " ", $entry))), ENT_QUOTES, $charset) . "','{$callback}')\">\n\t\t\t\t{$entry}</a>"); print "<br />"; } pmb_mysql_free_result($res); // constitution des liens $nbepages = ceil($nbr_lignes / $nb_per_page); $suivante = $page + 1; $precedente = $page - 1; // affichage du lien précédent si nécéssaire print '<hr /><div align=center>'; if ($precedente > 0) { print "<a href='{$base_url}&page={$precedente}&nbr_lignes={$nbr_lignes}" . $pclass_url . "&user_input=" . rawurlencode(stripslashes($user_input)) . "&exact={$exact}'><img src='./images/left.gif' border='0' title='{$msg['48']}' alt='[{$msg['48']}]' hspace='3' align='middle' /></a>"; } for ($i = 1; $i <= $nbepages; $i++) { if ($i == $page) { print "<b>{$i}/{$nbepages}</b>"; } } if ($suivante <= $nbepages) { print "<a href='{$base_url}&page={$suivante}&nbr_lignes={$nbr_lignes}" . $pclass_url . "&user_input=" . rawurlencode(stripslashes($user_input)) . "&exact={$exact}'><img src='./images/right.gif' border='0' title='{$msg['49']}' alt='[{$msg['49']}]' hspace='3' align='middle' /></a>"; } } print '</div>'; }
if (stristr($_SERVER['REQUEST_URI'], ".inc.php")) { die("no access"); } // premier niveau de recherche OPAC sur indexations decimales if ($opac_search_other_function) { require_once $include_path . "/" . $opac_search_other_function; } // contrôle du nombre de résultats à afficher en premier niveau (6 par défaut) if (!$opac_search_results_first_level) { $opac_search_results_first_level = 6; } // on regarde comment la saisie utilisateur se présente $clause = ''; $add_notice = ''; $aq = new analyse_query(stripslashes($user_query), 0, 0, 1, 0, $opac_stemming_active); $members = $aq->get_query_members("indexint", "concat(indexint_name,' ',indexint_comment)", "index_indexint", "indexint_id"); $clause .= "where " . $members["where"]; if ($opac_search_other_function) { $add_notice = search_other_function_clause(); } if ($typdoc || $add_notice) { $clause = ', notices ' . $clause . ' and indexint=indexint_id '; } if ($typdoc) { $clause .= " and typdoc='" . $typdoc . "' "; } if ($add_notice) { $clause .= ' and notice_id in (' . $add_notice . ')'; } $tri = 'order by pert desc, index_indexint'; $pert = $members["select"] . " as pert";
function show_results($dbh, $user_input, $nbr_lignes = 0, $page = 0, $id = 0) { global $nb_per_page; global $base_url; global $caller; global $callback; global $charset; global $msg; global $no_display; // on récupére le nombre de lignes qui vont bien if (!$id) { if ($user_input == "") { $requete = "SELECT COUNT(1) FROM collections where collection_id!='{$no_display}' "; } else { $aq = new analyse_query(stripslashes($user_input)); if ($aq->error) { error_message($msg["searcher_syntax_error"], sprintf($msg["searcher_syntax_error_desc"], $aq->current_car, $aq->input_html, $aq->error_message)); exit; } $requete = $aq->get_query_count("collections", "collection_name", "index_coll", "collection_id", "collection_id!='{$no_display}'"); } $res = mysql_query($requete, $dbh); $nbr_lignes = @mysql_result($res, 0, 0); } else { $nbr_lignes = 1; } if (!$page) { $page = 1; } $debut = ($page - 1) * $nb_per_page; if ($nbr_lignes) { // on lance la vraie requête if (!$id) { if ($user_input == "") { $requete = "SELECT collections.*,publishers.* FROM collections, publishers WHERE collection_id!='{$no_display}' and ed_id=collection_parent group by collection_id"; $requete .= " ORDER BY index_coll, index_publisher LIMIT {$debut},{$nb_per_page} "; } else { $members = $aq->get_query_members("collections", "collection_name", "index_coll", "collection_id"); $requete = "select collections.*,publishers.*, " . $members["select"] . " as pert from collections, publishers where " . $members["where"] . " and collection_id!='{$no_display}' and ed_id=collection_parent group by collection_id order by pert desc, index_coll, index_publisher LIMIT {$debut},{$nb_per_page}"; } } else { $requete = "select collections.*,publishers.* from collections,publishers where collection_id='" . $id . "' and collection_parent=ed_id group by collection_id"; } $res = @mysql_query($requete, $dbh); while ($col = mysql_fetch_object($res)) { print pmb_bidi("\n \t\t\t<a href='#' onclick=\"set_parent('{$caller}', {$col->collection_id}, '" . htmlentities(addslashes($col->collection_name), ENT_QUOTES, $charset) . "', {$col->ed_id}, '" . htmlentities(addslashes($col->ed_name), ENT_QUOTES, $charset) . "','{$callback}')\">\n\t\t\t\t{$col->collection_name}</a>"); print pmb_bidi(". {$col->ed_name}<br />"); } mysql_free_result($res); // constitution des liens $nbepages = ceil($nbr_lignes / $nb_per_page); $suivante = $page + 1; $precedente = $page - 1; // affichage pagination print "<div class='row'> <hr /></div><div align='center'>"; $url_base = $base_url . "&user_input=" . rawurlencode(stripslashes($user_input)); $nav_bar = aff_pagination($url_base, $nbr_lignes, $nb_per_page, $page, 10, false, true); print $nav_bar; print "</div>"; } }
$serie_list = "<tr>\n\t\t<th>" . $msg[103] . "</th>\n\t\t<!--!!col_num_autorite!!-->\n\t\t<th>" . $msg["count_notices_assoc"] . "</th>\n\t\t</tr>"; $num_auth_present = false; $req = "SELECT id_authority_source FROM authorities_sources WHERE authority_type='serie' AND TRIM(authority_number) !='' LIMIT 1"; $res_aut = pmb_mysql_query($req, $dbh); if ($res_aut && pmb_mysql_num_rows($res_aut)) { $serie_list = str_replace("<!--!!col_num_autorite!!-->", "<th>" . $msg["authorities_number"] . "</th>", $serie_list); $num_auth_present = true; } // on lance la vraie requête if (!$user_input) { $requete = "SELECT * FROM series ORDER BY serie_name LIMIT {$debut},{$nb_per_page} "; if ($last_param) { $requete = "SELECT * FROM series " . $tri_param . " " . $limit_param; } } else { $members = $aq->get_query_members("series", "serie_name", "serie_index", "serie_id"); $requete = "select *," . $members["select"] . " as pert from series where " . $members["where"] . " group by serie_id order by pert desc, serie_index limit {$debut},{$nb_per_page}"; } $res = @pmb_mysql_query($requete, $dbh); $parity = 1; $url_base = "./autorites.php?categ=series&sub=reach&user_input=" . rawurlencode(stripslashes($user_input)); while ($serie = pmb_mysql_fetch_object($res)) { if ($parity % 2) { $pair_impair = "even"; } else { $pair_impair = "odd"; } $parity += 1; $notice_count_sql = "SELECT count(*) FROM notices WHERE tparent_id = " . $serie->serie_id; $notice_count = pmb_mysql_result(pmb_mysql_query($notice_count_sql), 0, 0); $tr_javascript = " onmouseover=\"this.className='surbrillance'\" onmouseout=\"this.className='{$pair_impair}'\" ";
$num_auth_present = false; $req = "SELECT id_authority_source FROM authorities_sources WHERE authority_type='collection' AND TRIM(authority_number) !='' LIMIT 1"; $res_aut = pmb_mysql_query($req, $dbh); if ($res_aut && pmb_mysql_num_rows($res_aut)) { $collection_list = str_replace("<!--!!col_num_autorite!!-->", "<th>" . $msg["authorities_number"] . "</th>", $collection_list); $num_auth_present = true; } // on lance la vraie requête if (!$user_input) { $requete = "SELECT * FROM collections A left join publishers B on ed_id=collection_parent "; $requete .= " {$tri_param} LIMIT {$debut},{$nb_per_page} "; if ($last_param) { $requete = "SELECT * FROM collections A left join publishers B on ed_id=collection_parent " . $tri_param . " " . $limit_param; } } else { $members = $aq->get_query_members("collections", "collection_name", "index_coll", "collection_id"); $requete = "select collections.*, publishers.*, " . $members["select"] . " as pert from collections left join publishers on ed_id=collection_parent where " . $members["where"] . " group by collection_id order by pert desc,index_coll,index_publisher limit {$debut},{$nb_per_page}"; } $res = @pmb_mysql_query($requete, $dbh); $parity = 1; $url_base = "./autorites.php?categ=collections&sub=reach&user_input=" . rawurlencode(stripslashes($user_input)); while ($coll = pmb_mysql_fetch_object($res)) { if ($parity % 2) { $pair_impair = "even"; } else { $pair_impair = "odd"; } $parity += 1; $notice_count_sql = "SELECT count(*) FROM notices WHERE coll_id = " . $coll->collection_id; $notice_count = pmb_mysql_result(pmb_mysql_query($notice_count_sql), 0, 0); $tr_javascript = " onmouseover=\"this.className='surbrillance'\" onmouseout=\"this.className='{$pair_impair}'\" ";
function get_where_term() { global $msg, $charset; global $opac_stemming_active; //Si il y a déjà un terme where calculé alors renvoi tout de suite if ($this->where) { return $this->where; } //Si il y a un terme saisi alors close where if ($this->search_term) { $this->error_message = ""; $aq = new analyse_query($this->search_term, 0, 0, 1, 0, $opac_stemming_active); if (!$aq->error) { $members = $aq->get_query_members("categories", "libelle_categorie", "index_categorie", "num_noeud"); $where_term = "and " . $members["where"]; $this->order = $members["select"]; $this->where = $where_term; $this->aq = $aq; } else { $this->error_message = sprintf($msg["searcher_syntax_error_desc"], $aq->current_car, $aq->input_html, $aq->error_message); } } return $where_term; }
if (!$opac_allow_affiliate_search || $opac_allow_affiliate_search && $tab == "catalog") { print "\n\t<h3><span><b>{$count}</b> {$msg['categs_found']} <b>'" . htmlentities(stripslashes($user_query), ENT_QUOTES, $charset) . "'"; if ($opac_search_other_function) { require_once $include_path . "/" . $opac_search_other_function; print pmb_bidi(" " . search_other_function_human_query($_SESSION["last_query"])); } print "</b></font>"; print activation_surlignage(); print "</h3></span>"; if (!$opac_allow_affiliate_search) { print "\n\t\t\t\t</div>"; } print "\n\t\t\t\t<div id=\"resultatrech_liste\">\n\t\t\t\t<ul>"; $first_clause .= "catdef.libelle_categorie not like '~%' "; $aq = new analyse_query(stripslashes($user_query), 0, 0, 1, 0, $opac_stemming_active); $members_catdef = $aq->get_query_members('catdef', 'catdef.libelle_categorie', 'catdef.index_categorie', 'catdef.num_noeud'); $members_catlg = $aq->get_query_members('catlg', 'catlg.libelle_categorie', 'catlg.index_categorie', 'catlg.num_noeud'); $list_thes = array(); if ($id_thes == -1) { //recherche dans tous les thesaurus $list_thes = thesaurus::getThesaurusList(); } else { //recherche dans le thesaurus transmis $thes = new thesaurus($id_thes); $list_thes[$id_thes] = $thes->libelle_thesaurus; } $q = "drop table if exists catjoin "; $r = mysql_query($q, $dbh); $q = "create temporary table catjoin ENGINE=MyISAM as select "; foreach ($list_thes as $id_thesaurus => $libelle_thesaurus) { $thes = new thesaurus($id_thesaurus);
// $Id: author.inc.php,v 1.45 2013-12-10 09:06:14 dgoron Exp $ if (stristr($_SERVER['REQUEST_URI'], ".inc.php")) { die("no access"); } // premier niveau de recherche OPAC sur auteurs // inclusion classe pour affichage auteur (level 1) require_once $base_path . '/includes/templates/author.tpl.php'; require_once $base_path . '/classes/author.class.php'; if ($opac_search_other_function) { require_once $include_path . "/" . $opac_search_other_function; } // on regarde comment la saisie utilisateur se présente $clause = ''; $add_notice = ''; $aq = new analyse_query(stripslashes($user_query), 0, 0, 1, 1); $members = $aq->get_query_members("authors", "concat(author_name,', ',author_rejete)", "index_author", "author_id"); $clause = ' where ' . $members["where"]; if ($opac_search_other_function) { $add_notice = search_other_function_clause(); } if ($typdoc || $add_notice) { $clause = ',notices, responsability ' . $clause . ' and responsability_author=author_id and notice_id=responsability_notice'; } if ($typdoc) { $clause .= " and typdoc='" . $typdoc . "' "; } if ($add_notice) { $clause .= ' and notice_id in (' . $add_notice . ')'; } $tri = 'order by pert desc, index_author'; $pert = $members["select"] . " as pert";
function calcNbLignes($all_query = '') { global $dbh, $msg; //analyse_query switch ($this->type_acte) { case TYP_ACT_CDE: if ($all_query == '') { $q_cde = "create temporary table tmp_cde as "; $q_cde .= "select distinct id_ligne, id_acte, numero, actes.num_fournisseur as num_fournisseur, raison_sociale, type_ligne, date_acte, lignes_actes.nb as nb_cde, "; $q_cde .= "lignes_actes.code as code, libelle, lignes_actes.statut, lignes_actes.commentaires_gestion, lignes_actes.commentaires_opac, lignes_actes.num_produit as num_produit, num_acquisition "; $q_cde .= "from lignes_actes join actes on num_acte=id_acte join entites on actes.num_fournisseur=id_entite "; $q_cde .= "left join suggestions on num_acquisition=id_suggestion left join suggestions_origine on num_suggestion=id_suggestion "; $q_cde .= "where "; $q_cde .= $this->filtre_actes . $this->filtre_lignes . $this->filtre_origines; mysql_query($q_cde, $dbh); //echo $q_cde.'<br />'; $q_liv = "create temporary table tmp_liv as "; $q_liv .= "select lig_ref, sum(nb) as nb_liv from lignes_actes "; $q_liv .= "join actes on num_acte=id_acte and type_acte='" . TYP_ACT_LIV . "' "; $q_liv .= "where lig_ref in (select id_ligne from tmp_cde)"; $q_liv .= "group by lig_ref "; mysql_query($q_liv, $dbh); //echo $q_liv.'<br />'; $q_sol = "select distinct id_ligne, id_acte, numero, num_fournisseur, raison_sociale, type_ligne, date_acte, nb_cde ,if(nb_liv is null,0,nb_liv) as nb_liv, if(nb_liv is null,nb_cde,((nb_cde*1)-(nb_liv*1))) as nb_sol, "; $q_sol .= "code, libelle, statut, commentaires_gestion, commentaires_opac, num_produit, num_acquisition "; $q_sol .= "from tmp_cde left join tmp_liv on id_ligne=lig_ref "; $q_sol .= "where ((nb_cde*1)-(nb_liv*1)) > 0 or nb_liv is null "; $q_sol .= "order by raison_sociale, numero "; $r_sol = mysql_query($q_sol, $dbh); //echo $q_sol.'<br />'; $r = mysql_num_rows($r_sol); if ($r) { while ($row = mysql_fetch_object($r_sol)) { $i = $row->id_acte; $j = $row->id_ligne; $this->t_list[$i][$j] = array(); $this->t_list[$i][$j]['numero'] = $row->numero; $this->t_list[$i][$j]['date_acte'] = $row->date_acte; $this->t_list[$i][$j]['num_fournisseur'] = $row->num_fournisseur; $this->t_list[$i][$j]['raison_sociale'] = $row->raison_sociale; $this->t_list[$i][$j]['type_ligne'] = $row->type_ligne; $this->t_list[$i][$j]['nb_cde'] = $row->nb_cde; $this->t_list[$i][$j]['nb_liv'] = $row->nb_liv; $this->t_list[$i][$j]['nb_sol'] = $row->nb_sol; $this->t_list[$i][$j]['code'] = $row->code; $this->t_list[$i][$j]['libelle'] = $row->libelle; $this->t_list[$i][$j]['statut'] = $row->statut; $this->t_list[$i][$j]['commentaires_gestion'] = $row->commentaires_gestion; $this->t_list[$i][$j]['commentaires_opac'] = $row->commentaires_opac; $this->t_list[$i][$j]['num_produit'] = $row->num_produit; $this->t_list[$i][$j]['num_acquisition'] = $row->num_acquisition; } } } else { $aq = new analyse_query(stripslashes($all_query), 0, 0, 0, 0); if ($aq->error) { $this->error = return_error_message($msg["searcher_syntax_error"], sprintf($msg["searcher_syntax_error_desc"], $aq->current_car, $aq->input_html, $aq->error_message)); } else { //$members_actes = $aq->get_query_members("actes","numero","index_acte", "id_acte"); $members_actes = '0'; $members_lignes = $aq->get_query_members("lignes_actes", "code", "index_ligne", "id_ligne"); $members_global = $aq->get_query_members("notices_global_index", "infos_global", "index_infos_global", "num_notice"); $q_cde = "create temporary table tmp_cde as ( "; $q_cde .= "select distinct id_ligne,id_acte, numero, actes.num_fournisseur as num_fournisseur, raison_sociale, type_ligne, date_acte, lignes_actes.nb as nb_cde, "; $q_cde .= "lignes_actes.code as code, libelle, lignes_actes.statut, lignes_actes.commentaires_gestion, lignes_actes.commentaires_opac, lignes_actes.num_produit as num_produit, num_acquisition "; $q_cde .= "from lignes_actes join actes on num_acte=id_acte join entites on actes.num_fournisseur=id_entite "; $q_cde .= "left join notices_global_index on num_produit=notices_global_index.num_notice and type_ligne in ('1','5') "; $q_cde .= "left join suggestions on num_acquisition=id_suggestion left join suggestions_origine on num_suggestion=id_suggestion "; $q_cde .= "where "; $q_cde .= $this->filtre_actes . $this->filtre_lignes . $this->filtre_origines; $q_cde .= "and (" . $members_actes['where'] . " "; $q_cde .= "or " . $members_lignes['where'] . " "; $q_cde .= "or " . $members_global['where'] . ") "; $q_cde .= ") union ("; $q_cde .= "select distinct id_ligne,id_acte, numero, actes.num_fournisseur as num_fournisseur, raison_sociale, type_ligne, date_acte, lignes_actes.nb as nb_cde, "; $q_cde .= "lignes_actes.code as code, libelle, lignes_actes.statut, lignes_actes.commentaires_gestion, lignes_actes.commentaires_opac, lignes_actes.num_produit as num_produit, num_acquisition "; $q_cde .= "from lignes_actes join actes on num_acte=id_acte join entites on actes.num_fournisseur=id_entite "; $q_cde .= "left join bulletins on num_produit=bulletins.num_notice and type_ligne='2' "; $q_cde .= "left join notices_global_index on bulletins.num_notice=notices_global_index.num_notice "; $q_cde .= "left join suggestions on num_acquisition=id_suggestion left join suggestions_origine on num_suggestion=id_suggestion "; $q_cde .= "where "; $q_cde .= $this->filtre_actes . $this->filtre_lignes . $this->filtre_origines; $q_cde .= "and (" . $members_actes['where'] . " "; $q_cde .= "or " . $members_lignes['where'] . " "; $q_cde .= "or " . $members_global['where'] . ") "; $q_cde .= ") "; mysql_query($q_cde, $dbh); //echo $q_cde.'<br />'; $q_liv = "create temporary table tmp_liv as "; $q_liv .= "select lig_ref,sum(nb) as nb_liv from lignes_actes "; $q_liv .= "join actes on lignes_actes.num_acte=actes.id_acte and actes.type_acte='" . TYP_ACT_LIV . "' "; $q_liv .= "where lig_ref in (select id_ligne from tmp_cde) "; $q_liv .= "group by lig_ref "; mysql_query($q_liv, $dbh); //echo $q_liv.'<br />'; $q_sol = "select distinct id_ligne, id_acte, numero, num_fournisseur, raison_sociale, type_ligne, date_acte, nb_cde, if(nb_liv is null,0,nb_liv) as nb_liv, if(nb_liv is null,nb_cde, ((nb_cde*1)-(nb_liv*1))) as nb_sol, "; $q_sol .= "code, libelle, statut, commentaires_gestion, commentaires_opac, num_produit, num_acquisition "; $q_sol .= "from tmp_cde left join tmp_liv on id_ligne=lig_ref "; $q_sol .= "where ((nb_cde*1)-(nb_liv*1)) > 0 or nb_liv is null "; $q_sol .= "order by raison_sociale, numero "; $r_sol = mysql_query($q_sol, $dbh); //echo $q_sol.'<br />'; $r = mysql_num_rows($r_sol); if ($r) { while ($row = mysql_fetch_object($r_sol)) { $i = $row->id_acte; $j = $row->id_ligne; $this->t_list[$i][$j] = array(); $this->t_list[$i][$j]['numero'] = $row->numero; $this->t_list[$i][$j]['date_acte'] = $row->date_acte; $this->t_list[$i][$j]['num_fournisseur'] = $row->num_fournisseur; $this->t_list[$i][$j]['raison_sociale'] = $row->raison_sociale; $this->t_list[$i][$j]['type_ligne'] = $row->type_ligne; $this->t_list[$i][$j]['nb_cde'] = $row->nb_cde; $this->t_list[$i][$j]['nb_liv'] = $row->nb_liv; $this->t_list[$i][$j]['nb_sol'] = $row->nb_sol; $this->t_list[$i][$j]['code'] = $row->code; $this->t_list[$i][$j]['libelle'] = $row->libelle; $this->t_list[$i][$j]['statut'] = $row->statut; $this->t_list[$i][$j]['commentaires_gestion'] = $row->commentaires_gestion; $this->t_list[$i][$j]['commentaires_opac'] = $row->commentaires_opac; } $this->t_list[$i][$j]['num_produit'] = $row->num_produit; $this->t_list[$i][$j]['num_acquisition'] = $row->num_acquisition; } } } break; case TYP_ACT_DEV: if ($all_query == '') { /* $this->q_count = "select count(distinct id_ligne) from lignes_actes "; $this->q_count.= "join actes on lignes_actes.num_acte=actes.id_acte "; if ($this->filtre_origines) $this->q_count.="join suggestions on lignes_actes.num_acquisition=suggestions.id_suggestion join suggestions_origine on num_suggestion=id_suggestion "; $this->q_count.= "where "; $this->q_count.= $this->filtre_actes.$this->filtre_lignes.$this->filtre_origines; $this->q_list = "select lignes_actes.*, actes.numero, nom_acte from lignes_actes "; $this->q_list.= "join actes on lignes_actes.num_acte=actes.id_acte "; if ($this->filtre_origines) $this->q_list.="join suggestions on lignes_actes.num_acquisition=suggestions.id_suggestion join suggestions_origine on num_suggestion=id_suggestion "; $this->q_list.= "where "; $this->q_list.= $this->filtre_actes.$this->filtre_lignes.$this->filtre_origines; $this->q_list.= "group by id_ligne order by date_acte"; */ } else { } break; } if ($this->error) { return 0; } else { return $r; } }
$num_auth_present = false; $req = "SELECT id_authority_source FROM authorities_sources WHERE authority_type='uniform_title' AND TRIM(authority_number) !='' LIMIT 1"; $res_aut = mysql_query($req, $dbh); if ($res_aut && mysql_num_rows($res_aut)) { $titre_uniforme_list = str_replace("<!--!!col_num_autorite!!-->", "<th>" . $msg["authorities_number"] . "</th>", $titre_uniforme_list); $num_auth_present = true; } // on lance la vraie requête if (!$user_input) { $requete = "SELECT * FROM titres_uniformes "; $requete .= "ORDER BY index_tu LIMIT {$debut},{$nb_per_page} "; if ($last_param) { $requete = "SELECT * FROM titres_uniformes " . $tri_param . " " . $limit_param; } } else { $members = $aq->get_query_members("titres_uniformes", "tu_name", "index_tu", "tu_id"); $requete = "select *, " . $members["select"] . " as pert from titres_uniformes where " . $members["where"] . " group by tu_id order by pert desc, index_tu limit {$debut},{$nb_per_page}"; } $res = @mysql_query($requete, $dbh); $parity = 1; while ($titre_uniforme = mysql_fetch_object($res)) { $tire_uniforme_entry = $titre_uniforme->tu_name; $link_titre_uniforme = "./autorites.php?categ=titres_uniformes&sub=titre_uniforme_form&id={$titre_uniforme->tu_id}&user_input=" . rawurlencode(stripslashes($user_input)) . "&nbr_lignes={$nbr_lignes}&page={$page}"; if ($parity % 2) { $pair_impair = "even"; } else { $pair_impair = "odd"; } $parity += 1; $notice_count_sql = "SELECT count(*) FROM notices_titres_uniformes WHERE ntu_num_tu = " . $titre_uniforme->tu_id; $notice_count = mysql_result(mysql_query($notice_count_sql), 0, 0);
function make_search($prefixe = "") { global $search; global $dbh; global $msg; global $include_path; global $pmb_multi_search_operator; global $pmb_search_stemming_active; $this->error_message = ""; $last_table = ""; $field_keyName = $this->keyName; //Pour chaque champ for ($i = 0; $i < count($search); $i++) { //construction de la requete $s = explode("_", $search[$i]); //Recuperation de l'operateur $op = "op_" . $i . "_" . $search[$i]; //Recuperation du contenu de la recherche $field_ = "field_" . $i . "_" . $search[$i]; global ${$field_}; $field = ${$field_}; //Recuperation de l'operateur inter-champ $inter = "inter_" . $i . "_" . $search[$i]; global ${$inter}; global ${$op}; //Recuperation des variables auxiliaires $fieldvar_ = "fieldvar_" . $i . "_" . $search[$i]; global ${$fieldvar_}; $fieldvar = ${$fieldvar_}; //Si c'est un champ fixe if ($s[0] == "f") { $ff = $this->fixedfields[$s[1]]; //Choix du moteur if ($this->memory_engine_allowed && !$ff['MEMORYENGINEFORBIDDEN']) { $this->current_engine = 'MEMORY'; } else { $this->current_engine = 'MyISAM'; } //Calcul des variables $var_table = array(); for ($j = 0; $j < count($ff["VAR"]); $j++) { switch ($ff["VAR"][$j]["TYPE"]) { case "input": $var_table[$ff["VAR"][$j]["NAME"]] = @implode(",", $fieldvar[$ff["VAR"][$j]["NAME"]]); break; case "global": $global_name = $ff["VAR"][$j]["NAME"]; global ${$global_name}; $var_table[$ff["VAR"][$j]["NAME"]] = ${$global_name}; break; case "calculated": $calc = $ff["VAR"][$j]["OPTIONS"]["CALC"][0]; switch ($calc["TYPE"]) { case "value_from_query": $query_calc = $calc["QUERY"][0]["value"]; @reset($var_table); while (list($var_name, $var_value) = @each($var_table)) { $query_calc = str_replace("!!" . $var_name . "!!", $var_value, $query_calc); } $r_calc = pmb_mysql_query($query_calc); $var_table[$ff["VAR"][$j]["NAME"]] = @pmb_mysql_result($r_calc, 0, 0); break; } break; } } $q_index = $ff["QUERIES_INDEX"]; //Recuperation de la requete associee au champ et a l'operateur $q = $ff["QUERIES"][$q_index[${$op}]]; //Si c'est une requete conditionnelle, on sélectionne la bonne requete et on supprime les autres if ($q[0]["CONDITIONAL"]) { $k_default = 0; $q_temp = array(); $q_temp["OPERATOR"] = $q["OPERATOR"]; for ($k = 0; $k < count($q) - 1; $k++) { if ($var_table[$q[$k]["CONDITIONAL"]["name"]] == $q[$k]["CONDITIONAL"]["value"]) { break; } if ($q[$k]["CONDITIONAL"]["value"] == "default") { $k_default = $k; } } if ($k == count($q) - 1) { $k = $k_default; } $q_temp[0] = $q[$k]; $q = $q_temp; } //Remplacement par les variables eventuelles pour chaque requete for ($k = 0; $k < count($q) - 1; $k++) { reset($var_table); while (list($var_name, $var_value) = each($var_table)) { $q[$k]["MAIN"] = str_replace("!!" . $var_name . "!!", $var_value, $q[$k]["MAIN"]); $q[$k]["MULTIPLE_TERM"] = str_replace("!!" . $var_name . "!!", $var_value, $q[$k]["MULTIPLE_TERM"]); } } $last_main_table = ""; // pour les listes, si un opérateur permet une valeur vide, il en faut une... if ($this->op_empty[${$op}] && !is_array($field)) { $field = array(); $field[0] = ""; } // si sélection d'autorité et champ vide : on ne doit pas le prendre en compte if (${$op} == 'AUTHORITY') { $suppr = false; foreach ($field as $k => $v) { if ($v == 0) { unset($field[$k]); $suppr = true; } } if ($suppr) { $field = array_values($field); } } //Pour chaque valeur du champ for ($j = 0; $j < count($field); $j++) { //Pour chaque requete $field_origine = $field[$j]; for ($z = 0; $z < count($q) - 1; $z++) { //Pour chaque valeur du cha //Si le nettoyage de la saisie est demande if ($q[$z]["KEEP_EMPTYWORD"]) { $field[$j] = strip_empty_chars($field_origine); } elseif ($q[$z]["REGDIACRIT"]) { $field[$j] = strip_empty_words($field_origine); } elseif ($q[$z]["DETECTDATE"]) { $field[$j] = detectFormatDate($field_origine, $q[$z]["DETECTDATE"]); } $main = $q[$z]["MAIN"]; //Si il y a plusieurs termes possibles on construit la requete avec le terme !!multiple_term!! if ($q[$z]["MULTIPLE_WORDS"]) { $terms = explode(" ", $field[$j]); //Pour chaque terme, $multiple_terms = array(); for ($k = 0; $k < count($terms); $k++) { $multiple_terms[] = str_replace("!!p!!", $terms[$k], $q[$z]["MULTIPLE_TERM"]); } $final_term = implode(" " . $q[$z]["MULTIPLE_OPERATOR"] . " ", $multiple_terms); $main = str_replace("!!multiple_term!!", $final_term, $main); //Si la saisie est un ISBN } else { if ($q[$z]["ISBN"]) { //Code brut $terms[0] = $field[$j]; //EAN ? if (isEAN($field[$j])) { //C'est un isbn ? if (isISBN($field[$j])) { $rawisbn = preg_replace('/-|\\.| /', '', $field[$j]); //On envoi tout ce qu'on sait faire en matiere d'ISBN, en raw et en formatte, en 10 et en 13 $terms[1] = formatISBN($rawisbn, 10); $terms[2] = formatISBN($rawisbn, 13); $terms[3] = preg_replace('/-|\\.| /', '', $terms[1]); $terms[4] = preg_replace('/-|\\.| /', '', $terms[2]); } } else { if (isISBN($field[$j])) { $rawisbn = preg_replace('/-|\\.| /', '', $field[$j]); //On envoi tout ce qu'on sait faire en matiere d'ISBN, en raw et en formatte, en 10 et en 13 $terms[1] = formatISBN($rawisbn, 10); $terms[2] = formatISBN($rawisbn, 13); $terms[3] = preg_replace('/-|\\.| /', '', $terms[1]); $terms[4] = preg_replace('/-|\\.| /', '', $terms[2]); } } //Pour chaque terme, $multiple_terms = array(); for ($k = 0; $k < count($terms); $k++) { $multiple_terms[] = str_replace("!!p!!", $terms[$k], $q[$z]["MULTIPLE_TERM"]); } $final_term = implode(" " . $q[$z]["MULTIPLE_OPERATOR"] . " ", $multiple_terms); $main = str_replace("!!multiple_term!!", $final_term, $main); } else { if ($q[$z]["BOOLEAN"]) { if ($q[$z]['STEMMING']) { $stemming = $pmb_search_stemming_active; } else { $stemming = 0; } $aq = new analyse_query($field[$j], 0, 0, 1, 0, $stemming); $aq1 = new analyse_query($field[$j], 0, 0, 1, 1, $stemming); if ($q[$z]["KEEP_EMPTY_WORDS_FOR_CHECK"]) { $err = $aq1->error; } else { $err = $aq->error; } if (!$err) { if (is_array($q[$z]["TABLE"])) { for ($z1 = 0; $z1 < count($q[$z]["TABLE"]); $z1++) { $is_fulltext = false; if ($q[$z]["FULLTEXT"][$z1]) { $is_fulltext = true; } if (!$q[$z]["KEEP_EMPTY_WORDS"][$z1]) { $members = $aq->get_query_members($q[$z]["TABLE"][$z1], $q[$z]["INDEX_L"][$z1], $q[$z]["INDEX_I"][$z1], $q[$z]["ID_FIELD"][$z1], $q[$z]["RESTRICT"][$z1], 0, 0, $is_fulltext); } else { $members = $aq1->get_query_members($q[$z]["TABLE"][$z1], $q[$z]["INDEX_L"][$z1], $q[$z]["INDEX_I"][$z1], $q[$z]["ID_FIELD"][$z1], $q[$z]["RESTRICT"][$z1], 0, 0, $is_fulltext); } $main = str_replace("!!pert_term_" . ($z1 + 1) . "!!", $members["select"], $main); $main = str_replace("!!where_term_" . ($z1 + 1) . "!!", $members["where"], $main); } } else { $is_fulltext = false; if ($q[$z]["FULLTEXT"]) { $is_fulltext = true; } if ($q[$z]["KEEP_EMPTY_WORDS"]) { $members = $aq1->get_query_members($q[$z]["TABLE"], $q[$z]["INDEX_L"], $q[$z]["INDEX_I"], $q[$z]["ID_FIELD"], $q[$z]["RESTRICT"], 0, 0, $is_fulltext); } else { $members = $aq->get_query_members($q[$z]["TABLE"], $q[$z]["INDEX_L"], $q[$z]["INDEX_I"], $q[$z]["ID_FIELD"], $q[$z]["RESTRICT"], 0, 0, $is_fulltext); } $main = str_replace("!!pert_term!!", $members["select"], $main); $main = str_replace("!!where_term!!", $members["where"], $main); } } else { $main = "select notice_id from notices where notice_id=0"; $this->error_message = sprintf($msg["searcher_syntax_error_desc"], $aq->current_car, $aq->input_html, $aq->error_message); } } else { if ($q[$z]["WORD"]) { if ($q[$z]['CLASS'] == "searcher_all_fields") { //Pour savoir si la recherche tous champs inclut les docnum ou pas global $mutli_crit_indexation_docnum_allfields; if ($var_table["is_num"]) { $mutli_crit_indexation_docnum_allfields = 1; } else { $mutli_crit_indexation_docnum_allfields = -1; } } //recherche par terme... if ($q[$z]["FIELDS"]) { $searcher = new $q[$z]['CLASS']($field[$j], $q[$z]["FIELDS"]); } else { $searcher = new $q[$z]['CLASS']($field[$j]); } $main = $searcher->get_full_query(); // print "<br><br>".$main; } else { $main = str_replace("!!p!!", addslashes($field[$j]), $main); } } } } //Y-a-t-il une close repeat ? if ($q[$z]["REPEAT"]) { //Si oui, on repete !! $onvals = $q[$z]["REPEAT"]["ON"]; global ${$onvals}; $onvalst = explode($q[$z]["REPEAT"]["SEPARATOR"], ${$onvals}); $mains = array(); for ($ir = 0; $ir < count($onvalst); $ir++) { $mains[] = str_replace("!!" . $q[$z]["REPEAT"]["NAME"] . "!!", $onvalst[$ir], $main); } $main = implode(" " . $q[$z]["REPEAT"]["OPERATOR"] . " ", $mains); $main = "select * from (" . $main . ") as sbquery" . ($q[$z]["REPEAT"]["ORDERTERM"] ? " order by " . $q[$z]["REPEAT"]["ORDERTERM"] : ""); } if ($z < count($q) - 2) { pmb_mysql_query($main); } } if ($fieldvar["operator_between_multiple_authorities"]) { $operator = $fieldvar["operator_between_multiple_authorities"][0]; } elseif ($q["DEFAULT_OPERATOR"]) { $operator = $q["DEFAULT_OPERATOR"]; } else { $operator = $pmb_multi_search_operator ? $pmb_multi_search_operator : "or"; } if (count($field) > 1) { if ($operator == "or") { //Ou logique si plusieurs valeurs if ($prefixe) { $requete = "create temporary table " . $prefixe . "mf_" . $j . " ENGINE=" . $this->current_engine . " " . $main; @pmb_mysql_query($requete, $dbh); $requete = "alter table " . $prefixe . "mf_" . $j . " add idiot int(1)"; @pmb_mysql_query($requete); $requete = "alter table " . $prefixe . "mf_" . $j . " add unique({$field_keyName})"; @pmb_mysql_query($requete); } else { $requete = "create temporary table mf_" . $j . " ENGINE=" . $this->current_engine . " " . $main; @pmb_mysql_query($requete, $dbh); $requete = "alter table mf_" . $j . " add idiot int(1)"; @pmb_mysql_query($requete); $requete = "alter table mf_" . $j . " add unique({$field_keyName})"; @pmb_mysql_query($requete); } if ($last_main_table) { if ($prefixe) { $requete = "insert ignore into " . $prefixe . "mf_" . $j . " select " . $last_main_table . ".* from " . $last_main_table; } else { $requete = "insert ignore into mf_" . $j . " select " . $last_main_table . ".* from " . $last_main_table; } pmb_mysql_query($requete, $dbh); //pmb_mysql_query("drop table mf_".$j,$dbh); pmb_mysql_query("drop table " . $last_main_table, $dbh); } //else pmb_mysql_query("drop table mf_".$j,$dbh); if ($prefixe) { $last_main_table = $prefixe . "mf_" . $j; } else { $last_main_table = "mf_" . $j; } } elseif ($operator == "and") { //ET logique si plusieurs valeurs if ($prefixe) { $requete = "create temporary table " . $prefixe . "mf_" . $j . " ENGINE=" . $this->current_engine . " " . $main; @pmb_mysql_query($requete, $dbh); $requete = "alter table " . $prefixe . "mf_" . $j . " add idiot int(1)"; @pmb_mysql_query($requete); $requete = "alter table " . $prefixe . "mf_" . $j . " add unique({$field_keyName})"; @pmb_mysql_query($requete); } else { $requete = "create temporary table mf_" . $j . " ENGINE=" . $this->current_engine . " " . $main; @pmb_mysql_query($requete, $dbh); $requete = "alter table mf_" . $j . " add idiot int(1)"; @pmb_mysql_query($requete); $requete = "alter table mf_" . $j . " add unique({$field_keyName})"; @pmb_mysql_query($requete); } if ($last_main_table) { if ($prefixe) { $requete = "create temporary table " . $prefixe . "and_result_" . $j . " ENGINE=" . $this->current_engine . " select " . $last_tables . ".* from " . $last_tables . " where exists ( select " . $prefixe . "mf_" . $j . ".* from " . $prefixe . "mf_" . $j . " where " . $last_tables . ".notice_id=" . $prefixe . "mf_" . $j . ".notice_id)"; } else { $requete = "create temporary table and_result_" . $j . " ENGINE=" . $this->current_engine . " select " . $last_tables . ".* from " . $last_tables . " where exists ( select mf_" . $j . ".* from mf_" . $j . " where " . $last_tables . ".notice_id=mf_" . $j . ".notice_id)"; } pmb_mysql_query($requete, $dbh); pmb_mysql_query("drop table " . $last_tables, $dbh); } if ($prefixe) { $last_tables = $prefixe . "mf_" . $j; } else { $last_tables = "mf_" . $j; } if ($prefixe) { $last_main_table = $prefixe . "and_result_" . $j; } else { $last_main_table = "and_result_" . $j; } } } //else print $main; } if ($last_main_table) { $main = "select * from " . $last_main_table; } } elseif (array_key_exists($s[0], $this->pp)) { $datatype = $this->pp[$s[0]]->t_fields[$s[1]]["DATATYPE"]; $df = $this->dynamicfields[$s[0]]["FIELD"][$this->get_id_from_datatype($datatype, $s[0])]; $q_index = $df["QUERIES_INDEX"]; $q = $df["QUERIES"][$q_index[${$op}]]; //Choix du moteur if ($this->memory_engine_allowed && !$df['MEMORYENGINEFORBIDDEN']) { $this->current_engine = 'MEMORY'; } else { $this->current_engine = 'MyISAM'; } //Pour chaque valeur du champ $last_main_table = ""; if (count($field) == 0) { $field[0] = ""; } for ($j = 0; $j < count($field); $j++) { if ($q["KEEP_EMPTYWORD"]) { $field[$j] = strip_empty_chars($field[$j]); } elseif ($q["REGDIACRIT"]) { $field[$j] = strip_empty_words($field[$j]); } $main = $q["MAIN"]; //Si il y a plusieurs termes possibles if ($q["MULTIPLE_WORDS"]) { $terms = explode(" ", $field[$j]); //Pour chaque terme $multiple_terms = array(); for ($k = 0; $k < count($terms); $k++) { $mt = str_replace("!!p!!", addslashes($terms[$k]), $q["MULTIPLE_TERM"]); $mt = str_replace("!!field!!", $s[1], $mt); $multiple_terms[] = $mt; } $final_term = implode(" " . $q["MULTIPLE_OPERATOR"] . " ", $multiple_terms); $main = str_replace("!!multiple_term!!", $final_term, $main); } else { $main = str_replace("!!p!!", addslashes($field[$j]), $main); } $main = str_replace("!!field!!", $s[1], $main); if ($q["WORD"]) { //recherche par terme... $searcher = new $q['CLASS']($field[$j], $s[1]); $main = $searcher->get_full_query(); } //Choix de l'operateur dans la liste if ($q["DEFAULT_OPERATOR"]) { $operator = $q["DEFAULT_OPERATOR"]; } else { $operator = $pmb_multi_search_operator ? $pmb_multi_search_operator : "or"; } if (count($field) > 1) { if ($operator == "or") { //Ou logique si plusieurs valeurs if ($prefixe) { $requete = "create temporary table " . $prefixe . "mf_" . $j . " ENGINE=" . $this->current_engine . " " . $main; @pmb_mysql_query($requete, $dbh); $requete = "alter table " . $prefixe . "mf_" . $j . " add idiot int(1)"; @pmb_mysql_query($requete); $requete = "alter table " . $prefixe . "mf_" . $j . " add unique({$field_keyName})"; @pmb_mysql_query($requete); } else { $requete = "create temporary table mf_" . $j . " ENGINE=" . $this->current_engine . " " . $main; @pmb_mysql_query($requete, $dbh); $requete = "alter table mf_" . $j . " add idiot int(1)"; @pmb_mysql_query($requete); $requete = "alter table mf_" . $j . " add unique({$field_keyName})"; @pmb_mysql_query($requete); } if ($last_main_table) { if ($prefixe) { $requete = "insert ignore into " . $prefixe . "mf_" . $j . " select " . $last_main_table . ".* from " . $last_main_table; } else { $requete = "insert ignore into mf_" . $j . " select " . $last_main_table . ".* from " . $last_main_table; } pmb_mysql_query($requete, $dbh); //pmb_mysql_query("drop table mf_".$j,$dbh); pmb_mysql_query("drop table " . $last_main_table, $dbh); } //else pmb_mysql_query("drop table mf_".$j,$dbh); if ($prefixe) { $last_main_table = $prefixe . "mf_" . $j; } else { $last_main_table = "mf_" . $j; } } elseif ($operator == "and") { //ET logique si plusieurs valeurs if ($prefixe) { $requete = "create temporary table " . $prefixe . "mf_" . $j . " ENGINE=" . $this->current_engine . " " . $main; @pmb_mysql_query($requete, $dbh); $requete = "alter table " . $prefixe . "mf_" . $j . " add idiot int(1)"; @pmb_mysql_query($requete); $requete = "alter table " . $prefixe . "mf_" . $j . " add unique({$field_keyName})"; @pmb_mysql_query($requete); } else { $requete = "create temporary table mf_" . $j . " ENGINE=" . $this->current_engine . " " . $main; @pmb_mysql_query($requete, $dbh); $requete = "alter table mf_" . $j . " add idiot int(1)"; @pmb_mysql_query($requete); $requete = "alter table mf_" . $j . " add unique({$field_keyName})"; @pmb_mysql_query($requete); } if ($last_main_table) { if ($prefixe) { $requete = "create temporary table " . $prefixe . "and_result_" . $j . " ENGINE=" . $this->current_engine . " select " . $last_tables . ".* from " . $last_tables . " where exists ( select " . $prefixe . "mf_" . $j . ".* from " . $prefixe . "mf_" . $j . " where " . $last_tables . ".notice_id=" . $prefixe . "mf_" . $j . ".notice_id)"; } else { $requete = "create temporary table and_result_" . $j . " ENGINE=" . $this->current_engine . " select " . $last_tables . ".* from " . $last_tables . " where exists ( select mf_" . $j . ".* from mf_" . $j . " where " . $last_tables . ".notice_id=mf_" . $j . ".notice_id)"; } pmb_mysql_query($requete, $dbh); pmb_mysql_query("drop table " . $last_tables, $dbh); } if ($prefixe) { $last_tables = $prefixe . "mf_" . $j; } else { $last_tables = "mf_" . $j; } if ($prefixe) { $last_main_table = $prefixe . "and_result_" . $j; } else { $last_main_table = "and_result_" . $j; } } } //else print $main; } if ($last_main_table) { $main = "select * from " . $last_main_table; } } elseif ($s[0] == "s") { //instancier la classe de traitement du champ special $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]]; 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], $i, $sf, $this); $last_main_table = $specialclass->make_search(); break; } } if ($last_main_table) { $main = "select * from " . $last_main_table; } } elseif ($s[0] == "authperso") { $aq = new analyse_query($field[0], 0, 0, 1, 1, $opac_stemming_active); $members = $aq->get_query_members("authperso_authorities", "authperso_infos_global", "authperso_index_infos_global", "id_authperso_authority"); $clause = "where " . $members["where"] . " and notice_id=notice_authperso_notice_num and notice_authperso_authority_num=id_authperso_authority and authperso_authority_authperso_num=" . $s[1]; $main = "select distinct notice_id FROM notices,notices_authperso,authperso_authorities {$clause} "; if ($last_main_table) { $main = "select * from " . $last_main_table; } } if ($prefixe) { $table = $prefixe . "t_" . $i . "_" . $search[$i]; $requete = "create temporary table " . $prefixe . "t_" . $i . "_" . $search[$i] . " ENGINE=" . $this->current_engine . " " . $main; pmb_mysql_query($requete, $dbh); $requete = "alter table " . $prefixe . "t_" . $i . "_" . $search[$i] . " add idiot int(1)"; @pmb_mysql_query($requete); $requete = "alter table " . $prefixe . "t_" . $i . "_" . $search[$i] . " add unique({$field_keyName})"; pmb_mysql_query($requete); } else { $table = "t_" . $i . "_" . $search[$i]; $requete = "create temporary table t_" . $i . "_" . $search[$i] . " ENGINE=" . $this->current_engine . " " . $main; pmb_mysql_query($requete, $dbh); $requete = "alter table t_" . $i . "_" . $search[$i] . " add idiot int(1)"; @pmb_mysql_query($requete); $requete = "alter table t_" . $i . "_" . $search[$i] . " add unique({$field_keyName})"; pmb_mysql_query($requete); } if ($last_main_table) { $requete = "drop table " . $last_main_table; pmb_mysql_query($requete); } if ($prefixe) { $requete = "create temporary table " . $prefixe . "t" . $i . " ENGINE=" . $this->current_engine . " "; } else { $requete = "create temporary table t" . $i . " ENGINE=" . $this->current_engine . " "; } $isfirst_criteria = false; switch (${$inter}) { case "and": $requete .= "select " . $table . ".* from {$last_table},{$table} where " . $table . ".{$field_keyName}=" . $last_table . ".{$field_keyName} and {$table}.idiot is null and {$last_table}.idiot is null"; @pmb_mysql_query($requete, $dbh); break; case "or": //Si la table précédente est vide, c'est comme au premier jour ! $requete_c = "select count(*) from " . $last_table; if (!@pmb_mysql_result(pmb_mysql_query($requete_c), 0, 0)) { $isfirst_criteria = true; } else { $requete .= "select * from " . $table; @pmb_mysql_query($requete, $dbh); if ($prefixe) { $requete = "alter table " . $prefixe . "t" . $i . " add idiot int(1)"; @pmb_mysql_query($requete); $requete = "alter table " . $prefixe . "t" . $i . " add unique({$field_keyName})"; @pmb_mysql_query($requete); } else { $requete = "alter table t" . $i . " add idiot int(1)"; @pmb_mysql_query($requete); $requete = "alter table t" . $i . " add unique({$field_keyName})"; @pmb_mysql_query($requete); } if ($prefixe) { $requete = "insert into " . $prefixe . "t" . $i . " ({$field_keyName},idiot) select distinct " . $last_table . "." . $field_keyName . "," . $last_table . ".idiot from " . $last_table . " left join " . $table . " on " . $last_table . ".{$field_keyName}=" . $table . ".{$field_keyName} where " . $table . ".{$field_keyName} is null"; } else { $requete = "insert into t" . $i . " ({$field_keyName},idiot) select distinct " . $last_table . "." . $field_keyName . "," . $last_table . ".idiot from " . $last_table . " left join " . $table . " on " . $last_table . ".{$field_keyName}=" . $table . ".{$field_keyName} where " . $table . ".{$field_keyName} is null"; //print $requete; } @pmb_mysql_query($requete, $dbh); } break; case "ex": //$requete_not="create temporary table ".$table."_b select notices.notice_id from notices left join ".$table." on notices.notice_id=".$table.".notice_id where ".$table.".notice_id is null"; //@pmb_mysql_query($requete_not); //$requete_not="alter table ".$table."_b add idiot int(1), add unique(notice_id)"; //@pmb_mysql_query($requete_not); $requete .= "select " . $last_table . ".* from {$last_table} left join " . $table . " on " . $table . ".{$field_keyName}=" . $last_table . ".{$field_keyName} where " . $table . ".{$field_keyName} is null"; @pmb_mysql_query($requete); //$requete="drop table ".$table."_b"; //@pmb_mysql_query($requete); if ($prefixe) { $requete = "alter table " . $prefixe . "t" . $i . " add idiot int(1)"; @pmb_mysql_query($requete); $requete = "alter table " . $prefixe . "t" . $i . " add unique({$field_keyName})"; @pmb_mysql_query($requete); } else { $requete = "alter table t" . $i . " add idiot int(1)"; @pmb_mysql_query($requete); $requete = "alter table t" . $i . " add unique({$field_keyName})"; @pmb_mysql_query($requete); } break; default: $isfirst_criteria = true; @pmb_mysql_query($requete, $dbh); $requete = "alter table {$table} add idiot int(1)"; @pmb_mysql_query($requete); $requete = "alter table {$table} add unique({$field_keyName})"; @pmb_mysql_query($requete); break; } if (!$isfirst_criteria) { pmb_mysql_query("drop table if exists {$last_table}", $dbh); pmb_mysql_query("drop table if exists {$table}", $dbh); if ($prefixe) { $last_table = $prefixe . "t" . $i; } else { $last_table = "t" . $i; } } else { pmb_mysql_query("drop table if exists {$last_table}", $dbh); $last_table = $table; } } return $last_table; }
function show_results($dbh, $user_input, $nbr_lignes = 0, $page = 0, $id = 0) { global $nb_per_page; global $base_url; global $caller; global $msg; global $no_display; global $charset; global $niveau_biblio, $modele_id, $serial_id; global $acces_j; if ($niveau_biblio) { $filtre_notice = " and niveau_biblio='{$niveau_biblio}' "; } // on récupére le nombre de lignes qui vont bien if ($user_input == "") { $requete_count = "SELECT COUNT(1) FROM notices "; $requete_count .= $acces_j; $requete_count .= "where notice_id!='" . $no_display . "' {$filtre_notice} "; } else { $aq = new analyse_query(stripslashes($user_input)); if ($aq->error) { error_message($msg["searcher_syntax_error"], sprintf($msg["searcher_syntax_error_desc"], $aq->current_car, $aq->input_html, $aq->error_message)); exit; } $members = $aq->get_query_members("notices", "index_wew", "index_sew", "notice_id"); $isbn_verif = traite_code_isbn(stripslashes($user_input)); $suite_rqt = ""; if (isISBN($isbn_verif)) { if (strlen($isbn_verif) == 13) { $suite_rqt = " code like '" . formatISBN($isbn_verif, 13) . "' or code like '" . addslashes($isbn_verif) . "' "; } else { $suite_rqt = " code like '" . formatISBN($isbn_verif, 10) . "' or code like '" . addslashes($isbn_verif) . "' "; } $requete_count = "select count(1) from notices "; $requete_count .= $acces_j; $requete_count .= "where ( " . $suite_rqt . " ) "; $requete_count .= "and notice_id!='" . $no_display . "' {$filtre_notice}"; } else { $requete_count = "select count(1) from notices "; $requete_count .= $acces_j; $requete_count .= "where (" . $members["where"] . " or code like '" . addslashes($isbn_verif) . "' ) "; $requete_count .= "and notice_id!='" . $no_display . "' {$filtre_notice}"; } } $res = mysql_query($requete_count, $dbh); $nbr_lignes = @mysql_result($res, 0, 0); if (!$page) { $page = 1; } $debut = ($page - 1) * $nb_per_page; if ($nbr_lignes) { // on lance la vraie requête if ($user_input == "") { $requete = "SELECT notice_id, tit1, serie_name, tnvol, code FROM notices "; $requete .= $acces_j; $requete .= "left join series on serie_id=tparent_id "; $requete .= "where notice_id!='" . $no_display . "' {$filtre_notice} ORDER BY index_sew, code LIMIT {$debut},{$nb_per_page} "; } else { $isbn_verif = traite_code_isbn(stripslashes($user_input)); $suite_rqt = ""; if (isISBN($isbn_verif)) { if (strlen($isbn_verif) == 13) { $suite_rqt = " code like '" . formatISBN($isbn_verif, 13) . "' or code like '" . addslashes($isbn_verif) . "' "; } else { $suite_rqt = " code like '" . formatISBN($isbn_verif, 10) . "' or code like '" . addslashes($isbn_verif) . "' "; } $requete = "select notice_id, tit1, serie_name, tnvol, code from notices "; $requete .= $acces_j; $requete .= "left join series on serie_id=tparent_id "; $requete .= "where ( " . $suite_rqt . " ) "; $requete .= "and notice_id!='" . $no_display . "' {$filtre_notice} group by notice_id limit {$debut},{$nb_per_page}"; } else { $requete = "select notice_id, tit1, serie_name, tnvol, code, " . $members["select"] . " as pert from notices "; $requete .= $acces_j; $requete .= "left join series on serie_id=tparent_id where (" . $members["where"] . " or (code like '" . addslashes($isbn_verif) . "' )) "; $requete .= "and notice_id!='" . $no_display . "' {$filtre_notice} group by notice_id order by pert desc, index_sew, code limit {$debut},{$nb_per_page}"; } } $res = @mysql_query($requete, $dbh); while ($notice = mysql_fetch_object($res)) { $notice_entry = ""; if ($notice->serie_name) { $notice_entry .= $notice->serie_name; if ($notice->tnvol) { $notice_entry .= ", " . $notice->tnvol; } } $notice_entry ? $notice_entry .= '. ' . $notice->tit1 : ($notice_entry = $notice->tit1); if ($niveau_biblio) { $location = "./catalog.php?categ=serials&sub=modele&act=copy&modele_id={$modele_id}&serial_id={$serial_id}&new_serial_id={$notice->notice_id}"; $display = new mono_display($notice->notice_id, 0, '', 0, '', '', '', 0, 0, 0, 0, "", 0, false, true); print pmb_bidi("<div class='row'>\n\t\t\t\t\t\t\t\t<div class='left'>\n\t\t\t\t\t\t\t\t\t<a href='#' onclick=\"copier_modele('{$location}')\">" . $display->result . "</a>\n\t\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t\t<div class='right'>\n\t\t\t\t\t\t\t\t\t" . htmlentities($notice->code, ENT_QUOTES, $charset) . "\n\t\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t\t</div>"); } else { $display = new mono_display($notice->notice_id, 0, '', 0, '', '', '', 0, 0, 0, 0, "", 0, false, true); print pmb_bidi("<div class='row'>\n\t\t\t\t\t\t\t\t<div class='left'>\n\t\t\t\t\t\t\t\t\t<a href='#' onclick=\"set_parent('{$caller}', '{$notice->notice_id}', '" . htmlentities(addslashes($notice_entry), ENT_QUOTES, $charset) . " ({$notice->code})')\">" . $display->result . "</a>\n\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t\t<div class='right'>\n\t\t\t\t\t\t\t\t\t" . htmlentities($notice->code, ENT_QUOTES, $charset) . "\n\t\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t\t</div>"); } } mysql_free_result($res); // constitution des liens $nbepages = ceil($nbr_lignes / $nb_per_page); $suivante = $page + 1; $precedente = $page - 1; } print "<div class='row'> <hr /></div><div align='center'>"; $url_base = $base_url . "&user_input=" . rawurlencode(stripslashes($user_input)); $nav_bar = aff_pagination($url_base, $nbr_lignes, $nb_per_page, $page, 10, false, true); print $nav_bar; print "</div>"; }
function search_authperso($user_query) { global $opac_search_other_function, $typdoc, $charset, $dbh; global $opac_stemming_active; $total_results = 0; foreach ($this->info as $authperso) { if (!$authperso['opac_search']) { continue; } $look_name = "look_AUTHPERSO_" . $authperso['id'] . "#"; global ${$look_name}; $look = ${$look_name}; if (!$look) { continue; } $clause = ''; $add_notice = ''; $aq = new analyse_query(stripslashes($user_query), 0, 0, 1, 1, $opac_stemming_active); $members = $aq->get_query_members("authperso_authorities", "authperso_infos_global", "authperso_index_infos_global", "id_authperso_authority"); $clause .= "where " . $members["where"] . " and authperso_authority_authperso_num=" . $authperso['id']; if ($opac_search_other_function) { $add_notice = search_other_function_clause(); } if ($typdoc || $add_notice) { $clause = ', notices, notices_authperso ' . $clause; } if ($typdoc) { $clause .= " and notice_authperso_notice_num=notice_id and typdoc='" . $typdoc . "' "; } if ($add_notice) { $clause .= ' and notice_id in (' . $add_notice . ')'; } $tri = 'order by pert desc, authperso_index_infos_global'; $pert = $members["select"] . " as pert"; $auth_res = pmb_mysql_query("SELECT COUNT(distinct id_authperso_authority) FROM authperso_authorities {$clause}", $dbh); $nb_result = pmb_mysql_result($auth_res, 0, 0); if ($nb_result) { $total_results += $nb_result; //définition du formulaire $form = "<div style=search_result><form name=\"search_authperso_" . $authperso['id'] . "\" action=\"./index.php?lvl=more_results\" method=\"post\">"; $form .= "<input type=\"hidden\" name=\"user_query\" value=\"" . htmlentities(stripslashes($user_query), ENT_QUOTES, $charset) . "\">\n"; if (function_exists("search_other_function_post_values")) { $form .= search_other_function_post_values(); } $form .= "<input type=\"hidden\" name=\"mode\" value=\"authperso_" . $authperso['id'] . "\">\n"; $form .= "<input type=\"hidden\" name=\"search_type_asked\" value=\"simple_search\">\n"; $form .= "<input type=\"hidden\" name=\"count\" value=\"" . $nb_result . "\">\n"; $form .= "<input type=\"hidden\" name=\"name\" value=\"" . $authperso["name"] . "\">\n"; $form .= "<input type=\"hidden\" name=\"clause\" value=\"" . htmlentities($clause, ENT_QUOTES, $charset) . "\">"; $form .= "<input type=\"hidden\" name=\"pert\" value=\"" . htmlentities($pert, ENT_QUOTES, $charset) . "\">\n"; $form .= "<input type=\"hidden\" name=\"tri\" value=\"" . htmlentities($tri, ENT_QUOTES, $charset) . "\"></form>\n"; $form .= "</div>"; $_SESSION["level1"]["authperso_" . $authperso['id']]["form"] = $form; $_SESSION["level1"]["authperso_" . $authperso['id']]["count"] = $nb_result; $_SESSION["level1"]["authperso_" . $authperso['id']]["name"] = $authperso["name"]; } } return $total_results; }
/** * @abstract * Retourne une liste d'objets sous forme de tableau selon le type demandé * et la recherche effectuée * * @param array $params * array $params['objects'] : tableau de types d'objet * string $params['user_input'] : chaine recherchée * * @return array * [index] => [subject_uri] => uri de l'objet * * */ public function search_objects($params = array()) { global $msg; $this->params = $params; $result = array(); if (!$params['objects'] || !is_array($params['objects']) || !count($params['objects'])) { return $result; } else { //On ne garde dans le tableau que les objects possibles $object_final = array(); foreach ($params['objects'] as $value) { if (array_key_exists($value, $this->op->t_objects)) { $object_final[] = $value; } } $params['objects'] = $object_final; } if (!$params['user_input']) { return $msg["ontology_selector_do_search"]; } //On prepare la requete $aq = new analyse_query(stripslashes($params['user_input'])); if ($aq->error) { return return_error_message($msg["searcher_syntax_error"], sprintf($msg["searcher_syntax_error_desc"], $aq->current_car, $aq->input_html, $aq->error_message)); } $members = $aq->get_query_members("rdfstore_index", "object_val", "object_index", "subject_uri"); // On restreint la recheche aux objets demandés et aux labels définit pour les recherches dans skos_pmb.rdf $restrict = array(); foreach ($params['objects'] as $key => $value) { $restrict[$key] = "( subject_type='" . addslashes($this->op->from_ns($value)) . "' "; $search_label = array(); $search_label = $this->op->get_pmb_search_label($value); if ($search_label && is_array($search_label) && count($search_label)) { $restrict[$key] .= " AND ("; $tmp = ""; foreach ($search_label as $value2) { if ($tmp) { $tmp .= " OR "; } $tmp .= "predicat_uri='" . addslashes($this->op->from_ns($value2)) . "'"; } $restrict[$key] .= $tmp . ")"; } $restrict[$key] .= ")"; } $restrict_f = ""; if (count($restrict)) { $restrict_f = "(" . implode(" OR ", $restrict) . ")"; } $requete = "select *," . $members["select"] . " as pert from rdfstore_index where " . $members["where"] . ($restrict_f ? " AND " . $restrict_f : "") . " " . $members["post"]; $res = mysql_query($requete); if ($res && mysql_num_rows($res)) { while ($ligne = mysql_fetch_object($res)) { $result[] = array("subject_uri" => $ligne->subject_uri, "subject_type" => $this->op->to_ns($ligne->subject_type)); } } else { return $msg["ontology_selector_not_result"]; } return $result; }