From 067fe041164e8744b75abde338262343e3ceab5c Mon Sep 17 00:00:00 2001 From: Cerdic <cedric@yterium.com> Date: Wed, 27 Jul 2011 15:05:52 +0000 Subject: [PATCH] =?UTF-8?q?=20Filtre=20|affdate=5Fdebut=5Ffin=20mutualise?= =?UTF-8?q?=20a=20partir=20du=20filtre=20qui=20existait=20dans=20le=20plug?= =?UTF-8?q?in=20agenda=20=20+=203=20chaines=20de=20langues=20utilis=C3=A9e?= =?UTF-8?q?s=20par=20le=20filtre=20=20=20=20=20=20=20=20=20=20/**=20=20=20?= =?UTF-8?q?=20=20=20=20=20=20=20=20*=20Afficher=20de=20facon=20textuelle?= =?UTF-8?q?=20les=20dates=20de=20debut=20et=20fin=20en=20fonction=20des=20?= =?UTF-8?q?cas=20=20=20=20=20=20=20=20=20=20=20*=20-=20Lundi=2020=20fevrie?= =?UTF-8?q?r=20a=2018h=20=20=20=20=20=20=20=20=20=20=20*=20-=20Le=2020=20f?= =?UTF-8?q?evrier=20de=2018h=20a=2020h=20=20=20=20=20=20=20=20=20=20=20*?= =?UTF-8?q?=20-=20Du=2020=20au=2023=20fevrier=20=20=20=20=20=20=20=20=20?= =?UTF-8?q?=20=20*=20-=20du=2020=20fevrier=20au=2030=20mars=20=20=20=20=20?= =?UTF-8?q?=20=20=20=20=20=20*=20-=20du=2020=20fevrier=202007=20au=2030=20?= =?UTF-8?q?mars=202008=20=20=20=20=20=20=20=20=20=20=20*=20$horaire=3D'oui?= =?UTF-8?q?'=20ou=20true=20permet=20d'afficher=20l'horaire,=20toute=20autr?= =?UTF-8?q?e=20valeur=20n'indique=20que=20le=20jour=20=20=20=20=20=20=20?= =?UTF-8?q?=20=20=20=20*=20$forme=20peut=20contenir=20une=20ou=20plusieurs?= =?UTF-8?q?=20valeurs=20parmi=20=20=20=20=20=20=20=20=20=20=20*=20=20-=20a?= =?UTF-8?q?bbr=20(afficher=20le=20nom=20des=20jours=20en=20abbrege)=20=20?= =?UTF-8?q?=20=20=20=20=20=20=20=20=20*=20=20-=20hcal=20(generer=20une=20d?= =?UTF-8?q?ate=20au=20format=20hcal)=20=20=20=20=20=20=20=20=20=20=20*=20?= =?UTF-8?q?=20-=20annee=20(forcer=20l'affichage=20de=20l'annee)=20=20=20?= =?UTF-8?q?=20=20=20=20=20=20=20=20*=20=20=20=20=20=20=20=20=20=20=20*=20@?= =?UTF-8?q?param=20string=20$date=5Fdebut=20=20=20=20=20=20=20=20=20=20=20?= =?UTF-8?q?*=20@param=20string=20$date=5Ffin=20=20=20=20=20=20=20=20=20=20?= =?UTF-8?q?=20*=20@param=20string=20$horaire=20=20=20=20=20=20=20=20=20=20?= =?UTF-8?q?=20*=20@param=20string=20$forme=20=20=20=20=20=20=20=20=20=20?= =?UTF-8?q?=20*=20@return=20string=20=20=20=20=20=20=20=20=20=20=20*/?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ecrire/inc/filtres.php | 85 +++++++++++++++++++++++++++++++++++++++++ ecrire/lang/spip_fr.php | 3 ++ 2 files changed, 88 insertions(+) diff --git a/ecrire/inc/filtres.php b/ecrire/inc/filtres.php index 3988c5fb59..199662f131 100644 --- a/ecrire/inc/filtres.php +++ b/ecrire/inc/filtres.php @@ -1031,6 +1031,91 @@ function affdate_heure($numdate) { return _T('date_fmt_jour_heure', array('jour' => affdate($numdate), 'heure' => _T('date_fmt_heures_minutes', array('h'=> $heures, 'm'=> $minutes)))); } +/** + * Afficher de facon textuelle les dates de debut et fin en fonction des cas + * - Lundi 20 fevrier a 18h + * - Le 20 fevrier de 18h a 20h + * - Du 20 au 23 fevrier + * - du 20 fevrier au 30 mars + * - du 20 fevrier 2007 au 30 mars 2008 + * $horaire='oui' ou true permet d'afficher l'horaire, toute autre valeur n'indique que le jour + * $forme peut contenir une ou plusieurs valeurs parmi + * - abbr (afficher le nom des jours en abbrege) + * - hcal (generer une date au format hcal) + * - annee (forcer l'affichage de l'annee) + * + * @param string $date_debut + * @param string $date_fin + * @param string $horaire + * @param string $forme + * @return string + */ +function affdate_debut_fin($date_debut, $date_fin, $horaire = 'oui', $forme=''){ + $abbr = ''; + if (strpos($forme,'abbr')!==false) $abbr = 'abbr'; + $affdate = "affdate_jourcourt"; + if (strpos($forme,'annee')!==false) $affdate = 'affdate'; + + $dtstart = $dtend = $dtabbr = ""; + if (strpos($forme,'hcal')!==false) { + $dtstart = "<abbr class='dtstart' title='".date_iso($date_debut)."'>"; + $dtend = "<abbr class='dtend' title='".date_iso($date_fin)."'>"; + $dtabbr = "</abbr>"; + } + + $date_debut = strtotime($date_debut); + $date_fin = strtotime($date_fin); + $d = date("Y-m-d", $date_debut); + $f = date("Y-m-d", $date_fin); + $h = ($horaire==='oui' OR $horaire===true); + $hd = _T('date_fmt_heures_minutes_court', array('h'=> date("H",$date_debut), 'm'=> date("i",$date_debut))); + $hf = _T('date_fmt_heures_minutes_court', array('h'=> date("H",$date_fin), 'm'=> date("i",$date_fin))); + $au = " " . strtolower(_T('date_fmt_periode_to')) . " "; + $du = _T('date_fmt_periode_from') . " "; + if ($d==$f) + { // meme jour + $s = ucfirst(nom_jour($d,$abbr))." ".$affdate($d); + if ($h) + if ($hd!=$hf) + $s .= " $hd"; + else + $s = _T('date_fmt_jour_heure',array('jour'=>$s,'heure'=>$hd)); + $s = "$dtstart$s$dtabbr"; + if ($h AND $hd!=$hf) $s .= "-$dtend$hf$dtabbr"; + } + else if ((date("Y-m",$date_debut))==date("Y-m",$date_fin)) + { // meme annee et mois, jours differents + if ($h){ + $s = $du . $dtstart . affdate_jourcourt($d,date("Y",$date_debut)) . " $hd" . $dtabbr; + $s .= $au . $dtend . $affdate($f); + if ($hd!=$hf) $s .= " $hf"; + $s .= $dtabbr; + } + else { + $s = $du . $dtstart . jour($d) . $dtabbr; + $s .= $au . $dtend . $affdate($f) . $dtabbr; + } + } + else if ((date("Y",$date_debut))==date("Y",$date_fin)) + { // meme annee, mois et jours differents + $s = $du . $dtstart . affdate_jourcourt($d,date("Y",$date_debut)); + if ($h) $s .= " $hd"; + $s .= $dtabbr . $au . $dtend . $affdate($f); + if ($h) $s .= " $hf"; + $s .= $dtabbr; + } + else + { // tout different + $s = $du . $dtstart . affdate($d); + if ($h) + $s .= " ($hd)"; + $s .= $dtabbr . $au . $dtend. affdate($f); + if ($h) + $s .= " ($hf)"; + $s .= $dtabbr; + } + return $s; +} /** * Alignements en HTML (Old-style, preferer CSS) diff --git a/ecrire/lang/spip_fr.php b/ecrire/lang/spip_fr.php index 40d8949b6f..091472fce3 100644 --- a/ecrire/lang/spip_fr.php +++ b/ecrire/lang/spip_fr.php @@ -105,11 +105,14 @@ $GLOBALS[$GLOBALS['idx_lang']] = array( 'date_de_mois_9' => '@j@ @nommois@', 'date_demain' => 'demain', 'date_fmt_heures_minutes' => '@h@h@m@min', +'date_fmt_heures_minutes_court' => '@h@h@m@', 'date_fmt_jour_heure' => '@jour@ Ã @heure@', 'date_fmt_jour_mois' => '@jour@ @nommois@', 'date_fmt_jour_mois_annee' => '@jour@ @nommois@ @annee@', 'date_fmt_mois_annee' => '@nommois@ @annee@', 'date_fmt_nomjour_date' => 'le @nomjour@ @date@', +'date_fmt_periode_from' => 'Du', +'date_fmt_periode_to' => 'au', 'date_heures' => 'heures', 'date_hier' => 'hier', 'date_il_y_a' => 'il y a @delai@', -- GitLab