$hash, "location" => $location, "hash_location" => $hash_location); return $tmp; } function getimage_url($code = "", $vigurl = "", $empr_pic = 0) { global $opac_url_base, $opac_book_pics_url, $pmb_book_pics_url, $pmb_opac_url, $pmb_url_base, $prefix_url_image; global $pmb_img_cache_folder, $pmb_img_cache_url, $opac_img_cache_folder, $opac_img_cache_url; $url_return = $notice_id = $etagere_id = $authority_id = $noticecode = $url_image = "" ; if($empr_pic){ $code = pmb_preg_replace('/ /', '', $code); $vigurl = str_replace("!!num_carte!!", $code, $vigurl) ; $url_image = ""; $code = ""; } if(isset($prefix_url_image) && $prefix_url_image && ($prefix_url_image != $pmb_opac_url) && ($prefix_url_image != $opac_url_base)){ $url_image = $pmb_book_pics_url; $prefix = $prefix_url_image; $img_cache_folder = $pmb_img_cache_folder; $img_cache_url = $pmb_img_cache_url; $cached_in_opac = 0; }else{ $url_image = $opac_book_pics_url; $prefix = $opac_url_base; $img_cache_folder = $opac_img_cache_folder; $img_cache_url = $opac_img_cache_url; $cached_in_opac = 1; } if($code){ $noticecode = pmb_preg_replace('/-|\.| /', '', $code); }else{ $noticecode = ""; } $for_cut=""; $out = array(); if (($vigurl) && (preg_match('#^(.+)?getimage\.php(.+)?$#',$vigurl,$out))) { if(isset($out[1]) && trim($out[1])){ $contruct_url = trim($out[1]); if(($contruct_url == "./") || ($contruct_url == $opac_url_base) || ($contruct_url == $pmb_opac_url) || ($contruct_url == $pmb_url_base)){ //Je peux tenter de trouve une URL statique if(isset($out[2])){ $for_cut = trim($out[2]); } }/*else{ //Impossible on vient d'un autre PMB, on prend l'URL telque }*/ }elseif(isset($out[1]) && !trim($out[1])){//L'url de la vignette de la notice commence par getimage sans rien devant //Je peux tenter de trouve une URL statique if(isset($out[2])){ $for_cut = trim($out[2]); } } if($for_cut){ $out2=array(); if(preg_match("#(notice_id|etagere_id|authority_id)=([0-9]+)#",$for_cut,$out2)){ switch ($out2[1]) { case "notice_id": $notice_id = $out2[2]; $url_return = $prefix."getimage.php?notice_id=".$notice_id; break; case "etagere_id": $etagere_id = $out2[2]; $url_return = $prefix."getimage.php?etagere_id=".$etagere_id; break; case "authority_id": $authority_id = $out2[2]; $url_return = $prefix."getimage.php?authority_id=".$authority_id; break; } } } } if((strpos($vigurl,'data:image',0) === 0) || (strpos($vigurl,"vig_num.php") !== FALSE ) || (strpos($vigurl,"vign_middle.php") !== FALSE )){ $url_return = $vigurl; }elseif($img_cache_url && $img_cache_folder){ $manag_cache=getimage_cache($notice_id, $etagere_id, $authority_id, $vigurl, $noticecode, $url_image, $empr_pic, $cached_in_opac); $out=array(); if($manag_cache["location"] && preg_match("#^".$img_cache_folder."(.+)$#",$manag_cache["location"],$out)){ $url_return = $img_cache_url.$out[1]; } } if(!$url_return){ $url_return = $prefix."getimage.php?url_image=".urlencode($url_image)."&noticecode=!!noticecode!!&vigurl=".urlencode($vigurl) ; if(isset($empr_pic) && $empr_pic){ $url_return .="&empr_pic=1"; } $url_return = str_replace("!!noticecode!!", $noticecode, $url_return) ; } return $url_return; } //Fonction de récupération d'une URL vignette function get_vignette($notice_id) { global $opac_book_pics_url, $opac_show_book_pics; global $opac_url_base; $requete="select code,thumbnail_url from notices where notice_id=$notice_id"; $res=pmb_mysql_query($requete); $url_image_ok=$opac_url_base."images/vide.png"; if ($res) { $notice=pmb_mysql_fetch_object($res); if ($notice->code || $notice->thumbnail_url) { if ($opac_show_book_pics && ($opac_book_pics_url || $notice->thumbnail_url)) { $url_image_ok = getimage_url($notice->code, $notice->thumbnail_url); } } } return $url_image_ok; } // ---------------------------------------------------------------------------- // fonctions de formatage de chaine // ---------------------------------------------------------------------------- // reg_diacrit : fonction pour traiter les caracteres accentues en recherche avec regex // choix de la classe à utiliser pour envoi en pdf if (!isset($fpdf)) { if ($charset != 'utf-8') $fpdf = 'FPDF'; else $fpdf = 'UFPDF'; } function reg_diacrit($chaine) { $chaine = convert_diacrit($chaine); $tab = pmb_split('/\s/', $chaine); // mise en forme de la chaine pour les alternatives // on fonctionne avec OU (pour l'instant) if(sizeof($tab) > 1) { foreach($tab as $dummykey=>$word) { if($word) $this->mots[] = "($word)"; } return join('|', $this->mots); } else { return $chaine; } } function convert_diacrit($string) { global $tdiac; global $charset; global $include_path; global $tdiac_diacritique, $tdiac_replace; if(!$string) return; if (!$tdiac) { $tdiac = new XMLlist($include_path."/messages/diacritique".$charset.".xml"); $tdiac->analyser(); $tdiac_diacritique = array(); $tdiac_replace = array(); foreach($tdiac->table as $wreplace => $wdiacritique) { $wdiacritique = str_replace(array('(', ')'), "", $wdiacritique); foreach (explode('|', $wdiacritique) as $wdiac) { $tdiac_diacritique[] = $wdiac; $tdiac_replace[] = $wreplace; } } } $string = str_replace($tdiac_diacritique,$tdiac_replace,$string); return $string; } //strip_empty_chars : enleve tout ce qui n'est pas alphabetique ou numerique d'une chaine function strip_empty_chars($string) { // traitement des diacritiques $string = convert_diacrit($string); // Mis en commentaire : qu'en est-il des caracteres non latins ??? // SUPPRIME DU COMMENTAIRE : ER : 12/05/2004 : ça fait tout merder... // RECH_14 : Attention : ici suppression des eventuels " // les " ne sont plus supprimes $string = stripslashes($string) ; $string = pmb_alphabetic('^a-z0-9\s', ' ',pmb_strtolower($string)); // remplacement espace insécable 0xA0:   Non-breaking space $string = clean_nbsp($string); $string = pmb_preg_replace_spaces($string); return $string; } // strip_empty_words : fonction enlevant les mots vides d'une chaine function strip_empty_words($string, $lg = 0) { // on inclut le tableau des mots-vides pour la langue par defaut si elle n'est pas precisee // c'est normalement la langue de catalogage... // sinon on inclut le tableau des mots vides pour la langue precisee // si apres nettoyage des mots vide la chaine est vide alors on garde la chaine telle quelle (sans les accents) global $pmb_indexation_lang; // global $lang; global $include_path; if (!$lg || $lg == $pmb_indexation_lang) { global $empty_word; } else { include("$include_path/marc_tables/$lg/empty_words"); } //echo "
";
	//print_r($empty_word);
	//echo "
"; // nettoyage de l'entree // traitement des diacritiques $string = convert_diacrit($string); // Mis en commentaire : qu'en est-il des caracteres non latins ??? // SUPPRIME DU COMMENTAIRE : ER : 12/05/2004 : ça fait tout merder... // RECH_14 : Attention : ici suppression des eventuels " // les " ne sont plus supprimes $string = stripslashes($string) ; $string = pmb_alphabetic('^a-z0-9\s', ' ',pmb_strtolower($string)); // remplacement espace insécable 0xA0:   Non-breaking space $string = clean_nbsp($string); $string = pmb_preg_replace_spaces($string); $string_avant_mots_vides = $string ; // suppression des mots vides if(is_array($empty_word)) { global $empty_word_converted; if(!isset($empty_word_converted)) { $empty_word_converted = array(); foreach($empty_word as $dummykey=>$word) { $empty_word_converted[$dummykey] = convert_diacrit($word); } } foreach($empty_word_converted as $dummykey=>$word) { $string = pmb_preg_replace("/^${word}$|^${word}\s|\s${word}\s|\s${word}\$/i", ' ', $string); // RECH_14 : suppression des mots vides colles à des guillemets if (pmb_preg_match("/\"${word}\s/i",$string)) $string = pmb_preg_replace("/\"${word}\s/i", '"', $string); if (pmb_preg_match("/\s${word}\"/i",$string)) $string = pmb_preg_replace("/\s${word}\"/i", '"', $string); } } // re nettoyage des espaces generes $string = pmb_preg_replace_spaces($string); if (!$string) { $string = $string_avant_mots_vides ; // re nettoyage des espaces generes $string = pmb_preg_replace_spaces($string); } return $string; } // clean_string() : fonction de nettoyage d'une chaÓne function clean_string($string) { global $clean_string_matches; global $clean_string_replaces; // on supprime les caractËres non-imprimables $string = pmb_preg_replace("/\\x0|[\x01-\x1f]/U","",$string); // suppression des caractËres de ponctuation indesirables // $string = pmb_preg_replace('/[\{\}\"]/', '', $string); if(!isset($clean_string_matches) || !isset($clean_string_replaces)) { $clean_string_matches = array(); $clean_string_replaces = array(); // supression du point et des espaces de fin $clean_string_matches[] = '/\s+\.$|\s+$/'; $clean_string_replaces[] = ''; // nettoyage des espaces autour des parenthËses $clean_string_matches[] = '/\(\s+/'; $clean_string_replaces[] = '('; $clean_string_matches[] = '/\s+\)/'; $clean_string_replaces[] = ')'; // idem pour les crochets $clean_string_matches[] = '/\[\s+/'; $clean_string_replaces[] = '['; $clean_string_matches[] = '/\s+\]/'; $clean_string_replaces[] = ']'; // petit point de detail sur les apostrophes //$string = pmb_preg_replace('/\'\s+/', "'", $string); // 'trim' par regex $clean_string_matches[] = '/^\s+|\s+$/'; $clean_string_replaces[] = ''; // suppression des espaces doubles $clean_string_matches[] = '/\s+/'; $clean_string_replaces[] = ' '; } $string = preg_replace($clean_string_matches, $clean_string_replaces, $string); return $string; } //Corrections des caractères bizarres (voir pourris) de M$ function cp1252Toiso88591($str){ $cp1252_map = array( "\x80" => "EUR", /* EURO SIGN */ "\x82" => "\xab", /* SINGLE LOW-9 QUOTATION MARK */ "\x83" => "\x66", /* LATIN SMALL LETTER F WITH HOOK */ "\x84" => "\xab", /* DOUBLE LOW-9 QUOTATION MARK */ "\x85" => "...", /* HORIZONTAL ELLIPSIS */ "\x86" => "?", /* DAGGER */ "\x87" => "?", /* DOUBLE DAGGER */ "\x88" => "?", /* MODIFIER LETTER CIRCUMFLEX ACCENT */ "\x89" => "?", /* PER MILLE SIGN */ "\x8a" => "S", /* LATIN CAPITAL LETTER S WITH CARON */ "\x8b" => "\x3c", /* SINGLE LEFT-POINTING ANGLE QUOTATION */ "\x8c" => "OE", /* LATIN CAPITAL LIGATURE OE */ "\x8e" => "Z", /* LATIN CAPITAL LETTER Z WITH CARON */ "\x91" => "\x27", /* LEFT SINGLE QUOTATION MARK */ "\x92" => "\x27", /* RIGHT SINGLE QUOTATION MARK */ "\x93" => "\x22", /* LEFT DOUBLE QUOTATION MARK */ "\x94" => "\x22", /* RIGHT DOUBLE QUOTATION MARK */ "\x95" => "\b7", /* BULLET */ "\x96" => "\x20", /* EN DASH */ "\x97" => "\x20\x20", /* EM DASH */ "\x98" => "\x7e", /* SMALL TILDE */ "\x99" => "?", /* TRADE MARK SIGN */ "\x9a" => "S", /* LATIN SMALL LETTER S WITH CARON */ "\x9b" => "\x3e;", /* SINGLE RIGHT-POINTING ANGLE QUOTATION*/ "\x9c" => "oe", /* LATIN SMALL LIGATURE OE */ "\x9e" => "Z", /* LATIN SMALL LETTER Z WITH CARON */ "\x9f" => "Y" /* LATIN CAPITAL LETTER Y WITH DIAERESIS*/ ); $str = strtr($str, $cp1252_map); return $str; } // ---------------------------------------------------------------------------- // fonctions sur les dates // ---------------------------------------------------------------------------- // today() : retourne la date du jour au format MySQL-DATE function today() { $jour = date('Y-m-d'); return $jour; } // formatdate() : retourne une date formatee comme il faut function formatdate($date_a_convertir, $with_hour=0) { global $msg; global $dbh; if ($with_hour) $resultatdate=pmb_mysql_query("select date_format('".$date_a_convertir."', '".$msg["format_date_heure"]."') as date_conv "); else $resultatdate=pmb_mysql_query("select date_format('".$date_a_convertir."', '".$msg["format_date"]."') as date_conv "); $date_conv=pmb_mysql_result($resultatdate,0,0); return $date_conv ; } // formatdate_input() : retourne une date formatee comme il faut function formatdate_input($date_a_convertir, $with_hour=0) { global $msg; global $dbh; if ($with_hour) $resultatdate=pmb_mysql_query("select date_format('".$date_a_convertir."', '".$msg["format_date_heure"]."') as date_conv "); else $resultatdate=pmb_mysql_query("select date_format('".$date_a_convertir."', '".$msg["format_date_input_model"]."') as date_conv "); $date_conv=pmb_mysql_result($resultatdate,0,0); return $date_conv ; } // extraitdate() : retourne une date formatee comme il faut function extraitdate($date_a_convertir) { global $msg; $format_local = str_replace ("%","",$msg["format_date_input_model"]); $format_local = str_replace ("-","",$format_local); $format_local = str_replace ("/","",$format_local); $format_local = str_replace ("\\","",$format_local); $format_local = str_replace (".","",$format_local); $format_local = str_replace (" ","",$format_local); $format_local = str_replace ($msg["format_date_input_separator"],"",$format_local); list($date[substr($format_local,0,1)],$date[substr($format_local,1,1)],$date[substr($format_local,2,1)]) = sscanf($date_a_convertir,$msg["format_date_input"]) ; if ($date['Y'] && $date['m'] && $date['d']){ //$date_a_convertir = $date['Y']."-".$date['m']."-".$date['d'] ; $date_a_convertir = sprintf("%04d-%02d-%02d",$date['Y'],$date['m'],$date['d']); } else { $date_a_convertir=""; } return $date_a_convertir ; } function detectFormatDate($date_a_convertir,$compl="01"){ global $msg; if(preg_match("#\d{4}-\d{2}-\d{2}#",$date_a_convertir)){ $date = $date_a_convertir; }else if(preg_match(getDatePattern(),$date_a_convertir)){ $date = extraitdate($date_a_convertir); }elseif(preg_match(getDatePattern("short"),$date_a_convertir)){ $format = str_replace ("%","",$msg["format_date_short"]); $format = str_replace ("-","",$format); $format = str_replace ("/","",$format); $format = str_replace ("\\","",$format); $format = str_replace (".","",$format); $format = str_replace (" ","",$format); $format = str_replace ($msg["format_date_input_separator"],"",$format); list($date[substr($format,0,1)],$date[substr($format,1,1)],$date[substr($format,2,1)]) = sscanf($date_a_convertir,$msg["format_date_short_input"]); if ($date['Y'] && $date['m']){ if ($compl == "min") { $date = sprintf("%04d-%02d-%02s",$date['Y'],$date['m'],"01"); } elseif ($compl == "max") { $date = sprintf("%04d-%02d-%02s",$date['Y'],$date['m'],date("t",mktime( 0, 0, 0, $date['m'], 1, $date['Y'] ))); } else{ $date = sprintf("%04d-%02d-%02s",$date['Y'],$date['m'],$compl); } }else{ $date = "0000-00-00"; } }elseif(preg_match(getDatePattern("year"),$date_a_convertir,$matches)){ if ($compl == "min") { $date = $matches[0]."-01-01"; } elseif ($compl == "max") { $date = $matches[0]."-12-31"; } else{ $date = $matches[0]."-".$compl."-".$compl; } }else{ $format = str_replace ("%",".",$msg["format_date"]); $format = str_replace ("-","",$format); $format = str_replace ("/","",$format); $format = str_replace ("\\","",$format); $format = str_replace (".","",$format); $format = str_replace (" ","",$format); $pattern= array(); for($i=0 ; $i< strlen($format) ; $i++){ switch($format[$i]){ case "m" : case "d" : $pattern[$i] = '\d{1,2}'; break; case "Y" : $pattern[$i] = '(\d{2})'; break; } } if(preg_match("#".implode($pattern,".")."#", $date_a_convertir,$matches)){ if(substr(date("Y"),2,2) < $matches['1']){ $correct_year = ((substr(date("Y"),0,2)*1)-1).$matches[1]; }else{ $correct_year = substr(date("Y"),0,2).$matches[1]; } if(substr($format,-1) == "Y"){ $date = detectFormatDate(substr($date_a_convertir,0,-2).$correct_year,$compl); } }else{ $date = "0000-00-00"; } } return $date; } function getDatePattern($format="long"){ global $msg; switch($format){ case "long" : $format_date = str_replace ("%","",$msg["format_date"]); break; case "short" : $format_date = str_replace ("%","",$msg["format_date_short"]); break; case "year": $format_date = "Y"; break; } $format_date = str_replace ("-"," ",$format_date); $format_date = str_replace ("/"," ",$format_date); $format_date = str_replace ("\\"," ",$format_date); $format_date = str_replace ("."," ",$format_date); $format_date=explode(" ",$format_date); $pattern = array(); for($i=0;$i".htmlentities($liste_vide_info, ENT_QUOTES, $charset)."\n"; } else { if ($option_premier_info!="") { $renvoi.="