From a8a019030e94ec22e4aac609900dcde132dedf8a Mon Sep 17 00:00:00 2001 From: "Committo,Ergo:sum" <esj@rezo.net> Date: Sat, 7 May 2005 21:52:27 +0000 Subject: [PATCH] =?UTF-8?q?rationnalisation=20de=20l'usage=20des=20dates?= =?UTF-8?q?=20dans=20les=20fonctions=20des=20calendriers;=20au=20passage,?= =?UTF-8?q?=20r=C3=A9apparition=20dans=20les=20calendriers=20des=20article?= =?UTF-8?q?s=20sans=20num=C3=A9ro=20de=20jour?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ecrire/calendrier.css | 18 +- ecrire/inc_calendrier.php | 1757 +++++++++++++++++----------------- ecrire/inc_presentation.php3 | 11 +- ecrire/index.php3 | 39 +- ecrire/message.php3 | 9 +- ecrire/naviguer.php3 | 64 +- 6 files changed, 942 insertions(+), 956 deletions(-) diff --git a/ecrire/calendrier.css b/ecrire/calendrier.css index 81ba0778a2..536e1b6db4 100644 --- a/ecrire/calendrier.css +++ b/ecrire/calendrier.css @@ -70,6 +70,21 @@ a.calendrier-annee:hover { vertical-align: top; } +.calendrier-td { + width: 14%; + vertical-align: top; + } + +.calendrier-th { + width: 14%; + padding: 5px; + text-align: center; + vertical-align: center; + font-size: 10px; + font-weight: bold; + font-family: Verdana, Arial, Sans, sans-serif; + } + .calendrier-table-etroit .calendrier-td-gauche { width: 0px; vertical-align: top; @@ -91,9 +106,8 @@ a.calendrier-annee:hover { } .calendrier-jour { + position: relative; color: #999999; - background-color: white; - border: 1px solid #aaaaaa; } .calendrier-agenda { diff --git a/ecrire/inc_calendrier.php b/ecrire/inc_calendrier.php index 1eeb890fe7..84c360b942 100644 --- a/ecrire/inc_calendrier.php +++ b/ecrire/inc_calendrier.php @@ -15,7 +15,11 @@ if (defined("_ECRIRE_INC_CALENDRIER")) return; define("_ECRIRE_INC_CALENDRIER", "1"); -# Typographie generale des calendriers de 3 type: jour/semaine/mois(ou plus) +// Typographie generale des calendriers de 3 type: jour/semaine/mois(ou plus) + +// Notes: pour toutes les fonctions ayant parmi leurs parametres +// annee, mois, jour, echelle, partie_cal, script, ancre +// ceux-ci apparaissent TOUJOURS dans cet ordre define(DEFAUT_D_ECHELLE,120); # 1 pixel = 2 minutes @@ -40,82 +44,87 @@ $bleu = http_img_pack("m_envoi_bleu$spip_lang_rtl.gif", 'B', "class='calendrier- $vert = http_img_pack("m_envoi$spip_lang_rtl.gif", 'V', "class='calendrier-icone'"); $jaune= http_img_pack("m_envoi_jaune$spip_lang_rtl.gif", 'J', "class='calendrier-icone'"); -// init: calcul generique des evenements a partir des tables SQL -// et lancement de la mise en page du type jour/semaine/mois demandee - -function http_calendrier_init($date='', $ltype='', $lechelle='', $lpartie_cal='', $script='', $evt='') -{ - global $mois, $annee, $jour, $type, $echelle, $partie_cal; +// ce tableau est l'equivalent du switch affectant des globales dans inc.php +// plus 2 autres issus du inc_agenda originel - if (!$mois){ - $today=getdate($date ? strtotime($date) : time()); - $jour = $today["mday"]; - $mois = $today["mon"]; - $annee = $today["year"]; - } else {if (!isset($jour)) {$jour = 1; $type= 'mois';}} - if (!$date) $date = date("Y-m-d", mktime(0,0,0,$mois, $jour, $annee)); - if (!$script) $script = $GLOBALS['REQUEST_URI']; - if (!$type AND !($type = $ltype)) $type = 'mois'; - if (!isset($echelle)) $echelle = $lechelle; - if (!isset($lpartie_cal)) $partie_cal = $lpartie_cal; - $script = http_calendrier_retire_args($script); - if (!_DIR_RESTREINT) http_calendrier_titre($date, $type); - $f = 'http_calendrier_init_' . $type; - if (!$evt) { - $g = 'sql_calendrier_' . $type; - $evt = sql_calendrier_interval($g($annee,$mois, $jour)); - } - return $f($date, $echelle, $partie_cal, $script, $evt); +global $contrastes; +$contrastes = array( + /// Marron + array("#8C6635","#F5EEE5","#1A64DF","#955708"), + /// Fushia + array("#CD006F","#FDE5F2","#E95503","#8F004D"), + /// Bleu + array("#5da7c5","#EDF3FE","#814E1B","#435E79"), + /// Bleu pastel + array("#766CF6","#EBE9FF","#869100","#5B55A0"), + /// Orange + array("#fa9a00","#ffeecc","#396B25","#472854"), + /// Rouge (Vermillon) + array("#FF0000","#FFEDED","#D302CE","#D40202"), + /// Orange + array("#E95503","#FFF2EB","#81A0C1","#FF5B00"), + /// Jaune + array("#ccaa00", "#ffffee", "#65659C","#6A6A43"), + /// Vert pastel + array("#009F3C","#E2FDEC","#EE0094","#02722C"), + /// Vert + array("#9DBA00", "#e5fd63","#304C38","#854270"), + /// Rouge (Bordeaux) + array("#640707","#FFE0E0","#346868","#684747"), + /// Gris + array("#3F3F3F","#F2F2F2","#854270","#666666"), + // Noir + array("black","#aaaaaa", "#000000", "#ffffff"), + /// Caca d'oie + array("#666500","#FFFFE0","#65659C","#6A6A43") + ); -} +// +// Utilitaires sans html ni sql +// -// titre de la page, si on est dans l'espace de redaction +# Choisit dans le tableau ci-dessus les couleurs d'un evenement +# si l'indice fourni par CATEGORIES est negatif, inversion des plans +# +++ un hack pour le cas special de ecrire/message.php -function http_calendrier_titre($date, $type) +function calendrier_div_style($evenement) { -if ($type == 'semaine') { - - $GLOBALS['afficher_bandeau_calendrier_semaine'] = true; - - $titre = _T('titre_page_calendrier', - array('nom_mois' => nom_mois($date), 'annee' => annee($date))); - } -elseif ($type == 'jour') { - $titre = nom_jour($date)." ". affdate_jourcourt($date); - } - else { - $titre = _T('titre_page_calendrier', - array('nom_mois' => nom_mois($date), 'annee' => annee($date))); - } + global $contrastes; + global $calendrier_message_fermeture; + if (isset($calendrier_message_fermeture) && + (ereg("=$calendrier_message_fermeture$", $evenement['URL']))) + {return array('white', 'black');} + else + { + $categ = $evenement['CATEGORIES']; - debut_page($titre, "redacteurs", "calendrier"); - echo "<div> </div>" ; + if (!is_int($categ)) + return ""; + else + { + if ($categ >= 0) {$f=0;$b=1;$i=$categ;}else{$f=1;$b=0;$i=0-$categ;} + $i %= count($contrastes); + return array($contrastes[$i][$b], $contrastes[$i][$f]); + } + } } // utilitaire de separation script / ancre +// et de retrait des arguments a remplacer -function http_calendrier_script($script) -{ - if (ereg('^(.*)(#[^=&]*)$',$script, $m)) { - $purscript = $m[1]; - $ancre = $m[2]; - } else { $ancre = ''; $purscript = $script; } - if ($purscript[strlen($purscript)-1] == '?') - $purscript = substr($purscript,0,-1); - return array($purscript, $ancre); -} - -// utilitaire de retrait des arguments a remplacer - -function http_calendrier_retire_args($script) +function calendrier_retire_args_ancre($script) { $script = str_replace('?bonjour=oui&?','?',$script); + if (ereg('^(.*)(#[^=&]*)$',$script, $m)) { + $script = $m[1]; + $ancre = $m[2]; + } else { $ancre = ''; } + if ($script[strlen($script)-1] == '?') $script = substr($script,0,-1); foreach(array('echelle','jour','mois','annee', 'type', 'set_echelle', 'set_partie_cal') as $arg) { $script = preg_replace("/([?&])$arg=[^&]*&/",'\1', $script); - $script = preg_replace("/([?&])$arg=[^#]*#/",'\1#', $script); - $script = preg_replace("/([?&])$arg=[^&#]*$/",'\1', $script); + $script = preg_replace("/([?&])$arg=[^&]*$/",'\1', $script); } - return $script; + return array($script, $ancre); } # prend une heure de debut et de fin, ainsi qu'une echelle (seconde/pixel) @@ -140,7 +149,7 @@ function calendrier_echelle($debut, $fin, $echelle) # Calcule le "top" d'une heure -function http_cal_top ($heure, $debut, $fin, $dimheure, $dimjour, $fontsize) { +function calendrier_top ($heure, $debut, $fin, $dimheure, $dimjour, $fontsize) { $h_heure = substr($heure, 0, strpos($heure, ":")); $m_heure = substr($heure, strpos($heure,":") + 1, strlen($heure)); @@ -155,10 +164,10 @@ function http_cal_top ($heure, $debut, $fin, $dimheure, $dimjour, $fontsize) { } # Calcule la hauteur entre deux heures -function http_cal_height ($heure, $heurefin, $debut, $fin, $dimheure, $dimjour, $fontsize) { +function calendrier_height ($heure, $heurefin, $debut, $fin, $dimheure, $dimjour, $fontsize) { - $height = http_cal_top ($heurefin, $debut, $fin, $dimheure, $dimjour, $fontsize) - - http_cal_top ($heure, $debut, $fin, $dimheure, $dimjour, $fontsize); + $height = calendrier_top ($heurefin, $debut, $fin, $dimheure, $dimjour, $fontsize) + - calendrier_top ($heure, $debut, $fin, $dimheure, $dimjour, $fontsize); $padding = floor(($dimheure / 3600) * 240); $height = $height - (2* $padding + 2); // pour padding interieur @@ -168,11 +177,81 @@ function http_cal_height ($heure, $heurefin, $debut, $fin, $dimheure, $dimjour, return $height; } -# affiche un mois en grand, avec des tableau de clics vers d'autres mois -# si premier jour et dernier_jour sont donnes, affiche les semaines delimitees. +// +// init: calcul generique des evenements a partir des tables SQL +// + +function http_calendrier_init($time='', $ltype='', $lechelle='', $lpartie_cal='', $script='', $evt='') +{ + global $mois, $annee, $jour, $type, $echelle, $partie_cal; + + if (!$time) + { + if (!$mois){ + $time = time(); + } else { + if (!isset($jour)) + { + $today=getdate(time()); + $jour=$today["mday"]; + $type= 'mois'; + } + $time = mktime(0,0,0,$mois, $jour, $annee); + } + } + + $jour = date("d",$time); + $mois = date("m",$time); + $annee = date("Y",$time); + if (!$type) $type = $ltype ? $ltype : 'mois'; + if (!isset($echelle)) $echelle = $lechelle; + if (!isset($lpartie_cal)) $partie_cal = $lpartie_cal; + list($script, $ancre) = + calendrier_retire_args_ancre($script ? $script : + $GLOBALS['REQUEST_URI']); + if (!_DIR_RESTREINT) http_calendrier_titre($time, $type); + if (!$evt) { + $g = 'sql_calendrier_' . $type; + $evt = sql_calendrier_interval($g($annee,$mois, $jour)); + sql_calendrier_interval_articles("'$annee-$mois-00'", "'$annee-$mois-1'", &$evt[0]); + + } + $f = 'http_calendrier_' . $type; + return $f($annee, $mois, $jour, $echelle, $partie_cal, $script, $ancre, $evt); + +} + +# titre de la page, si on est dans l'espace de redaction + +function http_calendrier_titre($time, $type) +{ + $date = date("Y-m-d", $time); # a optimiser +if ($type == 'semaine') { + + $GLOBALS['afficher_bandeau_calendrier_semaine'] = true; + + $titre = _T('titre_page_calendrier', + array('nom_mois' => nom_mois($date), 'annee' => annee($date))); + } +elseif ($type == 'jour') { + $titre = nom_jour($date)." ". affdate_jourcourt($date); + } + else { + $titre = _T('titre_page_calendrier', + array('nom_mois' => nom_mois($date), 'annee' => annee($date))); + } + + debut_page($titre, "redacteurs", "calendrier"); + echo "<div> </div>" ; +} + +# affichage d'un calendrier de plusieurs semaines +# si la periode est inferieure a 31 jours, on considere que c'est un mois -function http_calendrier_init_mois($date, $echelle, $partie_cal, $script ,$evt) +function http_calendrier_mois($annee, $mois, $jour, $echelle, $partie_cal, $script, $ancre, $evt) { + global $spip_ecran, $couleur_claire, $couleur_foncee; + list($sansduree, $evenements, $premier_jour, $dernier_jour) = $evt; if ($sansduree) @@ -180,8 +259,7 @@ function http_calendrier_init_mois($date, $echelle, $partie_cal, $script ,$evt) { $evenements[$d] = !$evenements[$d] ? $r : array_merge($evenements[$d], $r); } - $annee = annee($date); - $mois = mois($date); + if (!$premier_jour) $premier_jour = '01'; if (!$dernier_jour) { @@ -189,269 +267,86 @@ function http_calendrier_init_mois($date, $echelle, $partie_cal, $script ,$evt) while (!(checkdate($mois,$dernier_jour,$annee))) $dernier_jour--; } - return - http_calendrier_mois($mois, $annee, $premier_jour, $dernier_jour, $partie_cal, $echelle, $evenements, $script) . - http_calendrier_sans_date($evenements["0"]) . - http_calendrier_aide_mess(); + return + "<table class='calendrier-table-$spip_ecran' cellspacing='0' cellpadding='0'>" . + http_calendrier_mois_navigation($annee, $mois, $premier_jour, $dernier_jour, $echelle, $partie_cal, $script, $ancre) . + http_calendrier_mois_noms($annee, $mois, $jour, $script, $ancre) . + http_calendrier_mois_sept($annee, $mois, $premier_jour, $dernier_jour,$evenements, $script, $ancre) . + '</table>' . + http_calendrier_sans_date($annee, $mois, $evenements) . + (_DIR_RESTREINT ? "" : http_calendrier_aide_mess()); } -function http_calendrier_sans_date($evenements) -{ - $r = http_calendrier_ics($evenements); - return (!$r ? '' : - ("\n<table><tr><td class='calendrier-arial10'><b>". - _T('info_mois_courant'). - "</b>" . - $r . - "</td></tr>\n</table>")); -} +// si la periore a plus de 31 jours, c'est du genre trimestre, semestre etc +// pas de navigation suivant/precedent alors -function http_calendrier_aide_mess() -{ - global $bleu, $vert, $jaune, $spip_lang_left; - if (_DIR_RESTREINT) return ""; - return - "\n<br /><br /><br />\n<font face='arial,helvetica,sans-serif' size='2'><table width='700'>\n<tr><th style='text-align: $spip_lang_left'> " . - "<b>"._T('info_aide')."</b>" . - "</th></tr><tr><td>$bleu\n"._T('info_symbole_bleu')."\n" . - "</td></tr><tr><td>$vert\n"._T('info_symbole_vert')."\n" . - "</th></tr><tr><td>$jaune\n"._T('info_symbole_jaune')."\n" . - "</td></tr>\n</table></font>"; - } +function http_calendrier_mois_navigation($annee, $mois, $premier_jour, $dernier_jour, $echelle, $partie_cal, $script, $ancre){ + if ($dernier_jour > 31) { + $prec = $suiv = ''; + $periode = affdate_mois_annee(date("Y-m-d", mktime(1,1,1,$mois,$premier_jour,$annee))) . ' - '. affdate_mois_annee(date("Y-m-d", mktime(1,1,1,$mois,$dernier_jour,$annee))); + } else { -# Bandeau superieur d'un calendrier selon son $type (jour/mois/annee): -# 2 icones vers les 2 autres types, a la meme date $jour $mois $annee -# 2 icones de loupes pour zoom sur la meme date et le meme type -# 2 fleches appelant le $script sur les periodes $pred/$suiv avec une $ancre -# et le $nom du calendrier + $mois_suiv=$mois+1; + $annee_suiv=$annee; + $mois_prec=$mois-1; + $annee_prec=$annee; + if ($mois==1){ + $mois_prec=12; + $annee_prec=$annee-1; + } + else if ($mois==12){$mois_suiv=1; $annee_suiv=$annee+1;} + $prec = "mois=$mois_prec&annee=$annee_prec"; + $suiv = "mois=$mois_suiv&annee=$annee_suiv"; + $periode = affdate_mois_annee("$annee-$mois-1"); + } + return + "\n<tr><td colspan='7'>" . + http_calendrier_navigation($annee, + $mois, + $jour, + $echelle, + $partie_cal, + $periode, + $script, + $prec, + $suiv, + 'mois', + $ancre) . + "</td></tr>"; -function http_calendrier_navigation($jour, $mois, $annee, $partie_cal, $echelle, $nom, $script, $args_pred, $args_suiv, $type, $ancre) -{ - global $spip_lang_right, $spip_lang_left, $couleur_foncee; +} - if (!isset($couleur_foncee)) $couleur_foncee = '#aaaaaa'; - if (!$echelle) $echelle = DEFAUT_D_ECHELLE; - $script = http_calendrier_retire_args($script); - if (!ereg('[?&]$', $script)) $script .= (strpos($script,'?') ? '&' : '?'); - $args = "jour=$jour&mois=$mois&annee=$annee$ancre"; - - $today=getdate(time()); - $jour_today = $today["mday"]; - $mois_today = $today["mon"]; - $annee_today = $today["year"]; +function http_calendrier_mois_noms($annee, $mois, $jour, $script, $ancre){ + global $couleur_claire; + $bandeau =""; + for ($j=1; $j<8;$j++){ + $bandeau .= + "\n\t<th class='calendrier-th'>" . + _T('date_jour_' . (($j%7)+1)) . + "</th>"; + } + return "\n<tr style='background-color: $couleur_claire'>$bandeau\n</tr>"; +} - $id = 'nav-agenda' .ereg_replace('[^A-Za-z0-9]', '', $ancre); +# dispose les lignes d'un calendrier de 7 colonnes (les jours) +# chaque case est garnie avec les evenements du jour figurant dans $evenements - return - "<div class='navigation-calendrier calendrier-moztop8'\nstyle='background-color: $couleur_foncee;'>" - . "<div style='float: $spip_lang_right; padding-left: 5px; padding-right: 5px;'>" - . (($type == "mois") ? '' : - ( - http_href_img(("$script$args&type=$type&set_partie_cal=tout"), - "heures-tout.png", - "class='calendrier-png" . - (($partie_cal == "tout") ? " calendrier-opacity'" : "'"), - _T('cal_jour_entier')) - .http_href_img(("$script$args&type=$type&set_partie_cal=matin"), - "heures-am.png", - "class='calendrier-png" . - (($partie_cal == "matin") ? " calendrier-opacity'" : "'"), - _T('cal_matin')) +function http_calendrier_mois_sept($annee, $mois, $premier_jour, $dernier_jour,$evenements, $script, $ancre='') +{ + global $couleur_claire, $spip_lang_left, $spip_lang_right; - .http_href_img(("$script$args&type=$type&set_partie_cal=soir"), - "heures-pm.png", - "class='calendrier-png" . - (($partie_cal == "soir") ? " calendrier-opacity'" : "'"), - _T('cal_apresmidi')) - . " " - . http_href_img(("$script$args&type=$type&set_echelle=" . - floor($echelle * 1.5)), - "loupe-moins.gif", - '', - _T('info_zoom'). '-') - . http_href_img(("$script$args&type=$type&set_echelle=" . - floor($echelle / 1.5)), - "loupe-plus.gif", - '', - _T('info_zoom'). '+') - )) - . http_href_img(("$script$args&type=jour&echelle=$echelle"),"cal-jour.gif", - (($type == 'jour') ? " class='calendrier-opacity'" : ''), - _T('cal_par_jour')) + if (!ereg('[?&]$', $script)) + $script .= (strpos($script,'?') ? '&' : '?'); - . http_href_img("$script$args&type=semaine&echelle=$echelle", "cal-semaine.gif", - (($type == 'semaine') ? " class='calendrier-opacity'" : "" ), - _T('cal_par_semaine')) - - . http_href_img("$script$args&type=mois&echelle=$echelle","cal-mois.gif", - (($type == 'mois') ? " class='calendrier-opacity'" : "" ), - _T('cal_par_mois')) - . "</div>" - . " " - . http_href_img($script . "type=$type&echelle=$echelle&jour=$jour_today&mois=$mois_today&annee=$annee_today$ancre", - "cal-today.gif", - (" onmouseover=\"montrer('$id');\"" . - (($annee == $annee_today && $mois == $mois_today && (($type == 'mois') || ($jour == $jour_today))) - ? " class='calendrier-opacity'" : "")), - _T("info_aujourdhui")) - . " " - . (!$args_pred ? '' : - http_href($script . "type=$type&echelle=$echelle&$args_pred$ancre", - http_img_pack("fleche-$spip_lang_left.png", '<<<', "class='calendrier-png'"), - _T('precedent'))) - . (!$args_suiv ? '' : - http_href(($script . "type=$type&echelle=$echelle&$args_suiv$ancre"), - http_img_pack("fleche-$spip_lang_right.png", '>>>', "class='calendrier-png'"), - _T('suivant'))) - . " " - . $nom - . (_DIR_RESTREINT ? '' : aide("messcalen")) - . "</div>" - . http_agenda_invisible($id, $annee, $jour, $mois, $script, $ancre); -} - - -// fabrique un petit agenda accessible par survol - -function http_agenda_invisible($id, $annee, $jour, $mois, $script, $ancre) -{ - global $spip_lang_right, $spip_lang_left, $couleur_claire; - if (!isset($couleur_claire)) $couleur_claire = 'white'; - $gadget = "<div style='position: relative;z-index: 1000;' - onmouseover=\"montrer('$id');\" - onmouseout=\"cacher('$id');\">"; - - $gadget .= "<table id='$id' class='calendrier-cadreagenda' style='position: absolute; background-color: $couleur_claire'>"; - $gadget .= "\n<tr><td colspan='3' style='text-align:$spip_lang_left;'>"; - - $annee_avant = $annee - 1; - $annee_apres = $annee + 1; - - for ($i=$mois; $i < 13; $i++) { - $gadget .= http_href($script . "mois=$i&annee=$annee_avant$ancre", - nom_mois("$annee_avant-$i-1"),'','', 'calendrier-annee') ; - } - for ($i=1; $i < $mois - 1; $i++) { - $gadget .= http_href($script . "mois=$i&annee=$annee$ancre", - nom_mois("$annee-$i-1"),'','', 'calendrier-annee'); - } - $gadget .= "</td></tr>" - . "\n<tr><td class='calendrier-tripleagenda'>" - . http_calendrier_agenda($mois-1, $annee, $jour, $mois, $annee, $GLOBALS['afficher_bandeau_calendrier_semaine'], $script,$ancre) - . "</td>\n<td class='calendrier-tripleagenda'>" - . http_calendrier_agenda($mois, $annee, $jour, $mois, $annee, $GLOBALS['afficher_bandeau_calendrier_semaine'], $script,$ancre) - . "</td>\n<td class='calendrier-tripleagenda'>" - . http_calendrier_agenda($mois+1, $annee, $jour, $mois, $annee, $GLOBALS['afficher_bandeau_calendrier_semaine'], $script,$ancre) - . "</td>" - . "</tr>" - . "\n<tr><td colspan='3' style='text-align:$spip_lang_right;'>"; - for ($i=$mois+2; $i <= 12; $i++) { - $gadget .= http_href($script. "mois=$i&annee=$annee$ancre", - nom_mois("$annee-$i-1"),'','', 'calendrier-annee'); - } - for ($i=1; $i < $mois+1; $i++) { - $gadget .= http_href($script . "mois=$i&annee=$annee_apres$ancre", - nom_mois("$annee_apres-$i-1"),'','', 'calendrier-annee'); - } - return $gadget . "</td></tr></table></div>"; -} - - -# affichage du bandeau d'un calendrier de plusieurs semaines -# si la periode est inferieure a 31 jours, on considere que c'est un mois -# et on place les boutons de navigations vers les autres mois et connexe; -# sinon on considere que c'est un planning ferme et il n'y a pas de navigation - -function http_calendrier_mois($mois, $annee, $premier_jour, $dernier_jour, $partie_cal, $echelle, $evenements, $script) -{ - global $spip_ecran, $couleur_claire, $couleur_foncee; - - $today=getdate(time()); - $j=$today["mday"]; - if ($dernier_jour > 31) { - $prec = $suiv = ''; - $periode = affdate_mois_annee(date("Y-m-d", mktime(1,1,1,$mois,$premier_jour,$annee))) . ' - '. affdate_mois_annee(date("Y-m-d", mktime(1,1,1,$mois,$dernier_jour,$annee))); - } else { - - $mois_suiv=$mois+1; - $annee_suiv=$annee; - $mois_prec=$mois-1; - $annee_prec=$annee; - if ($mois==1){ - $mois_prec=12; - $annee_prec=$annee-1; - } - else if ($mois==12){$mois_suiv=1; $annee_suiv=$annee+1;} - $prec = "mois=$mois_prec&annee=$annee_prec"; - $suiv = "mois=$mois_suiv&annee=$annee_suiv"; - $periode = affdate_mois_annee("$annee-$mois-1"); - } - list($purscript, $ancre) = http_calendrier_script($script); - - return - "<table class='calendrier-table-$spip_ecran' cellspacing='0' cellpadding='0'>" . - "\n<tr><td colspan='7'>" . - http_calendrier_navigation($j, - $mois, - $annee, - $partie_cal, - $echelle, - $periode, - $purscript, - $prec, - $suiv, - 'mois', - $ancre) . - "</td></tr>" . - http_calendrier_les_jours(array(_T('date_jour_2'), - _T('date_jour_3'), - _T('date_jour_4'), - _T('date_jour_5'), - _T('date_jour_6'), - _T('date_jour_7'), - _T('date_jour_1')), - $couleur_claire, - $couleur_foncee) . - http_calendrier_suitede7($mois,$annee, $premier_jour, $dernier_jour,$evenements, $purscript, $ancre) . - '</table>'; -} - -# affiche le bandeau des jours - -function http_calendrier_les_jours($intitul, $claire, $foncee) -{ - $nb = count($intitul); - if (!$nb) return ''; - $r = ''; - $bo = "\n\tstyle='width: " . round(100/$nb) . "%'"; - foreach($intitul as $j) $r .= "\n\t<th class='calendrier-titre calendrier-verdana10' $bo>$j</th>"; - return "\n<tr style='background-color: $claire'>$r\n</tr>"; -} - -# dispose les lignes d'un calendrier de 7 colonnes (les jours) -# chaque case est garnie avec les evenements du jour figurant dans $evenements - -function http_calendrier_suitede7($mois_today,$annee_today, $premier_jour, $dernier_jour,$evenements, $script, $ancre='') -{ - global $couleur_claire, $spip_lang_left, $spip_lang_right; - - if (!ereg('[?&]$', $script)) - $script .= (strpos($script,'?') ? '&' : '?'); - - $class_dispose = "border-bottom: 1px solid $couleur_claire; border-$spip_lang_right: 1px solid $couleur_claire; height: 100px; width: 14%; vertical-align: top;"; - - // affichage du debut de semaine hors periode - $jour_semaine = date("w",mktime(1,1,1,$mois_today,$premier_jour,$annee_today)); - if ($jour_semaine==0) $jour_semaine=7; + // affichage du debut de semaine hors periode + $ligne = ''; + $debut = date("w",mktime(1,1,1,$mois,$premier_jour,$annee)); + for ($i=$debut ? $debut : 7;$i>1;$i--) + {$ligne .= "\n\t<td style=\"border-bottom: 1px solid $couleur_claire;\"> </td>";} $total = ''; - $ligne = ''; - for ($i=1;$i<$jour_semaine;$i++){$ligne .= "\n\t<td style=\"border-bottom: 1px solid $couleur_claire;\"> </td>";} - - $ce_jour=date("Ymd"); - $border_left = " border-$spip_lang_left: 1px solid $couleur_claire;"; for ($j=$premier_jour; $j<=$dernier_jour; $j++){ - $nom = mktime(1,1,1,$mois_today,$j,$annee_today); + $nom = mktime(1,1,1,$mois,$j,$annee); $jour = date("d",$nom); $jour_semaine = date("w",$nom); $mois_en_cours = date("m",$nom); @@ -461,39 +356,51 @@ function http_calendrier_suitede7($mois_today,$annee_today, $premier_jour, $dern if ($jour_semaine == 0) { $couleur_lien = "black"; $couleur_fond = $couleur_claire; - } - else { + } else { $couleur_lien = "black"; $couleur_fond = "#eeeeee"; + if ($jour_semaine==1) + { + $total .= "\n<tr>$ligne\n</tr>"; + $ligne = ''; + $border_left = " border-$spip_lang_left: 1px solid $couleur_claire;"; + } else $border_left = ""; } - if ($amj == $ce_jour) { + if ($amj == date("Ymd")) { $couleur_lien = "red"; $couleur_fond = "white"; } - - $ligne .= "\n\t<td style='$class_dispose background-color: $couleur_fond;$border_left'>" . - http_calendrier_clics($annee_en_cours, $mois_en_cours, $jour, $script, $ancre) . - http_calendrier_ics($evenements[$amj], $amj). - "\n\t</td>"; - if ($jour_semaine==0) - { - $total .= "\n<tr>$ligne\n</tr>"; - $ligne = ''; - $border_left = " border-$spip_lang_left: 1px solid $couleur_claire;"; - } else $border_left = ""; + $evts = $evenements[$amj]; + if ($evts) { + $res = ''; + foreach ($evts as $evenement) + { + list($ev, $style, $class) = + is_int($evenement['CATEGORIES']) ? + http_calendrier_avec_heure($evenement, $amj) : + http_calendrier_sans_heure($evenement); + $res .= "\n<div class='$class' style='$style'>$ev\n</div>\n"; + } + $evts = $res; + } + $ligne .= "\n\t\t<td\tclass='calendrier-td' + style='height: 100px; background-color: $couleur_fond; border-bottom: 1px solid $couleur_claire; border-$spip_lang_right: 1px solid $couleur_claire;$border_left'>" . + http_calendrier_mois_clics($annee_en_cours, $mois_en_cours, $jour, $script, $ancre, $couleur_lien) . + $evts . + "\n\t</td>"; } return $total . ($ligne ? "\n<tr>$ligne\n</tr>" : ''); } -function http_calendrier_clics($annee, $mois, $jour, $script, $ancre) +function http_calendrier_mois_clics($annee, $mois, $jour, $script, $ancre, $color) { $script .= "jour=$jour&mois=$mois&annee=$annee"; if (!_DIR_RESTREINT) return http_href("$script&type=jour" . $ancre, $jour, - '', '','calendrier-helvetica16') . - http_calendrier_message3(false, $jour,$mois,$annee); + '', "color: $color",'calendrier-helvetica16') . + http_calendrier_ics_message($annee, $mois, $jour, false); else { $d = mktime(0,0,0,$mois, $jour, $annee); @@ -518,264 +425,345 @@ function http_calendrier_clics($annee, $mois, $jour, $script, $ancre) # dispose les evenements d'une semaine -function http_calendrier_init_semaine($date, $echelle, $partie_cal, $script, $evt) +function http_calendrier_semaine($annee, $mois, $jour, $echelle, $partie_cal, $script, $ancre, $evt) { - global $couleur_claire, $couleur_foncee, $spip_ecran, $spip_lang_left; - $jour_today = journum($date); - $mois_today = mois($date); - $annee_today = annee($date); + global $couleur_claire, $couleur_foncee, $spip_ecran; - list($articles, $evenements) = $evt; - list($script, $nav) = http_calendrier_script($script); + $init = date("w",mktime(1,1,1,$mois,$jour,$annee)); + $init = $jour+1-($init ? $init : 7); - if ($partie_cal == "soir") { - $debut = 12; - $fin = 23; - } else if ($partie_cal == "matin") { - $debut = 4; - $fin = 15; - } else { - $debut = 7; - $fin =20; - } - - if ($spip_ecran == "large") $largeur = 90; - else $largeur = 60; + return + "\n<table class='calendrier-table-$spip_ecran' cellspacing='0' cellpadding='0'>" . + http_calendrier_semaine_navigation($annee, $mois, $init, $echelle, $partie_cal, $script, $ancre) . + http_calendrier_semaine_noms($annee, $mois, $init, $script, $ancre) . + http_calendrier_semaine_sept($annee, $mois, $init, $echelle, $partie_cal, $evt) . + "</table>" . + http_calendrier_sans_date($annee, $mois,$evt[0]) . + (_DIR_RESTREINT ? "" : http_calendrier_aide_mess()); +} - $jour_semaine = date("w",mktime(1,1,1,$mois_today,$jour_today,$annee_today)); - if ($jour_semaine==0) $jour_semaine=7; - $intitul = array(); - $liens = array(); +function http_calendrier_semaine_navigation($annee, $mois, $jour, $echelle, $partie_cal, $script, $ancre){ + + $fin = mktime (1,1,1,$mois, $jour+6, $annee); + $fjour = date("d",$fin); + $fmois = date("m",$fin); + $fannee = date("Y",$fin); + $fin = date("Y-m-d", $fin); + $debut = mktime (1,1,1,$mois, $jour, $annee); + $djour = date("d",$debut)+0; + $dmois = date("m",$debut); + $dannee = date("Y",$debut); + $debut = date("Y-m-d", $debut); + $periode = (($dannee != $fannee) ? + (affdate($debut)." - ".affdate($fin)) : + (($dmois == $fmois) ? + ($djour ." - ".affdate_jourcourt($fin)) : + (affdate_jourcourt($debut)." - ".affdate_jourcourt($fin)))); + + return + "\n<tr><td colspan='7'>" . + http_calendrier_navigation($annee, + $mois, + $jour, + $echelle, + $partie_cal, + $periode, + $script, + "mois=$dmois&annee=$dannee&jour=".($djour-7), + "mois=$fmois&annee=$fannee&jour=".($fjour+1), + 'semaine', + $ancre) . + "</td></tr>\n"; +} + +function http_calendrier_semaine_noms($annee, $mois, $jour, $script, $ancre){ + global $couleur_claire, $couleur_foncee, $spip_ecran; $href = $script . (ereg('[?&]$', $script) ? '' : (strpos($script,'?') ? '&' : '?')) . "type=jour"; - for ($j=0; $j<7;$j++){ - $nom = mktime(0,0,0,$mois_today,$jour_today-$jour_semaine+$j+1,$annee_today); - $date = date("Y-m-d", $nom); - $v = array('date' => date("Ymd", $nom), - 'nom' => nom_jour($date), - 'jour' => journum($date), - 'mois' => mois($date), - 'annee' => annee($date), - 'index' => date("w", $nom)); - $intitul[$j] = $v; - $liens[$j] = - http_href(($href . - "&jour=" . - $v['jour'] . - "&mois=" . - $v['mois'] . - "&annee=" . - $v['annee'] . - $nav), - ($v['nom'] . - " " . - $v['jour'] . - (($v['jour'] ==1) ? 'er' : '') . - ($nav ? ('/' . (0+$v['mois'])) : '')), - '', - 'color:black;'); + + $bandeau = ''; + for ($j=$jour; $j<$jour+7;$j++){ + $nom = mktime(0,0,0,$mois,$j,$annee); + $num = intval(date("d", $nom)) ; + $numois = date("m",$nom); + $nomjour = _T('date_jour_'. (1+date('w',$nom))); + $bandeau .= + "\n\t<th class='calendrier-th'>" . + http_href(($href . + "&jour=" . + $num . + "&mois=" . + $numois . + "&annee=" . + date("Y",$nom) . + $ancre), + ($nomjour . + " " . + $num . + (($num == 1) ? 'er' : '') . + ($ancre ? ('/' . $numois) : '')), + '', + 'color:black;') . + "</th>"; } + return "\n<tr style='background-color: $couleur_claire'>$bandeau\n</tr>" ; +} - list($dimheure, $dimjour, $fontsize, $padding) = - calendrier_echelle($debut, $fin, $echelle); +function http_calendrier_semaine_sept($annee, $mois, $jour, $echelle, $partie_cal, $evt) +{ + global $couleur_claire, $couleur_foncee, $spip_ecran, $spip_lang_left; - $today=getdate(time()); - $jour_t = $today["mday"]; - $mois_t = $today["mon"]; - $annee_t = $today["year"]; + $largeur = ($spip_ecran == "large") ? 90 : 60; + + $today=date("Ymd"); $total = ''; - foreach($intitul as $k => $v) { - $d = $v['date']; - $total .= "\n<td style='width: 14%; vertical-align: top'>" . - "<div style='color: #999999; background-color: " . - (($v['index'] == 0) ? - $couleur_claire : - (($v['jour'] == $jour_t AND - $v['mois'] == $mois_t AND - $v['annee'] == $annee_t) ? - "white" : - "#eeeeee")) . - "; position: relative; height: ${dimjour}px; font-size: ${fontsize}px;\n" . - " border-$spip_lang_left: 1px solid $couleur_claire; border-bottom: 1px solid $couleur_claire;'>" . - http_calendrier_jour_ics($debut,$fin,$largeur, $echelle, $evenements[$d], $d). - "</div>" . - http_calendrier_jour_trois($articles[$d], 0, $dimjour, $fontsize, $couleur_claire) . + for ($j=$jour; $j<$jour+7;$j++){ + $v = mktime(0,0,0,$mois, $j, $annee); + $total .= "\n<td class='calendrier-td'>" . + http_calendrier_ics($annee,$mois,$j, $echelle, $partie_cal, $largeur, $evt, + (" background-color: " . + ((!date("w",$v)) ? + $couleur_claire : + ((date("Ymd", $v) == $today) ? "white" : + "#eeeeee")) . + "; border-$spip_lang_left: 1px solid $couleur_claire; border-bottom: 1px solid $couleur_claire;")) . "\n</td>"; } - $debut = date("Y-m-d",mktime (1,1,1,$mois_today, $jour_today-$jour_semaine+1, $annee_today)); - $fin = date("Y-m-d",mktime (1,1,1,$mois_today, $jour_today-$jour_semaine+7, $annee_today)); + return "\n<tr class='calendrier-verdana10'>$total</tr>"; +} - return - "\n<table class='calendrier-table-$spip_ecran' cellspacing='0' cellpadding='0'>" . - "\n<tr><td colspan='7'>" . - http_calendrier_navigation($jour_today, - $mois_today, - $annee_today, - $partie_cal, - $echelle, - ((annee($debut) != annee($fin)) ? - (affdate($debut)." -<br />".affdate($fin)) : - ((mois($debut) == mois($fin)) ? - (journum($debut)." - ".affdate_jourcourt($fin)) : - (affdate_jourcourt($debut)." - ".affdate_jourcourt($fin)))), + +function http_calendrier_jour($annee, $mois, $jour, $echelle, $partie_cal, $script, $ancre, $evt){ + global $spip_ecran; + + return + "\n<table class='calendrier-table-$spip_ecran'>" . + "\n<tr>" . "<td class='calendrier-td-gauche'></td>" . + "<td colspan='5' class='calendrier-td-centre'>" . + http_calendrier_navigation($annee, $mois, $jour, $echelle, $partie_cal, + (nom_jour("$annee-$mois-$jour") . " " . + affdate_jourcourt("$annee-$mois-$jour")), $script, - "mois=$mois_today&annee=$annee_today&jour=".($jour_today-7), - "mois=$mois_today&annee=$annee_today&jour=".($jour_today+7), - 'semaine', - $nav) . - "</td></tr>\n" . - http_calendrier_les_jours($liens, $couleur_claire, $couleur_foncee) . - "\n<tr class='calendrier-verdana10'>$total</tr>" . - "</table>" . - http_calendrier_sans_date($articles["0"]) . - http_calendrier_aide_mess(); + "jour=".($jour-1)."&mois=$mois&annee=$annee", + "jour=".($jour+1)."&mois=$mois&annee=$annee", + 'jour', + $ancre) . + "</td>" . + "<td class='calendrier-td-droit calendrier-arial10'></td>" . + "</tr>" . + http_calendrier_jour_noms($annee, $mois, $jour, $script, $ancre) . + http_calendrier_jour_sept($annee, $mois, $jour, $echelle, $partie_cal, $script, $ancre, $evt) . + "</table>"; } -// agenda mensuel - -function http_calendrier_agenda ($mois, $annee, $jour_ved, $mois_ved, $annee_ved, $semaine = false, $script='', $ancre='', $evt='') { +function http_calendrier_jour_noms($annee, $mois, $jour, $script, $ancre){ + global $spip_ecran; - if (!$script) $script = $GLOBALS['PHP_SELF'] ; - if (!strpos($script, '?')) $script .= '?'; - if (!$mois) {$mois = 12; $annee--;} - elseif ($mois==13) {$mois = 1; $annee++;} - if (!$evt) $evt = sql_calendrier_agenda($mois, $annee); - return - "<div class='calendrier-titre calendrier-arial10'>" . - http_href($script . "mois=$mois&annee=$annee$ancre", - affdate_mois_annee("$annee-$mois-1"), - '', - 'color: black;') . - "<table width='100%' cellspacing='0' cellpadding='0'>" . - http_calendrier_agenda_rv ($annee, $mois, $evt, - 'http_jour_clic', array($script, $ancre), - $jour_ved, $mois_ved, $annee_ved, - $semaine) . - "</table>" . - "</div>"; + $gauche = (_DIR_RESTREINT || ($spip_ecran != "large")); + return + "\n<tr><td class='calendrier-td-gauche'>" . + ($gauche ? '' : + http_calendrier_ics_titre($annee,$mois,$jour-1,$script)) . + "</td><td colspan='5' class='calendrier-td-centre'>" . + (_DIR_RESTREINT ? '' : + ("\n\t<div class='calendrier-titre'>" . + http_calendrier_ics_message($annee, $mois, $jour, true) . + '</div>')) . + "</td><td class='calendrier-td-droit calendrier-arial10'> " . + (_DIR_RESTREINT ? '' : http_calendrier_ics_titre($annee,$mois,$jour+1,$script)) . + "</td></tr>"; } -function http_jour_clic($annee, $mois, $jour, $type, $couleur, $perso) -{ +function http_calendrier_jour_sept($annee, $mois, $jour, $echelle, $partie_cal, $script, $ancre, $evt){ + global $spip_ecran; - list($script, $ancre) = $perso; + $gauche = (_DIR_RESTREINT || ($spip_ecran != "large")); + return + "<tr class='calendrier-verdana10'>" . + # afficher en reduction le tableau du jour precedent + "\n<td class='calendrier-td-gauche'>" . + ($gauche ? '' : + http_calendrier_ics($annee, $mois, $jour-1, $echelle, $partie_cal, 0, $evt)) . + "</td><td colspan='5' class='calendrier-td-centre'>" . + http_calendrier_ics($annee, $mois, $jour, $echelle, $partie_cal, 300, $evt) . + '</td>' . + # afficher en reduction le tableau du jour suivant + "\n<td class='calendrier-td-droit'>" . - return http_href($script . "type=$type&jour=$jour&mois=$mois&annee=$annee$ancre", - $jour, - '', - "color: $couleur; font-weight: bold"); + (_DIR_RESTREINT ? '' : + http_calendrier_ics($annee, $mois, $jour+1, $echelle, $partie_cal, 0, $evt)) . + '</td>' . + "\n</tr>"; } -// typographie un mois sous forme d'un tableau de 7 colonnes -function http_calendrier_agenda_rv ($annee, $mois, $les_rv, $fclic, $perso='', - $jour_ved='', $mois_ved='', $annee_ved='', - $semaine='') { - global $couleur_foncee; - global $spip_lang_left, $spip_lang_right; +// Conversion d'un tableau de champ ics en des balises div positionnees +// Les $evenements a $date commencant a $debut heure et finissant a $fin heure// ont des couleurs definies par calendrier_div_style +// $echelle est le nombre de secondes representees par 1 pixel - // Former une date correcte (par exemple: $mois=13; $annee=2003) - $date_test = date("Y-m-d", mktime(0,0,0,$mois, 1, $annee)); - $mois = mois($date_test); - $annee = annee($date_test); - if ($semaine) - { - $jour_semaine_valide = date("w",mktime(1,1,1,$mois_ved,$jour_ved,$annee_ved)); - if ($jour_semaine_valide==0) $jour_semaine_valide=7; - $debut = mktime(1,1,1,$mois_ved,$jour_ved-$jour_semaine_valide+1,$annee_ved); - $fin = mktime(1,1,1,$mois_ved,$jour_ved-$jour_semaine_valide+7,$annee_ved); - } else { $debut = $fin = '';} +function http_calendrier_ics($annee, $mois, $jour,$echelle, $partie_cal, $largeur, $evt, $style='') { + global $spip_lang_left; + + // tableau + if ($partie_cal == "soir") { + $debut = 12; + $fin = 23; + } else if ($partie_cal == "matin") { + $debut = 4; + $fin = 15; + } else { + $debut = 7; + $fin =20; + } - $today=getdate(time()); - $jour_today = $today["mday"]; - $cemois = ($mois == $today["mon"] AND $annee == $today["year"]); + if ($echelle==0) $echelle = DEFAUT_D_ECHELLE; + + list($dimheure, $dimjour, $fontsize, $padding) = + calendrier_echelle($debut, $fin, $echelle); + $modif_decalage = round($largeur/8); + + $date = date("Ymd", mktime(0,0,0,$mois, $jour, $annee)); + list($sansheure, $avecheure) = $evt; + $avecheure = $avecheure[$date]; + $sansheure = $sansheure[$date]; $total = ''; - $ligne = ''; - $jour_semaine = date("w", mktime(1,1,1,$mois,1,$annee)); - if ($jour_semaine==0) $jour_semaine=7; - for ($i=1;$i<$jour_semaine;$i++) $ligne .= "\n\t<td></td>"; - $style0 = "border: 1px solid $couleur_foncee;"; - for ($j=1; (checkdate($mois,$j,$annee)); $j++) { - $nom = mktime(1,1,1,$mois,$j,$annee); - $jour_semaine = date("w",$nom); - if ($jour_semaine==0) $jour_semaine=7; - if ($j == $jour_ved AND $mois == $mois_ved AND $annee == $annee_ved) { - $class= 'calendrier-arial11 calendrier-demiagenda'; - $style = $style0; - $type = 'jour'; - $couleur = "black"; - } else if ($semaine AND $nom >= $debut AND $nom <= $fin) { - $class= 'calendrier-arial11 calendrier-demiagenda' . - (($jour_semaine==1) ? " calendrier-$spip_lang_left" : - (($jour_semaine==7) ? " calendrier-$spip_lang_right" : - '')); - $style = $style0; - $type = ($semaine ? 'semaine' : 'jour') ; - $couleur = "black"; - } else { - if ($j == $jour_today AND $cemois) { - $style = "background-color: $couleur_foncee"; - $couleur = "white"; - } else { - if ($jour_semaine == 7) { - $style = "background-color: #aaaaaa"; - $couleur = 'white'; - } else { - $style = "background-color: #ffffff"; - $couleur = "#aaaaaa"; + if ($avecheure) + { + $tous = 1 + count($avecheure); + $i = 0; + foreach($avecheure as $evenement){ + + $d = $evenement['DTSTART']; + $e = $evenement['DTEND']; + $d_jour = substr($d,0,8); + $e_jour = substr($e,0,8); + $debut_avant = false; + $fin_apres = false; + + $radius_top = " radius-top"; + $radius_bottom = " radius-bottom"; + + if ($d_jour <= $date AND $e_jour >= $date) + { + + $i++; + + // Verifier si debut est jour precedent + if (substr($d,0,8) < $date) + { + $heure_debut = 0; $minutes_debut = 0; + $debut_avant = true; + $radius_top = ""; } - if ($les_rv[$j] > 0) { - $style = "background-color: #ffffff"; - $couleur = "black"; + else + { + $heure_debut = substr($d,-6,2); + $minutes_debut = substr($d,-4,2); } - } - $class= 'calendrier-arial11 calendrier-agenda'; - $type = ($semaine ? 'semaine' : 'jour') ; - } - $ligne .= "\n\t<td><div class='$class' style='$style'>" . - $fclic($annee,$mois, $j, $type, $couleur, $perso) . - "</div></td>"; - if ($jour_semaine==7) - { - $total .= "\n<tr>$ligne\n</tr>"; - $ligne = ''; - } - } - return $total . (!$ligne ? '' : "\n<tr>$ligne\n</tr>"); -} - -# si la largeur le permet, les evenements sans duree, -# se placent a cote des autres, sinon en dessous + if (!$e) + { + $heure_fin = $heure_debut ; + $minutes_fin = $minutes_debut ; + $haut = 0; + $bordure = "border-bottom: dashed 2px"; + } + else + { + $bordure = "border: 1px solid"; + if (substr($e,0,8) > $date) + { + $heure_fin = 23; $minutes_fin = 59; + $fin_apres = true; + $radius_bottom = ""; + } + else + { + $heure_fin = substr($e,-6,2); + $minutes_fin = substr($e,-4,2); + } + } + + if ($debut_avant && $fin_apres) $opacity = "-moz-opacity: 0.6; filter: alpha(opacity=60);"; + else $opacity = ""; + + + $haut = calendrier_top ("$heure_debut:$minutes_debut", $debut, $fin, $dimheure, $dimjour, $fontsize); + $bas = calendrier_top ("$heure_fin:$minutes_fin", $debut, $fin, $dimheure, $dimjour, $fontsize); + $hauteur = calendrier_height ("$heure_debut:$minutes_debut", "$heure_fin:$minutes_fin", $debut, $fin, $dimheure, $dimjour, $fontsize); + if ($bas_prec > $haut) $decale += $modif_decalage; + else $decale = (4 * $fontsize); + if ($bas > $bas_prec) $bas_prec = $bas; + $url = $evenement['URL']; + $desc = propre($evenement['DESCRIPTION']); + $perso = $evenement['ATTENDEE']; + $lieu = $evenement['LOCATION']; + $sum = ereg_replace(' +',' ', typo($evenement['SUMMARY'])); + if (!$sum) { $sum = $desc; $desc = '';} + if (!$sum) { $sum = $lieu; $lieu = '';} + if (!$sum) { $sum = $perso; $perso = '';} + if ($sum) + $sum = "<span class='calendrier-verdana10'><b>$sum</b>$lieu $perso</span>"; + if (($largeur > 90) && $desc) + $sum .= "\n<br /><span style='color: black'>$desc</span>"; + $colors = calendrier_div_style($evenement); + if ($colors) + { + list($bcolor,$fcolor) = $colors; + } + else + { + $bcolor = 'white'; + $fcolor = 'black'; + } + $total .= "\n<div class='calendrier-arial10$radius_top$radius_bottom' + style='cursor: auto; position: absolute; overflow: hidden;$opacity z-index: " . + $i . + "; $spip_lang_left: " . + $decale . + "px; top: " . + $haut . + "px; height: " . + $hauteur . + "px; width: ". + ($largeur - 2 * ($padding+1)) . + "px; font-size: ". + floor($fontsize * 1.3) . + "px; padding: " . + $padding . + "px; background-color: " . + $bcolor . + ";color: " . + $fcolor . + "; $bordure $fcolor;' + onmouseover=\"this.style.zIndex=" . $tous . "\" + onmouseout=\"this.style.zIndex=" . $i . "\">" . + ((!$url) ? + $sum : + http_href($url, $sum, $desc,"color: $fcolor")) . + "</div>"; + } + } + } + return + "\n<div class='calendrier-jour' style='height: ${dimjour}px; font-size: ${fontsize}px;" . + ($style ? $style : " background-color: white; border: 1px solid #aaaaaa;") . + "'>\n" . + http_calendrier_ics_grille($debut, $fin, $dimheure, $dimjour, $fontsize) . + $total . + "\n</div>" . + (!$sansheure ? "" : + http_calendrier_ics_trois($sansheure, $largeur, $dimjour, $fontsize, '')) ; -function http_calendrier_jour_trois($evt, $largeur, $dimjour, $fontsize, $border) -{ - global $spip_lang_left, $couleur_claire; - if (!$evt) return ''; - $types = array(); - foreach($evt as $v) $types[$v['CATEGORIES']][] = $v; - $res = ''; - foreach ($types as $k => $v) { - $res .= "\n<div class='calendrier-verdana10 calendrier-titre'>". - _T($k) . - "</div>" . - http_calendrier_ics($v); - } - - $pos = ((_DIR_RESTREINT || $largeur) ? "-$dimjour" : 0); - if ($largeur) $largeur += (5*$fontsize); - else if (_DIR_RESTREINT) $largeur = (3*$fontsize); - - return "\n<div style='position: relative; z-index: 2; top: ${pos}px; margin-$spip_lang_left: " . $largeur . "px'>$res</div>"; } # Affiche une grille horaire # Selon l'echelle demandee, on affiche heure, 1/2 heure 1/4 heure, 5minutes. -function http_calendrier_heures($debut, $fin, $dimheure, $dimjour, $fontsize) +function http_calendrier_ics_grille($debut, $fin, $dimheure, $dimjour, $fontsize) { global $spip_lang_left, $spip_lang_right; $slice = floor($dimheure/(2*$fontsize)); @@ -789,7 +777,7 @@ function http_calendrier_heures($debut, $fin, $dimheure, $dimjour, $fontsize) $gras = "calendrier-heure" . ($j ? "face" : "pile"); $total .= "\n<div class='$gras' style='$spip_lang_left: 0px; top: ". - http_cal_top ("$i:".sprintf("%02d",floor(($j*60)/$slice)), $debut, $fin, $dimheure, $dimjour, $fontsize) . + calendrier_top ("$i:".sprintf("%02d",floor(($j*60)/$slice)), $debut, $fin, $dimheure, $dimjour, $fontsize) . "px;'>$i:" . sprintf("%02d",floor(($j*60)/$slice)) . "</div>"; @@ -799,34 +787,103 @@ function http_calendrier_heures($debut, $fin, $dimheure, $dimjour, $fontsize) return "\n<div class='calendrier-heurepile' style='border: 0px; $spip_lang_left: 0px; top: 2px;'>0:00</div>" . $total . "\n<div class='calendrier-heurepile' style='$spip_lang_left: 0px; top: ". - http_cal_top ("$fin:00", $debut, $fin, $dimheure, $dimjour, $fontsize). + calendrier_top ("$fin:00", $debut, $fin, $dimheure, $dimjour, $fontsize). "px;'>$fin:00</div>" . "\n<div class='calendrier-heurepile' style='border: 0px; $spip_lang_left: 0px; top: ". ($dimjour - $fontsize - 2) . "px;'>23:59</div>"; } - -// Conversion d'un tableau de champ ics en des balises div successives -// un champ CATEGORIES numerique indique un evenement avec heure - -function http_calendrier_ics($evenements, $amj = "") +# si la largeur le permet, les evenements sans duree, +# se placent a cote des autres, sinon en dessous + +function http_calendrier_ics_trois($evt, $largeur, $dimjour, $fontsize, $border) +{ + global $spip_lang_left; + + $types = array(); + foreach($evt as $v) $types[$v['CATEGORIES']][] = $v; + $res = ''; + foreach ($types as $k => $v) { + $res2 = ''; + foreach ($v as $evenement) { + list($ev, $style, $class) = + http_calendrier_sans_heure($evenement); + $res2 .= "\n<div class='$class' style='$style'>$ev\n</div>\n"; + } + $res .= "\n<div class='calendrier-verdana10 calendrier-titre'>". + _T($k) . + "</div>" . + $res2; + } + + $pos = ((_DIR_RESTREINT || ($largeur > 90)) ? "-$dimjour" : 0); + if ($largeur > 90) $largeur += (5*$fontsize); + else $largeur = _DIR_RESTREINT ? (3*$fontsize) : 0; + + return "\n<div style='position: relative; z-index: 2; top: ${pos}px; margin-$spip_lang_left: " . $largeur . "px'>$res</div>"; +} + +function http_calendrier_ics_titre($annee, $mois, $jour,$script) +{ + $date = mktime(0,0,0,$mois, $jour, $annee); + $jour = date("d",$date); + $mois = date("m",$date); + $annee = date("Y",$date); + + return "<div class='calendrier-arial10 calendrier-titre'>" . + http_href("$script?type=jour&jour=$jour&mois=$mois&annee=$annee", + affdate_jourcourt("$annee-$mois-$jour"), + '', + 'color:black;') . + "</div>"; +} + +function http_calendrier_ics_message($annee, $mois, $jour, $large) +{ + global $bleu, $vert,$jaune; + $b = _T("lien_nouvea_pense_bete"); + $v = _T("lien_nouveau_message"); + $j= _T("lien_nouvelle_annonce"); + $href = "message_edit.php3?rv=$annee-$mois-$jour&new=oui"; + return + http_href("$href&type=pb", + $bleu . ($large ? $b : ''), + $b, + 'color: blue;', + 'calendrier-arial10') . + "\n" . + http_href("$href&type=normal", + $vert . ($large ? $v : ''), + $v, + 'color: green;', + 'calendrier-arial10') . + (($GLOBALS['connect_statut'] != "0minirezo") ? "" : + ("\n" . + http_href("$href&type=affich", + $jaune . ($large ? $j : ''), + $j, + 'color: #ff9900;', + 'calendrier-arial10'))); +} + +function http_calendrier_sans_date($annee, $mois, $evenements) { - $res = ''; - if ($evenements) - { - foreach ($evenements as $evenement) - { - list($ev, $style, $class) = - is_int($evenement['CATEGORIES']) ? - http_calendrier_avec_heure($evenement, $amj) : - http_calendrier_sans_heure($evenement); - $res .= "\n<div class='$class' style='$style'>$ev\n</div>\n"; - } - } - return $res; + $r = $evenements[0+($annee . $mois . "00")]; + if (!$r) return ""; + $res = "\n<div class='calendrier-arial10 calendrier-titre'>". + _T('info_mois_courant'). + "</div>"; + foreach ($r as $evenement) + { + list($ev, $style, $class) = + http_calendrier_sans_heure($evenement); + $res .= "\n<div class='$class' style='$style'>$ev\n</div>\n"; + } + return $res; } + function http_calendrier_sans_heure($evenement) { if ($evenement['CATEGORIES'] == 'info_articles') @@ -898,274 +955,268 @@ $opacity background-color: $b; color: $c; border: 1px solid $c", "calendrier-arial10$radius_top$radius_bottom"); } -// Conversion d'un tableau de champ ics en des balises div positionnees -// Les $evenements a $date commencant a $debut heure et finissant a $fin heure// ont des couleurs definies par calendrier_div_style -// $echelle est le nombre de secondes representees par 1 pixel - -function http_calendrier_jour_ics($debut, $fin, $largeur, $echelle, $evenements, $date) { - global $spip_lang_left; - - if ($echelle==0) $echelle = DEFAUT_D_ECHELLE; - +function http_calendrier_aide_mess() +{ + global $bleu, $vert, $jaune, $spip_lang_left; + return + "\n<br /><br /><br />\n<font face='arial,helvetica,sans-serif' size='2'><table width='700'>\n<tr><th style='text-align: $spip_lang_left'> " . + "<b>"._T('info_aide')."</b>" . + "</th></tr><tr><td>$bleu\n"._T('info_symbole_bleu')."\n" . + "</td></tr><tr><td>$vert\n"._T('info_symbole_vert')."\n" . + "</th></tr><tr><td>$jaune\n"._T('info_symbole_jaune')."\n" . + "</td></tr>\n</table></font>"; + } - list($dimheure, $dimjour, $fontsize, $padding) = calendrier_echelle($debut, $fin, $echelle); - $modif_decalage = round($largeur/8); +# Bandeau superieur d'un calendrier selon son $type (jour/mois/annee): +# 2 icones vers les 2 autres types, a la meme date $jour $mois $annee +# 2 icones de loupes pour zoom sur la meme date et le meme type +# 2 fleches appelant le $script sur les periodes $pred/$suiv avec une $ancre +# et le $nom du calendrier - $total = ''; +function http_calendrier_navigation($annee, $mois, $jour, $echelle, $partie_cal, $nom, $script, $args_pred, $args_suiv, $type, $ancre) +{ + global $spip_lang_right, $spip_lang_left, $couleur_foncee; - if ($evenements) - { - $tous = 1 + count($evenements); - $i = 0; - foreach($evenements as $evenement){ + if (!isset($couleur_foncee)) $couleur_foncee = '#aaaaaa'; + if (!$echelle) $echelle = DEFAUT_D_ECHELLE; - $d = $evenement['DTSTART']; - $e = $evenement['DTEND']; - $d_jour = substr($d,0,8); - $e_jour = substr($e,0,8); - $debut_avant = false; - $fin_apres = false; - - $radius_top = " radius-top"; - $radius_bottom = " radius-bottom"; - - if ($d_jour <= $date AND $e_jour >= $date) - { + if (!ereg('[?&]$', $script)) $script .= (strpos($script,'?') ? '&' : '?'); + $args = "jour=$jour&mois=$mois&annee=$annee$ancre"; + + $today=getdate(time()); + $jour_today = $today["mday"]; + $mois_today = $today["mon"]; + $annee_today = $today["year"]; - $i++; + $id = 'nav-agenda' .ereg_replace('[^A-Za-z0-9]', '', $ancre); - // Verifier si debut est jour precedent - if (substr($d,0,8) < $date) - { - $heure_debut = 0; $minutes_debut = 0; - $debut_avant = true; - $radius_top = ""; - } - else - { - $heure_debut = substr($d,-6,2); - $minutes_debut = substr($d,-4,2); - } + return + "<div class='navigation-calendrier calendrier-moztop8'\nstyle='background-color: $couleur_foncee;'>" + . "<div style='float: $spip_lang_right; padding-left: 5px; padding-right: 5px;'>" + . (($type == "mois") ? '' : + ( + http_href_img(("$script$args&type=$type&set_partie_cal=tout"), + "heures-tout.png", + "class='calendrier-png" . + (($partie_cal == "tout") ? " calendrier-opacity'" : "'"), + _T('cal_jour_entier')) + .http_href_img(("$script$args&type=$type&set_partie_cal=matin"), + "heures-am.png", + "class='calendrier-png" . + (($partie_cal == "matin") ? " calendrier-opacity'" : "'"), + _T('cal_matin')) - if (!$e) - { - $heure_fin = $heure_debut ; - $minutes_fin = $minutes_debut ; - $haut = 0; - $bordure = "border-bottom: dashed 2px"; - } - else - { - $bordure = "border: 1px solid"; - if (substr($e,0,8) > $date) - { - $heure_fin = 23; $minutes_fin = 59; - $fin_apres = true; - $radius_bottom = ""; - } - else - { - $heure_fin = substr($e,-6,2); - $minutes_fin = substr($e,-4,2); - } - } - - if ($debut_avant && $fin_apres) $opacity = "-moz-opacity: 0.6; filter: alpha(opacity=60);"; - else $opacity = ""; - - - $haut = http_cal_top ("$heure_debut:$minutes_debut", $debut, $fin, $dimheure, $dimjour, $fontsize); - $bas = http_cal_top ("$heure_fin:$minutes_fin", $debut, $fin, $dimheure, $dimjour, $fontsize); - $hauteur = http_cal_height ("$heure_debut:$minutes_debut", "$heure_fin:$minutes_fin", $debut, $fin, $dimheure, $dimjour, $fontsize); - if ($bas_prec > $haut) $decale += $modif_decalage; - else $decale = (4 * $fontsize); - if ($bas > $bas_prec) $bas_prec = $bas; - $url = $evenement['URL']; - $desc = propre($evenement['DESCRIPTION']); - $perso = $evenement['ATTENDEE']; - $lieu = $evenement['LOCATION']; - $sum = ereg_replace(' +',' ', typo($evenement['SUMMARY'])); - if (!$sum) { $sum = $desc; $desc = '';} - if (!$sum) { $sum = $lieu; $lieu = '';} - if (!$sum) { $sum = $perso; $perso = '';} - if ($sum) - $sum = "<span class='calendrier-verdana10'><b>$sum</b>$lieu $perso</span>"; - if (($largeur > 90) && $desc) - $sum .= "\n<br /><span style='color: black'>$desc</span>"; - $colors = calendrier_div_style($evenement); - if ($colors) - { - list($bcolor,$fcolor) = $colors; - } - else - { - $bcolor = 'white'; - $fcolor = 'black'; - } - $total .= "\n<div class='calendrier-arial10$radius_top$radius_bottom' - style='cursor: auto; position: absolute; overflow: hidden;$opacity z-index: " . - $i . - "; $spip_lang_left: " . - $decale . - "px; top: " . - $haut . - "px; height: " . - $hauteur . - "px; width: ". - ($largeur - 2 * ($padding+1)) . - "px; font-size: ". - floor($fontsize * 1.3) . - "px; padding: " . - $padding . - "px; background-color: " . - $bcolor . - ";color: " . - $fcolor . - "; $bordure $fcolor;' - onmouseover=\"this.style.zIndex=" . $tous . "\" - onmouseout=\"this.style.zIndex=" . $i . "\">" . - ((!$url) ? - $sum : - http_href($url, $sum, $desc,"color: $fcolor")) . - "</div>"; - } - } - } - return - http_calendrier_heures($debut, $fin, $dimheure, $dimjour, $fontsize) . - $total ; -} + .http_href_img(("$script$args&type=$type&set_partie_cal=soir"), + "heures-pm.png", + "class='calendrier-png" . + (($partie_cal == "soir") ? " calendrier-opacity'" : "'"), + _T('cal_apresmidi')) + . " " + . http_href_img(("$script$args&type=$type&set_echelle=" . + floor($echelle * 1.5)), + "loupe-moins.gif", + '', + _T('info_zoom'). '-') + . http_href_img(("$script$args&type=$type&set_echelle=" . + floor($echelle / 1.5)), + "loupe-plus.gif", + '', + _T('info_zoom'). '+') + )) + . http_href_img(("$script$args&type=jour&echelle=$echelle"),"cal-jour.gif", + (($type == 'jour') ? " class='calendrier-opacity'" : ''), + _T('cal_par_jour')) -function http_calendrier_init_jour($date, $echelle, $partie_cal, $script, $evt){ - global $spip_ecran; - $jour = journum($date); - $mois = mois($date); - $annee = annee($date); - list($script, $ancre) = http_calendrier_script($script); - $gauche = (_DIR_RESTREINT || ($spip_ecran != "large")); - return - "\n<table class='calendrier-table-$spip_ecran'>" . - "\n<tr><td class='calendrier-td-gauche'> " . - "</td><td colspan='5' class='calendrier-td-centre'>" . - http_calendrier_navigation($jour, $mois, $annee, $partie_cal, $echelle, - (nom_jour("$annee-$mois-$jour") . " " . - affdate_jourcourt("$annee-$mois-$jour")), - $script, - "jour=".($jour-1)."&mois=$mois&annee=$annee", - "jour=".($jour+1)."&mois=$mois&annee=$annee", - 'jour', - $nav) . - "</td><td class='calendrier-td-droit calendrier-arial10'> " . - "</td></tr>" . - "\n<tr><td class='calendrier-td-gauche'>" . - ($gauche ? '' : - http_calendrier_entetecol($script, $jour-1,$mois,$annee)) . - "</td><td colspan='5' class='calendrier-td-centre'>" . - (_DIR_RESTREINT ? '' : - ("\n\t<div class='calendrier-titre'>" . - http_calendrier_message3($script,$jour,$mois,$annee) . - '</div>')) . - "</td><td class='calendrier-td-droit calendrier-arial10'> " . - (_DIR_RESTREINT ? '' : http_calendrier_entetecol($script, $jour+1,$mois,$annee)) . - "</td></tr><tr>" . - # afficher en reduction le tableau du jour precedent - "\n<td class='calendrier-td-gauche calendrier-arial10'>" . - ($gauche ? '' : - http_calendrier_jour($jour-1,$mois,$annee, 0, $partie_cal, $echelle, 0, $script, $ancre, $evt)) . - "</td><td colspan='5' class='calendrier-td-centre'>" . - http_calendrier_jour($jour,$mois,$annee, 300, $partie_cal, $echelle, 0, $script, $ancre, $evt) . - '</td>' . - # afficher en reduction le tableau du jour suivant - "\n<td class='calendrier-td-droit calendrier-arial10'>" . + . http_href_img("$script$args&type=semaine&echelle=$echelle", "cal-semaine.gif", + (($type == 'semaine') ? " class='calendrier-opacity'" : "" ), + _T('cal_par_semaine')) - (_DIR_RESTREINT ? '' : - http_calendrier_jour($jour+1,$mois,$annee, 0, $partie_cal, $echelle, 0, $script, $ancre, $evt)) . - '</td>' . - "\n</tr></table>"; + . http_href_img("$script$args&type=mois&echelle=$echelle","cal-mois.gif", + (($type == 'mois') ? " class='calendrier-opacity'" : "" ), + _T('cal_par_mois')) + . "</div>" + . " " + . http_href_img($script . "type=$type&echelle=$echelle&jour=$jour_today&mois=$mois_today&annee=$annee_today$ancre", + "cal-today.gif", + (" onmouseover=\"montrer('$id');\"" . + (($annee == $annee_today && $mois == $mois_today && (($type == 'mois') || ($jour == $jour_today))) + ? " class='calendrier-opacity'" : "")), + _T("info_aujourdhui")) + . " " + . (!$args_pred ? '' : + http_href($script . "type=$type&echelle=$echelle&$args_pred$ancre", + http_img_pack("fleche-$spip_lang_left.png", '<<<', "class='calendrier-png'"), + _T('precedent'))) + . (!$args_suiv ? '' : + http_href(($script . "type=$type&echelle=$echelle&$args_suiv$ancre"), + http_img_pack("fleche-$spip_lang_right.png", '>>>', "class='calendrier-png'"), + _T('suivant'))) + . " " + . $nom + . (_DIR_RESTREINT ? '' : aide("messcalen")) + . "</div>" + . http_calendrier_invisible($annee, $mois, $jour, $script, $ancre,$id); } -function http_calendrier_entetecol($script, $jour,$mois,$annee) +// fabrique un petit agenda accessible par survol + +function http_calendrier_invisible($annee, $mois, $jour, $script, $ancre, $id) { - $date = date("Y-m-d", mktime(0,0,0,$mois, $jour, $annee)); - $jour = journum($date); - $mois = mois($date); - $annee = annee($date); - - return "<div class='calendrier-arial10 calendrier-titre'>" . - http_href("$script?type=jour&jour=$jour&mois=$mois&annee=$annee", - affdate_jourcourt("$annee-$mois-$jour"), - '', - 'color:black;') . - "</div>"; + global $spip_lang_right, $spip_lang_left, $couleur_claire; + if (!isset($couleur_claire)) $couleur_claire = 'white'; + $gadget = "<div style='position: relative;z-index: 1000;' + onmouseover=\"montrer('$id');\" + onmouseout=\"cacher('$id');\">"; + + $gadget .= "<table id='$id' class='calendrier-cadreagenda' style='position: absolute; background-color: $couleur_claire'>"; + $gadget .= "\n<tr><td colspan='3' style='text-align:$spip_lang_left;'>"; + + $annee_avant = $annee - 1; + $annee_apres = $annee + 1; + + for ($i=$mois; $i < 13; $i++) { + $gadget .= http_href($script . "mois=$i&annee=$annee_avant$ancre", + nom_mois("$annee_avant-$i-1"),'','', 'calendrier-annee') ; + } + for ($i=1; $i < $mois - 1; $i++) { + $gadget .= http_href($script . "mois=$i&annee=$annee$ancre", + nom_mois("$annee-$i-1"),'','', 'calendrier-annee'); + } + $gadget .= "</td></tr>" + . "\n<tr><td class='calendrier-tripleagenda'>" + . http_calendrier_agenda($annee, $mois-1, $jour, $mois, $annee, $GLOBALS['afficher_bandeau_calendrier_semaine'], $script,$ancre) + . "</td>\n<td class='calendrier-tripleagenda'>" + . http_calendrier_agenda($annee, $mois, $jour, $mois, $annee, $GLOBALS['afficher_bandeau_calendrier_semaine'], $script,$ancre) + . "</td>\n<td class='calendrier-tripleagenda'>" + . http_calendrier_agenda($annee, $mois+1, $jour, $mois, $annee, $GLOBALS['afficher_bandeau_calendrier_semaine'], $script,$ancre) + . "</td>" + . "</tr>" + . "\n<tr><td colspan='3' style='text-align:$spip_lang_right;'>"; + for ($i=$mois+2; $i <= 12; $i++) { + $gadget .= http_href($script. "mois=$i&annee=$annee$ancre", + nom_mois("$annee-$i-1"),'','', 'calendrier-annee'); + } + for ($i=1; $i < $mois+1; $i++) { + $gadget .= http_href($script . "mois=$i&annee=$annee_apres$ancre", + nom_mois("$annee_apres-$i-1"),'','', 'calendrier-annee'); + } + return $gadget . "</td></tr></table></div>"; } -function http_calendrier_message3($large, $jour,$mois,$annee) -{ - global $bleu, $vert,$jaune; - $b = _T("lien_nouvea_pense_bete"); - $v = _T("lien_nouveau_message"); - $j= _T("lien_nouvelle_annonce"); - $href = "message_edit.php3?rv=$annee-$mois-$jour&new=oui"; +// agenda mensuel + +function http_calendrier_agenda ($annee, $mois, $jour_ved, $mois_ved, $annee_ved, $semaine = false, $script='', $ancre='', $evt='') { + + if (!$script) $script = $GLOBALS['PHP_SELF'] ; + if (!strpos($script, '?')) $script .= '?'; + if (!$mois) {$mois = 12; $annee--;} + elseif ($mois==13) {$mois = 1; $annee++;} + if (!$evt) $evt = sql_calendrier_agenda($annee, $mois); return - http_href("$href&type=pb", - $bleu . ($large ? $b : ''), - $b, - 'color: blue;', - 'calendrier-arial10') . - "\n" . - http_href("$href&type=normal", - $vert . ($large ? $v : ''), - $v, - 'color: green;', - 'calendrier-arial10') . - (($GLOBALS['connect_statut'] != "0minirezo") ? "" : - ("\n" . - http_href("$href&type=affich", - $jaune . ($large ? $j : ''), - $j, - 'color: #ff9900;', - 'calendrier-arial10'))); + "<div class='calendrier-titre calendrier-arial10'>" . + http_href($script . "mois=$mois&annee=$annee$ancre", + affdate_mois_annee("$annee-$mois-1"), + '', + 'color: black;') . + "<table width='100%' cellspacing='0' cellpadding='0'>" . + http_calendrier_agenda_rv ($annee, $mois, $evt, + 'http_calendrier_clic', array($script, $ancre), + $jour_ved, $mois_ved, $annee_ved, + $semaine) . + "</table>" . + "</div>"; } - -function http_calendrier_jour($jour,$mois,$annee,$largeur, $partie_cal, $echelle, $le_message = 0, $script = 'calendrier.php3', $ancre='', $evt='') +function http_calendrier_clic($annee, $mois, $jour, $type, $couleur, $perso) { - global $spip_lang_left, $calendrier_message_fermeture; - - if ($partie_cal == "soir") { - $debut_cal = 12; - $fin_cal = 23; - } else if ($partie_cal == "matin") { - $debut_cal = 4; - $fin_cal = 15; - } else { - $debut_cal = 7; - $fin_cal =20; - } + list($script, $ancre) = $perso; - $date = date("Y-m-d", mktime(0,0,0,$mois, $jour, $annee)); - $jour = journum($date); - $mois = mois($date); - $annee = annee($date); - - list($articles, $messages) = - ($evt ? $evt : sql_calendrier_interval(sql_calendrier_jour($annee,$mois, $jour ))); + return http_href($script . "type=$type&jour=$jour&mois=$mois&annee=$annee$ancre", + $jour, + '', + "color: $couleur; font-weight: bold"); +} + +// typographie un mois sous forme d'un tableau de 7 colonnes + +function http_calendrier_agenda_rv ($annee, $mois, $les_rv, $fclic, $perso='', + $jour_ved='', $mois_ved='', $annee_ved='', + $semaine='') { + global $couleur_foncee; + global $spip_lang_left, $spip_lang_right; - $j = sprintf("%04d%02d%02d", $annee,$mois,$jour); + // Former une date correcte (par exemple: $mois=13; $annee=2003) + $date_test = date("Y-m-d", mktime(0,0,0,$mois, 1, $annee)); + $mois = mois($date_test); + $annee = annee($date_test); + if ($semaine) + { + $jour_semaine_valide = date("w",mktime(1,1,1,$mois_ved,$jour_ved,$annee_ved)); + if ($jour_semaine_valide==0) $jour_semaine_valide=7; + $debut = mktime(1,1,1,$mois_ved,$jour_ved-$jour_semaine_valide+1,$annee_ved); + $fin = mktime(1,1,1,$mois_ved,$jour_ved-$jour_semaine_valide+7,$annee_ved); + } else { $debut = $fin = '';} - list($dimheure, $dimjour, $fontsize, $padding) = - calendrier_echelle($debut_cal, $fin_cal, $echelle); - // faute de fermeture en PHP... - $calendrier_message_fermeture = $le_message; + $today=getdate(time()); + $jour_today = $today["mday"]; + $cemois = ($mois == $today["mon"] AND $annee == $today["year"]); - return - "<div class='calendrier-verdana10 calendrier-jour' - style='position: relative; height: ${dimjour}px; font-size: ${fontsize}px'>\n" . - http_calendrier_jour_ics($debut_cal,$fin_cal,$largeur, $echelle, $messages[$j], $j) . - "</div>" . - http_calendrier_jour_trois($articles[$j], $largeur, $dimjour, $fontsize, ''); + $total = ''; + $ligne = ''; + $jour_semaine = date("w", mktime(1,1,1,$mois,1,$annee)); + if ($jour_semaine==0) $jour_semaine=7; + for ($i=1;$i<$jour_semaine;$i++) $ligne .= "\n\t<td></td>"; + $style0 = "border: 1px solid $couleur_foncee;"; + for ($j=1; (checkdate($mois,$j,$annee)); $j++) { + $nom = mktime(1,1,1,$mois,$j,$annee); + $jour_semaine = date("w",$nom); + if ($jour_semaine==0) $jour_semaine=7; + + if ($j == $jour_ved AND $mois == $mois_ved AND $annee == $annee_ved) { + $class= 'calendrier-arial11 calendrier-demiagenda'; + $style = $style0; + $type = 'jour'; + $couleur = "black"; + } else if ($semaine AND $nom >= $debut AND $nom <= $fin) { + $class= 'calendrier-arial11 calendrier-demiagenda' . + (($jour_semaine==1) ? " calendrier-$spip_lang_left" : + (($jour_semaine==7) ? " calendrier-$spip_lang_right" : + '')); + $style = $style0; + $type = ($semaine ? 'semaine' : 'jour') ; + $couleur = "black"; + } else { + if ($j == $jour_today AND $cemois) { + $style = "background-color: $couleur_foncee"; + $couleur = "white"; + } else { + if ($jour_semaine == 7) { + $style = "background-color: #aaaaaa"; + $couleur = 'white'; + } else { + $style = "background-color: #ffffff"; + $couleur = "#aaaaaa"; + } + if ($les_rv[$j] > 0) { + $style = "background-color: #ffffff"; + $couleur = "black"; + } + } + $class= 'calendrier-arial11 calendrier-agenda'; + $type = ($semaine ? 'semaine' : 'jour') ; + } + $ligne .= "\n\t<td><div class='$class' style='$style'>" . + $fclic($annee,$mois, $j, $type, $couleur, $perso) . + "</div></td>"; + if ($jour_semaine==7) + { + $total .= "\n<tr>$ligne\n</tr>"; + $ligne = ''; + } + } + return $total . (!$ligne ? '' : "\n<tr>$ligne\n</tr>"); } // Fonction pour la messagerie et ecrire/index.php @@ -1319,6 +1370,7 @@ ORDER BY date $now = date("Ymd"); $script = 'article' . _EXTENSION_PHP . "?id_article="; } + while($row=spip_fetch_array($result)){ $amj = sql_calendrier_jour_ical($row['date']); if ((!_DIR_RESTREINT) || ($now >= $amj)) @@ -1500,7 +1552,7 @@ ORDER BY messages.date_heure"); return $r; } -function sql_calendrier_agenda ($mois, $annee) { +function sql_calendrier_agenda ($annee, $mois) { global $connect_id_auteur; $rv = array(); @@ -1520,65 +1572,4 @@ function sql_calendrier_agenda ($mois, $annee) { function sql_calendrier_jour_ical($d) { return substr($d, 0, 4) . substr($d, 5, 2) .substr($d, 8, 2); } - -// ce tableau est l'equivalent du switch affectant des globales dans inc.php -// plus 2 autres issus du inc_agenda originel - -global $contrastes; -$contrastes = array( - /// Marron - array("#8C6635","#F5EEE5","#1A64DF","#955708"), - /// Fushia - array("#CD006F","#FDE5F2","#E95503","#8F004D"), - /// Bleu - array("#5da7c5","#EDF3FE","#814E1B","#435E79"), - /// Bleu pastel - array("#766CF6","#EBE9FF","#869100","#5B55A0"), - /// Orange - array("#fa9a00","#ffeecc","#396B25","#472854"), - /// Rouge (Vermillon) - array("#FF0000","#FFEDED","#D302CE","#D40202"), - /// Orange - array("#E95503","#FFF2EB","#81A0C1","#FF5B00"), - /// Jaune - array("#ccaa00", "#ffffee", "#65659C","#6A6A43"), - /// Vert pastel - array("#009F3C","#E2FDEC","#EE0094","#02722C"), - /// Vert - array("#9DBA00", "#e5fd63","#304C38","#854270"), - /// Rouge (Bordeaux) - array("#640707","#FFE0E0","#346868","#684747"), - /// Gris - array("#3F3F3F","#F2F2F2","#854270","#666666"), - // Noir - array("black","#aaaaaa", "#000000", "#ffffff"), - /// Caca d'oie - array("#666500","#FFFFE0","#65659C","#6A6A43") - ); - -# Choisit dans le tableau ci-dessus les couleurs d'un evenement -# si l'indice fourni par CATEGORIES est negatif, inversion des plans -# +++ un hack pour le cas special de ecrire/message.php - -function calendrier_div_style($evenement) -{ - global $contrastes; - global $calendrier_message_fermeture; - if (isset($calendrier_message_fermeture) && - (ereg("=$calendrier_message_fermeture$", $evenement['URL']))) - {return array('white', 'black');} - else - { - $categ = $evenement['CATEGORIES']; - - if (!is_int($categ)) - return ""; - else - { - if ($categ >= 0) {$f=0;$b=1;$i=$categ;}else{$f=1;$b=0;$i=0-$categ;} - $i %= count($contrastes); - return array($contrastes[$i][$b], $contrastes[$i][$f]); - } - } -} ?> diff --git a/ecrire/inc_presentation.php3 b/ecrire/inc_presentation.php3 index 9578c9d7f3..42c3a9c86d 100644 --- a/ecrire/inc_presentation.php3 +++ b/ecrire/inc_presentation.php3 @@ -1994,6 +1994,11 @@ function afficher_menu_rubriques() { } +function afficher_javascript ($html) { + return http_script(" +document.write(\"" . addslashes(str_replace("\n", " ", $html))."\")"); +} + function debut_page($titre = "", $rubrique = "asuivre", $sous_rubrique = "asuivre", $onLoad = "") { global $couleurs_spip; global $couleur_foncee; @@ -2376,10 +2381,6 @@ else { // // Barre des gadgets // - function afficher_javascript ($html) { - return http_script(" -document.write(\"" . addslashes(str_replace("\n", " ", $html))."\")"); - } echo "<table width='$largeur' cellpadding='0' cellspacing='0' align='center'><tr><td>"; @@ -2548,7 +2549,7 @@ document.write(\"" . addslashes(str_replace("\n", " ", $html))."\")"); $gadget .= "<table><tr>"; $gadget .= "<td valign='top' width='200'>"; $gadget .= "<div>"; - $gadget .= http_calendrier_agenda($mois_today, $annee_today, $jour_today, $mois_today, $annee_today, false, 'calendrier.php3'); + $gadget .= http_calendrier_agenda($annee_today, $mois_today, $jour_today, $mois_today, $annee_today, false, 'calendrier.php3'); $gadget .= "</div>"; $gadget .= "</td>"; if ($afficher_cal) { diff --git a/ecrire/index.php3 b/ecrire/index.php3 index 87a73f7d9a..c94d3ac192 100644 --- a/ecrire/index.php3 +++ b/ecrire/index.php3 @@ -156,29 +156,22 @@ if ($spip_display != 4) { // Afficher le calendrier du mois s'il y a des rendez-vous // - $today = getdate(time()); - $jour_today = $today["mday"]; - $mois_today = $today["mon"]; - $annee_today = $today["year"]; - $date = date("Y-m-d", mktime(0,0,0,$mois_today, 1, $annee_today)); - $mois = mois($date); - $annee = annee($date); - $jour = jour($date); - - // rendez-vous personnels dans le mois - $evt = sql_calendrier_agenda($mois, $annee); - if ($evt) - echo http_calendrier_agenda ($mois_today, $annee_today, $jour_today, $mois_today, $annee_today, false, 'calendrier.php3', '', $evt); - - // et ceux du jour - $evt = date("Y-m-d"); - $evt = sql_calendrier_interval_rv("'$evt'", "'$evt 23:59:59'"); - - if ($evt) - { - echo http_calendrier_entetecol('calendrier.php3',$jour_today,$mois_today,$annee_today); - echo http_calendrier_jour($jour_today,$mois_today,$annee_today, 90, $partie_cal, $echelle, '', '', '', array('', $evt)); - } + $mois = date("m"); + $annee = date("Y"); + $jour = date("d"); + + $evt = sql_calendrier_agenda($annee, $mois); + if ($evt) + echo http_calendrier_agenda ($annee, $mois, $jour, $mois, $annee, false, 'calendrier.php3', '', $evt); + + // et ceux du jour + $evt = date("Y-m-d"); + $evt = sql_calendrier_interval_rv("'$evt'", "'$evt 23:59:59'"); + + if ($evt) { + echo http_calendrier_ics_titre($annee,$mois,$jour,'calendrier.php3'); + echo http_calendrier_ics($annee, $mois, $jour, $echelle, $partie_cal, 90, array('', $evt)); + } } debut_droite(); diff --git a/ecrire/message.php3 b/ecrire/message.php3 index f7c6ad8048..21a250f696 100644 --- a/ecrire/message.php3 +++ b/ecrire/message.php3 @@ -270,7 +270,7 @@ if ($row = spip_fetch_array(spip_query("SELECT * FROM spip_messages WHERE id_mes debut_gauche(); if ($rv != 'non') - echo http_calendrier_agenda ($lemois, $lannee, $lejour, $lemois, $lannee,false, 'calendrier.php3'); + echo http_calendrier_agenda ($lannee, $lemois, $lejour, $lemois, $lannee,false, 'calendrier.php3'); echo "<br />"; @@ -279,9 +279,12 @@ if ($row = spip_fetch_array(spip_query("SELECT * FROM spip_messages WHERE id_mes echo http_calendrier_rv(sql_calendrier_taches_rv(), "rv"); if ($rv != "non") { + // faute de fermeture en PHP... + $calendrier_message_fermeture = $id_message; + creer_colonne_droite(); - echo http_calendrier_entetecol('', $lejour,$lemois,$lannee); - echo http_calendrier_jour($lejour,$lemois,$lannee, 90, $partie_cal, $echelle, $id_message); + echo http_calendrier_ics_titre($lannee,$lemois,$lejour,'calendrier.php3'); + echo http_calendrier_ics($lannee,$lemois, $lejour, $echelle, $partie_cal, 90, sql_calendrier_interval(sql_calendrier_jour($lannee,$lemois, $lejour))); } debut_droite(); diff --git a/ecrire/naviguer.php3 b/ecrire/naviguer.php3 index e3f5afd16b..f03978d9d4 100644 --- a/ecrire/naviguer.php3 +++ b/ecrire/naviguer.php3 @@ -18,23 +18,20 @@ include_ecrire ("inc_mots.php3"); include_ecrire ("inc_documents.php3"); include_ecrire ("inc_abstract_sql.php3"); - -$id_rubrique = intval($id_rubrique); -$flag_mots = lire_meta("articles_mots"); - // // Gerer les modifications... // $id_parent = intval($id_parent); $id_rubrique = intval($id_rubrique); +$flag_mots = lire_meta("articles_mots"); $flag_editable = ($connect_statut == '0minirezo' AND (acces_rubrique($id_parent) OR acces_rubrique($id_rubrique))); // id_parent necessaire en cas de creation de sous-rubrique -if ($modifier_rubrique == "oui") { - calculer_rubriques(); -} -if ($titre) { +if (!$titre) { + if ($modifier_rubrique == "oui") calculer_rubriques(); +} +else { // creation, le cas echeant if ($new == 'oui' AND $flag_editable AND !$id_rubrique) { $id_rubrique = spip_abstract_insert("spip_rubriques", @@ -49,33 +46,25 @@ if ($titre) { // si c'est une rubrique-secteur contenant des breves, ne deplacer // que si $confirme_deplace == 'oui' - $query = "SELECT COUNT(*) AS cnt FROM spip_breves WHERE id_rubrique='$id_rubrique'"; - $row = spip_fetch_array(spip_query($query)); - if (($row['cnt'] > 0) and !($confirme_deplace == 'oui')) { - $id_parent = 0; - } - // verifier qu'on envoie bien dans une rubrique autorisee - if (acces_rubrique($id_parent)) { - $change_parent = "id_parent=\"$id_parent\","; - } - else { - $change_parent = ""; + if ((spip_num_rows(spip_query("SELECT id_rubrique FROM spip_breves WHERE id_rubrique='$id_rubrique' LIMIT 0,1")) > 0) + AND ($confirme_deplace != 'oui')) { + $id_parent = 0; } - $titre = addslashes($titre); - $descriptif = addslashes($descriptif); - $texte = addslashes($texte); - - if ($champs_extra) { - include_ecrire("inc_extra.php3"); - $add_extra = ", extra = '".addslashes(extra_recup_saisie("rubriques"))."'"; - } else - $add_extra = ''; - if ($flag_editable) { - $query = "UPDATE spip_rubriques SET $change_parent titre='$titre', descriptif='$descriptif', texte='$texte' $add_extra WHERE id_rubrique=$id_rubrique"; - $result = spip_query($query); + + if ($champs_extra) { + include_ecrire("inc_extra.php3"); + $champs_extra = ", extra = '".addslashes(extra_recup_saisie("rubriques"))."'"; + } + spip_query("UPDATE spip_rubriques SET " . +(acces_rubrique($id_parent) ? "id_parent=\"$id_parent\"," : "") . " +titre='" . addslashes($titre) ."', +descriptif='" . addslashes($descriptif) . "', +texte='" . addslashes($texte) . "' +$champs_extra +WHERE id_rubrique=$id_rubrique"); } calculer_rubriques(); @@ -90,7 +79,7 @@ if ($titre) { include_ecrire ("inc_index.php3"); indexer_rubrique($id_rubrique); } -} + } // // Appliquer le changement de langue @@ -114,10 +103,7 @@ if ($changer_lang AND $id_rubrique>0 AND lire_meta('multi_rubriques') == 'oui' A // infos sur cette rubrique // -$query="SELECT * FROM spip_rubriques WHERE id_rubrique='$id_rubrique'"; -$result=spip_query($query); - -while($row=spip_fetch_array($result)){ +if ($row=spip_fetch_array(spip_query("SELECT * FROM spip_rubriques WHERE id_rubrique='$id_rubrique'"))){ $id_rubrique=$row['id_rubrique']; $id_parent=$row['id_parent']; $titre=$row['titre']; @@ -187,12 +173,10 @@ if ($spip_display != 4) { // debut_raccourcis(); - $query = "SELECT id_rubrique FROM spip_rubriques LIMIT 0,1"; - $result = spip_query($query); - + icone_horizontale(_T('icone_tous_articles'), "articles_page.php3", "article-24.gif"); - if (spip_num_rows($result) > 0) { + if (spip_num_rows(spip_query("SELECT id_rubrique FROM spip_rubriques LIMIT 0,1")) > 0) { if ($id_rubrique > 0) icone_horizontale(_T('icone_ecrire_article'), "articles_edit.php3?id_rubrique=$id_rubrique&new=oui", "article-24.gif","creer.gif"); -- GitLab