3 /***************************************************************************\
4 * SPIP, Systeme de publication pour l'internet *
6 * Copyright (c) 2001-2014 *
7 * Arnaud Martin, Antoine Pitrou, Philippe Riviere, Emmanuel Saint-James *
9 * Ce programme est un logiciel libre distribue sous licence GNU/GPL. *
10 * Pour plus de details voir le fichier COPYING.txt ou l'aide en ligne. *
11 \***************************************************************************/
14 if (!defined('_ECRIRE_INC_VERSION')) return;
16 // http://doc.spip.org/@my_sel
17 function my_sel($num, $tex, $comp) {
18 return "<option value='$num'" . (($num != $comp) ?
'' : " selected='selected'") .
22 // http://doc.spip.org/@format_mysql_date
23 function format_mysql_date($annee=0, $mois=0, $jour=0, $h=0, $m=0, $s=0) {
24 $annee = sprintf("%04s",$annee);
25 $mois = sprintf("%02s",$mois);
27 if ($annee == "0000") $mois = 0;
28 if ($mois == "00") $jour = 0;
30 return sprintf("%04u",$annee) . '-' . sprintf("%02u",$mois) . '-'
31 . sprintf("%02u",$jour) . ' ' . sprintf("%02u",$h) . ':'
32 . sprintf("%02u",$m) . ':' . sprintf("%02u",$s);
36 // http://doc.spip.org/@afficher_mois
37 function afficher_mois($mois, $attributs, $autre=false){
39 "<select $attributs>\n" .
40 (!$autre ?
'' : my_sel("00",_T('mois_non_connu'),$mois)) .
41 my_sel("01", _T('date_mois_1'), $mois) .
42 my_sel("02", _T('date_mois_2'), $mois) .
43 my_sel("03", _T('date_mois_3'), $mois) .
44 my_sel("04", _T('date_mois_4'), $mois) .
45 my_sel("05", _T('date_mois_5'), $mois) .
46 my_sel("06", _T('date_mois_6'), $mois) .
47 my_sel("07", _T('date_mois_7'), $mois) .
48 my_sel("08", _T('date_mois_8'), $mois) .
49 my_sel("09", _T('date_mois_9'), $mois) .
50 my_sel("10", _T('date_mois_10'), $mois) .
51 my_sel("11", _T('date_mois_11'), $mois) .
52 my_sel("12", _T('date_mois_12'), $mois) .
56 // http://doc.spip.org/@afficher_annee
57 function afficher_annee($annee, $attributs, $debut=null, $fin=null) {
59 if (!isset($debut)) $debut = $annee - 8;
60 if (!isset($fin)) $fin = max($annee, date('Y')) +
3;
62 if ($fin - $debut > 15)
63 return "<input type='text' value='$annee' size='4' $attributs />";
65 $res = ($annee > $debut) ?
'' : my_sel($annee,$annee,$annee);
66 for ($i=$debut; $i < $fin; $i++
) {
67 $res .= my_sel($i,$i,$annee);
69 // plus de choix... on met une vieille date arbitraire, et au tour
70 // suivant on aura un champ input a la place du select (pas genial...)
71 $res .= my_sel(date('Y')-10,' ...',$annee);
72 return "<select $attributs>\n$res</select>\n";
75 // http://doc.spip.org/@afficher_jour
76 function afficher_jour($jour, $attributs, $autre=false){
78 $res = (!$autre ?
"" : my_sel("00",_T('jour_non_connu_nc'),$jour));
80 if ($i<10){$aff=" ".$i;}else{$aff=$i;}
81 $res .= my_sel($i,$aff,$jour);
83 return "<select $attributs>\n$res</select>\n";
86 // http://doc.spip.org/@afficher_heure
87 function afficher_heure($heure, $attributs, $autre=false){
89 for($i=0;$i<=23;$i++
){
90 $aff = sprintf("%02s", $i);
91 $res .= my_sel($i,$aff,$heure);
93 return "<select $attributs>\n$res</select>\n";
96 // http://doc.spip.org/@afficher_minute
97 function afficher_minute($minute, $attributs, $autre=false){
99 for($i=0;$i<=59;$i+
=5){
100 $aff = sprintf("%02s", $i);
101 $res .= my_sel($i,$aff,$minute);
103 if ($minute>$i AND $minute<$i+
5)
104 $res .= my_sel($minute,sprintf("%02s", $minute),$minute);
106 return "<select $attributs>\n$res</select>\n";
110 // http://doc.spip.org/@afficher_jour_mois_annee_h_m
111 function afficher_jour_mois_annee_h_m($date, $heures, $minutes, $suffixe='')
114 afficher_jour(jour($date), "name='jour$suffixe' id='jour$suffixe' size='1' class='verdana1'") .
115 afficher_mois(mois($date), "name='mois$suffixe' id='mois$suffixe' size='1' class='verdana1'") .
116 afficher_annee(annee($date), "name='annee$suffixe' id='annee$suffixe' class='verdana1'", date('Y')-1) .
117 " <input type='text' class='verdana1' name='heures$suffixe' id='heures$suffixe' value=\"".$heures."\" size='3'/> ".majuscules(_T('date_mot_heures'))." " .
118 "<input type='text' class='verdana1' name='minutes$suffixe' id='minutes$suffixe' value=\"$minutes\" size='3'/>";