[SPIP Zone] r3928 - in /_plugins_/_contenu_editorial_/Agenda: balise/ balise/calendrier_mini.php formulaires/ formulaires/calendrier_mini.html

Author: cedric@yterium.com
Date: Tue Jul 11 22:36:28 2006
New Revision: 3928

Log:
le calendrier_mini de james appliqué a l'agenda (exemple a customiser)

Added:
    _plugins_/_contenu_editorial_/Agenda/balise/
    _plugins_/_contenu_editorial_/Agenda/balise/calendrier_mini.php
    _plugins_/_contenu_editorial_/Agenda/formulaires/
    _plugins_/_contenu_editorial_/Agenda/formulaires/calendrier_mini.html

Added: _plugins_/_contenu_editorial_/Agenda/balise/calendrier_mini.php

--- _plugins_/_contenu_editorial_/Agenda/balise/calendrier_mini.php (added)
+++ _plugins_/_contenu_editorial_/Agenda/balise/calendrier_mini.php Tue Jul 11 22:36:28 2006
@@ -0,0 +1,110 @@
+<?php
+
+if (!defined("_ECRIRE_INC_VERSION")) return; #securite
+
+// Pas besoin de contexte de compilation
+global $balise_CALENDRIER_MINI_collecte;
+$balise_CALENDRIER_MINI_collecte = array('date', 'id_article','id_mot');
+
+function balise_CALENDRIER_MINI ($p) {
+ return calculer_balise_dynamique($p,'CALENDRIER_MINI', array('date', 'id_article', 'id_mot'));
+}
+
+function balise_CALENDRIER_MINI_stat($args, $filtres) {
+ return $args;
+}
+
+function balise_CALENDRIER_MINI_dyn($date, $id_article = 0, $id_mot = 0, $var_date = 'date', $url = '') {
+ if(!$url)
+ $url = self();
+ else{
+ // nettoyer l'url qui est passee par htmlentities pour raison de securités
+ $url = str_replace("&amp;","&",$url);
+ }
+ return array('formulaires/calendrier_mini', 3600,
+ array(
+ 'date' => $date,
+ 'id_article' => $id_article,
+ 'id_mot' => $id_mot,
+ 'var_date' => $var_date,
+ 'self' => $url
+ ));
+}
+
+function agenda_mini($i) {
+ $args = func_get_args();
+ $une_date = array_shift($args); // une date comme balise
+ $sinon = array_shift($args);
+ if (!$une_date) return $sinon;
+ $type = 'mini';
+ $agenda = Agenda_memo_full(0);
+ $evt = array();
+ foreach (($args ? $args : array_keys($agenda)) as $k) {
+ if (is_array($agenda[$k]))
+ foreach($agenda[$k] as $d => $v) {
+ $evt[$d] = $evt[$d] ? (array_merge($evt[$d], $v)) : $v;
+ }
+ }
+ $la_date = mktime(0, 0, 0, mois($une_date), 1, annee($une_date));
+ include_spip('inc/agenda');
+ return http_calendrier_init($la_date, $type, '', '', '', array('', $evt));
+}
+
+function http_calendrier_mini($annee, $mois, $jour, $echelle, $partie_cal, $script, $ancre, $evt) {
+ list($sansduree, $evenements, $premier_jour, $dernier_jour) = $evt;
+
+ if ($sansduree)
+ foreach($sansduree as $d => $r) {
+ $evenements[$d] = !$evenements[$d] ? $r :
+ array_merge($evenements[$d], $r);
+ }
+
+ if (!$premier_jour) $premier_jour = '01';
+ if (!$dernier_jour) {
+ $dernier_jour = 31;
+ while (!(checkdate($mois,$dernier_jour,$annee))) $dernier_jour--;
+ }
+
+ // 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>&nbsp;</td>";
+ }
+
+ $total = '';
+ for ($j=$premier_jour; $j<=$dernier_jour; $j++) {
+ $nom = mktime(1,1,1,$mois,$j,$annee);
+ $jour = date("d",$nom);
+ $jour_semaine = date("w",$nom);
+ $mois_en_cours = date("m",$nom);
+ $annee_en_cours = date("Y",$nom);
+ $amj = date("Y",$nom) . $mois_en_cours . $jour;
+
+ if ($jour_semaine==1) {
+ $total .= "\n<tr>$ligne\n</tr>";
+ $ligne = '';
+ }
+
+ $evts = $evenements[$amj];
+ $class="";
+ if ($evts) {
+ $evts = "<a href='".$evts[0]['URL']."' title='".$evts[0]['SUMMARY'].
+ "'>".intval($jour)."</a>";
+ $class='occupe';
+ }
+ else {
+ $evts = intval($jour);
+ $class='libre';
+ }
+ $ligne .= "\n\t<td class='$class".($amj == date("Ymd")?' today':'')."'>" . $evts . "\n\t</td>";
+ }
+ // affichage de la fin de semaine hors periode
+ for($j=$jour_semaine ? $jour_semaine : 7; $j<7; $j++) {
+ $ligne .= "\n\t<td>&nbsp;</td>";
+ }
+
+ return $total . ($ligne ? "\n<tr>$ligne\n</tr>" : '');
+}
+
+?>

Added: _plugins_/_contenu_editorial_/Agenda/formulaires/calendrier_mini.html

--- _plugins_/_contenu_editorial_/Agenda/formulaires/calendrier_mini.html (added)
+++ _plugins_/_contenu_editorial_/Agenda/formulaires/calendrier_mini.html Tue Jul 11 22:36:28 2006
@@ -0,0 +1,35 @@
+<div id="calendar">
+ <h2><BOUCLE_titre(ARTICLES){id_article}>#TITRE</BOUCLE_titre><:icone_calendrier:><//B_titre></h2>
+ <table summary="<:icone_calendrier:>">
+ <caption>[
+ <a
+ href="(#ENV{self}|parametre_url{#ENV{var_date},[(#ENV{date}|dateplus{-27*24*3600,'Y-m'})]})"
+ title="[(#ENV{date}|dateplus{-27*24*3600,'Y-m'}|affdate_mois_annee)]">&#171;</a>][
+ (#ENV{date}|affdate_mois_annee)][
+ <a
+ href="(#ENV{self}|parametre_url{#ENV{var_date},[(#ENV{date}|dateplus{33*24*3600,'Y-m'})]})"
+ title="[(#ENV{date}|dateplus{33*24*3600,'Y-m'}|affdate_mois_annee)]">&#187;</a>]
+ </caption>
+ <thead>
+ <tr>
+ <th scope="col"><abbr title="<:date_jour_2:>"><:date_jour_2|spip_substr{0,1}|strtoupper:></abbr></th>
+ <th scope="col"><abbr title="<:date_jour_3:>"><:date_jour_3|spip_substr{0,1}|strtoupper:></abbr></th>
+ <th scope="col"><abbr title="<:date_jour_4:>"><:date_jour_4|spip_substr{0,1}|strtoupper:></abbr></th>
+ <th scope="col"><abbr title="<:date_jour_5:>"><:date_jour_5|spip_substr{0,1}|strtoupper:></abbr></th>
+ <th scope="col"><abbr title="<:date_jour_6:>"><:date_jour_6|spip_substr{0,1}|strtoupper:></abbr></th>
+ <th scope="col"><abbr title="<:date_jour_7:>"><:date_jour_7|spip_substr{0,1}|strtoupper:></abbr></th>
+ <th scope="col"><abbr title="<:date_jour_1:>"><:date_jour_1|spip_substr{0,1}|strtoupper:></abbr></th>
+ </tr>
+ </thead>
+ <tbody><BOUCLE_calendrier(EVENEMENTS)
+ {id_article}{id_mot?}
+ {agenda date_debut, mois, (#ENV{date}|annee), (#ENV{date}|mois)}>[
+ (#DATE_DEBUT|Agenda_memo_full{#DATE_FIN,[(#TITRE|addslashes)],
+ #DESCRIPTIF,#LIEU,
+ [(#ENV{self}|parametre_url{#ENV{var_date},[(#DATE_DEBUT|affdate{'Y-m-d'})]})]})
+ ]</BOUCLE_calendrier>[
+ (#ENV{date}|agenda_mini)
+ ]</tbody>
+ </table>
+ <span>&nbsp;</span>
+</div>