$hash, "location" => $location, "hash_location" => $hash_location, "hash_location_empty" => $hash_location_empty); return $tmp; } function getimage_url($code = "", $vigurl = "", $empr_pic = 0, $no_cache=false) { 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; global $use_opac_url_base; $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(!$no_cache && $img_cache_url && $img_cache_folder && empty($use_opac_url_base)){ $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)."¬icecode=!!noticecode!!&vigurl=".urlencode($vigurl) ; if(isset($empr_pic) && $empr_pic){ $url_return .="&empr_pic=1"; } if(!empty($use_opac_url_base)){ $url_return .="&no_caching=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, $no_cache=false, $from_export=false) { 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 ($from_export && $notice->thumbnail_url) { return $notice->thumbnail_url; } elseif ($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, 0, $no_cache); } } } 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 (count($tab) > 1) { $mots = array(); foreach ($tab as $word) { if (!empty($word)) { $mots[] = "($word)"; } } return implode('|', $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; } function get_empty_words($lg = 0) { global $got_empty_word; global $pmb_indexation_lang; // global $lang; global $include_path; if(!isset($got_empty_word[$lg]) || !$got_empty_word[$lg]) { $got_empty_word[$lg] = array(); if (!$lg || $lg == $pmb_indexation_lang) { global $empty_word; } else { include($include_path."/marc_tables/".$lg."/empty_words"); } if(is_array($empty_word)) { $got_empty_word[$lg] = $empty_word; } $mots = array(); $query = "select mot from mots join linked_mots on mots.id_mot = linked_mots.num_mot where type_lien = 4"; $result = pmb_mysql_query($query); if($result && pmb_mysql_num_rows($result)) { while($row = pmb_mysql_fetch_object($result)) { $mots[] = convert_diacrit($row->mot); } $got_empty_word[$lg] = array_diff($got_empty_word[$lg], $mots); } } return $got_empty_word[$lg]; } // 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) $empty_word = get_empty_words($lg); // 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); } $empty_word_converted = implode("|",$empty_word_converted); } // AR-AP : \b => word boundary bien plus efficace $string = pmb_preg_replace("/\b(".$empty_word_converted.")\b/im", '', $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 $charset; 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[] = ' '; if($charset == 'utf-8') { foreach ($clean_string_matches as $key=>$matches) { $clean_string_matches[$key] = $matches.'u'; } } } $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; pmb_load_messages(); 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; $date_a_convertir = str_replace ("-","/",$date_a_convertir); $date_a_convertir = str_replace (".","/",$date_a_convertir); $date_a_convertir = str_replace ("\\","/",$date_a_convertir); $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", $date_flot = false){ global $msg; if(preg_match("#\d{4}-\d{2}-\d{2}#",$date_a_convertir)){ $date = $date_a_convertir; }else if(preg_match("#\d{4}.\d{2}.\d{2}#",$date_a_convertir)){ $date = str_replace('.', '-', $date_a_convertir); }else if(preg_match(getDatePattern(),$date_a_convertir)){ $date = extraitdate($date_a_convertir); } elseif (preg_match(getDatePattern("short"),$date_a_convertir)) { $dateArray = array(); $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); if (!empty(substr($format,0,1)) && !empty(substr($format,1,1)) && !empty(substr($format,2,1))) { list($dateArray[substr($format,0,1)],$dateArray[substr($format,1,1)],$dateArray[substr($format,2,1)]) = sscanf($date_a_convertir,$msg["format_date_short_input"]); } elseif (!empty(substr($format,0,1)) && !empty(substr($format,1,1))) { list($dateArray[substr($format,0,1)],$dateArray[substr($format,1,1)]) = sscanf($date_a_convertir,$msg["format_date_short_input"]); } elseif (!empty(substr($format,0,1)) && !empty(substr($format,1,1))) { list($dateArray[substr($format,0,1)]) = sscanf($date_a_convertir,$msg["format_date_short_input"]); } if ($dateArray['Y'] && $dateArray['m']){ if ($compl == "min") { $date = sprintf("%04d-%02d-%02s",$dateArray['Y'],$dateArray['m'],"01"); } elseif ($compl == "max") { $date = sprintf("%04d-%02d-%02s",$dateArray['Y'],$dateArray['m'],date("t",mktime( 0, 0, 0, $dateArray['m'], 1, $dateArray['Y'] ))); } else{ $date = sprintf("%04d-%02d-%02s",$dateArray['Y'],$dateArray['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; } if ($date_flot === true) { if ($date_a_convertir[0] == '-'){ $date = '-'.$matches[0]; } else { $date = $matches[0]; } } }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{ if (($date_flot === true) && preg_match("/^\-?\d+$/", $date_a_convertir)) { $date = $date_a_convertir; } else { $date = "0000-00-00"; } } } return $date; } function getDatePattern($format = "long") { global $msg; switch ($format) { case "long" : default: $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_array = explode(" ",$format_date); $pattern = array(); for ($i = 0; $i < count($format_date_array); $i++){ switch ($format_date_array[$i]) { case "m" : case "d" : $pattern[$i] = '\d{1,2}'; break; case "Y" : $pattern[$i] = '\d{4,}'; break; } } return "#".implode($pattern,".")."#"; } function getDojoPattern($date) { $formatted_date = str_replace (array("%d", "%m", "%y", "%D", "%M", "%Y"),array("dd","MM","yy","DD","MMMM","yyyy"),$date); if(strpos($formatted_date, '%') !== false) { return ''; } else { return $formatted_date; } } // construitdateheuremysql($date) : retourne une date formatee MySQL à partir de "YYYYmmddHHMMSS" function construitdateheuremysql($date_a_convertir) { global $msg; $date_a_convertir = str_replace('-', '', $date_a_convertir); $date_a_convertir = str_replace('/', '', $date_a_convertir ); $date_a_convertir = str_replace(' ', '', $date_a_convertir ); $date_a_convertir = str_replace('#', '', $date_a_convertir ); $date_a_convertir = str_replace(':', '', $date_a_convertir ); $date_a_convertir = str_replace('.', '', $date_a_convertir ); $date_a_convertir = str_replace('@', '', $date_a_convertir ); $date_a_convertir = str_replace('\\', '', $date_a_convertir ); $date_a_convertir = str_replace('%', '', $date_a_convertir ); $date_a_convertir = str_replace($msg["format_date_input_separator"], '', $date_a_convertir ); $dateconv = substr($date_a_convertir,0,4) ; $dateconv.= "-" ; $dateconv.= substr($date_a_convertir,4,2) ; $dateconv.= "-" ; $dateconv.= substr($date_a_convertir,6,2) ; if (substr($date_a_convertir,8,2)) { $dateconv.= " " ; $dateconv.= substr($date_a_convertir,8,2) ; $dateconv.= ":" ; $dateconv.= substr($date_a_convertir,10,2) ; if (substr($date_a_convertir,12,2)) { $dateconv.= ":" ; $dateconv.= substr($date_a_convertir,12,2) ; } } return $dateconv ; } // ---------------------------------------------------------------------------- // fonctions qui retourne le nom de la page courante (SANS L'EXTENSION .php) ! // ---------------------------------------------------------------------------- function current_page() { return str_replace("/", "", preg_replace("#\/.*\/(.*\.php)$#", "\\1", $_SERVER["PHP_SELF"])); } function gen_liste_option($value, $label, $selected=0) { global $charset; $renvoi="\n"; return $renvoi; } function gen_liste_options($result, $champ_code, $champ_info, $selected=0, $champ_optgroup='') { global $msg, $charset; $renvoi=""; $nb_liste=pmb_mysql_num_rows($result); $i=0; if($champ_optgroup) { $grouped_options = array(); while ($i<$nb_liste) { $champ_optgroup_label = pmb_mysql_result($result,$i,$champ_optgroup); if(!$champ_optgroup_label) { $champ_optgroup_label = $msg['classementGen_default_libelle']; } if($champ_optgroup_label && empty($grouped_options[$champ_optgroup_label])) { $grouped_options[$champ_optgroup_label] = array(); } $value = pmb_mysql_result($result,$i,$champ_code); $label = pmb_mysql_result($result,$i,$champ_info); $grouped_options[$champ_optgroup_label][] = gen_liste_option($value, $label, $selected); $i++; } foreach ($grouped_options as $groupment_name=>$options) { $renvoi.=""; } } else { while ($i<$nb_liste) { $value = pmb_mysql_result($result,$i,$champ_code); $label = pmb_mysql_result($result,$i,$champ_info); $renvoi .=gen_liste_option($value, $label, $selected); $i++; } } return $renvoi; } // ---------------------------------------------------------------------------- // fonction gen_liste qui genere des combo_box a partir d'une requete // ---------------------------------------------------------------------------- /* $requete : requete sql pour generer la liste (retourne $champ_code, $champ_info) $champ_code : valeur $champ_info : libelle $nom : id et name $on_change : fonction a appeler sur changement $selected : valeur affichee par defaut $liste_vide_code : valeur renvoyee si liste vide $liste_vide_info : libelle affiche si liste vide $option_premier_code : valeur en tete de liste $option_premier_info : libelle en tete de liste $multiple : selecteur multiple si 1 $attr attributs de la liste $champ_optgroup champ de regroupement */ function gen_liste ($requete, $champ_code, $champ_info, $nom, $on_change, $selected, $liste_vide_code, $liste_vide_info,$option_premier_code,$option_premier_info,$multiple=0,$attr='',$champ_optgroup='') { global $dbh, $charset ; $result=pmb_mysql_query($requete, $dbh) or die ($requete); $renvoi="\n"; return $renvoi; } // ---------------------------------------------------------------------------- // fonction gen_liste_multiple qui genere des combo_box super sympas avec selection multiple // ---------------------------------------------------------------------------- function gen_liste_multiple ($requete, $champ_code, $champ_info, $champ_selected, $nom, $on_change, $selected, $liste_vide_code, $liste_vide_info,$option_premier_code,$option_premier_info,$multiple=0,$champ_optgroup='') { $result=pmb_mysql_query($requete) or die (pmb_mysql_error()); $nb_liste=pmb_mysql_num_rows($result); if ($multiple && $nb_liste) { if ($nb_liste < $multiple) $size = $nb_liste+1; else $size = $multiple; } else $size = 1 ; $renvoi="\n"; return $renvoi; } // ---------------------------------------------------------------------------- // fonction do_selector qui genere des combo_box avec tout ce qu'il faut // ---------------------------------------------------------------------------- function do_selector($table, $name='mySelector', $value=0) { global $dbh; global $charset; $defltvar="deflt_".$table; global ${$defltvar}; if ($value==0) $value= ${$defltvar} ; if(!$table) return ''; $requete = "SELECT * FROM $table order by 2"; $result = @pmb_mysql_query($requete, $dbh); $nbr_lignes = pmb_mysql_num_rows($result); if(!$nbr_lignes) return ''; $selector = "'; return $selector; } //------like print_r but more readable--for debugging purposes function printr($arr,$filter="",$name="") { //array_shift($args) ; print "
\n" ; if ($name) { print "Printing content of array $name:\n"; } if ($filter == "" || ! is_array($arr) ) { print_r($arr) ; } else { if (is_array($arr)) { ksort($arr); foreach($arr as $key => $val) { if (preg_match("#$filter#", $key) || preg_match("#$filter#", $val) ) { print "[" . $key . "] => " . $val ."\n" ; } } } } print ""; return ; } // ---------------------------------------------------------------------------- // fonction de pagination // ---------------------------------------------------------------------------- function aff_pagination ($url_base="", $nbr_lignes=0, $nb_per_page=0, $page=0, $etendue=10, $aff_nb_per_page=false, $aff_extr=false ) { global $msg,$charset; global $pmb_items_pagination_custom; if(!$nb_per_page) $nb_per_page=1; $nbepages = ceil($nbr_lignes/$nb_per_page); $suivante = $page+1; $precedente = $page-1; $deb = $page - $etendue ; if ($deb<1) $deb=1; $fin = $page + $etendue ; if($fin>$nbepages)$fin=$nbepages; $nav_bar = ""; if ($aff_nb_per_page) { $nav_bar = "