Example #1
0
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 . "&nbsp;" . $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'>&nbsp;<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 pubmed_analyse_query($input, $debut = 0, $parenthesis = 0, $search_linked_words = 1, $keep_empty = 0, $field, $pubmed_stopwords)
 {
     $this->pubmed_stopwords = $pubmed_stopwords;
     $this->field = $field;
     $this->operator = strtoupper($this->operator);
     parent::analyse_query($input, 0, 0, 1, 0);
 }
Example #3
0
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 $msg;
    global $charset;
    global $no_display;
    // on récupére le nombre de lignes qui vont bien
    if (!$id) {
        if ($user_input == "") {
            $requete = "SELECT COUNT(1) FROM publishers where ed_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("publishers", "ed_name", "index_publisher", "ed_id", "ed_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 construit la vraie requête
        if (!$id) {
            if ($user_input == "") {
                $requete = "SELECT * FROM publishers where ed_id!='{$no_display}' ORDER BY index_publisher LIMIT {$debut},{$nb_per_page} ";
            } else {
                $members = $aq->get_query_members("publishers", "ed_name", "index_publisher", "ed_id");
                $requete = "select *," . $members["select"] . " as pert from publishers where " . $members["where"] . " and ed_id!='{$no_display}' group by ed_id order by pert desc,index_publisher limit {$debut},{$nb_per_page}";
            }
        } else {
            $requete = "select * from publishers where ed_id='" . $id . "'";
        }
        $res = @mysql_query($requete, $dbh);
        while ($ed = mysql_fetch_object($res)) {
            $editeur = new editeur($ed->ed_id);
            print pmb_bidi("\n \t\t\t\t<a href='#' onclick=\"set_parent('{$caller}', '{$ed->ed_id}', '" . htmlentities(addslashes($editeur->display), ENT_QUOTES, $charset) . "','{$callback}')\">" . htmlentities($editeur->display, ENT_QUOTES, $charset) . "</a><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'>&nbsp;<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>";
    }
}
Example #4
0
 protected function fetch_datas()
 {
     global $dbh;
     $query = "select id_faq_question from faq_questions !!join!!!!where!! order by faq_question_question_date desc, faq_question_answer_date desc";
     $join = $where = array();
     $where[] = $_SESSION["id_empr_session"] ? "faq_question_statut in (2,3)" : "faq_question_statut = 2";
     if (count($this->themes)) {
         $where[] = "faq_question_num_theme in (" . implode(",", $this->themes) . ")";
     }
     if (count($this->types)) {
         $where[] = "faq_question_num_type in (" . implode(",", $this->types) . ")";
     }
     if (count($this->descriptors)) {
         $join[] = "join faq_questions_categories on id_faq_question=num_faq_question ";
         $where[] = "num_categ in (" . implode(",", $this->descriptors) . ")";
     }
     if (count($this->years)) {
         $where[] = "year(faq_question_answer_date) in (" . implode(",", $this->years) . ")";
     }
     $query = str_replace("!!join!!", implode(" ", $join), $query);
     if (count($where)) {
         $where = implode(" and ", $where);
         $query = str_replace("!!where!!", "where " . $where, $query);
     } else {
         $query = str_replace("!!where!!", "", $query);
     }
     $result = pmb_mysql_query($query);
     if (pmb_mysql_num_rows($result)) {
         $this->questions_ids = array();
         while ($row = pmb_mysql_fetch_object($result)) {
             $this->questions_ids[] = $row->id_faq_question;
         }
     }
     if ($this->user_query) {
         $aq = new analyse_query($this->user_query);
         $query = $aq->get_query_mot("id_faq_question", "faq_questions_words_global_index", "word", "faq_questions_fields_global_index", "value");
         $query .= " where id_faq_question in(" . implode(",", $this->questions_ids) . ")";
         $this->questions_ids = array();
         $result = pmb_mysql_query($query);
         if (pmb_mysql_num_rows($result)) {
             while ($row = pmb_mysql_fetch_object($result)) {
                 $this->questions_ids[] = $row->id_faq_question;
             }
         }
     }
 }
Example #5
0
// +-------------------------------------------------+
// $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';
Example #6
0
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 = ".&nbsp;-&nbsp;<i>{$msg['210']}</i>&nbsp;:&nbsp;" . $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'>&nbsp;<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"];
    }
}
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 $charset;
    global $callback;
    // on récupére le nombre de lignes qui vont bien
    if (!$id) {
        if ($user_input == "") {
            $requete = "SELECT COUNT(1) FROM sub_collections where sub_coll_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("sub_collections", "sub_coll_name", "index_sub_coll", "sub_coll_id", "sub_coll_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 A.*,B.*,C.* FROM sub_collections A, collections B, publishers C";
                $requete .= " WHERE sub_coll_id!='{$no_display}' and A.sub_coll_parent=B.collection_id";
                $requete .= " AND B.collection_parent=C.ed_id";
                $requete .= " ORDER BY A.sub_coll_name LIMIT {$debut},{$nb_per_page} ";
            } else {
                $members = $aq->get_query_members("sub_collections", "sub_coll_name", "index_sub_coll", "sub_coll_id");
                $requete = "select sub_collections.*,collections.*,publishers.*, " . $members["select"] . " as pert from sub_collections, collections, publishers ";
                $requete .= "where " . $members["where"] . " and sub_coll_id!='{$no_display}' and sub_coll_parent=collection_id and collection_parent=ed_id group by sub_coll_id order by pert desc,index_sub_coll, index_coll, index_publisher limit {$debut},{$nb_per_page}";
            }
        } else {
            $requete = "select sub_collections.*,collections.*,publishers.* from sub_collections,collections,publishers where sub_coll_id='" . $id . "' and sub_coll_parent=collection_id and collection_parent=ed_id group by sub_coll_id";
        }
        $res = @pmb_mysql_query($requete, $dbh);
        while ($col = pmb_mysql_fetch_object($res)) {
            $idsubcoll = $col->sub_coll_id;
            $libellesubcoll = htmlentities(addslashes($col->sub_coll_name), ENT_QUOTES, $charset);
            $idparentcoll = $col->sub_coll_parent;
            $idparentlibelle = htmlentities(addslashes($col->collection_name), ENT_QUOTES, $charset);
            $idediteur = $col->ed_id;
            $libelleediteur = htmlentities(addslashes($col->ed_name), ENT_QUOTES, $charset);
            print pmb_bidi("\n\t\t\t<a href='#' onclick=\"set_parent('{$caller}', {$idsubcoll}, '" . $libellesubcoll . "', {$idparentcoll}, '" . $idparentlibelle . "', {$idediteur}, '" . $libelleediteur . "','{$callback}')\">\n\t\t\t\t{$col->sub_coll_name}</a>");
            print pmb_bidi("&nbsp;({$col->collection_name}.&nbsp;{$col->ed_name})<br />");
        }
        pmb_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'>&nbsp;<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>";
    }
}
Example #8
0
 function filterSearch($start, $datas)
 {
     global $dbh;
     //Liste des identifiants de périodiques disponibles
     $listeId = array();
     if (count($this->titles)) {
         foreach ($this->titles as $title) {
             $listeId[] = $title["id"];
         }
     }
     //commence par
     $this->start = $start;
     $titles = array_filter($this->titles, array($this, startwith));
     //on complète
     if (count($titles) < 20) {
         $aq = new analyse_query(stripslashes($datas . "*"));
         $query = $aq->get_query("notices", "index_sew", "index_sew", "notice_id", "niveau_biblio='s' AND niveau_hierar='1' AND notice_id IN (" . implode(",", $listeId) . ")");
         $result = pmb_mysql_query($query, $dbh);
         if ($result) {
             while ($row = pmb_mysql_fetch_object($result)) {
                 foreach ($this->titles as $title) {
                     if ($title["id"] == $row->notice_id) {
                         if (!in_array($title, $titles)) {
                             $titles[] = $title;
                         }
                         continue;
                     }
                 }
             }
         }
     }
     return $titles;
 }
 /**
  *
  *
  * @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;
 }
Example #10
0
    categ_browser::search_form();
    print pmb_bidi($categ_list_tmpl);
}
if (!$page) {
    $page = 1;
}
$debut = ($page - 1) * $nb_per_page;
if (!$nbr_lignes) {
    $requete = "SELECT SQL_CALC_FOUND_ROWS noeuds.id_noeud AS categ_id, ";
} else {
    $requete = "SELECT noeuds.id_noeud AS categ_id, ";
}
$requete .= "noeuds.num_renvoi_voir AS categ_see, ";
$requete .= "noeuds.num_thesaurus, ";
if ($user_input) {
    $aq = new analyse_query(stripslashes($user_input));
    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) {
Example #11
0
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>';
    }
}
<?php

// +-------------------------------------------------+
// © 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';
Example #13
0
 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;
 }
 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;
 }
Example #15
0
        if ($last_param) {
            $requete = "SELECT count(1) FROM series " . $tri_param . " " . $limit_param;
        }
    } else {
        $aq = new analyse_query(stripslashes($user_input));
        if ($aq->error) {
            serie::search_form();
            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("series", "serie_name", "serie_index", "serie_id");
    }
    $res = pmb_mysql_query($requete, $dbh);
    $nbr_lignes = pmb_mysql_result($res, 0, 0);
} else {
    $aq = new analyse_query(stripslashes($user_input));
}
if (!$page) {
    $page = 1;
}
$debut = ($page - 1) * $nb_per_page;
if ($nbr_lignes) {
    $serie_list_tmpl = str_replace("<! --!!nb_autorite_found!!-- >", $nbr_lignes . ' ', $serie_list_tmpl);
    $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;
    }
Example #16
0
// $Id: indexint.inc.php,v 1.30 2015-04-03 11:16:22 jpermanne Exp $
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';
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'>&nbsp;<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;
         }
     }
 }
Example #19
0
        if ($last_param) {
            $requete = "SELECT count(1) FROM collections " . $tri_param . " " . $limit_param;
        }
    } else {
        $aq = new analyse_query(stripslashes($user_input));
        if ($aq->error) {
            collection::search_form();
            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");
    }
    $res = pmb_mysql_query($requete, $dbh);
    $nbr_lignes = pmb_mysql_result($res, 0, 0);
} else {
    $aq = new analyse_query(stripslashes($user_input));
}
if (!$page) {
    $page = 1;
}
$debut = ($page - 1) * $nb_per_page;
if ($nbr_lignes) {
    $collection_list_tmpl = str_replace("<! --!!nb_autorite_found!!-- >", $nbr_lignes . ' ', $collection_list_tmpl);
    $collection_list .= "<tr>\n\t\t<th>" . $msg[103] . "</th>\n\t\t<th>" . $msg[165] . "</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='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;
    }
        if ($last_param) {
            $requete = "SELECT count(1) FROM titres_uniformes " . $tri_param . " " . $limit_param;
        }
    } else {
        $aq = new analyse_query(stripslashes($user_input), 0, 0, 1, 1);
        if ($aq->error) {
            titre_uniforme::search_form();
            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");
    }
    $res = mysql_query($requete, $dbh);
    $nbr_lignes = mysql_result($res, 0, 0);
} else {
    $aq = new analyse_query(stripslashes($user_input), 0, 0, 1, 1);
}
if (!$page) {
    $page = 1;
}
$debut = ($page - 1) * $nb_per_page;
if ($nbr_lignes) {
    $titres_uniformes_list_tmpl = str_replace("<! --!!nb_autorite_found!!-- >", $nbr_lignes . ' ', $titres_uniformes_list_tmpl);
    $url_base = "./autorites.php?categ=titres_uniformes&sub=reach&user_input=" . rawurlencode(stripslashes($user_input));
    $titre_uniforme_list = "<tr>\n\t\t\t<th>" . $msg[103] . "</th>\n\t\t\t<!--!!col_num_autorite!!-->\n\t\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='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;
Example #21
0
// 2- la recherche affiliée est active et on demande l'onglet catalog...
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) {
Example #22
0
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'>&nbsp;<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>";
}
Example #23
0
 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;
     }
 }
Example #24
0
 /** 
  * @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;
 }
Example #25
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;
 }
Example #26
0
if ($typdoc) {
    $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);
if (!$user_query) {
    $user_query = "*";
}
$serial_edit_access = str_replace('!!message!!', $msg[1914], $serial_edit_access);
$serial_edit_access = str_replace('!!etat!!', collect, $serial_edit_access);
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) {
Example #28
0
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>';
}
Example #29
0
 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;
 }
Example #30
0
<?php

// +-------------------------------------------------+
// © 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';